fbtf is a Node-first, ESM-only TypeScript library for deterministic backtesting and live paper trading.
The project is intentionally narrow. It is not trying to be a giant trading platform. The goal is to provide one runtime model that is easy to understand, easy to test, and explicit about how orders, feeds, brokers, and results fit together.
The first practical target is futures. The internals are asset-aware, but the current product story is centered on a clean futures backtesting workflow instead of pretending every asset class is equally mature.
npm install @thecommandcat/fbtfLonger-form docs live in this repository under docs/content/docs.
Run the docs site locally with:
npm run docs:devBuild the docs site with:
npm run docs:buildThe docs site also includes a roadmap page for the current direction of the project.
- deterministic historical backtests
- live paper trading with the same mental model
- strategies that benefit from explicit runtime behavior
- TypeScript-first workflows with readable contracts and results
- a real-money execution system
- a tick-level simulator
- a multi-market portfolio platform
- a cloud product or managed service
- a giant framework with hidden automation
Backtest mode and paper mode should feel like the same system, not two loosely related products.
Runs should be reproducible and explainable. That means explicit state transitions, structured diagnostics, and no hidden concurrency inside the runtime core.
The root package intentionally stays small:
defineStrategycreateRunnercreateHistoricalFeedcreateLiveFeedcreatePaperBrokerdefineMarket
Everything else lives on explicit subpaths like @thecommandcat/fbtf/data, @thecommandcat/fbtf/markets, @thecommandcat/fbtf/results, and @thecommandcat/fbtf/experiment.
The runtime core should stay vendor-neutral. Provider-specific behavior belongs in adapters instead of leaking into the core runtime API.
import {
createHistoricalFeed,
createPaperBroker,
createRunner,
defineStrategy,
} from '@thecommandcat/fbtf';
import { normalizeBars } from '@thecommandcat/fbtf/data';
import { mnq } from '@thecommandcat/fbtf/markets';
const bars = normalizeBars(
[
{
startTime: '2024-03-08T14:30:00.000Z',
open: 18420,
high: 18425,
low: 18418,
close: 18420,
volume: 120,
},
{
startTime: '2024-03-08T14:35:00.000Z',
open: 18420,
high: 18440,
low: 18420,
close: 18435,
volume: 180,
},
],
{
defaultMarketId: mnq.id,
defaultTimeframe: '5m',
},
);
const strategy = defineStrategy({
onBar(context) {
if (context.barIndex === 0) {
return { action: 'buy', qty: 1 };
}
return undefined;
},
});
const runner = createRunner({
mode: 'backtest',
runId: 'demo-run',
strategyId: 'demo-strategy',
market: mnq,
strategy,
feed: createHistoricalFeed(bars),
broker: createPaperBroker({ market: mnq, initialCash: 25_000 }),
});
await runner.start();
const result = runner.getResult();Use the root package for the main runtime entrypoints.
Use subpaths when you need more than the small front door:
@thecommandcat/fbtf/broker@thecommandcat/fbtf/context@thecommandcat/fbtf/data@thecommandcat/fbtf/data/databento@thecommandcat/fbtf/diagnostics@thecommandcat/fbtf/experiment@thecommandcat/fbtf/feeds@thecommandcat/fbtf/indicators@thecommandcat/fbtf/markets@thecommandcat/fbtf/results@thecommandcat/fbtf/risk@thecommandcat/fbtf/runner@thecommandcat/fbtf/services@thecommandcat/fbtf/strategy
The repository keeps a small example set:
examples/01-minimal-backtest.tsexamples/03-cost-slippage-comparison.tsexamples/07-minimal-experiment.tsexamples/09-databento-ema-bracket.ts
These examples live in the repository and are not shipped in the npm tarball.
The CLI expects one required run-config file.
npx @thecommandcat/fbtf run ./my-run.config.jsonExample config shape:
{
"modulePath": "./examples/07-minimal-experiment.ts",
"reportMode": "human",
"runId": "minimal-experiment",
"params": {},
"config": {}
}For the Databento example, store your key in a local ignored file such as .env.local:
DATABENTO_API_KEY=your-key-hereThe real-data example is intentionally opt-in.
Short version:
- keep tightening the deterministic runtime core
- improve the futures-first workflow and examples
- expand docs and developer ergonomics without turning the project into a giant framework
For the fuller version, see docs/content/docs/roadmap.md in the repository or the roadmap page in the docs site.
- Node.js 20+
- npm / pnpm
npm installnpm run typechecknpm testnpm run test:integrationnpm run verify:releaseStill early, but intentionally constrained.
The priority is to make the runtime trustworthy before making it broad.
MIT
