Solar energy stocks stumbled into 2017 in the midst of a 2-1/2 year washout.

Overproduction in China pressured solar-component prices down 35% in 2016, straining the industry’s bottom line. Incoming President Trump raised the specter of a trade war as he talked up a coal revival and set to work dismantling environmental regulations. And oil prices, traditionally the hottest prod helping to drive solar demand, showed no promise of recovering to even a shadow of their former highs.

But investors, who had sent solar stocks down 60% last year and another 17% in early 2017, had a sudden change of heart. The solar group turned sharply upward in early April. It rebounded 54% through Thursday, to a 29% gain for the year.

What happened? Solar-panel prices began to firm up on improving global demand. U.S. cities and utilities joined a rising number of regions around the world to buy into solar technology, which has grown increasingly efficient and cost-effective enough to compete with more traditional forms of energy.

“They’re not just thinking about climate change,” Williams Capital analyst Cynthia Motz said. “They’re thinking about the economics.”

This isn’t the first time analysts have argued that the industry was on the verge of transition. But the solar power community is flashing signs of increasing, if cautious, confidence. First Solar (FSLR), the largest U.S. manufacturer of solar panels, saw revenue drop 39% while earnings were flat in the second quarter, reported in late July. But the company raised its profit-margin outlook, with Chief Executive Mark Widmar citing firming prices for solar modules.

In May, Berkshire Hathaway’s (BRKB) Warren Buffett gave the industry a boost, saying he has “a big appetite for wind or solar.” The solar group rose 14% for the month.

And a curt comment from Trump in June about possibly placing solar panels along a proposed border wall helped send U.S.-based SunPower (SPWR) up 19% and First Solar (FSLR) up 24% for the month.

The stocks remain highly volatile. First Solar and SunPower both topped analyst expectations for second-quarter financial results. But SunPower trimmed the high end of its revenue guidance for the year, citing the timing of projects in Mexico. The news sent its shares 19% lower on Wednesday.

Read more: Solar Power’s New Dawn