A wonderful exercise that could make investors better is to study the best-performing stocks in the past. By understanding what made them successful, we can apply that knowledge to potential investment candidates. 

In the past decade, the stock of Mastercard (MA 0.07%) has climbed 504%, beating the 162% gain of the broader S&P 500 index. So someone who put $10,000 into this top financial stock in October of 2013 would see a balance of $60,400 today. That's a great return. 

Let's look at what factors have benefited Mastercard, while also considering what prospective investors should do today. 

Strong fundamentals and tailwinds 

Mastercard's price gains have come on the back of impressive top- and bottom-line growth. In the past 10 years, revenue and net income have had compound annual growth rates of 11.6% and 12.7%, respectively. It's hard to argue with those kinds of financials, especially when they continue to rise at double-digit percentage rates. 

Mastercard has been able to do this because it has some major trends working in its favor. One is the secular growth of cashless transactions. Fewer transactions are being conducted with cash these days, and this will only continue in the decades ahead. By operating one of the biggest payments networks in the world, processing $2.3 trillion of volume in the three-month period ended June 30, Mastercard is poised to keep growing. 

The emergence of the digital economy also helps Mastercard. The rising popularity of smartphones, as well as the increasing number of internet users around the world, likely mean that more commerce will happen over longer distances than when the merchant and consumer are in the same physical location. Think of the growth of online shopping, for example. This trend requires a major card network like Mastercard to help facilitate payments. 

Speaking more to the growth of the digital economy, artificial intelligence could provide another boost to Mastercard. As computers become smarter and more capable, and as more and more products are built to connect to the internet, these hardware devices might need to transact directly with one another without the need for human intervention. Mastercard's network can provide a base-layer solution. 

Is now a good time to buy the stock? 

One of the most obvious reasons to buy shares of Mastercard right now is because the business benefits from a network effect, which I would argue is the most imposing kind of economic moat in the corporate world. Handling trillions of dollars of payments between billions of cardholders and tens of millions of merchants has created an unstoppable force that only gets better over time. 

Because of Mastercard's competitive standing, and due to its network being so entrenched in our economy, it's nearly impossible for an upstart to launch a rival service from scratch. This makes its moat almost unbreachable, an irreplaceable attribute when looking for companies to invest in. 

I don't think investors need to worry about Mastercard running into any financial troubles anytime soon, either. The business posted an impressive operating margin of 58.3% in the last quarter, a usual occurrence. And free-cash-flow generation is the envy of probably every other enterprise outside of industry rival Visa. 

However, what should make you think twice before rushing to add Mastercard to your portfolio is the current valuation. At a trailing price-to-earnings ratio of 37, the stock is about in line with its 10-year historical average multiple. But that's not a bargain price, to be clear. 

Some bulls could make the valid argument that Mastercard always deserves a premium valuation due to all of the qualities I highlighted above. And naysayers will point to the optimism perhaps being priced into the stock right now.