|
| 1 | +# PyLimitBook |
| 2 | + |
| 3 | +PyLimitBook is an implementation of a fast limit-order book for level-2 US equities data writen in Python. It includes some tools to output sampled data as well as a curses-based application to view the book and move forward or backward in time. |
| 4 | + |
| 5 | +Input files must be for a single day, symbol, and exchange. |
| 6 | + |
| 7 | +This code is aimed at other developers looking for a limit-book implementation to include in their own trading projects. |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +* Python libraries bintrees (v0.4 used) and pandas. |
| 12 | +* curses and cPickle libraries are also used, but are often installed by default. |
| 13 | +* This code has thus far only been tested on Ubuntu Linux with Python 2.7.2. |
| 14 | + |
| 15 | +## Input Data Format |
| 16 | + |
| 17 | +PyLimitBook applications expect the following input format (in a CSV file): |
| 18 | + |
| 19 | +* bids: |
| 20 | + |
| 21 | + `B,<symbol>,<exchange>,<id>,<quantity>,<price>,<timestamp>` |
| 22 | +* asks: |
| 23 | + |
| 24 | + `A,<symbol>,<exchange>,<id>,<quantity>,<price>,<timestamp>` |
| 25 | +* trades: (optional) |
| 26 | + |
| 27 | + `T,<symbol>,<exchange>,<quantity>,<price>,<timestamp>` |
| 28 | + |
| 29 | +Symbol and exchange values are currently unimportant and can be dummy values. |
| 30 | +Lines should be in timestamp-order from earliest to latest (the order it is sent by the exchange). |
| 31 | + |
| 32 | +## Application Descriptions |
| 33 | + |
| 34 | +* `parse.py` - Simple illustration of using the limit book |
| 35 | +* `tseries.py` - Parse an input file and export 1-second snapshots of the book (Uses pandas library to fill in gaps, etc) |
| 36 | +* `convert.py` - Convert from an input format that uses ', ' as a CSV separator and different column order to the correct input format. |
| 37 | +* `bookViewer.py` - Graphically view the book state at any point in time |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## Known Issues |
| 42 | + |
| 43 | +* There are some resize issues when using bookViewer.py in a (uselessly) small terminal. |
| 44 | + |
0 commit comments