npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thecommandcat/fbtf

v0.1.0

Published

Node-first multi-asset backtesting and live paper trading runtime.

Downloads

105

Readme

fbtf

Futures Back Testing Framework for TypeScript

status runtime module language


What is it?

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.


Install

npm install @thecommandcat/fbtf

Documentation

Longer-form docs live in this repository under docs/content/docs.

Run the docs site locally with:

npm run docs:dev

Build the docs site with:

npm run docs:build

The docs site also includes a roadmap page for the current direction of the project.


What fbtf is for

  • 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

What fbtf is not

  • 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

Core ideas

One runtime model

Backtest mode and paper mode should feel like the same system, not two loosely related products.

Deterministic behavior

Runs should be reproducible and explainable. That means explicit state transitions, structured diagnostics, and no hidden concurrency inside the runtime core.

Small public API

The root package intentionally stays small:

  • defineStrategy
  • createRunner
  • createHistoricalFeed
  • createLiveFeed
  • createPaperBroker
  • defineMarket

Everything else lives on explicit subpaths like @thecommandcat/fbtf/data, @thecommandcat/fbtf/markets, @thecommandcat/fbtf/results, and @thecommandcat/fbtf/experiment.

Adapter-based integrations

The runtime core should stay vendor-neutral. Provider-specific behavior belongs in adapters instead of leaking into the core runtime API.


Minimal example

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();

Package entrypoints

Root package

Use the root package for the main runtime entrypoints.

Subpaths

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

Curated examples

The repository keeps a small example set:

  • examples/01-minimal-backtest.ts
  • examples/03-cost-slippage-comparison.ts
  • examples/07-minimal-experiment.ts
  • examples/09-databento-ema-bracket.ts

These examples live in the repository and are not shipped in the npm tarball.


Config-first CLI

The CLI expects one required run-config file.

npx @thecommandcat/fbtf run ./my-run.config.json

Example config shape:

{
  "modulePath": "./examples/07-minimal-experiment.ts",
  "reportMode": "human",
  "runId": "minimal-experiment",
  "params": {},
  "config": {}
}

Real-data example setup

For the Databento example, store your key in a local ignored file such as .env.local:

DATABENTO_API_KEY=your-key-here

The real-data example is intentionally opt-in.


Roadmap

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.


Development

Requirements

  • Node.js 20+
  • npm / pnpm

Install dependencies

npm install

Typecheck

npm run typecheck

Unit tests

npm test

Integration tests

npm run test:integration

Release verification

npm run verify:release

Status

Still early, but intentionally constrained.

The priority is to make the runtime trustworthy before making it broad.


License

MIT