People talk about the price of a share the way they talk about the height of a building. As if it were a property of the thing. The building is forty metres tall, the share is fourteen hundred rupees, go and measure it yourself.
It is not a property of the thing. It is a receipt.
I want to walk through how that receipt gets made, because the mechanism is simpler than it looks, and once you can see it a lot of things stop being mysterious. Why your order fills at a worse price than the one on your screen. Why a market can fall ten percent in four minutes and recover by lunch. Why serious firms spend serious money to shave millionths of a second off a journey that is already almost instant.
Three parts. What a stock exchange actually is. How a number gets made inside it. And what changed when both sides of the argument became software.
Start with the thing almost everyone has slightly wrong.
A company sells its shares once. That is the public offering. Money goes from investors to the company, the company takes the cash and builds a factory or hires people or pays down debt, and the investors get paper. That happens one time, plus the occasional later raise.
Everything after that is people who own shares selling to people who want them. The company is not a party to it. It does not receive a rupee when you buy its stock on a Tuesday. You are paying a stranger who owned it before you, and the company is watching from outside the transaction along with everybody else.
So a stock exchange is not a shop. It has no inventory and nothing comes out of a warehouse at the back. It is a room where people who already hold something meet people who want it, and argue about the number.
Now, inside the room.
You want to buy. You have exactly two ways of asking.
You can name your price. “I will buy a hundred shares at 1,399, not a paisa more.” That is a limit order, and it waits until someone is willing to meet it, which may be never.
Or you can decline to name a price. “I will buy a hundred shares, whatever they cost right now.” That is a market order, and it executes immediately at whatever the room is offering.
Every limit order that has not been filled yet sits in a list. Buyers on one side, sellers on the other, sorted by price. That list is the order book, and here is the part worth sitting with: it is the entire mechanism. There is nothing else underneath it. No valuation engine, no committee, no reference number that the book is trying to track.
The buyers are ranked most generous first, so the person willing to pay the most sits at the top of the queue. The sellers are ranked the other way, cheapest first. Which means the two most aggressive people in the room end up facing each other across a gap.
The most anyone will pay is the bid. The least anyone will accept is the ask. The distance between them is the spread.
And while that gap exists, nothing happens. The keenest buyer is still cheaper than the most desperate seller. Everybody waits.
A trade happens the instant somebody crosses the gap. A buyer decides the ask is tolerable and takes it, or a seller decides the bid is good enough and hits it. Two orders match, shares and money swap, and the price of that match gets printed.
That printed number is what your screen calls “the price”.
Three things follow from that, and all three are useful.
Your screen is showing you three numbers, and only one of them has already happened.
The last price is the history. The bid and the ask, either side of the gap, are the live ones: the bid is what you would get for selling now, the ask is what you would pay for buying now.
A big order does not get one price. It gets several, and you pay the average of them.
Look at the sellers in the picture again. The bar at 1,400 is short, so say it is 80 shares. The bar behind it at 1,401 is much longer: call it 340. Now you press buy on 300 shares. The first 80 come from the seller at 1,400, and that seller is finished. The other 220 have to come from the next one along, at 1,401. Your average works out at about 1,400.73.
The screen said 1,400. You paid 1,400.73, and nothing went wrong. That gap is called slippage, and it is not a glitch and not somebody cheating you. The 1,400 was only ever the price of the first 80 shares. You asked for 300. The rest was always going to cost more, because the queue behind the first seller is made of people asking for more.
And nobody set it. This is the part I keep coming back to.
Say some bad news lands. Watch what actually happens in the picture. The buyer bidding 1,399 cancels. So does the one at 1,398. Neither of them sold anything and neither of them announced anything; they just took their offers back. Now the best bid is 1,397, because 1,397 is what was left. A seller who wants out takes it, and 1,397 prints. The headline says the stock fell two rupees.
But look at where 1,397 came from. It was already sitting there, third in the queue, before any of this started. Nobody chose it and nobody wrote it down. It became the price because the two rows above it stopped existing. That is the whole event, and it is why “the market decided the company is worth less today” is really a sentence about who withdrew their offer and what happened to be next in the queue.
So who is on the other side of your trade?
Usually not another investor. Usually a market maker.
A market maker is a firm that posts a bid and an ask at the same time, continuously, across thousands of instruments. It will buy from you at 1,399 and sell to you at 1,399.20. It has no view on the company. It is not forecasting anything. It wants to buy and sell the same thing over and over and keep the twenty paise.
That business is ancient. Think of a money changer at a port.
A ship docks. The sailors have foreign coins and need local money by tonight.
The money changer sits there with a box of both kinds. Their board shows two numbers. Bring them a foreign coin and they give you 95. Want a foreign coin and they charge you 100. So they buy at 95, sell at 100, and keep the 5. They are not guessing whether that coin will be worth more next month. They do not care. They just want the next ship to come in so they can do it again.
What they are actually selling is not currency. It is not having to wait. The sailors could get a better rate in the city tomorrow, and they will have sailed by then.
That is the market maker’s business exactly, and it is what the spread is for. It is the price of trading now instead of waiting for someone who naturally wants the other side of your trade.
What is new is that it is now almost entirely software, and the reason is not that software is cleverer. It is that quoting both sides of a market is dangerous in a way that has nothing to do with intelligence.
Think about what your quote is once you have posted it. It is a standing offer, sitting in the book, to trade with anyone who turns up. You set the numbers a moment ago and you have not touched them since.
Now the company announces something genuinely bad, and everyone decides the shares are worth about 1,390.
Your offer to buy at 1,399 is still sitting there, because you have not got to it yet. For those few moments you are the best price in the room by a mile, and that is exactly the problem. Everyone holding shares comes straight to you. You buy at 1,399 from every one of them, and all of it is worth 1,390.
Most days you struggle to get trades at all. Your offer just sits there.
The moment your price goes stale, that flips. Every seller comes to you at once, there is no limit on how much they will hand over, and every share of it is a loss. So the defence is not to be clever. It is to take the offer down before anyone reaches it.
And because dozens of firms are competing to post that same quote, and only the best price gets filled, you also have to be quick to be first.
Those two pressures, taken together, explain the arms race that looks so absurd from outside. Firms rent rack space in the exchange’s own building so their servers sit metres from the matching engine. The NSE runs exactly such a facility in Mumbai, and the question of who got connected first became a long-running regulatory matter here. It reads like a race to be smarter than everyone else. It is mostly a race to withdraw a promise before somebody takes you up on it.
Market making is one family of algorithm. There is a second that matters more to how large orders actually reach the market.
If a pension fund wants to buy a hundred crore of something, it cannot put that into the book as one order. It would chew through every seller on the ladder, pay a dreadful average, and announce its intentions to the entire room while doing it. So the order goes to an execution algorithm, which chops it into hundreds of small pieces and drips them in over hours, trying to look like ordinary background noise.
I think this is the most under-appreciated fact about algorithmic trading. Most of it is not trying to predict anything. It is hiding a big order while it gets filled.
The strategies that do predict, the ones looking for patterns and betting on them, are real and they make money. They are just a much smaller share of the trading than the phrase makes people assume.
So what actually changed. Two things, pointing in opposite directions.
Spreads collapsed. The gap used to be wide enough to notice on every trade. On anything widely traded it is now a few paise.
That happened because machines compete to be at the front of the queue, and the only way to get to the front is to quote a better price. The saving is real and it goes to ordinary people.
If you buy an index fund every month you pay that gap every time, without ever seeing it. It got much smaller and almost nobody noticed.
Depth got thinner and much faster. The book looks well stocked, orders at every level, plenty of size. But almost none of it is committed. A resting order is not a promise, it is an advertisement, and it can be pulled in microseconds. On a calm day that is a distinction without a difference. Under stress it is the whole story, because everyone’s risk control does the same correct thing at the same moment, and the book that looked full is empty exactly when you need it.
That is the mechanism behind a flash crash. Not a rogue algorithm deciding to sell everything. Thousands of ordinary safety features firing simultaneously.
Now the argument against all of this, which I do not think is silly.
The romantic version says something was lost. That human market makers had judgement, that they stood in the way of a panic instead of running from it, that they knew who they were trading with.
I think that is mostly nostalgia, and the numbers are unkind to it. Spreads used to be wide, and that width was not a safety feature, it was income for the intermediary, taken straight out of the pocket of whoever was on the other side. A small investor in 1990 paid a great deal for the privilege of having a human being in the loop. The machines are cheaper and they do not get to decide they dislike you.
But the honest core of the objection survives.
The old market maker had a weak reason to keep quoting in a panic: people knew who they were, and walking away cost them something. A machine has no such reason. It withdraws in microseconds.
So look at the swap. We used to pay a wide gap on every trade, small and constant and visible. Now we pay almost nothing on ordinary days, and on rare days the book empties at the moment everyone needs it.
Most of the time that is the better deal. The days it is not are the days you can least afford it. I do not know how to weigh those against each other, and I do not trust anyone who says they do.
So here is where I land, and it is three sentences I would want someone to keep.
A share price is not a valuation. It is a transaction record, the last point at which two people holding opposite opinions agreed to stop arguing, and everything else on the screen is the shape of the disagreement that has not resolved yet.
Nobody sets it. There is no author anywhere in the system. “The market thinks” is, mechanically, a sentence about the gap between two sorted lists.
And the algorithms did not replace the disagreement. They took over the clerical work around it and shortened how long any single disagreement is allowed to survive. The argument is still between people. The machines just got extraordinarily fast at writing down where it stands, and just as fast at leaving the room.