A backtest is only useful if it respects the rules of the market it simulates. In China's A-share market, those rules are specific: shares bought today cannot be sold until the next trading day, price limits vary by board and by a stock's status, and order sizes follow different lot rules on different exchanges.
We built an internal web tool that applies those rules in both backtests and paper trading, so a strategy is tested under the same constraints it would face later. This is a project for our own research, not a client engagement, and it is not investment advice.
Project at a glance
- The problem: general-purpose backtesting tools often ignore A-share trading rules, which can make a strategy look better than it could ever perform.
- The approach: one set of market rules shared by the backtesting engine and the paper-trading accounts, with each rule documented in plain language.
- The deliverable: a password-protected web application for market data, backtests, multiple paper accounts, scheduled strategy execution, risk controls, and phone notifications.
- The verified output: 36 commits between October 26 and November 11, 2026, and 134 automated test functions in the repository.
Those are delivery figures. We do not publish results from our own strategies or trading, and backtest results are not a forecast of future performance.
The screenshots in this case were taken on November 11, 2026, from a local copy connected to real market data through AKShare. The paper account in them was created for the screenshots and holds no real money. The backtest uses the default settings of one built-in strategy to show the interface. It is not a strategy we trade or recommend.
Rules first, strategies second
Before adding strategies, we wrote down how the simulation should handle each market rule, then implemented and tested them:
- Next-day execution: a signal calculated from today's close trades at the next trading day's open, so the backtest cannot use information it would not have had.
- T+1: shares bought on a day cannot be sold the same day.
- Price limits by board: ±10% for the main board, ±5% for ST stocks, ±20% for ChiNext and STAR Market, and ±30% for the Beijing Stock Exchange, with exceptions for newly listed stocks. An order at the limit price may not fill.
- Lot sizes by exchange: 100-share lots on the main board and ChiNext, different minimums and increments on the STAR Market and Beijing exchange.
- Costs: commission with a minimum charge, transfer fees, and stamp duty on sales, including the rate change on August 28, 2023.
- Historical status: whether a stock was ST is judged by its name on that date, not by its name today, when the data source provides history.
The tool also states its own limits. Multi-stock strategies draw from the current members of an index, which leaves out stocks that were removed or delisted. That survivorship bias usually makes backtest returns look higher, and the documentation says so.
What we built
Market data with a local cache
The tool combines a free data source with an optional paid one, and caches downloaded daily prices in a local database so the same history is not fetched twice. A demo mode with generated data allows the interface to be tested without a network connection.

Backtests for single stocks, stock pools, and ETFs
Single-stock strategies include moving-average crossovers, MACD, RSI, KDJ, Bollinger Bands, channel breakouts, and buy-and-hold. Pool strategies select from major index constituents using momentum, low volatility, or short-term reversal. An ETF rotation strategy moves between index, gold, and bond funds.
Each result shows total and annualised return, maximum drawdown, Sharpe ratio, win rate, fees, yearly returns, trades, and final holdings, compared with a benchmark.
When the first trade happens later than the start date, the tool reports a second set of figures from the first trade onward, so a long period in cash does not dilute the annualised numbers without notice.

Comparing every strategy on one stock
A later update added a comparison view. For one stock and one period, it runs every single-stock strategy with its default settings and ranks them by total return, alongside the benchmark. Clicking a row opens that strategy as a full backtest, where its settings can be adjusted. The view states that the best past result does not mean the best future result. Stocks can now be found by code or name, and recent searches and the last backtest settings are remembered between visits.

Paper accounts that use live quotes
Several paper accounts can run at once. Orders are matched against live order-book quotes during trading hours, with limit and market orders, cancellations, and daily expiry. Dividends and stock splits are applied to holdings on the ex-date.
Strategy automation with a review trail
A backtested strategy can be attached to a paper account. After the market closes and the day's data is available, the tool generates a rebalancing plan. After the next open, it executes the plan: cancelling unfilled orders, selling positions no longer in the target, then buying. Small differences from the target are left alone to avoid unnecessary trades.
Risk controls that only restrict buying
Each account has its own limits: maximum order size, maximum position size, a daily loss threshold that stops new buying, a ban on buying ST stocks, per-position stop-losses, and a drawdown limit that pauses automation until someone resumes it manually. Selling is never blocked by risk rules.
When we prepared the paper account for these screenshots, an order for 281,088 yuan was rejected against its 200,000 yuan order limit, with a message naming both amounts. That is the behaviour the rule is meant to have.

Notifications to a phone
Fills, rebalancing plans, plan failures, risk events, and a daily summary can be sent through Telegram or several WeChat-based services.
Built to be safe before it is connected to a broker
The tool currently trades only paper accounts. It is designed so a real broker could later implement the same interface as the paper broker. One requirement is already fixed in the design: every real order will need the trading password to be entered, and there is no setting to turn that off.
Testing and maintenance
The repository includes automated tests for market rules, data providers, the backtesting engine, indicators, strategies, paper trading, risk controls, and automation. Recent changes show the kind of issue those tests target: one fix stopped concurrent buy orders from together exceeding a position limit; another made backtests use a stock's ST status as it was on each historical day.
What this project shows
The transferable lesson applies well beyond trading. When software simulates or automates a real-world process, the rules of that process need to be explicit, shared between the test environment and the live one, and checked by tests. A good simulation also explains where it is still simplified.
If your team relies on a spreadsheet or script that encodes important business rules, we can help turn it into a tested internal tool. Explore our prototyping and delivery service or email Storm Nova Labs.