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) dataload_trades()- Trade dataload_funding()- Funding rate dataload_reference_price()- Reference price dataload_open_interest()- Open interest dataload_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 marketBTC-USDT:PERP:LINEAR- Linear perpetualBTC-USDT:PERP:INVERSE- Inverse perpetualBTC-USD:FUT:LINEAR- Linear futureBTC-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 datatrades.py- Fetch trade dataorderbook_incremental.py- Fetch orderbook updates and build orderbookfunding.py- Fetch funding rate dataopen_interest.py- Fetch open interest datareference_price.py- Fetch reference price datainstrument_static.py- Fetch instrument metadatalist_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 exchangesplot_trades.py- Visualize trades with volume barsanalyze_instruments.py- Analyze instrument metadata with statisticsanimate_orderbook.py- Create animated orderbook visualizationplot_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
Comparison of BTC-USDT perpetual mid price across BINANCE, BYBIT, OKX, BITMART, and BITMEX exchanges showing price movements and spreads.
LTC-USDT Trades Visualization
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
- Download URL: lotech_market_data-2.0.8-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
946055aa4d82b5162fd6f91b95b90ba95ab5ff76cc379dc806d2c83bf583a473
|
|
| MD5 |
5ff8fcdf9c02a2a2b0e90bd2cc242463
|
|
| BLAKE2b-256 |
16852e49d3f8fed54490395650e2a2090ba88c053126932db6339e2b6b241100
|
File details
Details for the file lotech_market_data-2.0.8-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
808c40d3dc70aee89dd113897de6e70bbd24df34d5e23f606afdab89b521a998
|
|
| MD5 |
0aff22c329c7fe2f2957c05215697320
|
|
| BLAKE2b-256 |
15677feb4a37f80f7c2c0f6d2186374125c3aabd924ad762ccf18292dbb8c577
|
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
- Download URL: lotech_market_data-2.0.8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9028b400f54eb937613f436767f68238c2821701084aafca4cf163d6971ff2
|
|
| MD5 |
6d36987d1f53ac56313490853acabb15
|
|
| BLAKE2b-256 |
690b5e7ac98e452f674e8701a14cc75aedbce3971d5757ca6b5c5d9cf4923dfc
|
File details
Details for the file lotech_market_data-2.0.8-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20477477abc56096a34d75ae838a867f97cdb0625fa723f5ab0f6383a13eb9d7
|
|
| MD5 |
a8dc3c8f6db41c2987915b6e63e23db9
|
|
| BLAKE2b-256 |
bc1a0dca145b0c6e7e53088dcc0359f91967f056dc05430a61abe3a6d988c0e4
|
File details
Details for the file lotech_market_data-2.0.8-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d35adefe490e0e0d0983f01a29c021381be2461e7d8d97a46e5c035c0cd46143
|
|
| MD5 |
2d32f365072298620c9b9f104ba9a94e
|
|
| BLAKE2b-256 |
a381cafa139264362fe5f519197a8dae8cd3a7dc1e624ac288a400f8d16f4113
|
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
- Download URL: lotech_market_data-2.0.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8690b0f1cdd1ce456b55f4612e2cdc11351b88344c3a924bb3bc8ab3ecba3d6
|
|
| MD5 |
a92a93aa5fbb129c3fe752390d82e446
|
|
| BLAKE2b-256 |
f85525f6a977647d4523fa10f9dcf74cb0d7934d907507d7e842722162f7a9d3
|
File details
Details for the file lotech_market_data-2.0.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db4be8420f3fe92dda33bf7ccfe64e0d6da21da8d7b8119cbac3b7cfd653b4de
|
|
| MD5 |
f78e168a9abc3dbca8b5069f9a770897
|
|
| BLAKE2b-256 |
b8def8ac75e45954fa068298f641ac612eb2624b12cbac612e8f32fc643af72e
|
File details
Details for the file lotech_market_data-2.0.8-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c140fe71246e21d8272a295cb8d98d60478814e80c148f87ed15282eb5612933
|
|
| MD5 |
4082cc3a99aca8eb2a9596ce2a0b48ca
|
|
| BLAKE2b-256 |
185292065302f439830de13281b349c27654c61f4779074da812cb6fc22b8821
|
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
- Download URL: lotech_market_data-2.0.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e83df302e3583dc98b9fc5743b1fbec255c482634bc35d961a08e38d324008a7
|
|
| MD5 |
d3402872340ee33d64c862f654f37c19
|
|
| BLAKE2b-256 |
5f0449b95f931ca593593545611e809e14f31cf419b146e80865298b4722da04
|
File details
Details for the file lotech_market_data-2.0.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0be3dbc68227f4d1919d90632b16c162702e8405801365aeeadfe7502cfef11
|
|
| MD5 |
06b5dd50fb2a82e85a03ab377fb338c9
|
|
| BLAKE2b-256 |
75fa2e3f94d69243cc135e0c8b28184ee9d5f884aab58e905692fe1facee5a7f
|
File details
Details for the file lotech_market_data-2.0.8-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08dbc07a97540f1346ee875eb016da0a0bcc3dadc08742e4015104c8127b9d35
|
|
| MD5 |
3b0aeb9da31f103164663f6238166564
|
|
| BLAKE2b-256 |
20cf4ecb6ef9ec731225198062680b164ce94217e8ac85e74bc843b30e7a6806
|
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
- Download URL: lotech_market_data-2.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
975b92647097be4262bb855c1f82686a04179b22952d2316f926958c24e60e10
|
|
| MD5 |
deaab46cfc0e0b7f97d4abaf98831fba
|
|
| BLAKE2b-256 |
e6e9e1253e199a91da336b643c09563ce69a152714f579606f28295f156506aa
|
File details
Details for the file lotech_market_data-2.0.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aee7e5b9c2dd1323ab8fe8ec1269ef54e6ebc41ccedd5faebd4d6dd73b9195b9
|
|
| MD5 |
acbdbb2e0aad46f015d0ff3cc04a436a
|
|
| BLAKE2b-256 |
ca80182d743df35eb429ef449803631d9e197e9dd6fc41940a790c6c3cb76d83
|
File details
Details for the file lotech_market_data-2.0.8-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: lotech_market_data-2.0.8-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b43dd2323dc243a20e0fd46890118ad5cb57cdeac65ffdf1ad392c7327676632
|
|
| MD5 |
21edb500792c9f684ebec7d3327d0bbb
|
|
| BLAKE2b-256 |
82e965ce5a7625ef77b0d72ca5dd17b81dc10a223948403e6337b161275603cb
|