How AI parsing works
What happens when you submit a strategy description — language detection, model selection, code generation, and test generation.
When you submit a strategy description, Coinrule runs it through an AI pipeline to produce executable Python.
Stage 1 — Language detection
A lightweight heuristic checks whether the input looks like Pine Script, Python, or natural language. This is a keyword scan in the same request — not a separate network call.
Stage 2 — AI strategy generation
The description is sent to an LLM together with the platform's system context (supported indicators, exchange market config, allowed patterns). The model returns a structured tool call containing:
nameanddescriptionmarkets— market config (symbol, venue, interval, asset type)position— direction (long / short / both), sizing, and risk parameters (stop loss, take profit, trailing stop)settings— order type, max open positions, and other runtime settingsentry_conditionandexit_condition— human-readable summariesstrategy_py— the full Python source of the strategy
Model used for parsing: claude-haiku-4-5 (1× credit multiplier). Strategy parsing always uses Haiku — users cannot manually select a different model for this step.
Stage 3 — Validation
Before the strategy can be launched, the generated Python is validated (security checks, import whitelist, pattern checks). Validation runs server-side and blocks unsafe code.
Stage 4 — Test generation (background)
After you review and launch a strategy, a background task generates a test file using claude-sonnet-4-6 (3× credit multiplier). The test file is required before the engine loads the strategy. This happens automatically; you don't need to do anything.
How are credits charged?
You are charged for the LLM call when the parse succeeds. A failed or rejected parse does not charge credits. The credit cost is shown after parsing completes, before you launch. See Credit drivers and costs.
How do you iterate on a parse?
If the parsed strategy doesn't match your intent, edit your description and re-submit. Each re-parse is an independent LLM call (and a separate credit charge). There is no partial-update / delta-parse feature — each submission generates a fresh strategy.