A pandas interface for working with dxFeed data
The preferred installation of
dxFeed is from
pip install dxFeed
You'll need to install the Visual-Studio 17.0 tools for Windows installation. The Visual Studio Community package provides these tools for free.
To run the Python unit-test suite, run:
python -m unittest discover .
Basic usage function just like the pandas
read_csv function with an additional
positional parameter that describes the kind of dataset (see table below).
import dxFeed df = dxFeed.read_csv('AAPL.csv', 'order-ntv')
||Depth of book data from NTV|
||Depth of book data from EDGX|
||Time and Sale data|
||Time and Sale data (Reg)|
||CTA Quote data (BBO)|
||CTA Quote data (Reg)|
The package provides functionality to parse flags from the dxFeed data based on the documentation.
To parse order flags (NTV, EDGX data):
import dxFeed df = dxFeed.read_csv('AAPL.csv', 'order-ntv') df = df.flags.order.parse(df)
To parse event flags (NTV, EDGX data):
import dxFeed df = dxFeed.read_csv('AAPL.csv', 'order-ntv') df = df.flags.event.parse(df)
Time and Sale Flags
To parse time and sale flags (TNS data):
import dxFeed df = dxFeed.read_csv('SPX.csv', 'tns') df = df.flags.time_and_sale.parse(df)
Order Book Reconstruction
To reconstruct the order book using the dxFeed order book model, first load and parse appropriate flags:
import dxFeed df = dxFeed.read_csv('AAPL.csv', 'order-ntv') df = df.flags.order.parse(df) df = df.flags.event.parse(df)
Next define the
on_tick callback function that handles an immutable limit
order book at each tick (i.e., event):
def on_tick(book: dxFeed.LimitOrderBook, event: object, adds_sell: int = 0, adds_buy: int = 0, trades_sell: int = 0, trades_buy: int = 0, trade_volume_sell: int = 0, trade_volume_buy: int = 0, cancels: int = 0 ) -> None: """ Handle a tick on the book. Args: book: the book from the order book model event: the event that was just handled adds_sell: the number of sell limit orders that were added adds_buy: the number of buy limit orders that were added trades_sell: the number of sell market trades that occurred trades_buy: the number of buy market trades that occurred trade_volume_sell: the volume of sell market trades that occurred trade_volume_buy: the volume of buy market trades that occurred cancels: the number of orders that were canceled Returns: None """ print(book.best_buy(), book.best_sell())
To reconstruct the book, pass the dataset and on tick handler to an instance of
model = dxFeed.OrderBookModel() model.reconstruct(df.itertuples(), on_tick)
reconstruct expects an iterable set of events, so use
to pass an iterator over the rows (i.e., events) in the data.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size dxFeed-1.1.4.tar.gz (10.8 kB)||File type Source||Python version None||Upload date||Hashes View|