An innovative solar company started planning for the downturn nearly 3 years ago—and its stock is up 41% this year