dxfeed package
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()
Release files for dxfeed 0.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dxfeed-0.5.3.tar.gz | 547.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| dxfeed-0.5.3-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
| dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.27+ x86-64 | Details |
| dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl | CPython 3.9 | CPython 3.9 | macOS 10.15+ x86-64 | Details |
| dxfeed-0.5.3-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details |
| dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.27+ x86-64 | Details |
| dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.15+ x86-64 | Details |
| dxfeed-0.5.3-cp37-cp37m-win_amd64.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-64 | Details |
| dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | Linux glibc 2.27+ x86-64 | Details |
| dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.15+ x86-64 | Details |
| dxfeed-0.5.3-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | Linux glibc 2.27+ x86-64 | Details |
| dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | macOS 10.15+ x86-64 | Details |
Total release size: 14.3 MB
Release files / dxfeed-0.5.3.tar.gz
| Download URL | dxfeed-0.5.3.tar.gz |
|---|---|
| Size | 547.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1a60d8813ab93a59934dab06c44e172bcb1228060b6ff4fe9e100aceb1287c8
|
|
BLAKE2b-256 checksum How to use checksums |
0530ad471951a00e77a9aadd08cf4d314f1cb3094df5dd0d7b0e5efcb3e5b9c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp39-cp39-win_amd64.whl
| Download URL | dxfeed-0.5.3-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
396ad93c34b5fc3ff7c04382dbd9b11f05190793b95327411d140b8380dd5466
|
|
BLAKE2b-256 checksum How to use checksums |
76fec11ad09d9fcdea6dcdb05c22066795967a7405341d44d19d69bd25f89705
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl
| Download URL | dxfeed-0.5.3-cp39-cp39-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
03c2b0a7deff8c98e9cc47cb1302612e4f8b2b71d9f7005ce65fc288c1f71ccf
|
|
BLAKE2b-256 checksum How to use checksums |
ae71b5a3b45e41811b6c9c567cb41dd4d67c020a74f6d263e0f3dfdcbb1ed24d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl
| Download URL | dxfeed-0.5.3-cp39-cp39-macosx_10_15_x86_64.whl |
|---|---|
| Size | 800.6 kB |
| Tags | CPython 3.9 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
ea91e873757d273b0200c900012a520a611602df02e741edeb2c67ec4a366b81
|
|
BLAKE2b-256 checksum How to use checksums |
d003a3c2138dbb8ae21215f401c294dda7674e046a43e889290acc7fd1be3aba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp38-cp38-win_amd64.whl
| Download URL | dxfeed-0.5.3-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0dbfea4f80682d1a99ac56dbba1314c7f05a2a5a16b7443f1254b287439328f1
|
|
BLAKE2b-256 checksum How to use checksums |
ebe5faa0c2618a0bdec5bdff1443f5d948d0585157b22147393d6158cda81df5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl
| Download URL | dxfeed-0.5.3-cp38-cp38-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.8 Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
5cdf8ac42150dda6898bb7477858421790d8a420e4d9c9ba1b595932b1070af8
|
|
BLAKE2b-256 checksum How to use checksums |
ce2a28e24c3f87f7210fc43b3949ac5c5485b7a72c530b3046281c30df5e0aba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl
| Download URL | dxfeed-0.5.3-cp38-cp38-macosx_10_15_x86_64.whl |
|---|---|
| Size | 798.1 kB |
| Tags | CPython 3.8 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
2409461509b7fec3259354eac14b75ac143c43ca0c1945d777ee3440f12231bf
|
|
BLAKE2b-256 checksum How to use checksums |
721d6cd0ec1373e27055749151b9638338450d3e10b473473ccaa42b1ef153a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp37-cp37m-win_amd64.whl
| Download URL | dxfeed-0.5.3-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5fd2fe8ba0256f6db7ba3396dfb60c6c808dd072cc917373ac236d298aa768b8
|
|
BLAKE2b-256 checksum How to use checksums |
e96abddcecbfec8bacde0870e31e3b34fceabb4e861b8ba06b7ff71de2f9d7c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl
| Download URL | dxfeed-0.5.3-cp37-cp37m-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
e0096247d2d531f44f8b28f90784ba4c441370af3c766a522a16fd76efdc670b
|
|
BLAKE2b-256 checksum How to use checksums |
75859017e2a93d55e60e0e58843cfee250fcdd1dae7894f25d21b8145d235850
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl
| Download URL | dxfeed-0.5.3-cp37-cp37m-macosx_10_15_x86_64.whl |
|---|---|
| Size | 795.8 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a4a3eb61515c4abafdc590a85bbeabe72c99f84d5d13d238b09a06b7161bbf1
|
|
BLAKE2b-256 checksum How to use checksums |
06a0bc1a787bb6f9d122da9420b3e1ea5ec2b279c4f24ad243e54eb0ae456f90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp36-cp36m-win_amd64.whl
| Download URL | dxfeed-0.5.3-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
dbd4052fdb4058d08083975d4ba57a8ad56de2e26387d6af662195ff57bdd256
|
|
BLAKE2b-256 checksum How to use checksums |
39d76c9f638502c9b9a510e43fb668235f4290d2cda6d353be02bc54e60a3bfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl
| Download URL | dxfeed-0.5.3-cp36-cp36m-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.27+ x86-64 |
|
SHA-256 checksum How to use checksums |
4f420330e6d86944fcb78e0ff9f72481446bc876038db748f2650ec89305d816
|
|
BLAKE2b-256 checksum How to use checksums |
07d31fe5ac70ec33e4bd4251dd9a24bfe1e5784788c2070a8a4982a7e27fb055
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|
Release files / dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl
| Download URL | dxfeed-0.5.3-cp36-cp36m-macosx_10_15_x86_64.whl |
|---|---|
| Size | 798.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
cc0b4d6a65b6c43faaa2b964968a4415d33aacc0a011763d2c16d010a080289f
|
|
BLAKE2b-256 checksum How to use checksums |
5fa2f71f3386fd40ba79c8446a3383a91578926dd2c190e24dd659a92147208d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.7.11 Linux/5.4.0-1056-azure
|