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

The set of exchanges is fetched dynamically from the API and reflects exactly what your API key is permissioned for — the client does not hardcode a list:

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

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-3.0.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-3.0.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-3.0.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-3.0.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-3.0.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-3.0.0-cp314-cp314-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

lotech_market_data-3.0.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-3.0.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-3.0.0-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lotech_market_data-3.0.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-3.0.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-3.0.0-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lotech_market_data-3.0.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-3.0.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-3.0.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-3.0.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1bc49db19e46ec5e26729db050bf68d3b29de80873ff6636f0f51354607d0a3
MD5 ba0ae1e59e73f3bb06903dc3e580027b
BLAKE2b-256 7cca5a22f33823db51b73cfe63598c40df8da1ed66a6b15e89dd73d69c3ed9b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b2de5945a2521a584af419ec6c53aaae2d055e6803037ca431e68b9d9e6cc88e
MD5 c89e02c0720704ca4fbeab591098008e
BLAKE2b-256 a51bcbf95e822b8d35c01db339e80a67a5db64d1239722973773d77f1b514666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c36026469e0b879cf9fde529da8aa7786ad951acaa1ce7e781867d2c119d6842
MD5 f03c689b379f623f6f766a4783ccb6d5
BLAKE2b-256 72b1a303665c358accd8e347737e01e8aeac7c134a97f67659063edf81035c38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dbb5347740fda2822085c58ff736ae0350afd165da03dbf25ca19fdf08e41426
MD5 727fa2e90be6168fbd85b091bd2dc4fe
BLAKE2b-256 53df665b36b538f28ac4b893776e4163f80f708e93286f75f7cd662f6093bbfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2da297e3938d7fb3a0c04d52a32627b8c722f27d505a7e0ecfe074eacc670b9
MD5 84a0c2856905f78e8503c9b49aa8bafe
BLAKE2b-256 2ad96189a79761515074300e304cdf7c4ad4c8963bf06d2c9ce77bd2fb5b61f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8d0243d904c793afea57162cd466a833f8cfe320b0c83e268c24acdc9ae42ca7
MD5 fc86e150a5fea6e54d80fca3e5910d45
BLAKE2b-256 0129bb4e5bad9b9328ef17e32734b3ca453b5c9cf57da0fc535f791f7117267f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 620398a76921ce8c01da6122f26b153aab3e0f6751f066317652dbb07cbc4c59
MD5 dddc88758e1f0725f64b6bba8a21a08c
BLAKE2b-256 242c2bc7542a4b37956f42deca498d6942d5fdc13e096600b26b100c5ddabd2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cff1be3e186a86a96478f8c29a42876b0f93cbe8f3520f3d1a99eb2455875c42
MD5 93ea01cf99f8e17c6328f4e78967b6c4
BLAKE2b-256 9dc93587f7c8539f3f429339761a8e3bfac7afdb1336b7c473a5aee6e57301df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83bd0b38e049d96d14347d769a18d56cffe98c3e5abdda9b1ed7a9fc71c8f092
MD5 4ad681b5213a91f3147c72711989c917
BLAKE2b-256 c250e967ff003c58dc1a0bda1724c7a7c0b1cebbe974dfafd8881f60776d77bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25860ca3b91ea5536d1a2223a11e4f467e7880ab081633da31fa7256f8666f04
MD5 ed15cc7e13d50e40ce47a832c3619673
BLAKE2b-256 20ec55da60d451dd6dd3a8314af1ba14d311bdb4c55d34079c5d535a8bb20113

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18101652884224adc0146b1951267b5612d34f9fe6565eae943f6adda2faabfb
MD5 b0e406e18b02055c9e68ed3548f44298
BLAKE2b-256 714945de5146a21c7344f286889119ae302011e322b53445652dad03665f3a4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4581adecb3c28890aa5930aefe96f7a788966919a237bb95a9f8f73e5f04b8d
MD5 c978b53ec393c01f6a2b755f712f69ab
BLAKE2b-256 b3cee8e4635334b70fcfc54e75fb7d8e667f0cf53ae46bc88199808752cb7d61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e4144bd7045633f6bafc61b8297d698509d27362ecd54b8a5b2b8847bd05c44
MD5 5d081df2acc6b0362a4ca7688c837857
BLAKE2b-256 43cb64bc2bd8083c8cb5b39c39e8925a954b4c37c0dc1e6709b413be0d780b21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1419ba80f81cd8e79d81a476fed28c3e89ceebb76eaeb4aa3fa099c9e9edc02
MD5 e9702e13a03ce66584239f4943554078
BLAKE2b-256 9c12c9c848fb05733c819ba06406c5ea202b1281623a7b5e006762b7ed786df4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c0cee8e3425930b6bf2a6b1b85a24f6ebffe1ab0d1e5f1df12e34c9a188cbf88
MD5 056bfe2479ef07a7fe59646836ac1a75
BLAKE2b-256 733cf536031acce0d9073c340ac4846db53e0b46c4ffe68154974c760b458800

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-3.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08f583f5e842fc681dae26849bd59a28a4115610fba0ee55975fb78c924ad99c
MD5 bcffdb06fdd1325badea4f5d60c3dc30
BLAKE2b-256 3763598758b4a239ce3a7f191f71e6d5e253c3ad1e6767425c59e44b3d9e214c

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