# Bitcoinity.org

## Ranking system

TL;DR: Using order books instead of volume to decide which exchanges are the biggest.

#### Why complicate

Currently exchanges are ranked based on their volume. It's not a bad idea, but there are some problems with it. There's a big difference between volume on exchanges with or without fees. Even on exchange with fees, some big players with low fees can influence it heavily. It's also very hard to verify.

#### Proposed solution

Apart from volume there's another useful information available - order book. The deeper the better. Being able to execute a big order without moving the price too much seems to be a good indicator that the exchange should be ranking high.

Unlike reported volume, order book can be (at least partially) verified. Somebody can try to execute an order against it.

Ranking must not be easy to manipulate. Having some big wall at \$0.1 does not make you a great exchange. Clearly, open orders that are closer to the current price are more imporant.

But how close? When Bitcoin price is changing 10% per day, then surely those orders 10% away from the price are important. But if it stabilizes and only changes 0.1% for weeks, then some wall 10% away from the price is not very relevant. It shouldn't influnce the ranking.

To solve this problem we weight open orders based on how long ago given price was achieved.

Let's first take a look at an example orderbook with plotted amount of days since given price was present:

Bitstamp 2024-08-07 06:42:00 UTC

And now, jumping ahead, this is how weights assigned to these orders will look like (weigths are assigned to single orders, even though you see cumulative order book here for clarity):

Bitstamp 2024-08-07 06:42:00 UTC

As you can see, more weight is given to orders at prices that were present lately.

#### Weight

For given order, If we assume that d is number of days ago since we've last seen given price, the weight is:

$weight = \frac{1}{g*d + 1}$

Where g is a param that shapes how quickly should weight decay with days. I assumed g = 15, which makes orders at the price that was present 5 days ago two times less important than those at the price that was present today. This param is sucked out of my thumb and its value is open for discussion.

To be super clear, here's the chart how weight depends of number of days since given price was present.

When testing different values of g, it did not change ranking much. Higher values make rank more prone to manipulation with orders that are unlikely to get executed. Lower values make rank more noisy for shorter timespans.

#### Rank

Every rank calculation is based on a single order book. When you see e.g. 24h rank, it's an average rank of all order books collected during that time (for popular exchanges full order books are fetched every few minutes).

The general idea is that we're measuring money stored in the orderbook, giving more attention to the fresh one, to make manipulation of rank more difficult.

We can put it as:

$rank = rank_{asks} + rank_{bids}$

Let's focus on asks first. Asks are associated with bitcoins stored on the exchange.

We just want to sum that, assigning weight to each order:

$rank_{asks} = \sum^{asks} amount * weight$

In case of bids it's the fiat that is stored, not bitcoins. Amount of fiat can be calculated as: $price * amount$ . We want to add bids and asks rank at the end, so they need to have the same unit. To get amount in bitcoins we divide this amount of fiat by current bitcoin price:

$rank_{bids} = \sum^{bids} \frac{price * amount}{price_{current}} * weight$

To be consistent current price is also based on the orderbook and not trades:

$price_{current} = \frac{bid_{max} + ask_{min}}{2}$

And that's it. The results can be seen on data.bitcoinity.org

#### You did it

Thanks for getting through it. I'm open to ideas and suggestions. If you think something could be made more clear in the explanation or you found some errors, please let me know. This thing is new and the discussion is currently happening here ( previous one )