Shares of defense contractor Raytheon (RTN) got routed in Thursday trading and then continued falling on Friday. By the time the week drew mercifully to an end, Raytheon stock was down nearly 5%, and nearly two months' worth of gains the stock had previously racked up were erased.

"But wait!" you say. "Didn't Raytheon beat on earnings Thursday?"

Patriot missile battery

Investing in Raytheon stock may feel PATRIOT-ic, but it could could your portfolio at risk. Image source: Getty Images.

Well, yes, it did. Let's review. For Q3 2017, Raytheon reported 5% sales growth from last year's Q3. coming in at $6.3 billion. Operating profit margin shed 20 basis points, falling to 13.6%, but net income still managed to increase a respectable 5%, and thanks to a reduced share count, net income per diluted share grew 7%.

When all was said and done, Raytheon ended up earning $1.97 per share, beating analyst estimates that had predicted only $1.90. And on top of that earnings beat, Raytheon raised guidance for the rest of this year. Management now thinks it will record revenue between $25.3 billion and $25.6 billion by year's end, making the tiny revenue miss from Q3 seem less important, and will earn $7.45 to $7.55 per share on those revenues -- as much as a nickel more than previously expected.

So why did investors decide to sell off Raytheon stock despite this apparently good news? Two theories suggest themselves.

Guidance grows, but too slow

First off, it's worth pointing out that although Raytheon raised its guidance for this year, it didn't raise guidance enough to match analyst expectations. According to figures quoted on Yahoo! Finance, analysts were hoping Raytheon could produce as much as $7.60 per share in profit this year. The most Raytheon is promising, though, falls five cents short of that target -- and Raytheon could potentially fall as much as $0.15 short.

This probably wasn't what Wall Street wanted to hear.

Margin goes missing

The other thing that could be contributing to investor pessimism this week is the profit-margin story. Remember how I mentioned last quarter that Raytheon's operating profit margin, 13.2% at the time, was far above its historical average? Well, the good news is that despite the shrinking profit margin in Q3, the company's rolling, last-12-month  average operating profit margin is still 13.2% today. The bad news is that, on a year-over-year basis, Q3 was the second time in a row Raytheon experienced quarterly margin shrinkage.

If this turns into a trend, and Raytheon's profit margin starts reverting to the mean, well -- over the past decade, Raytheon's operating profit margin averaged about 12.1%. Before that, data from S&P Global Market Intelligence -- which goes back a long way -- shows that single-digit profit margin has been more the norm at Raytheon, with margin even dipping below 5% in 2001.

Even a reversion to a 12%-ish margin would be enough to crimp Raytheon's profit by about 8% on static revenues. A reversion to a sub-10% margin, however, could easily ding Raytheon's profit by a quarter to a third -- or more. Making up for such a big hit to profitability would require an awful lot of new revenue growth at Raytheon, and with revenue currently growing slower than 5%, it seems highly unlikely the company would be able to grow revenue quickly enough to make up for shrinking margin.

The moral for Raytheon investors is clear: Look out below. If margin takes another step down next quarter, that step could be a doozy for the stock price.