Wang Zi

CASE 07 / ENGINEERING IN DETAIL

Quant Research & Backtesting

Reconcile signals, costs, and cash movements before interpreting a backtest.

Personal research · AI-assisted · Simulated backtesting prototype

Context and constraints

This is an AI-assisted personal research prototype. LEAN / C# calculates signals, while an independent Python ledger simulates fills and cash movements. Transaction records are used to check the effects of costs and risk rules. The work focuses on finding calculation discrepancies and preserving experiment conditions; a return chart alone does not establish that a strategy works.

Core workflow

This diagram is a simplified view of the technical approach.

  1. 01 / Market data & signalsLEAN / C# calculations
  2. 02 / Independent ledgerPython execution simulation
  3. 03 / Costs & riskFees, cash, and constraints
  4. 04 / ReconciliationTrade records and research reports

Design decisions and implementation

01

Check signals and capital accounting separately

ChallengeAn engine’s final statistics alone make it difficult to identify whether a discrepancy comes from signals, execution assumptions, or capital calculations.

ApproachExported structured strategy signals from LEAN / C# for an independent Python ledger to consume and simulate cash and execution. Separate window calculations support row-by-row reconciliation, while the signal stage places no orders.

ReasoningDiscrepancies can be investigated in signal windows, execution assumptions, and cash calculations separately. The signal stage places no orders.

02

Base risk checks on net equity after costs

ChallengeDeducting costs in a report without reflecting them in cash and risk decisions can distort research conclusions.

ApproachDistinguished trading equity, net equity, actual cash deductions, and return attribution. The ledger includes commissions, slippage, funding fees, and settlement, with risk controls based on net equity after costs.

ReasoningCosts affect subsequent available funds and risk decisions. Transaction records allow checks for omitted charges, duplicate charges, and incorrect attribution.

03

Keep inputs, code, and transaction records

ChallengeSummary charts alone cannot explain result changes when inputs, parameters, or code are revised.

ApproachRetained individual trades, decision reasons, cost records, and risk events. Scripts connect signal validation, backtesting, and ledger acceptance checks, with hashes for inputs, code, and outputs.

ReasoningA rerun can first check data and code versions, then use trade, cost, and decision records to locate differences.

What the design addresses

Checks strategy signals, simulated execution, and capital accounting separately, with transaction records and hashes identifying each experiment.

Validation focus

  • Does row-by-row reconciliation reveal missing signals, alignment errors, or duplicate consumption?
  • Do cost deductions and risk pauses actually change available cash, positions, and subsequent entries?
  • Can the same inputs, code, and parameters reproduce both detailed records and aggregate results?

Research scope

An AI-assisted personal research prototype covering signal calculations, an independent capital ledger, risk rules, result reconciliation, and HTML research reports.

Current stage

Research and simulated backtesting only, with no brokerage connection or live orders. Backtest results do not establish future returns.

Technologies and topics

  • C# / LEAN
  • Python
  • Independent capital ledger
  • Cost modeling
  • Risk rules
  • Reproducible research

Let’s talk about what you’re building.

Share your goals, current systems, and delivery scope. We can work through the key technical questions and a practical path forward.

Send an email ↗