The first half of the year comes to a close Friday, and it certainly has been a strong period for stocks.
Over the past two decades, stocks have generally been positive in the second half of the year, pushed higher by the performance in the large-cap tech stocks, according to CNBC's analytics partner Kensho.
The Nasdaq 100 topped the list, trading higher three-quarters of the time, gaining an average of 6 percent in the final six months of the year.
The Nasdaq Composite and Dow each traded positively 70 percent of the time, with average gains of 4.3 percent and 3.2 percent respectively.
The S&P 500 was higher 65 percent of the time, with average gains of 2.7 percent.
Not surprisingly, the top performing sector was tech, trading positively 75 percent of the time, with gains of 4.5 percent.
Consumer staples shares were the most consistent gainers, positive 80 percent of the time with an average return of 3.7 percent.
Health care also tends to outperform, trading positively 70 percent of the time with average gains of 3.6 percent.
The materials, utilities and energy sectors were the biggest laggards.
Taking a closer look at the S&P 500, since 1988 there have been 12 other times when the index has seen a first-half gain of at least 6 percent. After each of those instances, the index has extended its increase through the second half — closing the year at a higher level than where it was at the end of June, with the gains often being substantial in the back half of the year.
To be sure, these past historical results do not guarantee future results and stocks typically rise more often than they fall. Also, history shows stocks often struggle during the third quarter before recovering in the fourth quarter, thus the second-half gain, on average.
Disclosure: NBCUniversal, the parent of CNBC, is a minority investor in Kensho.