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.0.8-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.0.8-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

lotech_market_data-2.0.8-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.0.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

lotech_market_data-2.0.8-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.0.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

lotech_market_data-2.0.8-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.0.8-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.0.8-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.0.8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 946055aa4d82b5162fd6f91b95b90ba95ab5ff76cc379dc806d2c83bf583a473
MD5 5ff8fcdf9c02a2a2b0e90bd2cc242463
BLAKE2b-256 16852e49d3f8fed54490395650e2a2090ba88c053126932db6339e2b6b241100

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 808c40d3dc70aee89dd113897de6e70bbd24df34d5e23f606afdab89b521a998
MD5 0aff22c329c7fe2f2957c05215697320
BLAKE2b-256 15677feb4a37f80f7c2c0f6d2186374125c3aabd924ad762ccf18292dbb8c577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c9028b400f54eb937613f436767f68238c2821701084aafca4cf163d6971ff2
MD5 6d36987d1f53ac56313490853acabb15
BLAKE2b-256 690b5e7ac98e452f674e8701a14cc75aedbce3971d5757ca6b5c5d9cf4923dfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20477477abc56096a34d75ae838a867f97cdb0625fa723f5ab0f6383a13eb9d7
MD5 a8dc3c8f6db41c2987915b6e63e23db9
BLAKE2b-256 bc1a0dca145b0c6e7e53088dcc0359f91967f056dc05430a61abe3a6d988c0e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d35adefe490e0e0d0983f01a29c021381be2461e7d8d97a46e5c035c0cd46143
MD5 2d32f365072298620c9b9f104ba9a94e
BLAKE2b-256 a381cafa139264362fe5f519197a8dae8cd3a7dc1e624ac288a400f8d16f4113

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8690b0f1cdd1ce456b55f4612e2cdc11351b88344c3a924bb3bc8ab3ecba3d6
MD5 a92a93aa5fbb129c3fe752390d82e446
BLAKE2b-256 f85525f6a977647d4523fa10f9dcf74cb0d7934d907507d7e842722162f7a9d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 db4be8420f3fe92dda33bf7ccfe64e0d6da21da8d7b8119cbac3b7cfd653b4de
MD5 f78e168a9abc3dbca8b5069f9a770897
BLAKE2b-256 b8def8ac75e45954fa068298f641ac612eb2624b12cbac612e8f32fc643af72e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c140fe71246e21d8272a295cb8d98d60478814e80c148f87ed15282eb5612933
MD5 4082cc3a99aca8eb2a9596ce2a0b48ca
BLAKE2b-256 185292065302f439830de13281b349c27654c61f4779074da812cb6fc22b8821

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e83df302e3583dc98b9fc5743b1fbec255c482634bc35d961a08e38d324008a7
MD5 d3402872340ee33d64c862f654f37c19
BLAKE2b-256 5f0449b95f931ca593593545611e809e14f31cf419b146e80865298b4722da04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0be3dbc68227f4d1919d90632b16c162702e8405801365aeeadfe7502cfef11
MD5 06b5dd50fb2a82e85a03ab377fb338c9
BLAKE2b-256 75fa2e3f94d69243cc135e0c8b28184ee9d5f884aab58e905692fe1facee5a7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08dbc07a97540f1346ee875eb016da0a0bcc3dadc08742e4015104c8127b9d35
MD5 3b0aeb9da31f103164663f6238166564
BLAKE2b-256 20cf4ecb6ef9ec731225198062680b164ce94217e8ac85e74bc843b30e7a6806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 975b92647097be4262bb855c1f82686a04179b22952d2316f926958c24e60e10
MD5 deaab46cfc0e0b7f97d4abaf98831fba
BLAKE2b-256 e6e9e1253e199a91da336b643c09563ce69a152714f579606f28295f156506aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aee7e5b9c2dd1323ab8fe8ec1269ef54e6ebc41ccedd5faebd4d6dd73b9195b9
MD5 acbdbb2e0aad46f015d0ff3cc04a436a
BLAKE2b-256 ca80182d743df35eb429ef449803631d9e197e9dd6fc41940a790c6c3cb76d83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lotech_market_data-2.0.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b43dd2323dc243a20e0fd46890118ad5cb57cdeac65ffdf1ad392c7327676632
MD5 21edb500792c9f684ebec7d3327d0bbb
BLAKE2b-256 82e965ce5a7625ef77b0d72ca5dd17b81dc10a223948403e6337b161275603cb

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