-5

How do websites like cryptocompare.com, coinmarketcap.com or livecoinwatch.com track the prices of cryptocurrencies? What are their sources?

Are they scanning or calculating or just using APIs?

How can I start building one?

AmyyazdaN
  • 303
  • 1
  • 9
  • They just connect to the exchange's API. It only takes 5 lines of code. Couldn't be more simple. – Alex B May 22 '22 at 04:47

1 Answers1

1

First you have to understand what the price of something is. The real price of something is how much people are willing to pay for it. If the seller is willing to sell at the price the buyer is willing to buy then a sale happens - the sale also defines the price of the item.

For example, McDonalds have the right to sell the BigMac at any price. They are free to sell BigMacs for $5000 each. However, if they do that then nobody would buy their burger. Therefore, while McDonalds can put any price on their product, the real price is the one which people are willing to pay. In economics-speak it is where the supply meets demand.

So the real price of a cryptocurrency is the the last price someone bought/sold that cryptocurrency. The easiest place to track this is at exchanges.

How exchanges set the price

Exchanges of all types (crypto, gold, oil, stock, forex etc.) don't actually set the price. Instead they infer the price from the last successful transaction. There are generally two types of transactions that exchanges deal with:

  1. Immediate/Quick buy/sell - this is where you buy/sell (or at least try to) your item (stock, bitcoin, gold etc.) at the market price. The exchange will use the information of past sales to set the market price.

  2. Orders - this is where you tell the exchange that you want to buy/sell the item at a specific price. Orders are recorded in a database called the order book. The Exchange will scan through all orders and try to match the sell orders to appropriate buy orders so that buyers willing to sell at a specific price can be matched to sellers willing to sell at a specific price.

Obviously sellers want to make profit and tend to set the price higher. Those who cannot find buyers willing to buy their expensive items will just wait forever in the order book (or cancel their order at some future time). Buyers on the other hand tend to set the price lower. Where the buyer price meets the seller price is the market price. With enough people in the market there will always be sellers who are more inclined to get the money now than wait for the price to go up.

Therefore, each exchange generally have their own "market price". Price aggregator websites like cryptocompare scan exchanges and average the overall prices.

Some exchanges have APIs allowing you access to their market data. Coinbase for example have such an API: https://docs.cloud.coinbase.com/exchange/docs. Other exchanges don't provide APIs so aggregators will need to screen scrape the data from their websites.

Note that purchase/sales of cryptocurrencies does not only happen in exchanges. There are quite a few WhatsApp and Telegram groups where you can advertise your cryptocurrency for cash. So there is quite an active and sizable "black market" of crypto sales that are not tracked by exchanges.

slebetman
  • 109,858
  • 19
  • 140
  • 171
  • Thank you so much for your great answer. But why am I need to track all other exchanges? And how I must to show final price in my website while I'm getting multiple prices from exchanges per cryptocurrency? – AmyyazdaN May 23 '22 at 08:10
  • Since each exchange only track their own price the price of one exchange (eg. coinbase) is not necessarily the same as another exchange (eg. Luno). Indeed, they're usually not the same but close. The difference in prices between exchanges is arbitrage. And indeed people do notice these things and will try to make money by buying crypto from cheaper exchanges and sell them to more expensive exchanges. This arbritage trading is what equalizes the prices between exchanges. A few years ago people were making a million dollars per day from arbitrage trading alone – slebetman May 23 '22 at 08:45