What happened

Shares of United Parcel Service (UPS 1.13%) climbed 15.7% in July, according to data provided by S&P Global Market Intelligence. Most of the gain occurred on a single day, as investors cheered UPS' better-than-expected quarterly results.

UPS Chart

UPS data by YCharts.

Given the challenges UPS has faced so far in 2019, the strong second quarter was a welcome surprise for holders of the stock.

So what

UPS shares underperformed the S&P 500 by 12 percentage points in the first half of 2019, weighed down by a range of concerns including weaker-than-expected first-quarter results, a new competitive threat from Amazon.com, and the threat of trade wars and a global economic slowdown.

With those worries in mind, investors likely breathed a sigh of relief when UPS reported second-quarter earnings that beat estimates by $0.02 per share on revenue up 3.4% year over year. The company also held steady to its full-year forecast of between $7.45 and $7.75 per share in earnings, signaling that management believes it is well positioned to navigate whatever headwinds present themselves in the second half of the year.

A UPS-branded 747 cargo plane.

Image source: UPS.

UPS has been investing heavily on new automation technology designed to help bring down costs, and the company is beginning to benefit from that spending. Operating profit growth of 6% doubled the 3% revenue growth, and CEO David P. Abney on a post-earnings call with investors said the gains should continue heading into 2020.

"Our transformation is also creating greater efficiency and agility and funding reimbursement in new state-of-the-art solutions," Abney said. "This will enable UPS to capture profitable growth opportunities in an even higher level."

Now what

The peak holiday season is a key to UPS' year, and Thanksgiving comes late in 2019 meaning there are six fewer days between Black Friday and Christmas this year than there were a year before. UPS is confident its investment in technology -- notably the automation of sorting facilities that should allow it to move more packages through the system -- will allow it to reverse a recent trend of underperformance through the holidays, but investors will be monitoring carefully.

The company faces other challenges as well. It is hard to imagine any international transport company thriving as long as the trade dispute between the U.S. and China is dominating headlines. UPS also is likely to face pricing pressure on the business-to-consumer side of the company as Amazon.com tries to flex its muscle in the sector.

UPS is making all the right moves to win over the long haul, but it seems unlikely that the shares will enjoy many more months as good as July for the remainder of the year.