A package for reading Level 2 market data
Project description
L2Data Reader
A Python package for reading Level 2 market data from binary files.
Installation
pip install l2data-reader
Usage
import logging
from l2data_reader import MarketDataReader, configure_logging
# 配置日志
logger = configure_logging(level=logging.INFO)
# 初始化读取器
reader = MarketDataReader(
logger=logger,
index_file="path/to/market_data.idx",
data_file="path/to/market_data.bin"
)
# 读取数据
while True:
result = reader.read_next()
if not result:
break
header, market_data = result
# 处理不同类型的市场数据
if header.msg_type == 1001: # Tick data
tick_data = market_data.secu_depth_market_data
print(f"Symbol: {tick_data.symbol}, Price: {tick_data.last_price}")
elif header.msg_type == 1002: # Order data
order_data = market_data.transaction_entrust_data
print(f"Symbol: {order_data.symbol}, Order Price: {order_data.order_price}")
elif header.msg_type == 1003: # Trade data
trade_data = market_data.transaction_trade_data
print(f"Symbol: {trade_data.symbol}, Trade Price: {trade_data.trade_price}")
# 关闭读取器
reader.close()
Features
- Read Level 2 market data from binary files
- Support for tick data, order data, and trade data
- Memory-efficient reading with memory mapping
- Configurable logging
License
MIT
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 Distribution
l2data_reader-0.1.6.tar.gz
(25.7 kB
view details)
Built Distribution
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 l2data_reader-0.1.6.tar.gz.
File metadata
- Download URL: l2data_reader-0.1.6.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8770b3e6e49512299c05ed7cccfd7e6528a2e2db345b33095afec9d5e8e1ecdc
|
|
| MD5 |
f4014e83a56929f61e0a26c49a681c2d
|
|
| BLAKE2b-256 |
af5ad4fa4db9fd621b1c1b6f484799ef69119027d380507f7ed9e7bdcedf8067
|
File details
Details for the file l2data_reader-0.1.6-py3-none-any.whl.
File metadata
- Download URL: l2data_reader-0.1.6-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8142ea76f604e7af2c634d15b3208fd372692f040abed504ea9defd70ee6d2
|
|
| MD5 |
49d3af65d1c04eae1369f0eda516f266
|
|
| BLAKE2b-256 |
6a0c52bd2ec7ea6622e16eacde9ac51de675b5ca7a433d91fcf235b80ce01af9
|