People reading this article right now are likely in a state of mind that's advantageous for investors. Based on the headline, you're looking for stocks to buy for the long term, even though the market is a crazy roller coaster right now. The S&P 500 was down more than 20% in the first half of the year -- it's worst first-half performance in over 50 years. But then it followed up that dreadful performance with a 9.1% gain in July -- one of its best months ever.

There's a lot going on with the global economy right now, leading to the aforementioned volatility. And because of this, other people want to sit on the sidelines and wait for calmer conditions. But time is one of the greatest assets an investor has. Therefore, whenever possible, we want to put time on our side by buying stocks regardless of market conditions.

For this reason, I congratulate you, dear reader, for willingly putting fear aside and investing for the future. And I'll try to make this worth your time. In this article I'll share my top stock for the long haul, another promising but risky bet, followed up by one of the safest growth stocks you'll ever find.

My top stock for the long haul

For one of the best mixes of safety and upside, home improvement retailer Floor & Decor Holdings (FND -0.28%) is my top stock for the coming decade.

Floor & Decor is counter-positioned in the home improvement space. Its average store size is 78,000 square feet -- much larger than most flooring retailers and larger than the flooring sections at companies like The Home Depot.

The company aims to expand to 500 locations in the coming decade, up from just 174 today. Operating this many huge stores would be a liability for some companies. But Floor & Decor's unit economics make sense. This year is poised to become its 14th straight year of same-store sales growth, which helps leverage the fixed cost of real estate to unlock profits. Its net-profit margin is 7.2% in the first half of 2022, which is behind Home Depot's almost 11% margin. But it's still sufficient to show that there's a place in the market for big-box flooring warehouses -- a niche filled by Floor & Decor.

For what it's worth, the market can support over 2,300 Home Depot stores. Therefore, 500 Floor & Decor locations seems very realistic. And as the company nearly triples it store count, I expect sales and profits to jump at least as much.

Finally, since I keep bringing up Home Depot, I'd like to note that Floor & Decor is led by Tom Taylor, a former 23-year Home Depot executive, meaning he's been around successful home improvement retailers for decades. Since taking over in 2012, Taylor has grown Floor & Decor from fewer than 30 locations to where it is today. And I believe his track record shows he's still the right CEO to grow the business now.

The riskiest stock of these three buys

Digital advertising supply side platform (SSP) PubMatic (PUBM 2.19%) has a lot of risk, but it's admirably overcoming the challenges with ease.

The opportunity in programmatic digital advertising (targeted, relevant ads) is huge. According to Insider Intelligence, the entire market could increase by 50% by 2025. And you'd think this rising tide would lift all boats. But that's not necessarily the case. Consider that PubMatic's top competitor is Magnite. And Magnite only had 7% revenue growth in the second quarter of 2022 when you exclude acquisitions. By comparison, PubMatic grew its top line by 27% during this time period.

Speaking of Magnite's acquisitions, the adtech space is consolidating from scores of tiny players to a select few larger players. This is a risky environment and PubMatic is choosing to plow ahead on its own, foregoing mergers and acquisitions. Management believes it can increase its market share from around 4% today to 20% in the future, which would be astronomical revenue growth. But missing out on just a handful of opportunities could greatly hinder its chances.

For example, customer concentration is a common risk for SSP adtech companies and PubMatic is no exception. One of the company's publisher customers accounted for 12% of its Q2 revenue. And just two demand-side platform (DSP) partners accounted for 32% of its accounts receivable. Losing any of these to a competitor would be catastrophic for PubMatic.

That said, PubMatic's growth has been consistently above average so far. And management is playing it safe. On top of being profitable according to generally accepted accounting principles (GAAP) for 13 straight quarters, the company is also sitting on over $180 million in cash, equivalents, and short-term investments. 

PubMatic's growth, profitability, and large cash position mitigate some of the downside risk for investors. And buying this stock right now gives exposure to an outsized growth opportunity as PubMatic takes market share and as the overall market expands rapidly.

The safest stock of these three buys

As the top e-commerce portal in the U.S., Amazon (AMZN -1.64%) needs no introduction. But did you know this company still has incredible long-term upside even at its size? Well, it does.

For me, I own Amazon stock because of Amazon Web Services (AWS), not its e-commerce business. In the first half of 2022, this cloud-computing platform accounted for just 16% of Amazon's total revenue. However, it was responsible for 175% of the operating income -- earning over $12 billion whereas the e-commerce operations in North America and around the world racked up nearly $7 billion in losses.

This isn't a recent phenomena for Amazon -- it's been this way for years and I think it clearly demonstrates the importance of AWS. And right now, things look as bright for AWS as ever. Consider that the company ended the second quarter of 2022 with contracted commitments of over $100 billion in future AWS spend. This future income stream was just $80 billion at the end of 2021 and less than $61 billion in the second quarter of 2021. In short, AWS' growth is strong and adoption is ongoing. 

All of this said, let's not under-appreciate Amazon's e-commerce potential. Consider that in China, 46% of retail sales are conducted through e-commerce portals, according to Insider Intelligence. In the U.S., it's just 16%. Given China's e-commerce sales penetration, it's not outrageous to think U.S. e-commerce sales could double or more in the coming decade. And I'll let the reader decide which e-commerce company is best positioned to capture the lion's share of that enormous opportunity.

Investing in growth despite market volatility

Because the market is volatile, it's possible that shares of Floor & Decor, PubMatic, and even Amazon could jump higher and plummet lower in the coming year. Being mentally prepared for this is important, so you don't sell out of fear at inopportune moments. Continually verify the long-term potential with each of these companies going forward. And keep your eyes on that steady horizon even if the boat hits rough seas.