PolyClaw Trading exposes two complementary CLI interfaces. TheDocumentation 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-engine package entrypoint runs individual pipeline stages (or the full cycle) inside a single Python process, while scripts/run_pipeline.py is a Windows-first subprocess runner that launches each stage as a separate process so that JSON files remain the only inter-process contract. Both interfaces share the same exit-code convention and understand the same --fixture flag for offline dry-run verification.
polyclaw-engine
polyclaw-engine is installed as a package entrypoint backed by src/polyclaw_engine/orchestrator.py. It accepts one positional command and two optional flags.
Synopsis
Flags
Path to an offline market fixture JSON file. Accepted only by
fetch, cycle, and loop. Passing --fixture to any other stage raises ConfigError and exits with code 2.Maximum number of loop iterations.
0 means unlimited. Only meaningful with the loop command.Exit codes
| Code | Meaning |
|---|---|
0 | Success |
2 | ConfigError, ContractError, HttpClientError, or OSError — printed to stderr as [blocked] ExceptionType: message |
130 | KeyboardInterrupt — loop was interrupted cleanly |
Commands
The full pipeline isfetch → candles → analyze → signal → bankroll → validate → execute → report. Each stage can be run in isolation:
| Command | Description |
|---|---|
fetch | Discover active BTC binary markets via Gamma keyset pagination, validate semantics, fetch YES-token price history, and write runtime/market_snapshot.json. |
candles | Build UTC-aligned 5m and 15m pseudo-OHLC candle arrays from raw price samples and write runtime/candles.json. |
analyze | Compute EMA8/EMA21, RSI14, ATR14, sample-density POC, realized volatility, candle patterns, and market/candle quality scores. Writes runtime/market_analysis.json. |
signal | Generate deterministic YES, NO, or HOLD decisions with confidence breakdown from analysis state. Writes runtime/decisions.json and runtime/manual_review.json. |
bankroll | Refresh equity, reserve, drawdown mode, and daily limits from the trade registry. Writes runtime/bankroll_state.json and runtime/risk_state.json. |
validate | Size approved decisions against every active capital cap and repeat semantic, quality, expiry, and cooldown checks. Writes updated runtime/decisions.json (stage: validate) and runtime/manual_review.json. |
execute | Submit to PolyClaw (live) or log a dry-run record. Appends to runtime/executions/YYYY-MM-DD.json. |
report | Print a terminal summary and write runtime/runtime_snapshot.json. Reads decisions.json, bankroll_state.json, risk_state.json, and execution_status.json; raises ContractError (exit 2) if any required file is missing or stale. |
cycle | Run all eight stages once in order. Equivalent to running each stage individually. Accepts --fixture. |
loop | Repeat the full cycle indefinitely (or up to --max-cycles), sleeping LOOP_INTERVAL_SEC seconds between cycles. Accepts --fixture and --max-cycles. |
audit | Run python -m unittest discover -s tests -v from the project root and return the subprocess exit code. |
Example invocations
--fixture is silently forwarded only to the fetch stage when running cycle or loop. The remaining stages always read from the standard runtime file locations.run_pipeline.py
scripts/run_pipeline.py is the Windows-first subprocess runner. It launches each polyclaw_engine stage as a separate python -m polyclaw_engine <stage> process, keeping JSON files as the only inter-process contract. Its safety guarantee is that dry-run forcibly pins LIVE_TRADING=0, ALLOW_REDEEM=0, PIPELINE_FORCE_LIVE_TRADING=0, and PIPELINE_FORCE_ALLOW_REDEEM=0 before any subprocess starts.
Synopsis
All modes
| Mode | Description |
|---|---|
dry-run | Runs the full pipeline (fetch → report) with LIVE_TRADING forcibly set to 0. Safe to call at any time. |
live | Runs the full pipeline with LIVE_TRADING=1. Requires --confirm-live; blocked otherwise (exits 1). |
pipeline / cycle / full-cycle | Runs the full pipeline with the current environment. Warns if LIVE_TRADING=1 is already set. |
trade-cycle | Runs stages fetch through execute (skips report). |
analysis-cycle | Runs stages fetch through signal (skips bankroll, validate, execute, report). |
loop | Delegates to polyclaw-engine loop, forwarding --fixture and --max-cycles. |
audit / test | Runs python -m unittest discover -s tests -v. |
fetch / candles / analyze / signal / bankroll / validate / execute / report | Runs the named stage as a subprocess, forwarding --fixture to fetch if provided. |
Flags
Forwarded to the
fetch stage subprocess as --fixture <path>. Enables fully offline operation.Forwarded to
polyclaw-engine loop. 0 means unlimited.Required for
live mode. Without it, the runner prints [blocked] live mode requires --confirm-live and exits 1.Example invocations
Standard offline dry-run (from the README andbtc_strategy_engine.md):