Record write-offs for bad loans and shrinking margins - caused by six consecutive interest rate cuts - led to flat profits and beaten down valuations last year for the likes of Industrial and Commercial Bank of China Ltd (ICBC) (>> Industrial and Coml Bank of China Ltd)<1398.HK> and China Construction Bank Corp (CCB) (>> China Construction Bank Corporation)<0939.HK> .

But with banks adopting government-mandated debt-restructuring measures like debt-for-equity swaps, the bad loans situation for the bigger banks could ease. And with margins stabilising as the impact of the rate cuts fades, the banks are gradually enticing investors again.

"In 2017, it's a focus on quality," said Wei Hou, senior equity analyst for China banks at research firm Sanford C. Bernstein. "The large banks are more protected on the downside and their valuations are relatively attractive," said Hou, who has an outperform ranking on ICBC, CCB and Bank of China (>> Bank of China Limited)<3988.HK> .

"Buy" and "strong buy" recommendations of analysts on more than 20 Chinese banks have risen to 171 now from 153 six months back. In contrast, "sell" and "strong sell" recommendations were at 56, up slightly from 51 over the same period, Thomson Reuters Starmine data shows.

Healthier banks are vital for China as the world's second-largest economy navigates a slowdown and attempts to halt a rapid build-up of debt. For the banks, higher share prices would make it easier for any fund-raising ahead of new global capital rules coming into force in the years ahead.

Some recent economic data in China has bolstered the case for investor optimism. Producer prices inflated by a stronger-than-expected 5.5 percent for December, its fastest increase since September 2011. That is positive for state-owned enterprises, which have been wrestling with falling prices and borrow heavily from the largest banks.

DISCOUNTED VALUATIONS

China's five biggest listed banks currently trade at an average 0.79 times book value, as investors have discounted for the costs of non-performing loans (NPLs) and subdued profitability. The steep price-to-book discount compares to the banks' five-year average of 1.0.

The numbers last year did look quite bad. Write-offs for just the first half of 2016 amounted to 220.8 billion yuan (26.22 billion pounds) for the top 23 banks listed in Hong Kong and Shanghai for which statistics are available, according to Reuters calculations. In 2015, bad loan disposals at those banks amounted to 353.2 billion yuan.

Loans 90 days past due increased 19.9 percent to 1.1 trillion yuan in the first half of 2016 for the same 23 banks.

Net interest margin (NIM), the difference between interest earned on loans and that paid out to depositors, shrank between 30 and 40 basis points across the banking sector in 2016, squeezing profits.

But the tide may be turning. The rate cuts will cease to hurt NIMs on a year-over-year basis in 2017.

The lenders have also begun a major restructuring of corporate debt. Since October, state lenders led by CCB and ICBC have announced debt-for-equity swap agreements totalling more than 300 billion yuan with big state-owned groups, mainly coal, energy and steel firms.

"The risks priced on the Chinese banks are somewhat overplayed, and combined with some of the highest savings rates in the world, there may be tactical opportunity," said Stephen Corry, chief investment strategist at LGT Bank in Hong Kong.

Not all banks are set to benefit. For some of the country's mid-tier and city commercial lenders, which have expanded their balance sheet by borrowing funds and through the issuance of wealth management products, tightening liquidity and Beijing's crackdown on excessive risks in the financial sector are likely to hurt.

Bank of Communications Co (BoCom) (>> Bank of Communications Co Ltd)<3328.HK> and China Minsheng Banking Corp (>> China Minsheng Banking Corp Ltd)<1988.HK> already are feeling the impact of margin compression and are expected to report that lending margins fell below 2 percent for the first time last year, according to Bernstein research.

"The valuation gap between leading banks and laggards could widen," Lucy Feng, UBS's banking analyst, wrote in a Jan. 5 report. "Banks with strong capital and less risky exposure could be the major outperformers."

(Reporting By Matthew Miller in Beijing; Saikat Chaterjee in Hong Kong; Additional reporting by Gaurav Dogra in Bengaluru; Editing by Muralikumar Anantharaman)

By Matthew Miller and Saikat Chatterjee