- Notifications
You must be signed in to change notification settings - Fork84
1.1 Order book
Figure 1:https://www.bitfinex.com/t/BTC:USD
The order book consists oflimit orders placed on eitherbid (representing potential buyers) orask (representing potential sellers) side of the book.The two sides are separated by thespread.For example, Figure 1 illustrates the state of the order book “BTC/USD” at some timet.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 typelimit.To the accumulation of unexecuted trades at the same price level in the same order book state, we refer to asorder book entry.The order book entry resides on a certainlevel in either side of the book.Furthermore, to the state of the order book at time t we refer as theorder 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 fileorderbook.py currently holds the prototype implementation of an order book.
OrderbookEntry price : float amount : floatOrderbookState lastTrade : Order buyers : [OrderbookEntry] sellers : [OrderbookEntry] timestamp : DatetimeOrderbook states : [OrderbookState]
TheOrderbook
holds a list ofOrderbookState
which should be ordered by their timestamps.TheOrderbookState
further contains the lastTrade
and a two lists ofOrderbookEntry
, representing the bids and asks of the particular state in time.TheOrderbookEntry
(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: