On Wednesday, the U.S. stock market suffered its worst day in eight months.

Both the Dow Jones Industrial Average DJIA, -0.46% and the S&P 500 SPX, -0.84% slid 1.8%, while the high-flying Nasdaq Composite Index COMP, -1.26% dropped 2.6%.

The sell-off came in the wake of a bombshell report in The New York Times that notes from fired FBI Director James Comey revealed President Donald Trump had asked Comey to stop the FBI’s investigation into fired National Security Adviser Michael Flynn’s ties to Russia.

I’ll leave it to legal scholars to determine whether that was obstruction of justice, but investors decided it had put Trump’s agenda of slashing regulation, cutting taxes and building infrastructure in jeopardy, as reports emerged the White House had descended into chaos.

But something else was also at work: earnings. Although the first quarter of 2017 looked great and estimates for all of 2017 are solid, share prices are way ahead of projected earnings growth, making stocks, particularly certain sectors, vulnerable.

According to FactSet Research, 91% of the companies in the S&P 500 had reported earnings as of last Friday, May 12. Three-quarters of them beat Wall Street’s mean earnings estimate, and 64% topped the consensus revenue forecast.

Earnings growth clocked in at 13.6%, making this the best reading since the third quarter of 2011, FactSet reported. It’s also the second consecutive quarter of earnings gains following the so-called “earnings recession.”

Everything you need to do in your 20s for a great financial future

The rest of the year looks good, too: For all of 2017, Wall Street analysts project S&P 500 companies’ earnings will grow by almost 10%, while revenues are expected to advance by more than 5%. Yet from last February’s market low to Friday’s close, the S&P 500 has advanced nearly 31%, more than twice as much as earnings have grown.

That’s why though stocks may indeed go higher before the bull market reaches its ultimate top, it’s a good time to take some profits and reduce your holdings in sectors that have gotten way too overvalued.

How to determine that? I used one of the simplest but most widely accepted valuation metrics, price-earnings ratio to earnings growth (the PEG ratio), to separate potential winners and losers.

As the table below shows, as of last Friday, the S&P 500 was trading at 17.5x its projected earnings over the next 12 months, yet analysts project earnings will grow 9.9% in calendar years 2017. So, its PEG ratio is 1.8x.

Also note that the financials sector, which as of last Friday had gained a stunning 47.5% since the February 2016 market low, has a PEG of just 1.1x, thanks to its reasonable P/E and high projected 2017 earnings growth. (The Financials Select Sector SPDR XLF, -1.04% was Wednesday’s worst performing sector, off 3.2%. It would presumably gain the most from Trump-initiated reforms.)

Materials, too, look attractive, with a 35.6% gain since February 2016 and a PEG of only 1.3x. Technology stocks, though on a tear lately, sport S&P-like growth prospects and decent valuations. These are all holds, in my opinion.

Projected 2017 Earnings Gains 12-Month Forward P/E 12-Month P/EG Ratio Sector SPDR ETF Performance 2/11/2016 -5/12/2017 Consumer Discretionary 5.5% 19.7 3.6 31.3% Consumer Staples 3.9% 20.2 5.2 11.3% Energy 287.5% 27.6 0.1 25.8% Financials 12.0% 13.5 1.1 47.5% Health Care 4.2% 15.8 3.8 18.5% Industrials 5.1% 17.9 3.5 36.2% Materials 13.9% 17.9 1.3 35.6% Technology 10.0% 18.5 1.9 43.5% Telecom Services -1.0% 12.9 N.M. 49.7% Utilities -3.0% 17.6 N.M. 13.2% S&P 500 9.9% 17.5 1.8 30.7% Source: FactSet Research, as of 5/12/2017

Most attractive of all are energy stocks. Having gained 25.8% from their February 2016 lows — less than the S&P and the third lowest of any sector—these shares barely reflect the anticipated earnings bounce from last year’s washout lows.

Wall Street is looking for an astonishing 287.5% surge in earnings for energy companies in 2017, according to FactSet. That’s typical of the huge earnings recoveries we see at the beginning of bull markets. If, as I believe, crude oil prices made a multiyear bottom in the mid-$20s last February, then energy is probably the only sector I would still buy — unless tech and financials sell off a bit more. (The Energy Select Sector SPDR XLE, +0.14% lost 1% on Wednesday.)

As for sectors to sell — the industrials have topped my list since last December. Given Trump’s sea of troubles, if tax reform is in jeopardy, then a massive infrastructure-building plan is off the table. Through last Friday, industrials gained 36.2% from the February 2016 market lows. But they trade at a hefty 3.5x projected earnings growth of only 5.1%, and the ETF, which peaked in March, appears to have made a double top in the charts.

I’d also dump telecom services — up almost 50% from last February — because projected earnings growth is negative. The SPDR S&P Telecom ETF XTL, -0.85% took a big hit on Wednesday. Utilities are grappling with earnings declines and rising interest rates. Consumer discretionary stocks rely too much on a strong economy and consumer staples are over-owned by risk-averse investors hungry for yield. Their PEG of 5.2x is by far the richest among all sectors.

Politics will surely roil stocks over the coming months, but corporate earnings will ultimately determine the market’s fate. It’s a good time to hold on to the likely winners and kick the losers to the curb.

Howard R. Gold is a MarketWatch columnist and founder and editor of GoldenEgg Investing, which offers exclusive market commentary and simple, low-cost, low-risk retirement investing plans. Follow him on Twitter @howardrgold.