Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-docs/llms.txt

Use this file to discover all available pages before exploring further.

These are not toy examples assembled for documentation purposes — they are production-quality strategies backtested against real historical OHLCV data with documented PnL results, Sharpe ratios, and full trade logs. Each one demonstrates a distinct approach to signal generation and position management, from a TensorFlow neural network retrained every 8 hours to a DCA ladder that averaged down into 10 rungs and closed at a blended profit target. Every strategy ships as runnable source code that works identically in backtest and live modes.

🧠 Neural Network (Oct 2021)

+18.26% PNL · Sharpe 0.31Feed-forward TensorFlow network (8→6→4→1) retrained every 8 hours on normalized candle data. Predicts next candle close within the high-low range; opens LONG when current price is below predicted price with a 1% trailing take-profit.

🌲 Pine Script Breakout (Dec 2025)

+2.40% PNL · Sharpe 0.06Runs a TradingView Pine Script Bollinger Band range breakout indicator natively in Node.js via @backtest-kit/pinets. Signals fire only on confirmed breakouts with volume confirmation; fixed ±2% bracket exits.

🔪 Signal Inversion (Jan 2026)

+8.58% PNL · Sharpe 1.14Consumes published Telegram channel signals and enters at the same price zone — but inverts the direction, exploiting the predictable liquidity flush that follows crowd-followed recommendations. 87.5% win rate on 8 trades.

📰 AI News Sentiment (Feb 2026)

+16.99% PNL · Sharpe 0.25Fetches live crypto and macro headlines via Tavily every 4–8 hours, passes them to a local Ollama LLM, and opens LONG or SHORT positions based on bullish, bearish, or wait forecasts. Achieved +16.99% during a month when BTC fell −16.4%.

🪂 SHORT DCA Ladder (Mar 2026)

+37.83% PNL · Sharpe 0.35Opens a SHORT on every pending signal, then adds rungs (up to 10) whenever price spikes upward outside a ±1–5% band around the last entry. Closes at 0.5% blended profit. Flipped a −0.41% losing baseline into +37.83%.

🧗 LONG DCA Ladder (Apr 2026)

+67.85% PNL · Sharpe 0.12Same mechanics as the SHORT version but LONG-biased with a 3% profit target. Deployed 2.4 entries per trade on average; improved per-position drawdown from −3.99% to −2.59% by blending cost basis down into dips.

🐍 Python EMA Crossover (Feb 2021)

+5.52% PNLPython strategy executed via WebAssembly (WASI). EMA(9) / EMA(21) crossover signals confirmed by the 4h range midpoint. Demonstrates that non-TypeScript runtimes can plug directly into Backtest Kit.

🔮 Polymarket Δprob (Apr 2024)

70% win rateUses real-time prediction market probability shifts on Polymarket as trade signals. When the implied probability of a macro event changes significantly, it opens a directional crypto position to trade the secondary effect.

What each example demonstrates

The DCA ladder examples show how to use commitAverageBuy, getPositionEntries, and getPositionEntryOverlap to build multi-entry positions with harmonic mean cost-basis tracking. You’ll see how the engine handles up to 10 rungs per position while enforcing a hard stop, automatically rejecting duplicate entries that fall within the overlap band, and closing the blended position once portfolio PnL crosses a percentage threshold via getPositionPnlPercent. The April 2026 LONG variant nearly tripled gross dollar profit compared to single-entry, while simultaneously lowering the per-position percentage drawdown from −3.99% to −2.59%.
These two examples sit at opposite ends of the signal-source spectrum. The news sentiment strategy integrates an external REST API (Tavily), a local LLM (Ollama), and Backtest Kit’s built-in Cron scheduler to produce a new forecast every 4–8 hours — then translates that forecast into LONG/SHORT entries with trailing take-profit exits. The signal inversion strategy instead reads structured data already published by a third party (a Telegram channel) and applies domain logic — 4h range midpoint filtering — to decide direction. Together they illustrate that Backtest Kit is agnostic to where signals come from.
Both examples demonstrate the framework’s look-ahead bias protections in practice. The Pine Script strategy runs @backtest-kit/pinets to execute an unmodified .pine file on 1h candles; the temporal context injected by AsyncLocalStorage ensures getCandles can never return data beyond the current backtest timestamp. The neural network example retrained its model every 8 hours inside the same temporal sandbox, so the training window always ended at the current virtual time. Neither example had to add any special backtest-vs-live branching — the same code runs in both modes.
Every example in this section is structured for deployment. The recommended path is @backtest-kit/cli, which provides zero-boilerplate backtest, paper, and live modes from a single command. For Docker deployments with automatic restart on crash, the CLI generates a ready-to-use docker-compose.yaml. For production-grade persistence at high tick throughput, @backtest-kit/mongo replaces the default file-based ./dump/ storage with MongoDB + Redis without any change to strategy code.

Common patterns across examples

Every strategy in this collection follows the same three-file structure: a strategy file that calls addStrategySchema, a frame file that calls addFrameSchema, and a runner that wires exchange, risk, and execution. This separation makes it straightforward to swap a backtest frame for a live runner without touching strategy logic. Starting from an existing example:
  1. Copy the strategy folder: cp -r example/content/apr_2026.strategy example/content/my_strategy
  2. Update strategyName, frameName, and exchangeName in the new files
  3. Replace the getSignal body and any listenActivePing handlers with your own logic
  4. Run the backtest: npm start -- --backtest --symbol BTCUSDT ./content/my_strategy/my_strategy.ts
Switching between LONG and SHORT in the DCA examples requires only changing position: 'long' to position: 'short' inside getSignalcommitAverageBuy and getPositionEntryOverlap work identically for both directions. Adding technical indicator context to any LLM-based strategy (like the news sentiment example) is a one-package install: @backtest-kit/signals computes 50+ indicators across four timeframes and returns a markdown report ready for injection into an LLM prompt.
The fastest way to explore any of these strategies hands-on is to clone the reference implementation and run it with --ui to open the visual dashboard: npm start -- --backtest --symbol BTCUSDT --ui ./content/apr_2026.strategy/apr_2026.strategy.ts. The dashboard shows every entry, exit, drawdown, and trailing stop in real time as the backtest replays.

Build docs developers (and LLMs) love