Skip to main content

Official Python client library for Databento

Project description

databento-python

test python pypi-version license code-style: black

The official Python client library for Databento.

Key features include:

  • Fast, lightweight access to both live and historical data from multiple markets.
  • Multiple schemas such as MBO, MBP, top of book, OHLCV, last sale, and more.
  • Fully normalized, i.e. identical message schemas for both live and historical data, across multiple asset classes.
  • Provides mappings between different symbology systems, including smart symbology for futures rollovers.
  • Point-in-time instrument definitions, free of look-ahead bias and retroactive adjustments.
  • Reads and stores market data in an extremely efficient file format using Databento Binary Encoding.
  • Event-driven market replay, including at high-frequency order book granularity.
  • Support for batch download of flat files.
  • Support for pandas, CSV, and JSON.

Documentation

The best place to begin is with our Getting started guide.

You can find our full client API reference on the Historical Reference and Live Reference sections of our documentation. See also the Examples section for various tutorials and code samples.

Requirements

The library is fully compatible with the latest distribution of Anaconda 3.7 and above. The minimum dependencies as found in the requirements.txt are also listed below:

  • Python (>=3.7)
  • aiohttp (>=3.7.2)
  • databento-dbn (>=0.3.2)
  • numpy (>=1.17.0)
  • pandas (>=1.1.3)
  • requests (>=2.24.0)
  • zstandard (>=0.19.0)

Installation

To install the latest stable version of the package from PyPI:

pip install -U databento

Usage

The library needs to be configured with an API key from your account. Sign up for free and you will automatically receive a set of API keys to start with. Each API key is a 32-character string starting with db-, that can be found on the API Keys page of your Databento user portal.

A simple Databento application looks like this:

import databento as db

client = db.Historical('YOUR_API_KEY')
data = client.timeseries.get_range(
    dataset='GLBX.MDP3',
    symbols='ES.FUT',
    stype_in='smart',
    start='2022-06-10T14:30',
    end='2022-06-10T14:40',
)

data.replay(callback=print)  # market replay, with `print` as event handler

Replace YOUR_API_KEY with an actual API key, then run this program.

This uses .replay() to access the entire block of data and dispatch each data event to an event handler. You can also use .to_df() or .to_ndarray() to cast the data into a Pandas DataFrame or numpy ndarray:

df = data.to_df(pretty_ts=True, pretty_px=True)  # to DataFrame, with pretty formatting
array = data.to_ndarray()  # to ndarray

Note that the API key was also passed as a parameter, which is not recommended for production applications. Instead, you can leave out this parameter to pass your API key via the DATABENTO_API_KEY environment variable:

import databento as db

# Pass as parameter
client = db.Historical('YOUR_API_KEY')

# Or, pass as `DATABENTO_API_KEY` environment variable
client = db.Historical()

License

Distributed under the Apache 2.0 License.

Project details


Release history Release notifications | RSS feed

This version

0.8.0

Download files

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

Source Distribution

databento-0.8.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

databento-0.8.0-py2.py3-none-any.whl (38.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file databento-0.8.0.tar.gz.

File metadata

  • Download URL: databento-0.8.0.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for databento-0.8.0.tar.gz
Algorithm Hash digest
SHA256 363c58289f24dea815b00e96f7aba9fe41d4fc965433c9a9e5b6954c5f5d0862
MD5 6d1b5b672438b3b3f886209975787522
BLAKE2b-256 79cdf0c0c1c07afb78011caa4e6f2df6e2c5453e0ba328a10bdea5d75cf51c8e

See more details on using hashes here.

File details

Details for the file databento-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: databento-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for databento-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a56d4593fe5ea34e28d3373fd7d2d21272b867d52eb40913627e6f3eb9cc81cc
MD5 a367618234e254907788af11743aa69d
BLAKE2b-256 5c06747e4429a957bb6541144c4dcf45fe0599890372797779d91c7756358ac3

See more details on using hashes here.

Supported by

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