The stock market can be confusing at times. 

Russia's Gazprom (OGZPY), for example, just did one of the largest business deals in history: It agreed to supply China with 38 billion cubic meters of gas annually for 30 years beginning in 2018. The megadeal could be ultimately worth as much as $400 billion, and Gazprom may get as much as $25 billion in advance payments. For the natural gas producer, the deal guarantees revenues and profits for decades to come and dramatically increases the net present value of its future cash flows.

Paradoxically, however, Gazprom's stock is down from when the news was first announced.

Why shares didn't rally
Gazprom's shares are down because of how the market works.

One way of thinking about the market is that it's a giant discounting mechanism that tries to factor in all publicly available information at all times.

Many market participants anticipated the megadeal several months ago when the Ukrainian crisis first began. Those investors logically assumed that Russia would do a large deal with China to soften the effect of possible Western sanctions.

The timing of this deal was also somewhat expected. Normally megadeals only occur when heads of state meet. Because of this, many investors assumed that the deal would only occur at events when President Xi Jinping and Putin were scheduled to meet.

Because many participants bought in anticipation of this deal, when the deal did occur, there were no surprises. 

This type of paradoxical stock behavior where companies make intermediate tops during good news is actually commonplace. This happens because of how the smart money behaves. Hedge funds and large institutions try to anticipate the outcomes of future news events and establish their positions beforehand. It is the smart money investors establishing their positions that causes a company's stock to move in one particular direction. When those news events do occur, the smart money will typically liquidate part of their position to lock in a profit. It is the liquidation that causes the stock to move in the opposite direction.

The bottom line
No matter what the short-term stock reaction is, the $400 billion deal is a win for Gazprom. The deal makes Gazprom's already cheap stock even cheaper and gives the natural gas producer more pricing power over Europeans because it is now no longer as dependent on Europe as before.

The deal is also a win for PetroChina (PTR), which will get cheaper natural gas from Russia than from LNG. Because it is getting discounted natural gas, some analysts estimate that the deal could bolster the company's earnings per share by 10% beginning in 2018. 

China and Russia are a great fit for each other because Russia has the world's largest natural gas reserves while China's economy needs as much clean energy as it can get. Because of this dynamic, there could be future deals to come. As holder of 65% of Russia's proven natural gas reserves, Gazprom will no doubt benefit from those deals as well.