Since the Nov. 8 election, the stock market has risen sharply. As of this writing, the S&P 500 (^GSPC -1.20%) has sported a 10.8% run since the polls closed.

Stock brokers working on the floor of an exchange.

Image source: Getty Images.

We've heard many explanations for the run, including the new Trump administration's expected policy changes, Federal Reserve speeches that tout a solid U.S. economy, and a rebound in international optimism following the initial post-election fears.

Here's the most fundamental reason, though, that stocks have been rallying.

What happened in 2016

When we strip away the political and emotional bias, the news (which is often more negative than reality), and speculation on future events, all we're left with is math. And the math for the past few quarters has looked pretty good.

Fourth-quarter 2016 earnings are wrapping up, and so far the S&P 500 is posting a 4.6% year-over-year gain. That makes the second quarter in a row in which profits are up from last year and the third consecutive quarter in a row of rising profits for the nation's biggest companies.

A chart showing US corporate profits over the last ten years. Profits peaked at the end of 2014 before falling nearly 20% through the first quarter 2016. Since then, profits have recovered to previous peaks.

Chart by author. Data source: Federal Reserve Bank of St. Louis.

In 2015, and through the first quarter of 2016, profits took a plunge because of several negative factors. Low oil and commodity prices hurt some companies, and wage and healthcare cost increases weighed on multiple industries.

As some of those factors started to ease through the past year, the way was paved for the stock market's run. The end of the election and the promise of looser regulations and lower taxes have certainly helped. But over the long term, growth in the bottom line is the most basic factor influencing the value of stocks.

The outlook for 2017

Consensus estimates are that profits will continue to rise this year, including in the first quarter, in which profits could surpass the big dip from the winter quarter a year ago. Analysts expect that full-year 2017 earnings will grow about 10% on the back of about 5.5% revenue growth for the S&P 500.

Leading the way with those estimates are the oil and materials sectors, which were beaten up the most when commodity prices tanked starting in 2014. After that, the financial sector is expected to see a 12.1% bump during the year. Rounding out the top five are technology and consumer discretionary, at a 7.3% and 5.7% rise, respectively.

Those positive estimates are the root of all reasons driving this rally. However, with that rally has come higher valuations. The average forward price-to-earnings ratio is now at 17.6, the highest since 2004. What should investors do now?

Time to go bargain hunting

Stock prices may be on the high side, but optimism isn't necessarily unfounded here. As long as there's a positive outlook for profits on the horizon, that should provide a safety net for those companies' stocks. However, exercising a bit of caution is always wise.

Investors will want to hold on to some cash this year to buy up shares if there are any dips in the market or if the economy decides to second-guess itself. Also, just because the market has hit new records doesn't mean all companies are expensive. Scooping up stocks that haven't rallied but are still expecting profitable gains this year are still out there. For example, the retailer and restaurant sector, as measured by the SPDR S&P 500 Retail ETF (NYSEMKT: XRT), had a tough time in 2016 and failed to enjoy the broad-based run-up the overall market has had.

XRT Chart

XRT data by YCharts.

Optimism is high, but it's important to remember how fickle the stock market is and how quickly things can change. At any rate, the one metric for investors to stay focused on is profitability and the future potential growth rate.