Skip to main content

lotech-market-data

Python client for accessing LO:TECH market data.

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

IV Surface

Fitted option-surface tables from the LO:TECH SVI engine (Deribit BTC, ETH and SOL), loaded exactly like the market data methods. The one difference: the time window applies to snapshot_ts (the market instant a row describes) rather than ingress_ts. Available on keys with the iv_* data types enabled.

The one-call question, "what is the IV of this strike on this expiry, as of this time":

from datetime import timedelta

client.iv_lookup("BTC", 80_000, "25DEC26")  # now
client.iv_lookup("BTC", 80_000, "2026-12-25", as_of=trade_time)  # as of a trade
client.iv_lookup("BTC", 80_000, "25DEC26", max_age=timedelta(hours=1))  # refuse a stale record
# IvLookupResult(iv=0.419, source=<IvSource.FIT: 'fit'>, surface_ok=True, extrapolated=False,
#                stale=False, forward=81048.0, snapshot_ts=datetime(2026, 8, 25, 12, 30, tzinfo=UTC),
#                age=timedelta(seconds=1846), ...)

iv is a decimal (0.419 = 41.9%), the same for a call and a put at one strike. The answer comes from the newest snapshot at or before as_of with a clean fit for the expiry (IvSource.FIT), else an older snapshot within three hours that has one (WALKBACK), else the newest fit of any quality (surface_ok False), else total-variance interpolation between the two fitted expiries that bracket it (INTERPOLATED, with bracket). It raises only when no fitted expiry brackets the request, or the expiry settled at or before as_of. stale is set past three hours of age; max_age turns that into a refusal. AioLotechMarketData.iv_lookup is the same call, awaited.

The tables themselves:

from lotech_market_data import iv_at

# One row per fitted expiry per snapshot: SVI parameters, forward, fit diagnostics
fits = client.load_iv_fits(exchange="DERIBIT", base_asset="BTC", start=start, end=end)

# Model IV at a strike, for every row in the frame
ivs = iv_at(fits, 80_000)  # adds strike, log_moneyness, iv, extrapolated

# One row per option instrument per snapshot: model IV at every listed strike, greeks, quote flags
quotes = client.load_iv_quotes(exchange="DERIBIT", base_asset="BTC", start=start, end=end)

# One row per constant-maturity tenor per snapshot (7/30/60/90/180 days)
cm = client.load_iv_cm(exchange="DERIBIT", base_asset=["BTC", "ETH"], start=start, end=end)

instrument keys every row: the option id on iv_quotes, an expiry-level id such as BTC-USD:OPT-EURO-2026_12_25T08_00:INVERSE on iv_fits, and a tenor-level id such as BTC-USD:OPT-CM-30D on iv_cm.

extrapolated marks strikes beyond the quoted range (model wing shape, not a market-anchored mark) and surface_ok / cm_ok mark slices that failed the engine's arbitrage gates; both are reported rather than repaired. Java: see tech.lo.marketdata.IvLookup and Svi.

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.

Locked-down environments (no extension downloads)

The Java client loads DuckDB's httpfs extension via INSTALL httpfs at startup. If your environment blocks that download, provision the extension file yourself (it must match the bundled DuckDB version, duckdb_jdbc in java/pom.xml) and point the client at it — nothing is downloaded:

Client c = Client.builder().httpfsExtension("/opt/duckdb/httpfs.duckdb_extension").build();
// or: export LOTECH_DUCKDB_HTTPFS_EXTENSION=/opt/duckdb/httpfs.duckdb_extension

Metadata

Release files for lotech-market-data 3.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lotech-market-data 3.1.11
File Actions
lotech_market_data-3.1.11-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for lotech_market_data-3.1.11-cp311-abi3-win_amd64.whl
lotech_market_data-3.1.11-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for lotech_market_data-3.1.11-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
lotech_market_data-3.1.11-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for lotech_market_data-3.1.11-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
lotech_market_data-3.1.11-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for lotech_market_data-3.1.11-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 24.1 MB

Release files / lotech_market_data-3.1.11-cp311-abi3-win_amd64.whl

Download URL lotech_market_data-3.1.11-cp311-abi3-win_amd64.whl
Size 7.0 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
671f70188b9ece35e7bc483927f517d156e1718910f66060f773822f60f43ee0
BLAKE2b-256 checksum
How to use checksums
4d45980d946ceb46e5fd7683af8f3d61746001c97fc2a669b3a128a3e5c34943
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / lotech_market_data-3.1.11-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL lotech_market_data-3.1.11-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 6.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2ed123579eeb1f2b22cac8c625f6e1240b9832ef4d7a16767854b28acd041297
BLAKE2b-256 checksum
How to use checksums
59faa4c230efe714a5b5027a4690ba2657c2376789207d9f97fbccc772b14239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / lotech_market_data-3.1.11-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL lotech_market_data-3.1.11-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 5.6 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d60ddd85b980e1770c613d04a9e55afe22e84f5bebaa0aa5c3bb28c1a492aafc
BLAKE2b-256 checksum
How to use checksums
97e1ecf75e07c2ec02a62f28ab596bc23f66bd0aec19f7da879b281c31db467b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / lotech_market_data-3.1.11-cp311-abi3-macosx_11_0_arm64.whl

Download URL lotech_market_data-3.1.11-cp311-abi3-macosx_11_0_arm64.whl
Size 5.4 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a7e1dd38d10096ff393a9ef419bdb74a9c79c5c37b9f3c290fa47761a56d84c4
BLAKE2b-256 checksum
How to use checksums
3dd3224cee5294fcd5316cef471cd660b42226c69b54347d68c151d75c01a834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for lotech-market-data 3.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page