Home

Awesome

tardis-client

PyPi Python <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>

Python client for tardis.dev - historical tick-level cryptocurrency market data replay API. Provides fast, high level and developer friendly wrapper for more low level HTTP API with local file based caching build in.

Installation

Requires Python 3.7.0+ installed.

pip install tardis-client

Usage

import asyncio
from tardis_client import TardisClient, Channel

async def replay():
    tardis_client = TardisClient()

    # replay method returns Async Generator
    # https://rickyhan.com/jekyll/update/2018/01/27/python36.html
    messages = tardis_client.replay(
        exchange="bitmex",
        from_date="2019-06-01",
        to_date="2019-06-02",
        filters=[Channel(name="trade", symbols=["XBTUSD","ETHUSD"]), Channel("orderBookL2", ["XBTUSD"])],
    )

    # this will print all trades and orderBookL2 messages for XBTUSD
    # and all trades for ETHUSD for bitmex exchange
    # between 2019-06-01T00:00:00.000Z and 2019-06-02T00:00:00.000Z (whole first day of June 2019)
    async for local_timestamp, message in messages:
        # local timestamp is a Python datetime that marks timestamp when given message has been received
        # message is a message object as provided by exchange real-time stream
        print(message)

asyncio.run(replay())

Try on repl.it

API

tardis-client package provides TardisClient and Channel classes.

from tardis_client import TardisClient, Channel

TardisClient

Optional client constructor parameters.

nametypedefault valuedescription
api_key (optional)string""optional string containing API key for tardis.dev API. If not provided only first day of each month of data is accessible (free access)
cache_dir (optional)string<os.tmpdir>/.tardis-cacheoptional string with path to local dir that will be used as cache location. If not provided default temp dir for given OS will be used.

Example:

# creates new client instance with access only to sample data (first day of each month)
tardis_client = TardisClient()

# creates new client with access to all data for given API key
tardis_client = TardisClient(api_key="YOUR_API_KEY")

# creates new client with custom cache dir
tardis_client = TardisClient(cache_dir="./cache")

FAQ

How to debug it if something went wrong?

tardis-client uses Python logging on DEBUG level for that purpose. In doubt please create issue in this repository with steps how to reproduce the issue.

Where can I find more details about tardis.dev API?

Check out API docs.

License

MPL-2.0