The S&P 500 index dropped into a bear market early last year as high inflation and rising interest rates gnawed away at investor confidence, and very little has changed since then. The S&P 500 is still down 17% from its highs, inflation remains elevated, and the Federal Reserve recently raised its benchmark interest rate for the ninth consecutive time. Given those challenges, JPMorgan Chase analysts estimate the odds of a 2023 recession at greater than 50%.

It may seem counterintuitive to buy stocks under those conditions, but that is exactly what investors should do. Pessimism has suppressed valuations across the market. The forward price-to-earnings ratio of the S&P 500 is now below its 10-year average, meaning many stocks are trading at a discount to their historical valuations.

Here are two of the best stocks to buy right now.

PayPal: Digital financial services

Juniper Research says the number of digital wallet users will increase at 11% annually through 2026, and digital wallets are steadily displacing cash and payment cards in both physical retail and e-commerce. More broadly, digital payments revenue is expected to grow at nearly 21% annually through 2027, according to Grand View Research. PayPal (PYPL -1.83%) is well positioned to benefit from that trend.

PayPal is the most accepted digital wallet in North America and Europe, and that strong competitive position underscores the value in its two-sided network. Whereas most payment processors work only with merchants, PayPal offers financial services to merchants and consumers, meaning the company often has data (and trust) on both sides of a transaction. That helps PayPal prevent fraud and boost approval rates. In fact, it has the highest authorization rate and the lowest loss rates in the industry, according to CEO Dan Schulman.

PayPal reported somewhat lackluster financial results for its fiscal year 2022. Revenue rose just 8% to $27.5 billion and non-GAAP earnings dropped 10% to $4.13 per diluted share. But that weak growth can be ascribed to the challenging economic climate. Even so, management has taken steps to cut costs and refocus investments, and those efforts should lead to strong results this year. In fact, management expects non-GAAP earnings per share to climb at least 18% in fiscal year 2023.

Currently, shares trade at 3.1 times sales, a discount to the three-year average of 8.8 times sales. At that price, this growth stock is worth buying.

The Trade Desk: Digital advertising

Ad tech company The Trade Desk (TTD 0.85%) operates a demand-side platform (DSP). Its software allows marketers to run data-driven campaigns through digital channels like connected TVs, desktops, and mobile apps. Its DSP is unique in its use of bid factors, a system that allows marketers to set detailed targeting parameters with just a few clicks. Its platform also includes the world's most advanced data marketplace and industry-leading artificial intelligence , which provide marketers with unparalleled targeting and campaign optimization capabilities.

The Trade Desk has further distinguished itself by eschewing affiliation with specific content. Ad giants like Alphabet and Meta Platforms have a clear incentive to push marketers toward their own ad inventory on web properties like Google Search and Facebook. But The Trade Desk does not own any web properties, so it has no reason to steer marketers toward any particular inventory. That keeps its values aligned with marketers, which has helped the company maintain a retention rate above 95% for eight consecutive years.

The Trade Desk delivered solid financial results last year despite operating in a difficult economic climate. Revenue increased 32% to $1.6 billion and free cash flow climbed 43% year over year to $457 million. Those metrics are particularly impressive given that Alphabet only managed to grow revenue 10% and Meta Platforms actually saw revenue decline 1%. And investors have good reason to believe that outperformance will continue.

Consultancy Quadrant Knowledge Solutions recently recognized The Trade Desk as a leader in the ad tech space, citing better technology and a more profound customer impact than any other vendor. That portends strong growth in the coming years. The ad tech market is expected to increase by 14% annually to reach $2.4 trillion by 2030, according to Grand View Research.

Currently, The Trade Desk's shares trade at 19.5 times sales, a discount to the three-year average of 30.3 times sales. That creates a compelling buying opportunity for patient investors.