user136644: I find the mechanisms behind crypto fascinating, so I wanted to do the thought exercise of creating my own coin, and seeing how it evolves in a simplistic spreadsheet-based example such as this one:

The idea is that each month, in turn, each person (that would be me, here, every time) decides whether to buy, or sell, "Crypto" coins, and how any of them. Each person is different in the amount they already own (the creator of the coin) or the amount of money they have at their disposal.
I know that when creating a coin, the creator determines: a) how many coins it mints, b) how many coins the creator keeps, c) how many coins are injected as liquidity in the exchange, and d) for how much money when adding in the liquidity to set the initial price. The table is here populated with arbitrary data. I'm assuming here that this coin has a fixed supply and no more can be minted, to simplify things.
... Happy as a clam, I tried to run "month 2" - then I realised, that someone who believes in this coin would buy a lot of it because it's cheap, effectively all that's available as a liquidity seeing how cheap it is. What now? If nobody sells, does the exchange automatically increase the price until holders are incentivised to sell? Second, if for some obscure reason here I would not buy all the liquidity, would the price increase because someone bought it? By how much?
This made me realise that I have absolutely no clue about how exchanges calculate the price of a coin in their system. Is it always the same formula (and just the liquidity + members change) or does each exchange have their own algorithm? How could I simulate an exchange here?
This would help me tremendously if someone could actually try to "play" this example in their answer to illustrate. I'm sure this will be of interest to many as well, because I found this question around quite a lot in my research, but never has how been answered.

user85: Exchanges don't calculate prices, they report them. They aggregate people who want to sell and people who want to buy and report the prices they are willing to buy and sell for. When one person is willing to sell at a price that another person is willing to buy, they facilitate that exchange and report the price.
Say you look at what's going on at a particular exchange with a particular asset. There cannot exist a person who is willing to buy that asset at a price another person is willing to sell it for. Why? Because if that were the case, they would have already transacted.
So there must be a highest price anyone is willing to buy the asset for and a lowest price anyone is wiling to sell the asset for. And the highest buy price must be lower than the highest sell price.
So may there are people willing to buy ABC for $100 or less and people willing to sell ABC for $101 or more. At this exchange, you can now buy ABC for $101 or sell ABC for $100.
This can happen for some time, with people buying ABC at $101 and selling ABC at $100. The trades take place at different prices (buys at $101, sells at $100) but the price isn't actually changing. (This is why even though every transaction is both a buy and a sell since someone is selling and someone is buying, a "buy" is still a logically different transaction from a "sell" at an exchange.)
If someone buys all the ABC that people are willing to sell for $100, then anyone who wants to buy ABC will have to pay more than $100 for it. That's how prices go up.
Similarly, if sells exhaust all the willing buyers at $100 by selling more ABC than that, the next sales will have to go to buyers willing to pay less than $100. That's how prices go down.

136644: <p>I find the mechanisms behind crypto fascinating, so I wanted to do the thought exercise of creating my own coin, and seeing how it evolves in a simplistic spreadsheet-based example such as this one:
<a href="https://i.stack.imgur.com/1H3yY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1H3yY.jpg" alt="enter image description here" /></a></p>
<p>The idea is that each month, in turn, each person (that would be me, here, every time) decides whether to buy, or sell, &quot;Crypto&quot; coins, and how any of them. Each person is different in the amount they already own (the creator of the coin) or the amount of money they have at their disposal.</p>
<p>I know that when creating a coin, the creator determines: a) how many coins it mints, b) how many coins the creator keeps, c) how many coins are injected as liquidity in the exchange, and d) for how much money when adding in the liquidity to set the initial price. The table is here populated with arbitrary data. I'm assuming here that this coin has a fixed supply and no more can be minted, to simplify things.</p>
<p>... Happy as a clam, I tried to run &quot;month 2&quot; - then I realised, that someone who believes in this coin would buy a lot of it because it's cheap, effectively all that's available as a liquidity seeing how cheap it is. What now? If nobody sells, does the exchange automatically increase the price until holders are incentivised to sell? Second, if for some obscure reason here I would not buy all the liquidity, would the price increase because someone bought it? By how much?</p>
<p><strong>This made me realise that I have absolutely no clue about how exchanges calculate the price of a coin in their system. Is it always the same formula (and just the liquidity + members change) or does each exchange have their own algorithm? How could I simulate an exchange here?</strong></p>
<p>This would help me tremendously if someone could actually try to &quot;play&quot; this example in their answer to illustrate. I'm sure this will be of interest to many as well, because I found this question around quite a lot in my research, but never has <em>how</em> been answered.</p>
 85: <p>Exchanges don't calculate prices, they report them. They aggregate people who want to sell and people who want to buy and report the prices they are willing to buy and sell for. When one person is willing to sell at a price that another person is willing to buy, they facilitate that exchange and report the price.</p>
<p>Say you look at what's going on at a particular exchange with a particular asset. There cannot exist a person who is willing to buy that asset at a price another person is willing to sell it for. Why? Because if that were the case, they would have <em>already</em> transacted.</p>
<p>So there must be a highest price anyone is willing to buy the asset for and a lowest price anyone is wiling to sell the asset for. And the highest buy price <em>must</em> be lower than the highest sell price.</p>
<p>So may there are people willing to buy ABC for $100 or less and people willing to sell ABC for $101 or more. At this exchange, you can now buy ABC for $101 or sell ABC for $100.</p>
<p>This can happen for some time, with people buying ABC at $101 and selling ABC at $100. The trades take place at different prices (buys at $101, sells at $100) but the price isn't actually changing. (This is why even though every transaction is both a buy and a sell since someone is selling and someone is buying, a &quot;buy&quot; is still a logically different transaction from a &quot;sell&quot; at an exchange.)</p>
<p>If someone buys <em>all</em> the ABC that people are willing to sell for $100, then anyone who wants to buy ABC will have to pay <em>more</em> than $100 for it. That's how prices go up.</p>
<p>Similarly, if sells exhaust all the willing buyers at $100 by selling more ABC than that, the next sales will have to go to buyers willing to pay less than $100. That's how prices go down.</p>
