Skip to main content

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


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.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

l2data_reader-0.1.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file l2data_reader-0.1.0.tar.gz.

File metadata

  • Download URL: l2data_reader-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for l2data_reader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3278889983df44704b0feb78df1fa9923ec8446b9b4b7901415c1889101a3b55
MD5 42b0b8618cc5770648ac90ebb0417e4d
BLAKE2b-256 80607daf35eaca0e1c8985a6921af72396ab4ab56916ea853b1799cc444c8cf9

See more details on using hashes here.

File details

Details for the file l2data_reader-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: l2data_reader-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for l2data_reader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 599658a8e4c1ebf40e50ece71dbd7d54f40acdd694671db2b4de2ded4ab284de
MD5 74b40bd8c8e507b598b7c2b7659f1a57
BLAKE2b-256 5ad1e3c06a80b9aaf8b752a86e75a44231ec80ef72fde64fe2ac40ac2f1cf879

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