How yutiansut/quantaxis works
1. Purpose and entry points
QUANTAXIS is a Python quantitative-finance framework for market-data ingestion, research, backtesting, accounts, and live/simulated trading. Its package/CLI entry points are QUANTAXIS/__init__.py, QUANTAXIS/__main__.py, and QUANTAXIS/QACmd/runner.py. Python 3.9–3.12 is the primary runtime; optional Rust acceleration is exposed through Python bridges.
2. Market-data ingestion and persistence
QAFetch provides adapters and query layers for Chinese equities/futures and crypto venues, normalizing external feeds before storage or use:
• QUANTAXIS/QAFetch/Fetcher.py
• QUANTAXIS/QAFetch/QAQuery_Advance.py
• QUANTAXIS/QAFetch/QATushare.py
QASU is the operational ingestion/save layer, with source-specific update jobs and persistence routines:
• QUANTAXIS/QASU/main.py
• QUANTAXIS/QASU/save_tdx_parallelism.py
• QUANTAXIS/QASU/save_tusharepro_pg.py
The principal storage boundary is MongoDB, with ClickHouse support for analytic/tabular workloads; connector code also identifies Redis as infrastructure.
3. In-memory data and cross-language boundary
Financial datasets are represented by market-aware Python data structures, then transformed for adjustment, resampling, indicators, research, or backtests:
• QUANTAXIS/QAData/QADataStruct.py
• QUANTAXIS/QAData/QAFinancialStruct.py
• QUANTAXIS/QAData/data_resample.py
QADataBridge is the high-performance interchange boundary: Arrow conversion and shared memory permit DataFrame-oriented data to move across processes/languages, with fallback behavior when optional acceleration is absent:
• QUANTAXIS/QADataBridge/arrow_converter.py
• QUANTAXIS/QADataBridge/shared_memory.py
4. Research, indicators, and strategies
Indicators operate over the data layer; factor modules manage feature construction, analysis, visualization, and factor backtests:
• QUANTAXIS/QAIndicator/indicators.py
• QUANTAXIS/QAFactor/feature.py
• QUANTAXIS/QAFactor/featurebacktest.py
Strategy base classes consume market data and account/order state for CTA, factor, hedge, and multi-instrument workflows:
• QUANTAXIS/QAStrategy/qactabase.py
• QUANTAXIS/QAStrategy/qafactorbase.py
• QUANTAXIS/QAStrategy/qahedgebase.py
5. Account, order, and execution protocol
QIFI is the canonical cross-language account-state protocol and supports account persistence/management. Python order, position, and market presets form the baseline execution model:
• QUANTAXIS/QIFI/QifiAccount.py
• QUANTAXIS/QAMarket/QAOrder.py
• QUANTAXIS/QAMarket/QAPosition.py
QARSBridge wraps the optional QARS2 Rust account and backtest implementation while preserving QIFI-compatible Python APIs and falling back to Python:
• QUANTAXIS/QARSBridge/qars_account.py
• QUANTAXIS/QARSBridge/qars_backtest.py
• QUANTAXIS/QARSBridge/QIFI_PROTOCOL.md
6. Asynchronous and service control plane
The Python service/control plane uses task, event, thread, and async scheduling primitives:
• QUANTAXIS/QAEngine/QAEvent.py
• QUANTAXIS/QAEngine/QAAsyncSchedule.py
• QUANTAXIS/QASchedule/schedulefunc.py
RabbitMQ-backed pub/sub decouples real-time market, task, and order flows:
• QUANTAXIS/QAPubSub/producer.py
• QUANTAXIS/QAPubSub/consumer.py
Tornado-based handlers expose web/service endpoints:
• QUANTAXIS/QAWebServer/server.py
• QUANTAXIS/QAWebServer/qifiserver.py
7. Rust core and deployment topology
qapro-rs is a substantial Rust runtime/library containing account, strategy/backtest, market, protocol, data, query planner, and infrastructure connectors:
• qapro-rs/src/main.rs
• qapro-rs/src/qastrategy/backtest.rs
• qapro-rs/src/qaconnector/mongo/mongoclient.rs
Deployment supports Docker Compose and Kubernetes. The v2.1 service stack explicitly provisions MongoDB, RabbitMQ, ClickHouse configuration, and application services:
• docker/qa-service-v2.1/docker-compose.yaml
• docker/k8s-deployment/10-mongodb.yaml
• docker/k8s_deploy_qaservice/helm_charts/templates/qaeventmq-deployment.yaml
Main entry points: QADataStruct.py Market data structures · docker-compose.yaml Container orchestration · main.py Ingestion jobs · qactabase.py Strategy bases
Components 18
Python framework
- Package and CLI
QUANTAXIS/__main__.py - Market fetch/query · Normalizes Chinese market and crypto feeds.
QUANTAXIS/QAFetch/Fetcher.py - Ingestion jobs
QUANTAXIS/QASU/main.py - Market data structures · Market-aware data, financial structures, and resampling.
QUANTAXIS/QAData/QADataStruct.py - Data bridge · Optional high-performance cross-process interchange.
QUANTAXIS/QADataBridge/arrow_converter.py - Indicators
QUANTAXIS/QAIndicator/indicators.py - Factor research
QUANTAXIS/QAFactor/feature.py - Strategy bases
QUANTAXIS/QAStrategy/qactabase.py
Execution runtime
- QIFI account protocol · Canonical cross-language account and persistence protocol.
QUANTAXIS/QIFI/QifiAccount.py - Orders and positions
QUANTAXIS/QAMarket/QAOrder.py - QARS bridge · Keeps QIFI-compatible APIs with Python fallback.
QUANTAXIS/QARSBridge/qars_account.py
Service control plane
- Event and async engine
QUANTAXIS/QAEngine/QAEvent.py - RabbitMQ pub/sub · Decouples market, task, and order flows.
QUANTAXIS/QAPubSub/producer.py - Web and QIFI services
QUANTAXIS/QAWebServer/server.py - Container orchestration · Provisions application services and infrastructure.
docker/qa-service-v2.1/docker-compose.yaml
Rust acceleration
- qapro-rs core · Contains strategy, market, protocol, query, and connector layers.
qapro-rs/src/main.rs
Other components
- MongoDB
- ClickHouse
Connections 22
- Package and CLI → Market fetch/query: queries data
- Package and CLI → Ingestion jobs: runs updates
- Market fetch/query → Market data structures: normalizes into
- Ingestion jobs → MongoDB: persists
- Ingestion jobs → ClickHouse: writes analytics
- MongoDB → Market data structures: loads
- Market data structures → Data bridge: converts
- Market data structures → Indicators: feeds
- Indicators → Factor research: provides features
- Market data structures → Strategy bases: supplies market data
- Factor research → Strategy bases: drives factor workflows
- Strategy bases → Orders and positions: creates orders
- Orders and positions → QIFI account protocol: updates account state
- QIFI account protocol → QARS bridge: compatible protocol
- QARS bridge → qapro-rs core: optional acceleration
- Event and async engine → RabbitMQ pub/sub: dispatches events
- RabbitMQ pub/sub → Orders and positions: carries order flow
- Web and QIFI services → QIFI account protocol: exposes account APIs
- Web and QIFI services → Event and async engine: submits work
- Container orchestration → MongoDB: provisions
- Container orchestration → ClickHouse: configures
- Container orchestration → RabbitMQ pub/sub: provisions