Skip to main content

Documentation Index

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

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

backtest-ollama-crontab is a TypeScript monorepo demonstrating how to use a locally-running Ollama LLM as an outline-based risk filter for cryptocurrency trading signals parsed from public Telegram channels. A 15-minute crontab drives live ingestion; the same codebase runs a full historical backtest so you can measure whether the LLM gate actually improves P&L. In a January 2026 backtest on real Telegram signal data, enabling the LLM filter improved total PnL from +52.22% to +68.90%, raised win rate from 68% to 82%, and lifted the Sharpe ratio from 0.309 to 0.512 — by vetoing just five trades.

Quickstart

Build the workspace, authenticate Telegram, and run your first backtest in four steps.

Architecture

Understand the five-layer pipeline from Telegram crawl to LLM veto to strategy position.

Risk Outline

Deep-dive into the Ollama outline prompt, the two empirical veto rules, and zod-validated output.

Backtest Results

Full trade log and statistics for January 2026 — with and without the LLM gate.

How It Works

1

Telegram crawler ingests signals

CrawlerService pulls raw messages from a public Telegram channel via Telegram’s MTProto API and upserts them into the parser-items MongoDB collection.
2

Parser extracts structured fields

CryptoYodaScreenService applies regex patterns to extract symbol, direction, entry, targets, and stoploss from each message.
3

Ollama LLM applies risk rules

For every parsed signal, the RiskOutline sends 1m/15m candle data plus pre-computed metrics to a local gpt-oss model. The LLM returns a riskAction: "skip" | "follow" verdict validated by zod.
4

Strategy opens positions on 'follow' only

The jan_2026_strategy reads screen-items, checks that the current price is inside the entry zone, and opens a position only when riskAction === "follow".

Key Features

Outline-Based LLM Filter

Two empirical veto rules (sleeping-coin SHORT, knife-catching LONG) are embedded directly in the Ollama system prompt — no recompilation needed to tune thresholds.

15-Minute Crontab

Cron.register from backtest-kit schedules a live Telegram poll every 15 minutes and a one-shot backtest data fetch at startup.

Zod-Validated LLM Output

LLM responses are parsed against a zod schema and validated with five custom rules before they can influence trading decisions.

Full Backtest Harness

Replay any date range against the full pipeline using backtest-kit, with optional candle caching for fast iteration.

MongoDB + Redis Backend

Parsed signals go into parser-items; LLM-screened results go into screen-items. Redis provides queuing for the signal job pipeline.

DI Container via globalThis

All services are accessible through globalThis.core, typed via TypeScript path aliases and rolled-up types.d.ts declarations.

Quick Reference

What you wantWhere to look
First-time setupQuickstart
Environment variablesEnvironment Setup
Docker infrastructureInfrastructure
Telegram QR authTelegram Auth
Running a backtestRunning Backtest
Live modeRunning Live
Writing your own strategyWriting Strategies
LLM prompt detailsRisk Outline
Service API referenceServices
January 2026 resultsBacktest Report

Build docs developers (and LLMs) love