About the author:
Daniel is CTO at rhome GmbH, and Co-Founder at Aqarios GmbH. He holds a M.Sc. in Computer Science from LMU Munich, and has published papers in reinforcement learning and quantum computing. He writes about technical topics in quantum computing and startups.
jrnl · home about list ventures publications LinkedIn Join my Slack

# Building a Trading Backtesting Framework with Codex in Less Than a Month

In less than a month, Codex helped me move from ad hoc research scripts to a structured backtesting framework for both stock and options strategies. This includes strategy profiles, data loaders, orchestration, diagnostics, remote execution, and validation gates all together.

The most important method in my opinion is a tight debug and self-review loop.

My main mistake was building a first backtesting framework, iterating with backtests until I found a good algorithm just to find out that there is data leakage. In the options path, contract-selection and quote-handling logic was using information that was not truly available at decision time (classic: using a OHLCV bar to decide, then buying on the open price).

At this stage I test new algorithms very quickly with a tight loop: Ideate with Codex, set up an initial research implementation, backtest it, let it fail the first time (always), debug and continue implementation, and repeat.

The resulting system is closer to a research platform than a single backtester. It supports multi-stage evaluation flows such as signal scout, exit-fit, and holdout; nested walk-forward validation; profile-driven parameter sweeps; and strict control-versus-candidate comparison before promotion. That means strategy ideas are not evaluated on a single in-sample pass, but on a staged pipeline that can reject unstable ideas early and preserve only candidates that survive sample, robustness, and comparability checks.

Picture of the trading platform Codex built including signal scout, exit-fit, holdout and CuteMarkets API access.

Due to the history and, one main thing the framework does is treat causality as a first-class constraint. For options research, contract selection, quote access, and fallback behavior are controlled explicitly so the engine can distinguish between valid intraday selection logic and non-causal leakage. For stocks, premarket and pre-open context can be attached causally at the symbol-day level and then carried forward into strategy gating, diagnostics, or later modeling work. This makes it possible to debug whether a failure was real alpha decay or just a data-path or contract-selection failure.

At this point the framework includes:

  • Walk-forward and nested walk-forward backtesting
  • Multi-stage promotion pipelines: scout, exit-fit, holdout
  • Stock and options backtesting paths
  • Strategy/profile registries for controlled sweeps and reruns
  • Regime filters and router-based signal selection
  • Premarket and pre-open feature pipelines
  • Robustness diagnostics across time slices, regime buckets, month buckets, and control gaps
  • Artifact generation for summaries, leaderboards, trade exports, and audit files
  • Remote orchestration on multiple servers with reproducible workspaces and validation gates

Data and API dependencies

Two external APIs are especially important: CuteMarkets and Alpaca. CuteMarkets is the core historical market-data dependency for equities and options research, including minute bars, options reference data, and live quote-chain data used in contract selection and replay. Alpaca is needed as a secondary market-data and brokerage-facing integration layer, i.e. to actually paper test these strategies.

Let's where this gets us in the future - I'll continue research.

Published on