Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/deniszidbaev-cmyk/polyclaw-trading/llms.txt

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

PolyClaw Trading includes a multi-role LLM orchestration layer that reads runtime artifacts and produces analysis, critique, risk notes, copy text, explanations, and a final synthesis. This layer is entirely separate from the deterministic execution engine and has no authority over whether a trade is placed.
The LLM orchestration layer is advisory only. It may read runtime artifacts such as runtime/decisions.json, runtime/bankroll_state.json, and runtime/market_analysis.json, but it does not control the deterministic execution gate. Signal generation, risk gating, and order submission are handled by the deterministic engine in src/polyclaw_engine/ — these never depend on an LLM response. An LLM timeout, error, or misconfiguration will not prevent dry-run or live execution from proceeding normally.

Provider & API key configuration

Four cloud providers and one local endpoint are supported. Configure only the keys for providers you intend to use; unused providers can be left blank or set to disabled at the role level.
VariablePurpose
OPENROUTER_API_KEYOpenRouter multi-provider gateway key
OPENROUTER_BASE_URLOptional base URL override for OpenRouter
OPENAI_API_KEYOpenAI API key; also used for local Ollama-compatible endpoints
OPENAI_BASE_URLBase URL override; set to http://127.0.0.1:11434/v1 for local Ollama
ANTHROPIC_API_KEYAnthropic Claude API key
ANTHROPIC_BASE_URLBase URL override for Anthropic (e.g. Tokenator gateway)
GEMINI_API_KEYGoogle Gemini API key
ANTHROPIC_VERSIONAnthropic API version header sent with every request (default: 2023-06-01)
HTTPS_PROXYOptional HTTP/S proxy for all outbound LLM calls

Per-role configuration

Each orchestration role is independently configured with a provider ID, model name, and per-request timeout. Set ORCH_ROLE_<ROLE>_PROVIDER=disabled to skip a role entirely.
RoleProvider variableModel variableTimeout variableDefault providerDefault model
memoryORCH_ROLE_MEMORY_PROVIDERORCH_ROLE_MEMORY_MODELORCH_ROLE_MEMORY_TIMEOUT_SECopenaiqwen2.5:14b-instruct
scoreboardORCH_ROLE_SCOREBOARD_PROVIDERORCH_ROLE_SCOREBOARD_MODELORCH_ROLE_SCOREBOARD_TIMEOUT_SECopenaiqwen2.5:14b-instruct
contextORCH_ROLE_CONTEXT_PROVIDERORCH_ROLE_CONTEXT_MODELORCH_ROLE_CONTEXT_TIMEOUT_SECopenaiqwen2.5:14b-instruct
marketORCH_ROLE_MARKET_PROVIDERORCH_ROLE_MARKET_MODELORCH_ROLE_MARKET_TIMEOUT_SECopenaigpt-5.5
volatilityORCH_ROLE_VOLATILITY_PROVIDERORCH_ROLE_VOLATILITY_MODELORCH_ROLE_VOLATILITY_TIMEOUT_SECdisabledsonar
macroORCH_ROLE_MACRO_PROVIDERORCH_ROLE_MACRO_MODELORCH_ROLE_MACRO_TIMEOUT_SECdisabledsonar
microstructureORCH_ROLE_MICROSTRUCTURE_PROVIDERORCH_ROLE_MICROSTRUCTURE_MODELORCH_ROLE_MICROSTRUCTURE_TIMEOUT_SECdisabledsonar
criticORCH_ROLE_CRITIC_PROVIDERORCH_ROLE_CRITIC_MODELORCH_ROLE_CRITIC_TIMEOUT_SECanthropicclaude-sonnet-4-6
riskORCH_ROLE_RISK_PROVIDERORCH_ROLE_RISK_MODELORCH_ROLE_RISK_TIMEOUT_SECanthropicclaude-sonnet-4-6
copyORCH_ROLE_COPY_PROVIDERORCH_ROLE_COPY_MODELORCH_ROLE_COPY_TIMEOUT_SECanthropicclaude-haiku-4-5
explainerORCH_ROLE_EXPLAINER_PROVIDERORCH_ROLE_EXPLAINER_MODELORCH_ROLE_EXPLAINER_TIMEOUT_SECanthropicclaude-haiku-4-5
finalORCH_ROLE_FINAL_PROVIDERORCH_ROLE_FINAL_MODELORCH_ROLE_FINAL_TIMEOUT_SECanthropicclaude-opus-4-7
Role timeout defaults vary: memory, scoreboard, and context default to 20 seconds; volatility, macro, and microstructure default to 60 seconds; all remaining Anthropic-backed roles (market, critic, risk, copy, explainer, final) default to 90 seconds. A minimal production configuration using only Anthropic roles looks like this:
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_VERSION=2023-06-01

ORCH_ROLE_CRITIC_PROVIDER=anthropic
ORCH_ROLE_CRITIC_MODEL=claude-sonnet-4-6
ORCH_ROLE_CRITIC_TIMEOUT_SEC=90

ORCH_ROLE_RISK_PROVIDER=anthropic
ORCH_ROLE_RISK_MODEL=claude-sonnet-4-6
ORCH_ROLE_RISK_TIMEOUT_SEC=90

ORCH_ROLE_COPY_PROVIDER=anthropic
ORCH_ROLE_COPY_MODEL=claude-haiku-4-5
ORCH_ROLE_COPY_TIMEOUT_SEC=90

ORCH_ROLE_EXPLAINER_PROVIDER=anthropic
ORCH_ROLE_EXPLAINER_MODEL=claude-haiku-4-5
ORCH_ROLE_EXPLAINER_TIMEOUT_SEC=90

ORCH_ROLE_FINAL_PROVIDER=anthropic
ORCH_ROLE_FINAL_MODEL=claude-opus-4-7
ORCH_ROLE_FINAL_TIMEOUT_SEC=90

Default model shortcuts

These convenience variables set fallback models used when a role-specific variable is absent. Role-specific variables always take precedence.
VariableDefaultPurpose
ORCH_DEFAULT_MARKET_MODELgpt-5.5Default model for market-facing roles
ORCH_DEFAULT_CLAUDE_MODELclaude-sonnet-4-6Default Claude model for analysis roles
ORCH_DEFAULT_COPY_MODELclaude-haiku-4-5Default model for the copy role
ORCH_DEFAULT_EXPLAINER_MODELclaude-haiku-4-5Default model for the explainer role
ORCH_DEFAULT_FINAL_MODELclaude-opus-4-7Default model for the final synthesis role

Token budgets

Each role has an independent token budget that limits how much context it may consume per orchestration cycle. Setting a budget to 0 does not disable the role; use ORCH_ROLE_<ROLE>_PROVIDER=disabled for that.
VariableDefaultDescription
ORCH_TOKEN_BUDGET_TOTAL60000000Aggregate token budget across all roles in one orchestration run
ORCH_ROLE_MARKET_TOKEN_BUDGET14000000Token budget for the market role
ORCH_ROLE_VOLATILITY_TOKEN_BUDGET6000000Token budget for the volatility role
ORCH_ROLE_MACRO_TOKEN_BUDGET6000000Token budget for the macro role
ORCH_ROLE_MICROSTRUCTURE_TOKEN_BUDGET6000000Token budget for the microstructure role
ORCH_ROLE_CRITIC_TOKEN_BUDGET10000000Token budget for the critic role
ORCH_ROLE_RISK_TOKEN_BUDGET10000000Token budget for the risk role
ORCH_ROLE_COPY_TOKEN_BUDGET4000000Token budget for the copy role
ORCH_ROLE_EXPLAINER_TOKEN_BUDGET6000000Token budget for the explainer role
ORCH_ROLE_FINAL_TOKEN_BUDGET16000000Token budget for the final synthesis role

Kilo worker

The Kilo worker is a separate recurring LLM analysis loop that runs independently of the main trading pipeline. It reads runtime state, produces a compressed analysis report to runtime/kilo_orchestrator_latest.md, and optionally proposes BTC/ETH filter rule updates that the llm_bundle.py simulation gate may auto-apply if they pass a minimum quality bar.
VariableDefaultDescription
KILO_PROVIDER_IDtokenatorProvider ID string used to identify the Kilo provider
KILO_DISPLAY_NAMETokenatorHuman-readable display name for the Kilo provider
KILO_BASE_URLhttps://api.tokenator.cloud/v1OpenAI-compatible base URL for the Kilo provider
KILO_ANTHROPIC_BASE_URLhttps://api.tokenator.cloud/anthropicAnthropic-compatible base URL for the Kilo provider
KILO_API_KEY(empty)API key for the Kilo provider
KILO_MODELtokenator/claude-opus-4-7Primary model for Kilo analysis
KILO_FALLBACK_MODELStokenator/gpt-5.5,tokenator/gemini-3.1-pro-previewComma-separated fallback models if the primary is unavailable
KILO_VARIANTmediumKilo analysis depth variant
KILO_AVAILABLE_MODELSgpt-5.5,claude-opus-4-7,gemini-3.1-pro-preview,claude-sonnet-4-6,claude-opus-4-6,claude-haiku-4-5Comma-separated list of models the Kilo provider supports
KILO_TOKEN_BUDGET20000000Maximum tokens per Kilo analysis pass
KILO_ANALYSIS_TIMEOUT_SEC75Per-request timeout for Kilo analysis calls
KILO_WORKER_INTERVAL_SEC90Seconds between Kilo worker analysis cycles

Orchestration loop settings

VariableDefaultDescription
ORCH_HEARTBEAT_SEC300Seconds between orchestrator heartbeat ticks
ORCH_REDEEM_CRON_SEC900Seconds between automated redeem checks (when ALLOW_REDEEM=1)
ORCH_LLM_RETRY_ATTEMPTS2Number of retry attempts for a failed LLM API call
ORCH_LOCAL_OPENAI_BASE_URLhttp://127.0.0.1:11434/v1Base URL for the local OpenAI-compatible endpoint used in orchestration

Role prompts

System prompts for each orchestration role are stored as plain-text files under the prompts/ directory. Edit them to change how each role reasons about the runtime snapshot without modifying any Python code. The filenames correspond to role names (e.g. prompts/critic.txt, prompts/risk.txt). Refer to prompts/README.md for the full list and editing guidelines.

Local Qwen / Ollama endpoint

The memory, scoreboard, and context roles default to a local Qwen model served by Ollama. Configure the endpoint with:
LOCAL_QWEN_MODEL=qwen2.5:14b-instruct
LOCAL_QWEN_BASE_URL=http://127.0.0.1:11434/v1
LOCAL_QWEN_API_KEY=local
LOCAL_QWEN_TIMEOUT_SEC=90

# Used by the orchestrator's local OpenAI-compatible path
ORCH_LOCAL_OPENAI_BASE_URL=http://127.0.0.1:11434/v1
If OPENAI_BASE_URL is not set, the local memory step is skipped and a missing_OPENAI_BASE_URL reason is logged; the rest of the pipeline continues normally.

Build docs developers (and LLMs) love