TAIWAN’S president, Tsai Ing-wen, has had a tough first year in office. Her popularity has plummeted as she has struggled to find a path through thorny policy debates. Hope that she might have a staunch ally in Donald Trump has receded. China has ratcheted up pressure, leaving Taiwan more isolated internationally. Less noticed is that Ms Tsai has, for now, won over one important group: investors. Cash inflows from abroad have made Taiwan’s stockmarket and currency among Asia’s best performers. Foreign direct investment in the electronics industry has also surged.

The government, to be sure, cannot take too much credit. A revival in global trade is the main reason for Taiwan’s improved fortunes. Exports rose 15% in the first quarter, the fastest rate in six years. The big gains for Taiwan’s stockmarket—up 40% in dollar terms since Ms Tsai’s inauguration—are about the same as those in South Korea, another economy whose growth is fuelled by the global electronics sector.

Nevertheless, without a deft touch from Ms Tsai, things could have been worse. It is easy to forget that, a year ago, the odds seemed stacked against Taiwan’s economy. Falling exports had tipped it into a recession. Slowing smartphone sales pointed to little relief ahead. Most worrying was the political backdrop, with Ms Tsai caught between her supporters, many of whom crave independence, and China, which demands that she acknowledge Taiwan to be part of “one China”.

Ms Tsai has, so far at least, steered a middle course, neither ceding ground to China nor taking actions that might provoke a harsh response. Investors, judging that cross-strait relations are frosty but generally stable, have felt confident enough to scoop up Taiwanese assets. The $8.3bn in foreign direct investment in Taiwan last year was more than triple the 2015 amount and the highest on record. If exports remain strong, the economy has a good chance of beating the government’s forecast of 2% growth this year.

A focus on commercial ties with Asian countries other than China has helped tourism. Ms Tsai’s election prompted China to push its travel agencies to send tour groups elsewhere in the region. In the first three months of this year Chinese arrivals in Taiwan were down by some 42% from the same period in 2016. Taiwan, however, has made up for much, if not all, of the loss by attracting visitors from Japan, South Korea and South-East Asia.