Strong earnings from these banks bode well for the stock market

What's good for banks is good for the stock market.

Earnings from the financials dominate the early part of earnings season, setting the pace for the rest of the period, and so far it looks pretty good. The big banks that have reported so far have largely exceeded the Street's forecast, with trading revenue, loan growth and interest income among the highlights.

Last Friday, JPMorgan Chase was one of the first of the big banks out of the gate with earnings. The largest U.S. bank by assets reported earnings per share of $1.58 on revenues of $25.51 billion, topping estimates by 19 cents per share and revenue by more than $1.5 billion.

Working with analytics firm Kensho, CNBC ran a screen looking at how the markets performed two weeks after JPMorgan beat earnings per share estimates by at least 18 cents.

In the past decade, JPMorgan topped earnings per share estimates by at least 18 cents on eight occasions, and two weeks later the Dow Jones industrial average traded positively 75 percent of the time, returning an average of just under 1 percent.

The S&P 500 and the largest financial ETF, the XLF, were also consistently positive on average, though to a lesser degree, each trading up 63 percent of the time. JPMorgan itself has historically been a coin flip, trading positively half the time, gaining an average of 1.2 percent.

This historical trend continued when looking at Goldman Sachs after a big beat.

The investment bank posted third-quarter earnings Tuesday morning of $4.88 per share, on revenue of $8.17 billion, beating the Street's earnings per share estimates by $1.06 a share and revenue expectations by $740 million.

Using Kensho once again with the same parameters, we found a similar story. The S&P was consistently positive, up 82 percent of the time, with an average return of 1.2 percent. The Dow and the XLF are also historically positive, each finishing better 64 percent of the time, returning an average of 1.27 percent and 0.47 percent respectively.

Most surprisingly, perhaps, Goldman Sachs itself was negative more often than positive, on average, down 55 percent of the time, but still managing an average return of 0.49 percent.

Disclosure: NBCUniversal, parent of CNBC, is a minority investor in Kensho.