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

Uploaded CPython 3.14macOS 11.0+ ARM64

lotech_market_data-2.4.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.4.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.4.0-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lotech_market_data-2.4.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.4.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.4.0-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lotech_market_data-2.4.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.4.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.4.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.4.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2443ed063e213961d9f1da647c8daad73f1af07adb4270efda7bf4fceddc3564
MD5 8afcbdbe7bffd6d66e1cc011ae81553e
BLAKE2b-256 4e6aeb9f7e18e2dc81a17a5a91f2c3d8ae29a3687f8ee4da2580bc8a74b1143e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1c7079829df940b0985f9f9a406532a8b3cea366761a27db977e729ff7548841
MD5 7faf57b3ba33da687bccde7b92dd297b
BLAKE2b-256 ab58299411d8a9275619daeccb1fc4c11dcec2649436f7667a5b861b1b4def73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea5aac2faac26ac4083116d62412d88bb19254630fbf26dffe203b06c4e0884f
MD5 7bcd009f278e6e55ece2ba5018fa4e46
BLAKE2b-256 43e6b5ea2b322109b6b0c718738d1765ee2798ac15889ff6b84a37847132a823

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f307ec2eac797ada5d13634d1f2eb0b1bf73b4e41ea5ea8f135f7ef882fd85f
MD5 843fb183ce8d870991e924ef1d8d2e68
BLAKE2b-256 ee17e9dd97c007909b7c7d4a2ada4cb4fd34e9bc59e2b9c636a4872a1e5931ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f201651c9cdfafb8799a78bf26a5ea8914cd1baa47ba46fb615d38d5a596118
MD5 56b2a008bf460a87b95856a23ed41f46
BLAKE2b-256 41e0dc6f9f4f89baebf9232288b814d18319caf13b020216e84ec8485803dea0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8b8595ceb9cd1427be83e8a38b4f4e24cae2b8e3eb530a72d72ba72038e81af7
MD5 cee304c30aef367b05c05678890cfe46
BLAKE2b-256 5faac4d64eceb76645338744966d86c5995eb8f4b98ae9506572d8aa22b06bad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01790aa552658fe435464f85a57503501b551c4136a27d50acc912dfb982d4fb
MD5 017dc8816399923906acb4291d9de99c
BLAKE2b-256 dd094b4c9e47c816a46e75dda34efe767c662d700b372aefd50f232dfd738622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5caa56bb9e7c8d27d70089c272c71b1971012eab12199695d267679e543387b2
MD5 3ed83bd478f6d74173f9b6aec955572c
BLAKE2b-256 65992350912b7e0f8bfd86f282ae1edd46c142a17e5135576c95b2d90f7eddf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4effb9c59bd476cc5d182232d90276df651924fdc5ca778064079fa2782fbf10
MD5 97adb80468e255a620ef656a6f3c4594
BLAKE2b-256 011325266a6fd0814e39d7f42ac1a33bba7d85eee4bbd985301b04dae1a1b2b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 440e3e3f2f061236faab54504a5915dc13d1227b610e21c15fab189d71209b9f
MD5 fcafe38f2eb8ae73bcfeef6d555af2b3
BLAKE2b-256 a5bcf8fc59d52d6eeca0073e06cce8e5cfa4492fafade548df5be8423535170e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae1cebe1c498f93664561427c778c5b80fa9305b27327eff45857f9613579678
MD5 a284a8a3dcb03f8e1f6380cc81d2f805
BLAKE2b-256 3e2d0d17447713403d9bcb8b67bf03f74143ca9b64f7e1b50d3644e0de4b360a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b8c4ee8fa1c7241af5232d5cfab72b1b6a07dc1234d80aaff79d156a4e21b491
MD5 5397123ed45fbd8f4affc96abb7f01c3
BLAKE2b-256 ed28471b49f5344ee1549bd9a51b42ece6639544464215f4a6333747beae8da3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 456df3e1e187c29d4b74deccb9b012a2555c0e817b8b9aea915fc9b96f973f2e
MD5 3e8e38bcc2130d00201b8f000007bc60
BLAKE2b-256 fae59c37fa09f7cc7194e601c6c0a75ef3c02a9ab5585b41660dacaf94a92faf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c112a41615251eaf1ef1a979c6c2d2c2de7b583897170846523b093a4f9b1c45
MD5 5bd3b54fedbd39fef4708ba9b103f05c
BLAKE2b-256 d71abf4c2990a5636b57e15295f3f1d9d51dbda845974b7c0013cbe338095c61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 40f31000d94e6d16dcef004d861fb1f0a205aa148c6a1bb1318cd7744bea74b5
MD5 5f2f6ebc37d9ef03eb7b9e8b09aadd4f
BLAKE2b-256 58ab7e7e2fec46ed46f2d9313ce72fd601b0917bf3694be610e5ae0cff3872a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bad922f772bcaeb82d99c1e0f17c9fc76b7036cfaed7ad77265ea9cea6ed573d
MD5 cc7914b67659bea2fec1b5813ea8997a
BLAKE2b-256 dc1430486cf078145190996d7bc1ccbd27ff8ba619b46804176984e0603775a1

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