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.

Documentation: dxfeed.readthedocs.io

Package distribution: pypi.org/project/dxfeed

Installation

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 https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | 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('demo.dxfeed.com:7300')

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: demo.dxfeed.com:7300
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', date_time=datetime.now()) \
                  .add_symbols(['AMZN'])
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.

candle_handler.get_list()

Close connection

endpoint.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 details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

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

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 details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

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 details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

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

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 details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

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

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 details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

File details

Details for the file dxfeed-0.5.3.tar.gz.

File metadata

  • Download URL: dxfeed-0.5.3.tar.gz
  • Upload date:
  • Size: 547.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3.tar.gz
Algorithm Hash digest
SHA256 a1a60d8813ab93a59934dab06c44e172bcb1228060b6ff4fe9e100aceb1287c8
MD5 2d0e697a2e840c1ec837c328b3774691
BLAKE2b-256 0530ad471951a00e77a9aadd08cf4d314f1cb3094df5dd0d7b0e5efcb3e5b9c5

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 396ad93c34b5fc3ff7c04382dbd9b11f05190793b95327411d140b8380dd5466
MD5 9ffd9bda6eaf935947ed423f14b44b0b
BLAKE2b-256 76fec11ad09d9fcdea6dcdb05c22066795967a7405341d44d19d69bd25f89705

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 03c2b0a7deff8c98e9cc47cb1302612e4f8b2b71d9f7005ce65fc288c1f71ccf
MD5 507765f01266d69503bae1df78579ac3
BLAKE2b-256 ae71b5a3b45e41811b6c9c567cb41dd4d67c020a74f6d263e0f3dfdcbb1ed24d

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 800.6 kB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ea91e873757d273b0200c900012a520a611602df02e741edeb2c67ec4a366b81
MD5 513355fe4f457073176d4d73a29dcb90
BLAKE2b-256 d003a3c2138dbb8ae21215f401c294dda7674e046a43e889290acc7fd1be3aba

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0dbfea4f80682d1a99ac56dbba1314c7f05a2a5a16b7443f1254b287439328f1
MD5 1629e17094e05096f88c881d4e9904f4
BLAKE2b-256 ebe5faa0c2618a0bdec5bdff1443f5d948d0585157b22147393d6158cda81df5

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, manylinux: glibc 2.27+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5cdf8ac42150dda6898bb7477858421790d8a420e4d9c9ba1b595932b1070af8
MD5 9642904b1c272258ba947b171c9ce3ac
BLAKE2b-256 ce2a28e24c3f87f7210fc43b3949ac5c5485b7a72c530b3046281c30df5e0aba

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 798.1 kB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2409461509b7fec3259354eac14b75ac143c43ca0c1945d777ee3440f12231bf
MD5 46076f4a57ae1a89e1d89f41efddaec7
BLAKE2b-256 721d6cd0ec1373e27055749151b9638338450d3e10b473473ccaa42b1ef153a7

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5fd2fe8ba0256f6db7ba3396dfb60c6c808dd072cc917373ac236d298aa768b8
MD5 a5220906e7d3f7925c0e297a23d3bd4a
BLAKE2b-256 e96abddcecbfec8bacde0870e31e3b34fceabb4e861b8ba06b7ff71de2f9d7c1

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.27+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 e0096247d2d531f44f8b28f90784ba4c441370af3c766a522a16fd76efdc670b
MD5 f463ce02557ff6be1527ea73189d27c0
BLAKE2b-256 75859017e2a93d55e60e0e58843cfee250fcdd1dae7894f25d21b8145d235850

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 795.8 kB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6a4a3eb61515c4abafdc590a85bbeabe72c99f84d5d13d238b09a06b7161bbf1
MD5 be40fea2d3dda449107a66d0dba297eb
BLAKE2b-256 06a0bc1a787bb6f9d122da9420b3e1ea5ec2b279c4f24ad243e54eb0ae456f90

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 dbd4052fdb4058d08083975d4ba57a8ad56de2e26387d6af662195ff57bdd256
MD5 4ffb35e043635df792bec3f8f0f87b87
BLAKE2b-256 39d76c9f638502c9b9a510e43fb668235f4290d2cda6d353be02bc54e60a3bfa

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.27+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 4f420330e6d86944fcb78e0ff9f72481446bc876038db748f2650ec89305d816
MD5 ec04ec30cdfab880e019ebe3ef82abf4
BLAKE2b-256 07d31fe5ac70ec33e4bd4251dd9a24bfe1e5784788c2070a8a4982a7e27fb055

See more details on using hashes here.

File details

Details for the file dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 798.6 kB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure

File hashes

Hashes for dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cc0b4d6a65b6c43faaa2b964968a4415d33aacc0a011763d2c16d010a080289f
MD5 1b9638609d1e7df951f8df1fc49c110c
BLAKE2b-256 5fa2f71f3386fd40ba79c8446a3383a91578926dd2c190e24dd659a92147208d

See more details on using hashes here.

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