About this project
This is a local-first paper trading and quantitative research infrastructure designed for China A-share trading rules. The project does not connect to brokers or touch real funds; the public repository contains only source code, container configurations, and sanitized documentation.
The core philosophy is to integrate A-share rules directly into the matching and order validation paths rather than applying approximate corrections after backtesting. T+1 settlement, 100-share lot sizes, price limits, suspensions, commissions, stamp duty, and slippage are all integrated into pre-order validation. Market data follows a fail-closed default: stale, missing, or insufficient coverage data will not be silently patched into a "real-time price," and simulated trades will be rejected if evidence is insufficient.
On the data side, the system employs multi-source scraping and independent verification. Real-time prices carry explicit timestamps and sources, and full-market snapshots have coverage gates; if a data source fails, the system prioritizes degrading signal richness or blocking the corresponding path.
Risk control is implemented via a layered state machine. Every buy/sell order first passes through an independent risk layer, producing structured results such as approved, rejected, deferred_capacity, or downside_warning. It supports hard stop-loss, trailing stop-loss, tiered take-profit, quality rotation, capacity compression, and concentration guards. Downside protection uses a state machine for segmented position reduction to full liquidation, with risk reasons recorded via stable tags and audit ledgers.
On the funding side, a shared fund pool performs budget attribution by strategy, including seat limits, per-stock budgets, fairness protection, and hard funding caps. Fund reservation is separated from formal deduction, utilizing SQLite savepoints to prevent duplicate occupancy during concurrent scans.
Scheduling uniformly supports six types of slots: auction, open, risk, intraday, close, and weekly-review. A one-click start enables the built-in 3-minute intraday scheduler by default, which can be disabled if external scheduling exists. Runtime leases, heartbeats, and fencing tokens are used to prevent duplicate orders, zombie writers, and concurrent overwrites.
At the strategy level, five defined strategies are fully preserved and integrated into the strategy registry, historical replay, and audit display: tq_breakout (strong breakout), trend_pullback (trend pullback), sector_rotation (sector rotation), reported_profit_breakout (quality breakout), and main_force_top10 (main force funds). They share the matching, fund pool, risk control, and audit infrastructure, but maintain their own candidate lanes, position seats, and exit rules. The project explicitly does not implement real-trade routing, leverage, short selling, or T+0 day trading for ordinary stocks.
Signals, candidates, risk decisions, orders, trades, positions, NAV, and per-round scan results all form traceable evidence. Research modules such as adaptive_*, news_learning, neural_shadow, and dual_ai_tuner save independent shadow observations without bypassing the formal matching path. LLM capabilities are optional; the basic paper trading system does not depend on LLMs.
Deployment requires Python 3.11+. It provides start.ps1/start.bat for Windows and start.sh for Linux/macOS, allowing automatic selection between Docker or local mode, as well as specifications for ports, browser launching, and built-in scheduling. Docker Compose provides application images and named volumes, mapping port 8600 by default. The repository notes that the current Compose mapping listens on all network interfaces; for personal use, it is recommended to change this to 127.0.0.1, as the application lacks full built-in authentication.
For users who do not wish to connect to real market data, setting ASTOCK_DEMO=1 injects fully synthetic demo data upon first launch. This requires no network or API keys and includes 10 synthetic tickers and a complete narrative ledger covering scenarios such as normal buy trades, T+1 same-day sell rejections, stale quote rejections, hard stop-loss sells, and limit-up price buys. This injection is idempotent, and structured content is byte-compared in CI as a golden replay to prevent narrative drift.
The repository includes the backend matching/risk/audit main engine, a dashboard read model, market data scraping, a decision engine, strategy definitions, HTTP API with FastAPI/Web dashboard entry, and offline regression tests. CI runs regressions on Python 3.11/3.12, Ruff static checks, lockfile consistency checks, pip-audit, and Docker smoke tests. The project is licensed under MIT. The README includes a risk disclaimer emphasizing that paper trading, backtesting, and historical results do not constitute guarantees of future returns or investment advice.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.