Our Bitcoin index XBTCUSD is an index calculated in realtime based on order books of major exchanges including
BTC/CNY exchanges: BTCC, HUOBI, and OKCOIN, and
BTC/USD exchanges: BITFINEX, BTC-E, COINBASE, BITSTAMP, and KRAKEN.
Order books of those exchanges are obtained either periodically through HTTP requests or in realtime through WebSocket.
Since BTC-E's price is usually 2% lower than other BTC/USD exchanges, we adjust BTC-E's price by multiplying it by 102%.
We then calculate the USD/CNY exchange rate as the ratio between the average of all BTC/USD tick prices and the average of all BTC/CNY tick prices.
Then we convert the prices in all CNY exchanges' order books into BTC/USD by dividing the price by the calculated USD/CNY exchange rate.
We then combine all order books together to form a global order book representing the realtime liquidity of all major exchanges.
Calculate the index
The index is calculated in realtime, and it only depends on the current global order book. Because it does not take order book histories into consideration, history information can not help much in predicting it.
We first get the market depths of the bid side and the ask side. The market depth is represented by an array of (Bitcoin price, Bitcoin quantity accumulated from the best bid/ask to the bitcoin price) pair, sorted according to bitcoin price. Graphically, it can be shown as the following:
Then we enumerate a number of quantities, and for each quantity, we find the corresponding Bitcoin prices with the accumulated quantity matching the enumerated quantity for both the bid and ask sides. This is shown as the following graph, where the red line represents the enumerated quantity, and the two prices (bid: 748, ask: 887) are represented by the two green lines.
We then calculate the average of the two prices, which is 817.5 in the above case, represented as the blue line below.
Therefore, for each enumerated quantity, we have obtained one average price. And finally, we calculate a weighted mean price of all the average prices. The weight is a monotonically decreasing function of the volume. Thus we give higher weight to the order book entires closer to the best bid/ask prices. The following graph depict the weight function.