The fate of the S&P 500 index — used by investors as a barometer for the health of corporate America, and cited by presidents as a measure of their handling of the economy — often comes down to just two companies: Apple and Microsoft.

This means it’s hard to invest in the U.S. stock market, such as through a 401(k) or pension plan, and not be highly dependent on the fate of the two tech giants. More than $15 trillion in assets, from pension funds and endowments to insurance companies, are linked to the performance of the S&P 500 index in some way, according to S&P Dow Jones Indices, with more than 10 cents of every dollar allocated to the index flowing through to Microsoft’s and Apple’s valuation.

It is a phenomena explained by how the benchmark is constructed, and it is amplified by the way tech has come to dwarf other industries, in the markets and the economy. And it means that the two companies together can sway the direction of the broad market, sometimes masking turmoil that has taken place underneath.

Trading in March offers a clear example. Even after the failures of two regional banks in the United States and the rescue of a global investment bank in Europe sent a jolt through the financial system and raised new fears about an already fragile global economy, the S&P 500 was on track to end the month about 2 percent higher, as of Thursday.

Apple and Microsoft accounted for more than half of that gain, according to data from S&P. Both were seemingly immune to the banking crisis and boosted by fervor over artificial intelligence, with Apple rising 10 percent during the month and Microsoft nearly 14 percent.

It was true even at the height of the frenzy. On Monday, March 13, immediately after the government seized Silicon Valley Bank and Signature Bank, signs of panic were everywhere: Several regional banks suffered their worst day ever in the stock market, with First Republic Bank down more than 60 percent, in conditions so chaotic that trading in many individual stocks was halted as stock exchanges tried to limit the damage.

Outside the stock market, government bond yields went haywire, oil prices slid and the dollar weakened, all showing that alarms about the economy were ringing on trading desks around the world.

Yet the S&P 500 spent much of the day in positive territory, and it ended with a barely noticeable decline of 0.1 percent. Credit, again, goes to Microsoft and Apple, which both rose enough to counter a 15 percent slide in the entire regional banking sector that day.

It can be jarring for investors to see the index perform so differently from what they may have predicted, said Fiona Cincotta, a stock market analyst at StoneX, a brokerage.

“The dynamics of the indices are definitely playing a part in this,” she said. “Sometimes the markets just do things that you don’t expect.”

Much of this comes down to how the S&P 500 is designed. Its value is calculated by a measure that considers the overall market capitalization of a company. It means the stock moves of the largest companies carry the greatest weight, because even slight changes in their value create or destroy billions of dollars of shareholder value.

Apple, at roughly $2.4 trillion, and Microsoft, at $2.1 trillion, are so large that, taken together, the two companies would be the third-largest sector of the index, behind tech and health care. They would be larger than the energy sector and roughly the size of the financials sector.

This influence is a result of a decades-long shift in both the markets and the economy since the dot-com boom, a change that accelerated after the 2008 financial crisis. Low interest rates put in place to support the economy after the Great Recession made borrowing cheap and pushed investors to seek out higher returns from riskier companies, spurring financing and growth for tech companies.

Apple in 2018 became the first American company valued at more than $1 trillion on the stock market. As its value inflated, so did that of its rivals Facebook (now Meta), Amazon, Netflix, and Google (now Alphabet) — a group that came to be called the FANG stocks. They helped to lift the index to new highs over a more than decade-long bull market.

This dynamic is not wholly unusual in the history of the S&P 500, though it is extreme, and it has been exacerbated by the rapid growth of some tech companies through the pandemic. (At the end of 2018, Microsoft’s and Apple’s combined index weight was less than Apple’s is today on its own.) The previous company to reach Microsoft’s 6.2 percent weight in the index was IBM in the mid-80s, based on data for the end of each calendar year.

“I don’t think it’s a problem,” said Howard Silverblatt, senior index analyst at S&P Dow Jones Indices. “This is what the whole thing is worth, and if Apple or Microsoft go up or down, there is proportional impact because they are worth more. It’s market-driven.”

The S&P also produces an “equal weight” index, where each stock has the same effect on the wider group. In March, that index is down 3 percent.

Another commonly cited measure of Wall Street’s performance, the Dow Jones industrial average is a price-weighted index that has been criticized for how it emphasizes companies based on their share price alone.

And then there are the underlying sectors, which are also tracked in separate indexes by S&P. These indexes, which tend to more directly show pain afflicting their subsets of stocks, show that the financial sector fell more than 10 percent in March, while energy stocks dropped 1.1 percent and real estate companies slid 4.2 percent. They also shows that other parts of the market — like utilities — fared just fine.

S&P Dow Jones Indices, which maintains the S&P 500 as well as the Dow, has tried to address the impact of these specific weightings, at least on different sectors. In 2018, it moved Alphabet and Meta out of the tech sector and into the communications category with Netflix, while leaving Amazon in the consumer discretionary category with other retailers.

Since then, Meta, Amazon and Alphabet have slowly lost value, while Apple and Microsoft have grown. The technology sector in the S&P 500 has also been bolstered by the emergence of new behemoths like the chip maker Nvidia, which is valued close to $1 trillion.

This month, S&P sought to rebalance the index again, moving a handful of large tech-oriented companies — like Visa and PayPal — into the financials sector, but further entrenching Apple and Microsoft’s dominance as the two tech heavyweights.

Of course, this cuts both ways. In 2022, the S&P 500 slumped close to 20 percent, a drop that would have been much smaller without the lousy performance of the tech sector. In fact, just removing Apple and Microsoft from the picture last year would have cut the index’s loss to less than 1 percent.

For now, analysts see reasons for tech to continue to rally.

One reason is the excitement over artificial intelligence. Microsoft has a large stake in OpenAI, the creator of ChatGPT, and many investors foresee the nascent technology driving the next phase of growth for the companies developing the software as well as the chip makers whose processors power it.

Tech stocks are also benefiting from the concern over the country’s banks, which has led investors to quickly cut back their expectation for interest rate increases from the Federal Reserve. The sector is particularly sensitive to interest rates, and absent an imminent recession, lower rates in the future would be a boost for the sector.

And, analysts said, large technology companies have become havens where investors can wait out the current storm.

“It’s been a big bull cycle for tech,” said George Catrambone, the head of Americas trading at DWS, a fund manager. “I don’t think people will give up that paradigm easily.”