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.

This package already contains basic C-API functions related to creating connections, subscriptions etc. Moreover default listeners (functions responsible for event processing) are ready to use. The user is also able to write his own custom listener in Cython


Requirements: python >3.6, pandas

pip3 install pandas

Install package via PyPI

pip3 install dxfeed

Basic usage

Following steps should be performed:

  • Import
  • Create Endpoint
  • Create Subscription
  • Attach listener
  • 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', data_len=-1)

Attach default listener - function that process incoming events

trade_sub = trade_sub.attach_listener()

Add tikers you want to recieve events for

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

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

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

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

Data is stored as deque. Its length is configured with data_len parameter and by default is 100000. When you call method below you extracts all data recieved to the moment and clears the buffer in class.


Close connection

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

Transform data to pandas DataFrame

trade_df = trade_sub.get_dataframe()
tns_df = tns_sub.get_dataframe()
candle_df = candle_sub.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.3.0.tar.gz (409.1 kB view hashes)

Uploaded Source

Built Distributions

dxfeed-0.3.0-cp38-cp38m-win_amd64.whl (732.8 kB view hashes)

Uploaded CPython 3.8m Windows x86-64

dxfeed-0.3.0-cp38-cp38-macosx_10_14_x86_64.whl (736.5 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

dxfeed-0.3.0-cp37-cp37m-win_amd64.whl (730.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

dxfeed-0.3.0-cp37-cp37m-macosx_10_14_x86_64.whl (734.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

dxfeed-0.3.0-cp36-cp36m-win_amd64.whl (730.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

dxfeed-0.3.0-cp36-cp36m-macosx_10_14_x86_64.whl (739.5 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ 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