President Donald Trump, right, speaks as Tim Cook, CEO of Apple, listens during the American Technology Council roundtable hosted at the White House in Washington, D.C.

Wall Street is buzzing over Apple's strong earnings results, driving its shares to a new all-time high.

But in addition to the smartphone maker's premium pricing for its latest iPhone, Apple shareholders should credit President Donald Trump's tax reform for their gains this year.

Apple shares rose 5.9 percent Wednesday, a day after the company posted better-than-expected fiscal third-quarter earnings per share of $2.34, beating the $2.18 Thomson Reuters consensus. The company's stock is now up about 19 percent so far this year versus the S&P 500's 5 percent return.

The gains come even as Apple has slightly missed Wall Street's iPhone unit sales estimates in each quarter this year, reporting unit sales growth of 1 percent year over year in its June quarter and 3 percent year over year in its March quarter.

This may be confusing to some market veterans because in the past Apple's stock traded primarily on whether its iPhone unit sales beat or missed Wall Street expectations. Estimates that were already lowered from a year ago, when analysts predicted the iPhone X would drive a "super cycle" of double-digit unit growth.

Apple was able to offset slower unit growth by charging higher prices with the iPhone X, which starts at $999. The average selling price of the iPhone rose about 20 percent year over year to $724 in the June quarter, though some investors don't believe the company will able to sustain such pricing in the future.

But the other difference maker for Apple this year was Trump's tax reform.

The president signed the Republican tax overhaul in December, which lowered the corporate tax rate to 21 percent from 35 percent. The bill also taxed overseas profits at a lower 15.5 percent repatriation tax rate, allowing companies to use foreign cash balances to invest in domestic projects or increase shareholder capital returns.

As a result, Apple was able to unleash its balance sheet of more than $200 billion in cash overseas and report higher earnings growth.

For example, the company's June quarter earnings per share rose by 40 percent year over year, while operating profits grew 17 percent. The difference in growth rates is due to a lower tax rate and increased shareholder capital returns (buybacks) versus the prior year.

Apple's June quarter tax rate dropped to 13.3 percent from 22.9 percent last year.

And the company returned about $25 billion per quarter to shareholders through stock buybacks and dividends this year versus the approximately $11 billion per quarter last year. Buybacks lower Apple's shares outstanding, resulting in a higher earnings per share.