The share prices of United Parcel Service (NYSE:UPS) and FedEx (NYSE:FDX) have been on fire recently, riding upward on a broader rise in transportation stocks.

With both shipping giants gaining more than 30% in the past month -- and more than 75% over the past three months -- should investors be thinking about selling, or do the stocks have more room to run?

A sculpted metallic casting of a bull with a dark background.

Image Source: Getty Images.

Why the transportation sector is rising

The transportation sector is comprised of shippers like UPS and FedEx, as well as airlines, railroads, logistics companies, and more. UPS and FedEx tell only one part of the story of why that entire sector has outperformed the broader market over the past three months.

UPS Chart

UPS and FedEx Stock Performance, data by YCharts.

For starters, the sector had been down even further than the market earlier in 2020. Wall Street's fears about the COVID-19 pandemic peaked in mid-March. At the bottom, the S&P 500 was down by about 30% on a year-to-date basis, while the S&P Transportation Sector index was down by around 40%.

Since then, the economies of many countries have begun to recover, and global commerce is starting to pick up again. However, many macroeconomic indicators point to a long road back from this recession. Large airlines, for example, continue to lose millions of dollars a day. Despite the reality that economic conditions are still bad, it seems that the market is optimistic about the prospects for a recovery, so some investors are dipping their toes back into downtrodden transportation stocks.

Best of the sector

UPS and FedEx have been propelled by those same sector-wide tailwinds, but with an added boost, as they are benefiting from the pandemic-necessitated shift by consumers to order a lot more of what they need online.

Both companies posted huge earnings beats in their most recently completed quarters, sending their stocks up by double-digit percentages on the days after their reports. FedEx and UPS both reported lower commercial deliveries, but grew residential deliveries substantially. In early July, I mentioned that FedEx would be a stock to watch after its earnings beat gave it a much-needed win; the company had spent the prior two years languishing due to several disappointing earnings reports. FedEx's gains were meaningful because the company demonstrated that residential deliveries are booming. However, the real catalyst for both shippers came when UPS posted its earnings beat in late July.

Going into the quarter, most analysts expected that UPS's business-to-consumer (B2C) sales would grow, but some doubted that it would be enough to offset declines in higher-margin business-to-business (B2B) shipments. But despite slightly lower margins for the quarter, UPS's adjusted net income grew by 8.8% year over year, while revenue grew 13.4%, thanks to a record daily volume surge of 20.9%. 

These strong earnings reports in what was otherwise a difficult quarter for industrial companies were a big reason why shares of UPS and FedEx continue to trend upward.

Dividend breakdown

UPS has one of the safest dividends in its sector right now. Its free cash flow far exceeds its annual dividend payments, and it has maintained or raised its payout annually since 2001. Even in the wake of its recent share price gains, UPS stock still yields 2.5%. 

FedEx has maintained or raised its dividend since 2003, but those increases have been rather inconsistent. It also hasn't raised its dividend since 2018, and at current share prices, the stock only yields 1.2%. 

Let your winners run. High.

The classic Foolish principle -- "Let your winners run. High." -- applies well to UPS and FedEx. Fundamentally, both companies are doing well and leading the transportation sector (and arguably the entire industrial sector). UPS has a better track record of earnings success and dividend growth, whereas FedEx had its first (and much needed) win in a while. I mentioned in June that UPS was a dividend investor's dream, and I continue to believe that the company exhibits many qualities of a strong long-term dividend stock.

After such a strong run-up in a short period of time, it would be understandable if investors might want to sell a few shares of either company and take a victory lap. And if you're going to take some profits on one, I would make it FedEx. However, both companies have proven that they can perform well in a world where people are choosing to rely a lot more on e-commerce. Until the fundamentals change, both companies seem to be positioned well.