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 (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.
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
| Technology | Role |
|---|---|
Ollama (gpt-oss:120b quantized) | Local LLM server that evaluates each signal and returns a structured riskAction: "skip" | "follow" verdict |
| backtest-kit | Provides the Cron, addStrategySchema, addExchangeSchema, and position-tracking primitives |
| agent-swarm-kit | Supplies the outline/completion abstraction used by risk.outline.ts |
| MongoDB | Persists parser-items (raw parsed signals) and screen-items (LLM-enriched signals) |
| Redis | Used 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 + Binance | Provides 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 ofrisk.outline.ts. They encode domain knowledge about common failure modes in spot-signal channels:
-
Sleeping-coin SHORT — If
direction === "SHORT"andavgRangePct < 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. -
Knife-catching LONG — If
direction === "LONG"andmomentum24hPct < -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.
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:| Metric | Without Ollama | With Ollama | Δ |
|---|---|---|---|
| Total trades | 22 | 17 | −5 trades skipped |
| Total PNL | +52.22% | +68.90% | +16.68 pp |
| Win rate | 68% | 82% | +14 pp |
| Wins / Losses | 15 / 7 | 14 / 3 | −4 losing trades |
| Sharpe Ratio | +0.309 | +0.512 | +0.203 |
| Profit factor | 2.73 | 6.37 | +3.64 |
| Expectancy per trade | +$2.37 | +$4.05 | +$1.68 |
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.