PyAlgoEngine
GitHub Actions: ⛔ temporarily disabled — kept disabled until the GitHub Actions issue is resolved. See
.github/workflows/README.md. CI runs on the GitLab mirror pipeline while disabled.
High-Performance Algorithmic Trading Engine in Python, Cython, and C
PyAlgoEngine is a low-latency trading engine for HFT (High-Frequency Trading) systems. It provides C-level market data structures, shared-memory buffers, an event-driven engine architecture, backtesting with simulated order matching, exchange calendar profiles, and web-based visualization — all with Cython acceleration for latency-critical paths.
Features
| Category | Capabilities |
|---|---|
| Market Data | TickData, TickDataLite, BarData, DailyBar, OrderBook, TransactionData, OrderData, TradeData — all C-backed via Cython |
| Buffers | MarketDataBuffer, MarketDataRingBuffer, MarketDataConcurrentBuffer, MarketDataBufferCache |
| Engines | EVENT_ENGINE (pub/sub), MDS (Market Data Service), ALGO_ENGINE (algo lifecycle), trade engine (DMA, positions, risk) |
| Exchange Profiles | CN (A-share) and default global calendars, session phases, holidays via PROFILE, PROFILE_CN, PROFILE_DEFAULT |
| Backtesting | SimpleReplay, ProgressReplay, SimMatch (simulated matching), TradeMetrics |
| Strategy Framework | StrategyEngine, AlgoTemplate, global singletons (BALANCE, DMA, STRATEGY_ENGINE) |
| Web Apps | Flask + Bokeh dashboards, candlestick charts, strategy tester UI |
| Compile-Time Config | BOOK_SIZE, ID_SIZE, LONG_ID_SIZE, MD_BUF_PTR_DEFAULT_CAP, MD_BUF_DATA_DEFAULT_CAP via env vars |
Quick Install
git clone https://github.com/BolunHan/PyAlgoEngine.git
cd PyAlgoEngine
./build.sh -i
Requires Python 3.12+ and a C compiler (GCC, Clang, or MSVC). See the Setup Guide for detailed instructions, compile-time configuration, and optional dependencies.
Quick Verify
import algo_engine
print(algo_engine.__version__)
from algo_engine.base import CONFIG
print(CONFIG) # compile-time and runtime configuration
Documentation
Build locally:
cd docs && ./update_docs.sh
# open build/html/index.html
- Read the Docs: pyalgoengine.readthedocs.io
- GitHub Pages: bolunhan.github.io/PyAlgoEngine
Architecture
┌──────────────────────────────────────────────────────┐
│ apps/ Web visualization (Flask, Bokeh) │
├──────────────────────────────────────────────────────┤
│ strategy/ Strategy framework, global singletons│
├──────────────────────────────────────────────────────┤
│ engine/ Event, Market, Algo, Trade engines │
├──────────────────────────────────────────────────────┤
│ backtest/ Replay, SimMatch, Metrics │
├──────────────────────────────────────────────────────┤
│ base/ Market data types, buffers (Cython/C)│
├──────────────────────────────────────────────────────┤
│ exchange_profile/ Calendars, sessions (CN + global)│
├──────────────────────────────────────────────────────┤
│ monitor/ Synthetic order book, bar monitor │
├──────────────────────────────────────────────────────┤
│ utils/ Time-series indices, fake data │
└──────────────────────────────────────────────────────┘
Build System
| Command | Description |
|---|---|
./build.sh -i |
Clean, build Cython extensions in-place, install |
make build |
Clean and build extensions in-place |
make install |
Build + pip install |
./build.sh -l |
List all compile-time macros and defaults |
make list-args |
Same as above |
Override compile-time constants:
BOOK_SIZE=20 ./build.sh -i
Dependencies
- Runtime: numpy, pandas, exchange_calendars, PyCyBase, PyEventEngine, Cython
- Web (optional): flask, waitress, bokeh
- Docs (optional): sphinx, sphinx-rtd-theme
License
MIT — Han Bolun
Metadata
Release files for PyAlgoEngine 0.12.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 89.7 MB
Release files / pyalgoengine-0.12.6-cp315-cp315t-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp315-cp315t-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d71973292f82c732443cc43f4e9fa11ed603062e63c8938785ebe6d0751948fe
|
|
BLAKE2b-256 checksum How to use checksums |
23fa6bece230322d3d2b1fcaf89ddac6790bf042a2c24455c214fdeb47b6dea4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.9 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
afc52c604ba241131099bd7667c0c784e728c15fa52f9c9ec9d3089b14539529
|
|
BLAKE2b-256 checksum How to use checksums |
7005a6a19674fe3ce1d8237bb69fae877a9d72e1ea74fa3f53ba2b00dc6d9b38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyalgoengine-0.12.6-cp315-cp315-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e1270cbf1d63fc084a409a89fb3ad683a2a0359a6e3bc465c91667bd83dcd5a2
|
|
BLAKE2b-256 checksum How to use checksums |
919ecbbdbe4f38eb0748822956be2c7393171595452c19e05f275ba1ea1dceac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.15 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5c2851f7adc71a8c2fa50455f26e64ab316d7f40cf90e212e8db3b5aebaed2f1
|
|
BLAKE2b-256 checksum How to use checksums |
6c5e95bd33c5af6a4f86814a7c191ddec6f6cf674884f381536c367f8e73938e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyalgoengine-0.12.6-cp314-cp314t-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fb015c6e43082e637a031928e04bc01764b9faf0490aa49c9f25affae82f9f74
|
|
BLAKE2b-256 checksum How to use checksums |
ed34f636fe4ab8631d812e76cd3f404741b33414a02ec5708a2077469bff7d2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.9 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
8632c0422334118b7d282916fd9d3c414fd3e237aae4b8c7f0cdca430efc99d3
|
|
BLAKE2b-256 checksum How to use checksums |
70c0f8b8b65149837ba0ae6411b2dc7c3104bcab021416334b4def42e24d2ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyalgoengine-0.12.6-cp314-cp314-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
08d619397ff63bf5197b46bd6ed173e6c9b5a10f22ff0f9b6daca2462d94105a
|
|
BLAKE2b-256 checksum How to use checksums |
75079c8377892141bc360bdb5b27b5323ccb1467d0b8cde8d0597a127c6458f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a9b8007531919f9c380a4a8137ad6913382bff016c603af3fe0c492ae2f3f555
|
|
BLAKE2b-256 checksum How to use checksums |
e56d5d3375b11b13a1df2209043d6417de948b17422b9d7d6429e13e0595f6ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyalgoengine-0.12.6-cp313-cp313-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ff82e7fac31faa99e7176fa7243b159e4dc731aa889dcf7fccba7ecbdbed06cf
|
|
BLAKE2b-256 checksum How to use checksums |
54a71e28a2445e05a571c0a2a8de4464ff0609854a3117ac32551963204108ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
0145b00efa92a2f207aa96abd3db43df316dce6ec48fe97bd30439c6bc4eacc2
|
|
BLAKE2b-256 checksum How to use checksums |
9f696b043382b8515be6954969ea73087256e330131b52a6a007e188aa6b391a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyalgoengine-0.12.6-cp312-cp312-win_amd64.whl
| Download URL | pyalgoengine-0.12.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f1b192d49b22651839fb4bcaab8173db94f6425ca43556563167d2cba39d5a46
|
|
BLAKE2b-256 checksum How to use checksums |
58eee46a5d870d12806a1373f857c40a149884493cd2d334a9e3b9b1c70cf485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyalgoengine-0.12.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyalgoengine-0.12.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
56c8e151bc330470ff038625b4e7ccfa8164b5ed797022dba92a1d5a99484e37
|
|
BLAKE2b-256 checksum How to use checksums |
1e7148930f9f096f10ccc85b9619d0b68263dfb33e38876c62e91796e3d4bfbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|