Skip to main content

Official Python client library for Databento

Project description

databento-python

test python pypi-version license code-style: black Slack

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 distributions of Anaconda 2023.x and above. The minimum dependencies as found in the pyproject.toml are also listed below:

  • python = "^3.10"
  • aiohttp = "^3.8.3"
  • databento-dbn = "~0.53.0"
  • numpy = ">=1.23.5"
  • pandas = ">=1.5.3"
  • pip-system-certs = ">=4.0" (Windows only)
  • pyarrow = ">=13.0.0"
  • requests = ">=2.25.1"
  • zstandard = ">=0.21.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='parent',
    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()  # to DataFrame
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

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.75.0.tar.gz (70.7 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.75.0-py3-none-any.whl (88.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: databento-0.75.0.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for databento-0.75.0.tar.gz
Algorithm Hash digest
SHA256 a1ea531d332dd7e315ec328f35f0fd18868141f463ae33e9bf92aabee8c96ab5
MD5 77cda24072abff147d3c40ccb47b71ab
BLAKE2b-256 25b27c7aa74f72c8a19b94252765561efc9f35c2a31c410fb210528195846871

See more details on using hashes here.

File details

Details for the file databento-0.75.0-py3-none-any.whl.

File metadata

  • Download URL: databento-0.75.0-py3-none-any.whl
  • Upload date:
  • Size: 88.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for databento-0.75.0-py3-none-any.whl
Algorithm Hash digest
SHA256 357bd9e9768c54a5b5760b6a1cc9ed3b15a9dec9a1fd2f47d7cf25005c5d5709
MD5 a5f2506ea082ae94852b355ae598d6ae
BLAKE2b-256 7c08f9281410393ddfa4d9a7887b765e00d3605dc571b46c86857df4f6b2871d

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