THE omens for the Chinese yuan seemed bad heading into 2017. The capital account looked as porous as ever, making a mockery of the government’s attempts to fix the leaks. The new year, when residents received fresh allowances for buying foreign currency, was due to bring even more pressure. Analysts braced for a stampede for the exits from China. The yuan had fallen sharply at the beginning of 2016, catching them by surprise. This time, they were ready. Instead, the yuan began the year as one of the world’s star performers. This was particularly so in the offshore market, where foreigners trade it most freely. It gained 2.5% against the dollar over two days in the first week of 2017, its biggest two-day increase since 2010, when trading began in Hong Kong, its main offshore hub. Within China itself, price increases were more subdued, but the yuan still climbed to a one-month high.

Currency markets are notoriously fickle, so it is dangerous to read too much into a few days of price swings. But in China the government has always had a tight grip on the yuan. So the currency’s strength raised the question of whether it was simply being propped up—or whether the yuan’s prospects were in fact improving.

The Hong Kong rally has the Chinese central bank’s fingerprints all over it. The proximate cause was a shortage of yuan in Hong Kong. As its residents have turned away from the Chinese currency, deposits there have fallen to just over 600bn yuan ($86.7bn), their lowest level since early 2013. That has led to periodic liquidity squeezes, making the cost of borrowing yuan in Hong Kong prohibitive: the overnight rate soared to 61% at the start of 2017.

In normal circumstances, central banks would be expected to inject money to ease such shortages. But the Chinese authorities did little to stem the cash crunch, pleased to see it hurt those betting against the yuan. To make money by “shorting” a currency, investors borrow it, sell it and then hope to buy it back after its value has fallen. With borrowing rates so high, this becomes all but untenable. As the liquidity squeeze has abated in recent days, the offshore yuan has pared its earlier gains.

China’s success in defending the yuan suggests that, as the government tightens capital controls, they are having more effect. In the past two months it has started reviewing all transfers abroad by companies worth $5m or more. Transfers by individuals will also soon face more scrutiny. The controls should slow the erosion of China’s foreign-exchange reserves, which are down to $3trn from $4trn in 2014.

Most important, the Chinese economy is sounder than it was two years ago, when the yuan’s gradual descent began. A property boom has breathed life into heavy industry. Producer-price inflation is running at its fastest in more than half a decade. The central bank is tightening monetary conditions, however gingerly. As China’s economic and policy cycles more closely track those in America, there is less scope for runaway strength in the dollar, which in turn takes pressure off the yuan.

Even so, many of the factors remain that led the yuan to drop by 7% last year, its steepest fall on record. The broad money supply is still growing at a double-digit rate. Chinese companies and households still have a ravenous appetite for foreign assets. Most analysts expect the yuan soon to start falling again, though that consensus is no longer rock-solid. China’s central bank has long said that it wants to make the yuan more volatile and less predictable. On that score, it has surely succeeded.