Skip to main content

Documentation Index

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

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

backtest-ollama-crontab is a TypeScript monorepo built on top of backtest-kit and agent-swarm-kit that answers a concrete empirical question: does routing free public Telegram trading signals through a local LLM gate actually improve profit and loss on historical data? The project wires every parsed signal through a locally running Ollama instance (gpt-oss quantized) acting as an outline-based risk filter, then compares the before/after P&L on a January 2026 backtest dataset. A Cron.register call with interval: "15m" keeps the pipeline alive in live mode, re-polling the configured Telegram channel every quarter-hour without any manual intervention.
This repository is a demonstration and research experiment — it is not production trading software. Numbers reported are historical backtest results on a single one-month dataset and do not constitute financial advice or a guarantee of future performance. Use it to explore the architecture and the LLM-gating technique, not to deploy real capital.

What Problem It Solves

Public Telegram signal channels generate a noisy stream of trade ideas. Without any filtering, a naive strategy that follows every signal in the January 2026 dataset achieved +52.22% total P&L and a 68% win rate over 22 trades. The experiment embeds two heuristic rules — expressed in natural language inside the LLM system prompt rather than hard-coded conditionals — and asks the model to veto signals that violate them. With the LLM gate active, the same signal set produced +68.90% P&L and an 82% win rate across 17 trades: six signals were vetoed by the LLM, four of which were losing trades, and one additional winning trade was captured that the baseline missed. The key insight is that the rules live in the outline prompt, not in compiled TypeScript, so you can tune the filter’s risk appetite by editing a text file and re-running the backtest without touching any package code.

Key Technologies

TechnologyRole
Ollama (gpt-oss:120b quantized)Local LLM server that evaluates each signal and returns a structured riskAction: "skip" | "follow" verdict
backtest-kitProvides the Cron, addStrategySchema, addExchangeSchema, and position-tracking primitives
agent-swarm-kitSupplies the outline/completion abstraction used by risk.outline.ts
MongoDBPersists parser-items (raw parsed signals) and screen-items (LLM-enriched signals)
RedisUsed by backtest-kit internals for pub/sub and ephemeral state
Telegram MTProto (GramJS)CrawlerService calls iterMessages on any public channel via the MTProto API
ccxt + BinanceProvides historical OHLCV candles for backtesting and live price feeds

The Two Empirical Rules

The LLM is not instructed to perform open-ended financial analysis. Instead, two concrete, measurable heuristics are embedded in the system prompt of risk.outline.ts. They encode domain knowledge about common failure modes in spot-signal channels:
  1. Sleeping-coin SHORT — If direction === "SHORT" and avgRangePct < 0.07%, skip the signal. A coin whose average candle range is under seven basis points is too illiquid or dormant to produce meaningful short-side momentum; the spread alone often exceeds the expected move.
  2. Knife-catching LONG — If direction === "LONG" and momentum24hPct < -1%, skip the signal. Buying into a coin that has already dropped more than one percent in the last 24 hours is a classic knife-catch pattern: the channel may be signalling a bottom before it forms.
Both metrics (avgRangePct, momentum24hPct) are pre-computed from recent candle history and injected into the LLM prompt as a commitMetricsHistory payload, so the model receives numeric evidence rather than raw OHLCV arrays.

January 2026 Backtest Results

The table below summarises the headline numbers from the single-month experiment that ships with this repository:
MetricWithout OllamaWith OllamaΔ
Total trades2217−5 trades skipped
Total PNL+52.22%+68.90%+16.68 pp
Win rate68%82%+14 pp
Wins / Losses15 / 714 / 3−4 losing trades
Sharpe Ratio+0.309+0.512+0.203
Profit factor2.736.37+3.64
Expectancy per trade+$2.37+$4.05+$1.68
The LLM correctly vetoed six signals: four were losing trades (avoided −17.29% combined), and two were modest winners (cost −2.47%). Net filtering benefit: +14.82%, plus one additional winning trade the LLM-gated run captured that the baseline missed.

Explore the Documentation

Quickstart

Build the monorepo, authenticate Telegram, and run the January 2026 backtest in four steps.

Architecture

Deep dive into the five-stage pipeline — Crawl, Parse, Risk Outline, Strategy, and Cron.

Risk Outline Guide

Learn how the LLM outline prompt is structured, how metrics are injected, and how to tune the heuristics.

Backtest Results Reference

Full trade-by-trade log and statistical breakdown for January 2026, with and without the Ollama gate.

Build docs developers (and LLMs) love