-
Notifications
You must be signed in to change notification settings - Fork 84
1.1 Order book
Figure 1: https://www.bitfinex.com/t/BTC:USD
The order book consists of limit orders placed on either bid (representing potential buyers) or ask (representing potential sellers) side of the book. The two sides are separated by the spread. For example, Figure 1 illustrates the state of the order book “BTC/USD” at some time t. The current best bid-price, on the buyer side (left), is $14,910.00 and the best ask-price, on the seller side (right), is $14,930.00. Therefore, the spread is currently $20.00 wide.
Note that the exchanges, in this case Bitfinex, define a minimal spread per asset as well as a minimum quantity to be traded).
In order to appear in either of the side of the order book, a trader is required to place an Order of type limit. To the accumulation of unexecuted trades at the same price level in the same order book state, we refer to as order book entry. The order book entry resides on a certain level in either side of the book. Furthermore, to the state of the order book at time t we refer as the order book state. Moreover, for every executed order (e.g. trade), the order book state changes and a new state evolves. The same applies for new or amended limit orders.
What is generally regarded as the order book is oftentimes only the current state of an order book. We like to refer to that as order book state and regard the order book as a data structure that holds order book states from the past.
The file orderbook.py currently holds the prototype implementation of an order book.
OrderbookEntry
price : float
amount : float
OrderbookState
lastTrade : Order
buyers : [OrderbookEntry]
sellers : [OrderbookEntry]
timestamp : Datetime
Orderbook
states : [OrderbookState]
The Orderbook
holds a list of OrderbookState
which should be ordered by their timestamps.
The OrderbookState
further contains the last Trade
and a two lists of OrderbookEntry
, representing the bids and asks of the particular state in time.
The OrderbookEntry
(e.g. bid or ask) is contains a price and amount of the asset the trader is willing to buy or sell.
Issue:
- #1: A more stable and efficient implementation (PyLimitBook) should be used.
Currently there are two methods implemented in order to generate an order book from historical data given a .tsv
file: