Twitter’s stock soared after it debuted on the market. This may surprise you, but that kind of gain was bad for the company and good for Wall Street.

To understand why, here’s a little background on how investment banks estimated the price for Twitter’s initial public offering in the first place.

Coming up with that number requires some financial acumen and a lot of educated guesswork. It’s a little like selling a newly built house. A real estate broker can only look at similar houses, gauge the market and come up with a price that is attractive enough to buyers, but not so low that it disappoints the builder.

When a company wants to raise money by selling stock, it also relies on a broker — in Twitter’s case, it was Goldman Sachs as well as a bevy of other investment banks. For a fee and a chunk of the stock, these financial types examine the firm’s profits, estimate its growth potential and compare that to peers who have already sold stock on the markets.

After doing this work, the bankers set an IPO price of $17 for Twitter, although they knew this would likely change after they gauged interest by potential investors.

How Twitter's first day of trading compares to other tech companies

To do that, the bankers launched what’s called a road show. To extend the real estate metaphor: This is like holding an open house on a Sunday afternoon and allowing buyers to come inside and take a look. In an IPO, however, the bankers typically make their sales pitches only to a select group of big investors — hedge funds, mutual funds and super-wealthy individuals.

For Twitter, there was massive interest. So the bankers raised the IPO price to $26 on Wednesday. With Twitter selling 70 million shares, the new price meant the company would raise $1.8 billion through its IPO. It’s important to note that no matter what happens to the stock after its market debut, Twitter gets the exact same amount of money.

So a massive gain on the first few days of trading generally means the bankers priced the IPO too low, leaving Twitter with less money than it could have raised. If the stock price tumbles, Twitter will still get $1.8 billion, but a sell-off is a little embarrassing, showing that the company’s share price may have reached too high. This stigma dogged Facebook after its disastrous market debut last year.

One other calculation goes into setting the price.

Often when bankers know there is great interest in an IPO, they price the shares a little low. That delivers the banks and their investing clients a nice “pop” on the first day of trading. This is one of the least democratic aspects of the financial markets. Mom-and-pop investors likely could not buy Twitter at $26. That privilege was reserved for insiders who have connections to either the company’s top ranks or the investment banks.

The initial gain was massive in the case of Twitter on its first day. The stock rose about 90 percent as soon as the stock began trading. That means Twitter likely left some money on the table. It also meant a huge gain for the insiders of the IPO game.

Related stories:

Twitter’s divesity problem: Vivek Wadhwa criticized Twitter for going public with no women on its board. (The Washington Post)

Twitter opens at $45.10 a share, compnay valued at over $25 billion

Where is Twitter most popular? This map will surprise you.