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.
SignalLogicService is the thin but critical layer that converts a structured IParserRow — a previously parsed Telegram trading signal stored in parser-items — into a fully enriched IScreenDto ready for screen-items storage. It does this by invoking the RiskOutline agent from agent-swarm-kit with the signal’s key parameters (symbol, direction, targets, stoploss) and merging the LLM’s risk assessment fields onto the passthrough signal fields. The service itself contains no prompt logic; that lives inside the outline definition. SignalLogicService is only responsible for calling the outline, validating the response, and assembling the final DTO.
SignalLogicService
SignalLogicService is registered under TYPES.signalLogicService in the DI container and is accessible as core.signalLogicService.
execute(row: IParserRow): Promise<IScreenDto>
The sole public method. Runs the RiskOutline LLM outline against the given parser row and returns a complete screen DTO.
A document from the
parser-items MongoDB collection. Must carry all signal
fields populated by CrawlerService. Key properties consumed by this method:| Field | Type | Description |
|---|---|---|
id | string | MongoDB _id (used as parserItemId in the DTO) |
channel | string | Source channel identifier, e.g. "crypto_yoda_channel" |
source | string | Origin source string (same as channel for Telegram) |
publishedAt | Date | Original Telegram message timestamp |
symbol | string | Trading pair symbol, e.g. "BTCUSDT" |
direction | "long" | "short" | Trade direction |
entry | { from: number; to: number } | Entry price zone |
targets | number[] | Ordered take-profit price levels |
stoploss | number | Stop-loss price level |
note | string | Raw message text stored as a note |
content | unknown | Full parsed signal data (Mixed) |
Error if the LLM outline returns isValid: false. The error message is the error string from the outline response.
Return value: IScreenDto
The
id of the source parser-items row. Used as the unique key in the
screen-items collection ({ parserItemId: 1 } unique index).Passed through from
row.channel.Passed through from
row.source.Passed through from
row.publishedAt.Passed through from
row.symbol (e.g. "ETHUSDT").Passed through from
row.direction.Flattened from
row.entry.from — the lower bound of the entry price zone.Flattened from
row.entry.to — the upper bound of the entry price zone.Passed through from
row.targets.Passed through from
row.stoploss.Mapped from
outline.sure_level. Indicates the LLM’s confidence that market
manipulation (candle anomalies, volume accumulation) is present.| Value | Meaning |
|---|---|
low | No signs of manipulation; organic volume structure |
low_medium | One recent anomaly without price displacement |
medium | One older anomaly or one with price displacement |
medium_high | Recurring accumulation pattern |
high | Multiple accumulation events with clear price displacement |
Mapped from
outline.confidence. Indicates data quality for the assessment.| Value | Meaning |
|---|---|
reliable | Data is unambiguous |
not_reliable | Data is contradictory, weak, or missing |
Mapped from
outline.action. The LLM’s trade recommendation.| Value | Meaning |
|---|---|
follow | Open a position in the signal’s direction |
skip | Do not open a position |
Mapped from
outline.description. A 2–3 sentence human-readable summary of
the action decision, naming the applied rule and key figures. Example:
"Action skip. SHORT on a dormant asset (avgRangePct 0.045% < 0.07%) — stop-hunt target. Sure_level high, confidence reliable."Mapped from
outline.reasoning. A detailed step-by-step reasoning trace
(single string, newline-separated steps):- Raw metric values used
- Applied rule → action decision
sure_levelandconfidencejustification
Passed through from
row.note (the raw Telegram message text).Passed through from
row.content (the full parsed data object stored as
Mixed).Full execute Implementation
json() from agent-swarm-kit
RUN_OUTLINE_FN uses the json<T, Args>() helper to invoke a named outline by its string identifier.
The registered outline identifier. For the risk filter this is
OutlineName.RiskOutline which resolves to the string "risk_outline".Positional arguments forwarded to the outline, typed as
[Symbol, Direction, Targets, StopLoss]:row.symbol— e.g."BTCUSDT"row.direction—"long"or"short"row.targets—number[]of take-profit levelsrow.stoploss— stop-loss price asnumber
The structured LLM response when
isValid is true. Shape is validated
against the RiskOutlineFormat Zod schema (see below).An error message string when
isValid is false, otherwise null.true when the LLM produced a valid, schema-conformant response.
SignalLogicService throws on false.RiskOutlineContract Schema
Defined in contract/RiskOutline.ts using Zod. This is the exact shape of outline after RUN_OUTLINE_FN returns.
DTO Field Mapping Cheatsheet
The table below shows the complete mapping fromIParserRow and RiskOutlineContract fields to IScreenDto fields.
IScreenDto field | Source | Origin field |
|---|---|---|
parserItemId | IParserRow | row.id |
channel | IParserRow | row.channel |
source | IParserRow | row.source |
publishedAt | IParserRow | row.publishedAt |
symbol | IParserRow | row.symbol |
direction | IParserRow | row.direction |
entryFrom | IParserRow | row.entry.from (flattened) |
entryTo | IParserRow | row.entry.to (flattened) |
targets | IParserRow | row.targets |
stoploss | IParserRow | row.stoploss |
note | IParserRow | row.note |
content | IParserRow | row.content |
riskSureLevel | RiskOutlineContract | outline.sure_level |
riskConfidence | RiskOutlineContract | outline.confidence |
riskAction | RiskOutlineContract | outline.action |
riskDescription | RiskOutlineContract | outline.description |
riskReasoning | RiskOutlineContract | outline.reasoning |
The
entry object from IParserRow ({ from, to }) is flattened into
two top-level fields (entryFrom, entryTo) in IScreenDto. The nested
object is not stored in screen-items.Error Handling
SignalLogicService.execute propagates errors in two scenarios:
-
isValid: false— The LLM outline returned an invalid or unparseable response.RUN_OUTLINE_FNthrowsnew Error(error). The caller (SignalJobService.RUN_IN_CONTEXT_FN) receives the exception. -
Network / timeout errors — Any exception thrown by
json()itself (e.g. the Ollama instance is unreachable) propagates unmodified.
SignalJobService
Calls
execute() inside RUN_IN_CONTEXT_FN for every unvisited
parser-items row.CrawlerService
Produces the
IParserRow documents that execute() consumes.