Skip to content

About

A local-first workbench for investment research and strategy backtesting, with traceable data and reproducible results.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuantSandbox — research, test, reproduce

QuantSandbox

Investment research you can trace, test, and reproduce.

A local workbench to research markets, test strategies, and replay results from the same evidence.

Checks MIT license Python 3.12 or newer React 19 Read-only market access

English · 简体中文
Workbench preview · Quick start · Reproduce an experiment · Contribute · Releases


Workbench preview

Financial terminal showing a synthetic moving-average backtest with a price chart, trade evidence, and replay controls

Strategy replay in the Financial terminal theme. The example uses synthetic prices, even where the interface shows a real ticker. It illustrates the workflow, not investment performance.

Start with the offline example to generate and verify the same evidence without a live-data account.

One workspace, from question to evidence

QuantSandbox connects a research question to its data, assumptions, experiments, and saved conclusions. The browser, CLI, and API share the same Python calculations. Data and research records stay in your local workspace. Fetch public market data on demand; ETF flows also supports a local daily refresh schedule.

01 · Research
Compare quarterly financials and peers using company-specific templates. Track industry indicators, ETF flows, and disclosed institutional holdings.
02 · Test
Explore correlation, lags, and conditional probabilities. Inspect execution, fees, cash, and positions through backtests and historical replay.
03 · Reproduce
Keep fixed snapshots, saved parameters, source metadata, and execution fingerprints. Export an evidence bundle and recompute it.
04 · Keep your workflow
English or Chinese. Classic light or Financial terminal. Download Markdown, SVG charts, and attachments; Obsidian integration is optional.

The workbench focuses on mainland China's A-share market. Its daily strategies include dual moving averages, Bollinger bands, RSI reversal, and momentum. You can compare the dual moving-average rule with volume confirmation or volatility-based entry sizing, and use budgeted buy and hold as a control. Experiments include historical forks, cost stress, parameter sensitivity, rolling out-of-sample evaluation, and blind replay.

US company research · initial scope

A separate US research module starts with McDonald’s (NYSE: MCD): explicitly refresh public SEC annual financial facts and filing references, import USD unadjusted daily OHLCV CSV with a source URL, and save research evidence to a local project. English/Chinese UI is supported. US prices do not enter the A-share backtest engine. SEC access needs a user-configured identifying User-Agent; no paid data subscription is required for SEC data or manual imports. See the US research guide for setup, provenance and limits.

Quick start

Choose a source: Use the commands below for the current public main branch, or download the tagged source release for a fixed version. Use main for the latest instrument research, daily Chan replay, and strategy updates described here.

Windows: Python 3.12+, Node.js 22.12+, and PowerShell 7+. Python 3.12 and Node 22 are used by CI. Installation needs internet access for dependencies; the synthetic example runs offline after installation.

git clone https://github.com/tail258/QuantSandbox.git QuantSandbox
Set-Location QuantSandbox
.\setup.cmd
.\start.cmd

Open http://127.0.0.1:8766. The service listens on your computer only. On later visits, run start.cmd; stop this workspace with pwsh -NoProfile -File stop.ps1.

Windows setup also configures the project-local QuantSandbox MCP server. Codex can find research projects, reuse frozen data, preview and submit backtests, read evidence, and save conclusions. If already installed, run pwsh -File scripts/enable-codex.ps1 to configure MCP. See the Codex workflow (Chinese).

The interface starts in English. Use the top-bar language and Appearance selectors to switch to Chinese or the dark Financial terminal theme. Preferences stay in the current browser. Company names, user notes, source documents, and archived evidence retain their original text.

ETF refresh: use Refresh now on ETF flows, or let the workspace fetch daily at 15:30 Asia/Shanghai by default. You can change the time or disable automatic fetching. The service must be running; source dates and warnings show whether the latest shares and NAVs have actually been published. See the ETF methodology.

ETF flows also offers lightweight batch quotes and same-time turnover comparisons using completed five-minute bars. Quote polling and historical baseline updates run separately; source times, eligible samples and missing data stay visible. See the intraday guide.

Preview the offline synthetic ETF example

Synthetic ETF example: fixed artificial inputs, source precision, 20 samples and a 1.5 turnover ratio

Open ETF flows → View synthetic demo. The example uses artificial data and a fixed clock; it does not download prices or replace your research data.

Manual setup, including Linux/macOS

The backend and frontend are tested on Linux; the convenience launchers target Windows. From the repository root, create and activate a Python virtual environment using your platform's commands, then run:

python -m pip install -r requirements-dev.txt -c requirements-lock.txt
npm ci --prefix frontend
npm run build --prefix frontend
python -m uvicorn backend.main:app --host 127.0.0.1 --port 8766

For production-only Python dependencies, use requirements.txt; add requirements-market.txt for live providers. The offline reproduction tool requires the development dependencies. The lock file constrains Python dependency versions, and npm ci uses the committed package lock.

On the Projects home page, choose Open offline strategy demo. Start with a daily moving-average question, run the baseline, change the windows on the same synthetic snapshot, and replay the evidence. The demo needs the local service and leaves your research projects, runs, and caches untouched.

Use Chan structure in a research project to inspect daily fractals, strokes, segments, and centers on a fixed snapshot or in the offline example. Step through when each structure appears and is confirmed, then download and verify the original replay evidence. See the daily replay guide (Chinese) and the project handoff (Chinese).

Read the first-run guide for the strategy and ETF demos, refresh controls, and a first saved research project. Maintainers can follow the release readiness checklist.

Reproduce an experiment

Run a complete synthetic example without starting a server or downloading market data:

.\.venv\Scripts\python.exe -X utf8 scripts/reproduce.py

The command creates isolated temporary stores, runs a backtest, exports its evidence, imports the original JSON into a second store, and verifies the replay against fixed expectations. It exits with a failure if verification fails. To open the example shown above in the workbench, first keep the evidence file in a new, empty directory:

.\.venv\Scripts\python.exe -X utf8 scripts/reproduce.py --output exports/repro-demo

Open Validation → Strategies & replay, choose Record actions → Import evidence package, and select the original exports/repro-demo/evidence.json file.

This example is explicitly synthetic. Your existing datasets, research projects, and notes are not used. See the reproducibility guide for the fixture, checks, and tagged-release instructions, and the release guide for archive checksums and rebuilding from source.

A practical research loop

  1. Choose a question. Create a project and select its securities, company template, peers, and research focus.
  2. Check the inputs. Reuse cached data or fetch/import a snapshot. Read each series' actual coverage, source, unit, reporting period, and availability date.
  3. Compare and test. Analyze quarterly financials and industry series, then bridge a specific unadjusted-price snapshot into strategy experiments.
  4. Inspect the path. Review signals, next-session execution, fees, positions, and the account ledger. Compare alternative assumptions on the same inputs.
  5. Save the evidence. Link analyses and experiments to the project, save a conclusion, and choose what to export.

Data and calculation boundaries

Topic What the workbench preserves
Missing data Missing values remain missing. Provider failures stay visible; live-data failures never silently become synthetic prices.
Financial statements Income and cash-flow cumulative amounts are split into quarters; balance-sheet balances are not differenced. Ratios are recomputed. Currently revised statements are not a complete historical point-in-time archive.
Statistics Transform, alignment, frequency, lag direction, sample count, baseline, and interval accompany the result. Correlation and repeated parameter searches need separate validation.
Execution Daily closing signals execute no earlier than the next tradable session's open. Suspension, price limits, and sourced gross cash dividends survive snapshots and replay. Cash dividends are credited after the payment-date opening match. Dividend tax, non-cash actions, and complete delisting returns are outside the model.
Market proxies ETF subscriptions/redemptions and margin data cannot identify a specific trading entity. State-backed holdings require original disclosure evidence. RU0 is a vendor continuous series, not a directly tradable total-return contract.
Evidence Content hashes check integrity. Import replays the saved inputs with the current engine and reports differences. A hash is not third-party certification.

Method details: backtesting · financials and statistics · ETF flows · institutional disclosures. These detailed methodology documents are currently in Chinese; the API contract, architecture, and reproduction guide are in English.

Local data and optional notes

The strategy store lives under data/; company research uses data/workbench/. Local data, exports, attachments, company profiles, environment settings, dependencies, and build output are excluded from Git and release packages. Back up data/ and exports/ separately when the service is stopped.

Markdown and attachment downloads work without a notebook configuration. Direct Obsidian writing is an explicit, previewed action that creates new files and refuses to overwrite existing notes. There is no vault scan, background sync, or scheduled publishing. See the integration contract (Chinese).

Develop and contribute

pwsh -NoProfile -File scripts/dev.ps1
pwsh -NoProfile -File scripts/check.ps1

Development uses frontend port 5174 and API port 8000. Production uses 8766. Interactive API documentation is at /docs; the research CLI starts with python -m backend.workbench.cli status.

Start with CONTRIBUTING.md. Report a reproducible problem using the bug form, propose an improvement using the feature form, and follow SECURITY.md for sensitive reports. The roadmap separates current capabilities from planned work. Changes are recorded in the changelog.

Licensed under MIT. Market-data providers have their own terms; the software license does not grant redistribution rights to third-party datasets.

About

A local-first workbench for investment research and strategy backtesting, with traceable data and reproducible results.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages