Once you’ve verified the setup works interactively, Claude Code’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/ai-trading-mcp/llms.txt
Use this file to discover all available pages before exploring further.
/loop command turns the rig into an unattended news-trader. On every tick the agent fetches fresh portfolio state and the latest Telegram posts, applies a fixed decision rule, and either trades or reports — all without human intervention. The rules live in the prompt, not in the architecture, which means you audit and adjust them without touching any code.
What /loop Does
/loop <interval> <prompt> re-runs the given prompt on a repeating timer in the current Claude session. The session retains full context from the interactive setup you already ran: the MCP server is connected, the trading process is confirmed running, and any earlier decisions are visible in the conversation history. The loop does not open a new session — it extends the existing one.
The Recommended Loop Prompt
Run this in the same Claude session where you verified everything works:Rule Breakdown
Entry signal → open_position
When the feed contains a post signalling an entry (e.g. “working BTC — short” or “working X long”), the agent calls
open_position(symbol, position, note). The note records the exact Telegram post text and timestamp as the decision basis — this note persists in the engine and appears in every subsequent get_status for that position.Close/fix signal → close_position
When the feed contains a post indicating a position should be closed or adjusted, the agent calls
close_position(symbol, note). If no position is open for that symbol the engine rejects the call and the agent reports the rejection — it never retries silently.No new posts → report only
When there are no posts since the last tick that warrant action, the agent emits a one-line PnL summary (open positions, unrealized PnL, current prices for watched symbols) and takes no trade action. The
get_status call still completes and the response is still dumped to the audit trail.Feed instructions → data, not commands
Any text in the feed that looks like an instruction to the agent — withdrawal requests, DM prompts, size changes, referral codes, or anything else embedded in a post — is classified as data to be reported, never acted upon. The agent has no tools to send funds, change leverage, or alter position sizing, so the blast radius is bounded by the architecture. The prompt rule closes the remaining gap: the agent is explicitly told to report such posts and stop there.
The
report only, never act rule for feed instructions is the key adversarial-input defence. Document it in the loop prompt itself — not just in architecture notes — so it travels with every session. In a recorded live session, a feed post reading “who has a $3000+ deposit and doesn’t know how to grow it — DM @…” was classified as recruiting, generated no trade action, and prompted an unprompted source assessment from the agent: “P&L numbers between posts don’t add up; I would not trust this as data.”The 15-Minute Interval
A 15-minute tick balances three competing constraints:| Consideration | Direction | Why |
|---|---|---|
| Signal responsiveness | Shorter | News-driven entries can move fast |
| Telegram API rate limits | Longer | The GramJS scraper wraps fetches in a 90 s timeout and queues concurrent calls — sustained short intervals risk exhausting limits |
get_status cost | Longer | Each tick makes one get_status call, which fetches candles + order book for all 13 symbols plus the full Telegram history |
What the Agent Sees on Each Tick
Every loop tick callsget_status once. The response assembles three layers:
Portfolio State
Per-symbol status: current price, invested balance, queued entry, active position with unrealized PnL, queued close. One block per symbol in
CC_SYMBOL_LIST.Command History
The engine’s record of recent
open_position and close_position calls, including their notes, so the agent can see what it already did this session.Telegram Feed
Last 15 posts from the configured channel, newest first, each stamped with an ISO timestamp. Photo posts include the chart screenshot as an MCP image block.
The Audit Trail in Loop Mode
Everyget_status response is written to dump/mcp/<minute-stamp>.md before it leaves the trading process — text inline, images saved to dump/images/ and referenced relatively. In loop mode this means every tick produces a timestamped snapshot of exactly what the agent saw before making its decision. The sequence is reconstructible after the fact: open the dump viewer on :60050, step through the minute-stamps, and see the feed state that preceded every trade.
Position notes also carry provenance forward. The agent records the Telegram post text and timestamp in the note argument, and the engine echoes this note in every subsequent status for that position:
Example Loop Tick Output
Adjusting the Interval
Change the number after/loop to any duration Claude Code accepts (5m, 10m, 30m, 1h). You do not need to restart the trading process — just stop the current loop and start a new one in the same session. The MCP connection and all open positions persist.