IT’S not easy being green, especially if you’re a fund manager. A decade or so ago, when mainstream politicians such as Britain’s David Cameron were petting huskies and embracing environmental issues, the stocks of renewable-energy producers were in vogue. But as in the dotcom boom a few years earlier, share prices ran way ahead of the potential for profits. An exchange-traded fund in global clean-energy stocks, set up by iShares in 2008, has lost investors 79% since its launch. Over the longer term, an analysis by Gbenga Ibikunle and Tom Steffen in the Journal of Business Ethics found that European green mutual funds had significantly underperformed their conventional rivals between 1991 and 2014.

The rise in shale-oil and -gas production, and the accompanying decline in energy prices, have spelled double trouble for green investors. On the one hand, they have reduced the incentive for governments to favour renewable-energy producers—and thus dented the prospects of some green stocks. On the other hand, they have also hit the share prices of conventional oil and gas companies, which environmental funds tend to avoid.

That decline has given succour to a campaign joined by a number of investors—mostly from the public and charitable sectors—to boycott the shares of fossil-fuel producers. Such investors cannot be accused, at least in the short term, of breaking the “fiduciary duty” that fund managers owe to their clients to generate the best possible return.

In a new paper, BlackRock, a big fund-management group, argues that there are more sophisticated approaches to greenery than boycotting oil and coal companies, or piling into wind-turbine manufacturers. For example, investors could own a portfolio as close as possible to a given index, but choose the greenest companies within each sector. BlackRock reckons that it is possible to create a portfolio which tracks the MSCI World Index with an annual error of just 0.3% a year, yet comprises companies with carbon emissions 70% lower than the index as a whole.

Another option is to look at the figures companies report for their own carbon emissions. BlackRock found that over the period from March 2012 to April 2016, the firms that had reduced their carbon emissions most beat the MSCI World Index by 4%; those that had shown the smallest improvement underperformed the index by nearly 5% (see chart).

Although the world has struggled to reduce its carbon emissions, it would be a mistake for investors to believe that green policies cannot cause upheaval in individual industries.

BlackRock points to the revolution in lighting. The phasing-out of incandescent light bulbs, induced by regulation, has spurred investment in light-emitting diode (LED) bulbs; the price of LEDs has fallen by 90% since 2010. Improvements in battery technology may yet transform the power industry, BlackRock thinks, by making it easier and cheaper to store energy from renewable sources such as wind and solar power.

There are other climate-related risks that investors need to consider. In America the frequency of extreme weather events that cause at least $1 billion-worth of damage has risen sharply since 2000; that has implications for insurers. Extreme weather can cause short-term shocks to economic activity; rising temperatures can dent productivity growth.

Nevertheless, even as the impact of environmental change is felt, short-term factors can still cause problems for investors keen on greenery. China and America may have ratified the Paris climate-change agreement on the eve of the G20 summit this week but there is plenty of resistance to green policies that are perceived to be expensive. Barack Obama has succeeded in boosting the use of renewable energy in America but has had to use executive action to bypass Republican opposition in Congress.

As mainstream politicians fend off attacks from the populist right and left, the task of cutting emissions may get even harder. In Britain, for example, Mr Cameron has been and gone, and Theresa May, his successor, has abolished the Department for Energy and Climate Change.

Even if Hillary Clinton defeats Donald Trump, a climate-change denier, in America’s presidential race, she seems likely to face a sceptical Congress. The undemocratic government of China may find it easier to meet its targets.

Although they may be confident about their long-term analysis, therefore, environmental investors will need internal fortitude. Owning a green portfolio means enduring stormy moments.