Skip to main content

DXFeed Python API via C API

Project description

dxfeed package

PyPI Documentation Status PyPI - Python Version PyPI - Wheel PyPI - License Test workflow

This package provides access to dxFeed streaming data. The library is build as a thin wrapper over dxFeed C-API library. We use Cython in this project as it combines flexibility, reliability and usability in writing C extensions.

The design of the dxfeed package allows users to write any logic related to events in python as well as extending lower level Cython functionality. Moreover, one may start working with the API using the default values like function arguments or a default event handler.


Package distribution:


Requirements: python >= 3.6

Install package via PyPI:

pip3 install dxfeed

Installation from sources

To install dxfeed from source you need Poetry. It provides a custom installer. This is the recommended way of installing poetry according to documentation

For macOS / Linux / Windows (with bash):

curl -sSL | python

In the project root directory (same one where you found this file after cloning the git repo), execute:

poetry install 

By default package is installed in development mode. To rebuild C extensions, after editing .pyx files:

poetry run task build_inplace  # build c extensions

Basic usage

Following steps should be performed:

  • Import
  • Create Endpoint
  • Create Subscription
  • Attach event handler
  • Add tickers
  • Finally close subscription and connection

Import package

import dxfeed as dx
from datetime import datetime  # for timed subscription

Configure and create connection with Endpoint class

Create instance of Endpoint class which will connect provided address.

endpoint = dx.Endpoint('')

Endpoint instance contains information about the connection, e.g. connection address or status

print(f'Connected address: {endpoint.address}')
print(f'Connection status: {endpoint.connection_status}')
Connected address:
Connection status: Connected and authorized

Configure and create subscription

You should specify event type. For timed subscription (conflated stream) you should also provide time to start subscription from.

trade_sub = endpoint.create_subscription('Trade')

Attach default or custom event handler - class that process incoming events. For details about custom event handler look into CustomHandlerExample.ipynb jupyter notebook in exapmles folder of this repository.

trade_handler = dx.DefaultHandler()
trade_sub = trade_sub.set_event_handler(trade_handler)

Add tikers you want to receive events for

trade_sub = trade_sub.add_symbols(['C', 'AAPL'])

For timed subscription you may provide either datetime object or string. String might be incomplete, in this case you will get warning with how your provided date parsed automatically.

tns_sub = endpoint.create_subscription('TimeAndSale', \
candle_sub = endpoint.create_subscription('Candle', date_time='2020-04-16 13:05')
candle_sub = candle_sub.add_symbols(['AAPL', 'MSFT'])

We didn't provide subscriptions with event handlers. In such a case DefaultHandler is initiated automatically. One may get it with get_event_handler method.

tns_handler = tns_sub.get_event_handler()
candle_handler = candle_sub.get_event_handler()

Subscription instance properties

print(f'Subscription event type: {tns_sub.event_type}')
print(f'Subscription symbols: {candle_sub.symbols}')
Subscription event type: TimeAndSale
Subscription symbols: ['AAPL', 'MSFT']

Access data

In DefaultHandler the data is stored as deque. Its length may be configured, by default 100000 events.


Close connection

print(f'Connection status: {endpoint.connection_status}')
Connection status: Not connected

Transform data to pandas DataFrame

DefaultHandler has get_dataframe method, which allows you to get pandas.DataFrame object with events as rows.

trade_df = trade_handler.get_dataframe()
tns_df = tns_handler.get_dataframe()
candle_df = candle_handler.get_dataframe()

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dxfeed-0.5.3.tar.gz (547.6 kB view hashes)

Uploaded Source

Built Distributions

dxfeed-0.5.3-cp39-cp39-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64

dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl (800.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

dxfeed-0.5.3-cp38-cp38-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.27+ x86-64

dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl (798.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

dxfeed-0.5.3-cp37-cp37m-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.27+ x86-64

dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl (795.8 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

dxfeed-0.5.3-cp36-cp36m-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.27+ x86-64

dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl (798.6 kB view hashes)

Uploaded CPython 3.6m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page