visit
Summary: I provide an open-source code for calculating the Volume Weighted Average Market Pair Price (VWAMPP) for all cryptocurrencies. The code continuously fetches the prices from all given exchanges and calcualtes the average price, where the price from each exchange is weighted by its volume. This is an open source alternative to websites such as coinmarketcap. You can download the code from .
Let’s begin with a simple question:What is the true price of Bitcoin or any other cryptocurrency?
Answer:
It depends on who you ask from: Bitcoin is currently traded on hundreds of exchanges. all over the world. Each exchange reports a different price. In fact, people make money from taking advantage of this price difference in a process called .So among all these prices which one is the true price of Bitcoin? Let’s take a simple example:Suppose there are only two exchanges who report the price of BTC in USD:One way is to report the average of the two prices, i.e., $11,000. The problem with this approach is that there might be only a few trades on Exchange1, but millions of trades on Exchange2. So a better approach is to give more weight to the exchange that has more trades (or more traffic).
The amount of a cryptocurrency that was traded on an exchange is called the volume.We would like to give more weight to the exchange with higher volume.So assume:
The currency that is used as the reference is called the quote currency and the currency that is quoted in relation is called the base currency. In this example, BTC is the base, and USD is the quote.
Moreover, exchanges report a volume for each market pair.Volume-Weighted Average Market Market Pair Price (VWAMPP) is the average of the market pair prices from all exchanges where each market pair price is weighted by its volume.and are among the leading websites to report a volume weighted average price for each coin which is calculated on hundreds of exchanges.
The VWAMPP is a great approach in calculating a fair price for each cryptocurrency, but the problem is that not every exchange reports the price of each cryptocurrency directly in US Dollars (USD).
Since the first pair is in USD, and the second is in EUR, we should first convert both the price and the volume of Exchange2 from EUR to USD, before calculating the volume average price.
Suppose EUR/USD is 1.2, i.e. each EUR is 1.2 USD. Then we can write:Therefore VWAMPP for BTC is $9,886.71.
What is VWAMPP in USD?
We need to find two things:1. BTC/USD on Exchange2
Exchange2 only reports the price of ETH to be 0.02 BTC. But what we need is the price of BTC in USD on Exchange2.
In order to get to BTC/USD, we can write:Assuming we keep a database of all cryptocurrency prices and in our latest calculations we had the VWAMPP of ETH/USD=204, we can write
2. The Volume on Exchange2
Since Exchange2 is reporting ETH/BTC, the reported 1 B volume unit is in ETH. In order to calculate the volume in USD, again we should use the latest VWAMPP for ETH/USD from our last calculations. Assuming this value is 204, the volume on Exchange2 would be 5 M * 204 ≈ 1 B
Now, we can rewrite our original data as:Therefore, the new VWAMPP for BTC/USD is:
For one reason or another the price of a cryptocurrency on one exchange might be significantly different from the price on other exchanges. It is often desired to exclude that exchange in our calculations of VWAMPP.
An outlier price is:A price that “lies outside” (is much smaller or larger than) most of the other pricesThis can be done by first calculating the mean among all exchanges, and then exclude the prices that are significantly distant from the mean.We can define an outlier to be more than 1 to 5 away from the mean.
I mentioned and already calculate VWAMPP for all cryptocurrencies, so why would you want to calculate it yourself?
For each cryptocurrency C, we need to have a snapshot of all the pairs involving C (either as a quote or as base), on all exchanges of interest in our database. Once we have this data, we can iterate through all of these pairs, convert them to C/USD, and then calculate the VWAMPP on them.
At the minimum, we need the following the following API’s:Exchange API’s to get all the pair informationThere are several issues with VWAMPP that you may want to consider before using it:
You can download a NodeJS implementation for calculating VWAMPP from . This code can be run on a simple Linux-compatible machine and calculate the VWAMPP for each cryptocurrency.
Issues and pull requests are welcome!