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.

All PolyClaw Trading configuration is environment-driven. There are no config files, no registry entries, and no hard-coded defaults that silently override your intent. Every tunable parameter — from wallet credentials to risk caps to LLM timeouts — is read from the process environment at startup, validated strictly, and never echoed or logged.
.env.local is gitignored by design and must never be committed. It is the only place secrets should live. If you accidentally commit credentials, rotate them immediately and run uv run python run_pipeline.py audit to confirm the secret scanner test passes.

Getting started

The repository ships .env.example as the exhaustive, up-to-date template. Copy it to .env.local and fill in only the values you need:
cp .env.example .env.local
Env loading is handled by env_local.py, which exposes two functions:
  • load_env_file(path) — parses the file and returns a dictionary of key/value pairs.
  • inject_into_environment(mapping) — writes parsed values into the process environment without echoing or logging any value.
Neither function prints variable contents. The secret scanner test (tests/test_secret_scanner.py) fails the CI build if any secret-like pattern appears in tracked files.

Variable groups

These variables authenticate the system against Polymarket and your blockchain node. Leave them blank to run in dry-run mode with no on-chain activity.
VariableDefaultPurpose
POLYMARKET_WALLET_ADDRESS(empty)EVM wallet address used to own positions
POLYCLAW_PRIVATE_KEY(empty)Private key for signing PolyClaw CLI transactions
CHAINSTACK_NODE(empty)RPC endpoint for on-chain reads (Chainstack or equivalent)
POLYCLAW_PATH must point to the PolyClaw CLI executable. The legacy spelling POCLAW_PATH is accepted as a backward-compatible alias; if both are set, POLYCLAW_PATH takes precedence.
POLYCLAW_PATH=/usr/local/bin/polyclaw
# Backward-compatible typo only; prefer POLYCLAW_PATH.
POCLAW_PATH=
PolyClaw Trading supports four cloud LLM providers plus a local Ollama-compatible endpoint. You only need API keys for the providers you actually use. See LLM Orchestration for per-role model assignment.
VariablePurpose
OPENROUTER_API_KEYOpenRouter multi-provider gateway key
OPENROUTER_BASE_URLOverride OpenRouter base URL (optional)
OPENAI_API_KEYOpenAI or OpenAI-compatible (e.g. local Ollama) key
OPENAI_BASE_URLOverride OpenAI base URL; also used for local Qwen/Ollama
ANTHROPIC_API_KEYAnthropic Claude API key
ANTHROPIC_BASE_URLOverride Anthropic base URL (e.g. Tokenator gateway)
GEMINI_API_KEYGoogle Gemini API key
ANTHROPIC_VERSIONAnthropic API version header (default: 2023-06-01)
These three boolean flags are the primary safety controls. All default to 0 (off). Set them explicitly in .env.local; do not rely on unset being equivalent to 0 in production.
VariableDefaultPurpose
LIVE_TRADING0Hard execution gate: 0 = dry-run only, 1 = send real orders via PolyClaw
ALLOW_REDEEM0Automatic redemption of resolved positions (opt-in)
PANIC_STOP0Immediately halts all trade-gate execution when set to 1
The PANIC_STOP flag is also tripped automatically when runtime/panic_stop.flag exists on disk — which is created after PANIC_AUTO_THRESHOLD consecutive failed live orders (default 5). Set PANIC_AUTO_THRESHOLD=0 to disable the automatic circuit breaker entirely.
Both BANK_USD and BANKROLL_USD represent the initial trading bankroll in USD. BANKROLL_USD takes precedence when both are set. Defaults to 100 if neither is provided.
VariableDefaultPurpose
BANK_USD100Initial bankroll (legacy name)
BANKROLL_USD100Initial bankroll (preferred; overrides BANK_USD if present)
All per-trade and daily risk variables are expressed as percentages of this bankroll.
VariableDefaultPurpose
HTTPS_PROXY(empty)Optional HTTP/S proxy for all outbound calls (LLM APIs, market data)
HTTP_TIMEOUT_SEC20Timeout in seconds for all outbound HTTP requests (market data, price history)
CLOB_MAX_RETRIES10Maximum retry attempts for CLOB API requests before the call is abandoned
DASHBOARD_HOST127.0.0.1Mission Control dashboard bind address
DASHBOARD_PORT8080Mission Control dashboard port
DASHBOARD_AUTH_TOKEN(empty)Bearer / X-Auth-Token auth for non-loopback dashboard hosts
TELEGRAM_BOT_TOKEN(empty)Telegram bot token for trade notifications
TELEGRAM_CHAT_ID(empty)Destination chat ID for Telegram messages
TELEGRAM_DELIVERY_ENABLED1Enable Telegram delivery when credentials are present
TELEGRAM_DELIVERY_MIN_INTERVAL_SEC300Minimum seconds between Telegram messages
OPENCLAW_GATEWAY_URL(empty)OpenClaw gateway URL
OPENCLAW_GATEWAY_TOKEN(empty)Auth token for the OpenClaw gateway

Key safety variables at a glance

The table below reproduces the quick-reference from the README with every variable that directly governs whether and how real money moves.
LIVE_TRADING=1 is the only switch that causes real orders to be submitted. The system requires the exact string 1; any other value (including true or yes) is rejected with a ConfigError. Never set this variable in a shared environment or CI runner.
VariableDefaultPurpose
LIVE_TRADING0Hard gate: 0 logs orders, 1 sends them via PolyClaw
ALLOW_REDEEM0Automatic redeem on resolved markets (opt-in)
MIN_TRADE_USD0.25Minimum micro-order size in USD
MAX_TRADE_USD1.00Maximum micro-order size in USD
BASE_RISK_PER_TRADE_PCT1Per-trade risk as a percentage of bankroll
MAX_DAILY_RISK_PCT8Daily risk cap as a percentage of bankroll
MAX_OPEN_EXPOSURE_PCT20Working-bankroll open-exposure cap
MAX_TRADES_PER_DAY6Maximum trade executions per calendar day
MIN_MARKET_MINUTES_TO_EXPIRY30Skip markets within this many minutes of resolution
FAILED_ORDER_COOLDOWN_SEC1800Pause after a failed live order (seconds)
MIN_EXECUTION_CONFIDENCE0.72Minimum deterministic signal confidence required to trade

Runtime directory

RUNTIME_DIR (default: runtime) sets the working state directory. All generated JSON files — candles, decisions, bankroll state, ledgers — are written here. This directory is never a source of secrets and can be freely committed or inspected.
RUNTIME_DIR=runtime

Build docs developers (and LLMs) love