Indian stock markets ended with gains on Wednesday, tracking Asian and European stock markets. The S&P BSE Sensex closed at 24,854, up 172 points, or 0.70%, while the NSE Nifty was up 52 points at 7,562.

The markets shrugged off negative macroeconomic data released on Tuesday, which showed that retail inflation for December was up at 5.61% from 5.41% in the previous month while industrial output contracted by 3.2% in November after rising by 9.8% in October.

Stock markets across Asia, except China, gained on news that China's trade data for December was not so bearish as expected. The country's exports fell 1.4% on a year-on-year basis, but was far better than the 6.8% decline registered in November 2015, Reuters reported.

Imports dropped 7.6%, falling for the 14th straight month, but far less than 11.5% forecast by economists, Reuters added.

The Sensex witnessed a day of high volatility, with the 30-share benchmark index opening with gains but later correcting sharply to touch an intraday low of 24,402. The index recovered later to touch a high of 24,956, before closing the day at 24,854.

The recovery was led by index heavyweight Reliance Industries, which gained about 3.09% to close at Rs 1,077.35, and Infosys, which will announce its third quarter results on 14 January. The stock closed with a gain of 3.08% at Rs 1,082.35. 

Reliance Industries will declare its December quarter results on 19 January. 

Other Sensex gainers were Tata Motors, Mahindra, Hindustan Unilever, HDFC, Sun Pharma and Bajaj Auto.

Stocks that put pressure on the index included Adani Ports, Bharti Airtel, Lupin, Wipro and TCS, which declared its third quarter results on Tuesday. The TCS stock touched a new 52-week low on Wednesday of Rs 2,258 but recovered later to close at Rs 2,280.

Bharti Airtel said on Wednesday in a regulatory filing with the BSE that the company will sell its operations in Burkina Faso and Sierra Leone to Orange. However, Bharti Airtel did not disclose the terms of the deal.

Banking stocks hit a new 52-week low on Wednesday, with State Bank of India, Axis Bank and ICICI Bank registering a new low despite ending the day with moderate gains.