Tech stocks haven't been the only market segment to be hammered in the last six months. Solar energy stocks have also gotten crushed despite a sharp rise in oil and natural gas prices around the world.

The reason for the sell-off in solar stocks actually makes some sense at this point, though. Interest rates are rising, and the global economy may be slowing, which may be enough to hurt solar energy stocks long term.

Solar farm on the side of a hill.

Image source: Getty Images.

Why solar stocks are dropping

The chart below shows why solar stocks are down. Solar projects are built with high up-front costs and generate revenue over the course of decades, so rising interest rates will have a negative impact on project values. That cascades down to installers, manufacturers, and component suppliers.

SPWR Chart

SPWR data by YCharts.

There's long been a clear line between interest rates in solar energy stocks, with lower interest rates pushing shares higher and, obviously, the opposite holding true as well. Right now, higher rates for the foreseeable future will be a meaningful headwind for financing solar projects.

Good news for solar stocks

While higher interest rates may make solar energy more costly on a per KwH basis, higher commodity prices are raising the cost of fossil fuel electricity, too. You can see below that other energy commodities are climbing as well. Natural gas is the most notable here because it's the biggest fuel source for electric power plants in the U.S.

WTI Crude Oil Spot Price Chart

WTI Crude Oil Spot Price data by YCharts.

Power plant developers, utilities, and regulators are looking at the overall cost of energy from power plants, and when fuel prices are up, it's more compelling to choose wind or solar over fossil fuels. So, the higher-rate environment may not be as bad as it seems when commodity prices are considered.

What investors need to look for

As dire as the interest rate and stock price trends look for solar stocks, there are some positive signs for the industry. You can see below that the same stocks I highlighted above -- SunPower (SPWR -2.21%), Sunrun (RUN 1.39%), SolarEdge Technologies (SEDG -2.77%), and Enphase Energy (ENPH -2.46%) -- all have somewhat steady gross margins over the last three years.

With SunPower and Sunrun, this doesn't even include the long-term margin they have on the balance sheet from installed projects. It's possible that price increases passed on to customers will allow these companies to offset any cost increases.

SPWR Gross Profit Margin (Quarterly) Chart

SPWR Gross Profit Margin (Quarterly) data by YCharts.

We'll get a better idea of what demand and pricing look like in a few weeks when earnings season starts for the solar industry. Based on the decline in stock prices, expectations are low. But this is still a growing industry that's consolidating its power into the hands of a few companies. Long term, that should be a good place for investors' to put their energy investments.