Skip to main content

A Python library for analyzing ultra-high-frequency tick data and discovering micro-alpha trading signals.

Project description

MicroAlpha (starter)

A minimal, vectorized Python library for tick-level microstructure signals using rolling time windows (default 100ms).

Features implemented

  • Quote stuffing frequency (qs_freq): cancels per adds in window
  • Spread stats: instantaneous spread and rolling volatility (spread_vol)
  • Order book imbalance (obi): (bid_size - ask_size) / (bid_size + ask_size)
  • Trade intensity
  • Realized volatility proxy (rv)
  • Optional cancel burst flags per side

Quickstart

# In a virtual environment
pip install -r requirements.txt
python -m microalpha.example

Or use your own data:

from microalpha import read_ticks, compute_features, rolling_forward_returns, join_features_and_labels

df = read_ticks("data/your_ticks.csv", ts_unit="ms")  # or "ns" / "s"
feats = compute_features(df, window="100ms")
labels = rolling_forward_returns(df, horizon="100ms")
dataset = join_features_and_labels(feats, labels)

Expected CSV schema

  • timestamp, symbol, event_type, side, price, size, best_bid, best_ask, bid_size, ask_size

Notes

  • Time-based rolling uses pandas offset windows (e.g. "100ms"). Ensure your index is DatetimeIndex.
  • This starter uses synthetic data in example.py for a reproducible demo.

Schema Converter

Convert any CSV to MicroAlpha schema:

python -m microalpha.convert --in data/raw.csv --out data/my_ticks.csv --symbol BTCUSDT --ts-unit ms

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

microalpha-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

microalpha-0.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file microalpha-0.1.1.tar.gz.

File metadata

  • Download URL: microalpha-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for microalpha-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ea2ebacce027eecbb1ff88f7b9a8673f0e1d5b2ea3d652d859a6fbd499f5b6f5
MD5 4701552c6f5444d52730627e82e8d0b3
BLAKE2b-256 c450feeb56c625279fa2296cc07a6c2894fd94d6cd261ff9aa017886a9038d5c

See more details on using hashes here.

File details

Details for the file microalpha-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: microalpha-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for microalpha-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fe1a7add416221c6d4961e3ef97d169c4d0d4d8b73771edb6b5812ed11d80fc
MD5 42b4c52aa8fffba605a3cbb81b260865
BLAKE2b-256 90334be425b1e491985e019e1d22cf26137a90c240e0b6d0d9ab0c292f855029

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