EMERGING markets are back. The stockmarkets of developing countries have flipped in and out of fashion over the past 20 years as investors have switched from naive enthusiasm about their long-term growth prospects to heightened concern about their riskiness. This year they are once again in style, having generated a return of more than 13%.

That is an abrupt change of mood from 2010-14, when the markets were about as popular as a drug tester at a Russian athletics event (see chart). During those years, investors seemed to focus entirely on the negatives. The growth rates of many emerging economies, even China, seemed to falter.

Commodity producers were hit by a decline in raw-materials prices. Political worries resurfaced about previously popular investment destinations, such as Brazil and Turkey.

Eventually, however, markets tend to fall far enough that they reflect all the bad news. Robeco, a Dutch fund-management group, reckons that emerging markets trade at a 30% discount to rich-world equities, in terms of their prospective price-earnings ratio (the next year’s profits, relative to the share price).

And there may be good news on the economic fundamentals. In its April forecast, the IMF predicted a modest uplift in emerging-market GDP growth this year to 4.1% (from 4% in 2015) and a more vigorous rebound in 2017 to 4.6%. In particular, two troubled economies—Brazil and Russia—are expected to stop shrinking next year. After a long period of decline, emerging-market exports are showing signs of stabilising; in volume terms, they rose by 3% in May, compared with the same month a year earlier.

Although the oil price has been weak in recent weeks, raw-materials prices in general seem to have stabilised this year, an important factor since many developing countries are commodity producers.

As a result, investors are starting to recover their enthusiasm. The monthly survey of fund managers by Bank of America Merrill Lynch shows that most had a lower-than-normal exposure to emerging markets from 2013 onwards. Since May, they have shifted to a higher-than-normal weighting, although their optimism is nowhere near the levels seen before the financial crisis of 2008.

Emerging markets are also benefiting from the search for a decent return. With cash rates at close to zero or below in many economies, and trillions of dollars worth of government bonds trading on a negative yield, investors are willing to take some risk. As a result, emerging-market currencies and government bonds have also rallied this year.

Historically, the most dangerous time for emerging markets is when investors’ enthusiasm for the sector is highest and when it trades at a premium, in valuation terms, to the developed world. Neither caveat applies at the moment.

Still, investors should beware the naive belief that, because emerging markets are growing faster than advanced economies, they must be a better bet. A study by Elroy Dimson, Paul Marsh and Mike Staunton of the London Business School found that, from 1900 to 2013, there was actually a negative correlation between economic growth per person over five-year periods and inflation-adjusted equity returns.

One reason for the anomaly is that a country’s stockmarket is not a facsimile of the domestic economy; many companies are not quoted. Another reason is that minority investors may not get the full benefit of corporate growth. John-Paul Smith of Ecstrat, a consultancy, has been bearish on emerging markets for some time and still argues that there is “very little prospect of a shift in the underlying governance regimes of the major emerging equity markets in a direction that would benefit minority investors”.

Perhaps the biggest threat to the emerging-market rally would be a Donald Trump presidency.

There are direct threats—his plans to leave the North American Free Trade Agreement or his hints about quitting the World Trade Organisation—that would hit economic growth in developing countries.

Then there are his foreign-policy pronouncements, including a willingness to disengage from overseas defence alliances. Citigroup, a global bank, thinks that South Korea and Taiwan would be harmed by such a shift, with Russia probably the only beneficiary.

The erratic nature of Mr Trump’s pronouncements might also lead to a dose of risk aversion among global investors. And emerging markets tend to lose out when investors grow cautious. There is still time for this rally to get derailed.