Add backtesting entry point for offline strategy testing

Introduces a BacktestClient that replays historical 1-min bars against the
existing strategy code, plus a CLI entry point (npm run backtest) that fetches
bars from Alpaca and runs the bot over a date range. Makes wait() pluggable
so the backtest resolves delays instantly while advancing simulated time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon
2026-02-10 00:59:22 -07:00
parent 1d3688e9ae
commit 4f1e745534
6 changed files with 593 additions and 6 deletions

View File

@@ -16,7 +16,8 @@
"dev": "nodemon --exec ts-node src/index.ts",
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint src/"
"lint": "eslint src/",
"backtest": "ts-node src/backtest.ts"
},
"dependencies": {
"@alpacahq/alpaca-trade-api": "^3.1.3",