Skip to main content

Python client for accessing LO:TECH market data

Project description

lotech-market-data

Python client for accessing Lotech market data from AWS Athena.

Installation

pip install lotech-market-data

For running the advanced plotting examples:

pip install lotech-market-data[examples]

Usage

Basic Example

import logging
from datetime import datetime, timezone
from lotech_market_data import LotechMarketData

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

client = LotechMarketData()

# Get time range for today
query_date = datetime.now(timezone.utc).date()
start = datetime.combine(query_date, datetime.min.time()).replace(tzinfo=timezone.utc)
end = datetime.combine(query_date, datetime.max.time()).replace(tzinfo=timezone.utc)

# Fetch top of book data
df = client.load_top_of_book(
    exchange="BINANCE",
    instrument="BTC-USDT:SPOT",
    start=start,
    end=end,
)

logger.info("Total rows: %d", df.height)

API Methods

The LotechMarketData class provides the following methods:

Market Data Methods

All market data methods accept the following parameters:

  • exchange: Single exchange string or list of exchanges (e.g., "BINANCE" or ["BINANCE", "BYBIT"])
  • instrument: Single instrument or list (e.g., "BTC-USDT:SPOT" or ["BTC-USDT:SPOT", "ETH-USDT:SPOT"])
  • start: Start datetime (timezone-aware)
  • end: End datetime (timezone-aware)
  • columns (optional): List of columns to return

Available methods:

  • load_top_of_book() - Top of book (bid/ask) data
  • load_trades() - Trade data
  • load_funding() - Funding rate data
  • load_reference_price() - Reference price data
  • load_open_interest() - Open interest data
  • load_orderbook_incremental() - Incremental orderbook updates

Instrument Static

# Get all instruments for an exchange (latest)
df = client.load_instr_static(exchange="BINANCE")

# Get all instruments at a specific datetime
df = client.load_instr_static(
    exchange="BINANCE",
    datetime=some_datetime
)

# Filter for specific instrument(s)
df = client.load_instr_static(
    exchange="BINANCE",
    instrument="BTC-USDT:SPOT"
)

df = client.load_instr_static(
    exchange="BINANCE",
    instrument=["BTC-USDT:SPOT", "ETH-USDT:SPOT"]
)

Column Filtering

You can filter columns to reduce data transfer:

df = client.load_top_of_book(
    exchange="BINANCE",
    instrument="BTC-USDT:SPOT",
    start=start,
    end=end,
    columns=["exchange", "instrument", "ingress_ts", "bid_price", "ask_price"],
)

Multiple Exchanges

Query multiple exchanges:

df = client.load_top_of_book(
    exchange=["BINANCE", "BYBIT"],
    instrument="BTC-USDT:SPOT",
    start=start,
    end=end,
)

Multiple Instruments

Query multiple instruments:

df = client.load_top_of_book(
    exchange="BINANCE",
    instrument=["BTC-USDT:SPOT", "ETH-USDT:SPOT", "SOL-USDT:SPOT"],
    start=start,
    end=end,
)

Available Exchanges

Get the list of available exchanges programmatically:

exchanges = LotechMarketData.get_available_exchanges()
logger.info("Available exchanges: %s", exchanges)

Current exchanges include:

  • BINANCE
  • BITFINEX
  • BITGET
  • BITMART
  • BITMEX
  • BITRUE
  • BITSTAMP
  • BYBIT
  • COINBASEINTL
  • COINBASEUS
  • CRYPTOCOM
  • GATEIO
  • HTX
  • HYPERLIQUID
  • KRAKEN
  • KUCOIN
  • MEXC
  • OKX
  • POLYMARKET

Instrument Format

Instruments follow the format: SYMBOL:KIND[:SUBKIND]

Examples:

  • BTC-USDT:SPOT - Spot market
  • BTC-USDT:PERP:LINEAR - Linear perpetual
  • BTC-USDT:PERP:INVERSE - Inverse perpetual
  • BTC-USD:FUT:LINEAR - Linear future
  • BTC-USD:FUT:INVERSE - Inverse future

Examples

Basic Examples (examples/basic/)

These examples showcase fetching each data type and display all available columns:

  • top_of_book.py - Fetch bid/ask data
  • trades.py - Fetch trade data
  • orderbook_incremental.py - Fetch orderbook updates and build orderbook
  • funding.py - Fetch funding rate data
  • open_interest.py - Fetch open interest data
  • reference_price.py - Fetch reference price data
  • instrument_static.py - Fetch instrument metadata
  • list_exchanges.py - List all available exchanges

Advanced Examples (examples/advanced/)

These examples demonstrate more complex use cases:

  • plot_btc_usdt_exchanges.py - Plot BTC-USDT mid price across multiple exchanges
  • plot_trades.py - Visualize trades with volume bars
  • analyze_instruments.py - Analyze instrument metadata with statistics
  • animate_orderbook.py - Create animated orderbook visualization
  • plot_polymarket_binary.py - Compare Polymarket binary options to GBM theoretical pricing

Example Outputs

The advanced examples generate visualizations in examples/outputs/:

BTC-USDT Mid Price Across Exchanges

BTC-USDT Exchanges

Comparison of BTC-USDT perpetual mid price across BINANCE, BYBIT, OKX, BITMART, and BITMEX exchanges showing price movements and spreads.

LTC-USDT Trades Visualization

LTC-USDT Trades

Trades visualization for LTC-USDT perpetual contracts showing taker buy/sell trades colored by exchange, with weighted mid price overlay and 30-second volume bars.

DOGE-USDT Orderbook Animation

DOGE Orderbook

Animated visualization of DOGE orderbook across 5 exchanges (BINANCE, BYBIT, OKX, COINBASEUS, BITSTAMP) showing cumulative order book depth, mid price movement, and cross-exchange dynamics at 10ms intervals.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

lotech_market_data-2.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

lotech_market_data-2.3.0-cp314-cp314-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

lotech_market_data-2.3.0-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

lotech_market_data-2.3.0-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

lotech_market_data-2.3.0-cp311-cp311-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file lotech_market_data-2.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9eabea681a76207388f48370c6e3d07371c70d0f1b83778104cea49c4f451b0
MD5 f3d5f98cff500d00a1db998bfefa5327
BLAKE2b-256 9609bf5d3a2b55d53cca7a94df47d455bf6e32e4c9d8bb1fd492dcf424606f51

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 109d875db3fbec996fb7f409205e49acbaab57579df8670c94efe043d9591665
MD5 0187d7c19df2d4f2268e7b87118faa1b
BLAKE2b-256 ca61a565a30421ac95bcd3910a366a2548d57cc15757b623d1c9ba1614dcd102

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e038419740cf31c94d4a3e420374a1d99f1a45ca7684aa03f662990341068da
MD5 50092c1c0c94a4b7ce22db0145b7695e
BLAKE2b-256 345cdf599d05307581d8834bc5a5eb85dea8d25e6fb61293de130be0154fc155

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ab633c7f97aaf62b93573a9385c867fd769d4ed0d89de41455a3dcd0c7dac471
MD5 c64e40ebd2d147a2caec1a9885574948
BLAKE2b-256 7dd9e2c9033d6bd2d2aca23c8b891a7c955108c5ff933a604a9c408e9550ac1e

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 283e273ac3081d5541f042f7e71b3a10d6bb9830a3e9ecd9011a70070d27c256
MD5 5cef977ce781d72e8a16a531618077b9
BLAKE2b-256 404020c6271823ab041205274f26559023b054d4502167758073b96e6d953c72

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d725ae630d3321759554afd4c1ba9fab100d6598f572839622c2cd679fabe62f
MD5 832d057c1fab27997909d3fbc46e65d2
BLAKE2b-256 3dd9c68be86dd63e12b929386eeefc20d6f74e66743858f1ea29bc3dbf0f540d

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e929b2bb655be2c682a7045726d72c8ad70b7a4d0804dbe4e6a51320510de667
MD5 15308005f1af0880de6610a0d7446e0e
BLAKE2b-256 78b5df07a5d40341502009cc11286aeed40f3ccb06a1362422c65ac05b35bf52

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f90128a3257dd6ef833312f3e3d47a75986cbf54bac07829caf69905ecf56e1
MD5 9bcddc2c965d56f1a3afccd7325301b0
BLAKE2b-256 42c1ddfac4ca0d76f92816ab2394716b0b8b3aa1ce165293f119a66c850d3284

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ebe6020c1125663db5677087270e19d1da799903c13116464ce8a7e1e834c1d4
MD5 ab1d2b23302d3deb24bac3feec187e28
BLAKE2b-256 4f6ba82d7373a3131f31d8310933f217f337ab83a709bd342a8f1c907cfc8528

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23037706033cb7acb350bcbfdb3ebe36120146a9b0bbf0f396587a1f8218ccde
MD5 cef7b48f0d15b333fd56808680a18fa0
BLAKE2b-256 6ad4ebac5f23f93e410807ae080d7d7013b405a37b4e35cd3a0cde4e7d6cee6e

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff31a1c80721e72f920bdca67ef55ed0c8c62800100736af1a28f44f8d09fa49
MD5 3fecf011dbbc5264edaafb93b46f0366
BLAKE2b-256 13b0c1fc6d042cbba785149806e378e8d6f7e4697911086c2e59a2df8188dbbc

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9906b7910a729ed86c822aa6359b298a846798e25035a35dadbdb22c41d86dcc
MD5 732ff1b781a189ddc8f9d84b09e1c9dc
BLAKE2b-256 5482add252ab5f127d175ee0046c81919b229233b64d2aac97ebf4396732dbc8

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c109af3bbd72d92a9b8c3958c36e7ccd5ce03f9ef2f152c7e10bd5dd50a1c97e
MD5 7b6486c1b2357c0049c19b7373120097
BLAKE2b-256 fd4acc24e6b99fab57a3738aa5eac432121582eb322d39db311634e4a4f3293f

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3b717638cb11271c2bc0f4cddd479680a728033612ce637e6deaa6ae7a9dbc1a
MD5 e211b8d97bd3b1be4af8fb72513e6f8e
BLAKE2b-256 9df96ccd17be0630038054023dc6e3510a1283a86fae7221b9b324aff7d0f99d

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a9a0a172c41ad93ab84dfcd23977e813cc0ac5937d7daff2e64f82a2d14dbdaf
MD5 8777205e2fdcfc3b3807bcc880630fc5
BLAKE2b-256 dd85060df660292833ad7b84d53b91389001a36d2e17e8a9a02efce47ce2b247

See more details on using hashes here.

File details

Details for the file lotech_market_data-2.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5841537e151cd32cfb6f79fc5b47f967e5388c41f29ed957bbca40517ecf0e3
MD5 693d913d831c1b7e90d57a201b4a2b85
BLAKE2b-256 6e98dc0e62609b298041107fd185aac69b6025ddef3ee27babbe6e2fba86267c

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