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 was designed Windows-first. The scripts/bootstrap_polyclaw_kilo.bat script automates the full startup sequence — dependency validation, secret configuration, OpenClaw config patching, Polygon RPC validation, and multi-window service launch — in a single command. Companion PowerShell and CMD launchers let you start individual services independently, and the secret configuration helpers write .env.local without ever echoing a value to the screen.

Prerequisites

Before running the bootstrap, ensure the following are available on your system. Install any missing tools via WinGet or Scoop:
  • Python 3.12+winget install Python.Python.3.12
  • Node.js and npm — required for the Kilo CLI
  • uv — installed automatically by the bootstrap if missing
  • gitwinget install Git.Git

The Full Bootstrap Flow

scripts/bootstrap_polyclaw_kilo.bat performs ten numbered steps. It validates each step before proceeding and exits with a non-zero code at the first failure, so you always know exactly where a setup issue occurred.
1

Validate project files

The script checks that all required project files are present in the repository root before doing anything else. Missing files produce an explicit error message naming the missing file.
scripts\bootstrap_polyclaw_kilo.bat
2

Ensure runtime directories

Creates runtime/, runtime/logs/, and runtime/executions/ if they do not already exist.
3

Check Node.js, npm, Python, git, and uv

Each tool is checked with where. If uv is not found, the script installs it automatically via pip:
python -m pip install --upgrade pip
python -m pip install uv
4

Install the Kilo CLI if missing

npm install -g @kilocode/cli
5

Install OpenClaw if missing

If openclaw is not found on PATH, the script installs it via the official PowerShell installer. If ~/.openclaw/openclaw.json does not exist, the script checks for a bundled config and explains what to do if neither is present.
6

Locate or clone PolyClaw

The script searches for polyclaw.py in %OPENCLAW_HOME%\skills\polyclaw, %USERPROFILE%\polyclaw, and a bundled polyclaw/ directory inside the repository. If none is found it clones the repository:
git clone https://github.com/chainstacklabs/polyclaw %SKILLS_DIR%\polyclaw
Then runs uv sync inside the cloned directory.
7

Configure .env.local

If .env.local does not exist, the script prompts for secrets using PowerShell’s Read-Host -AsSecureString so that private keys are never visible. The following values are collected interactively:
  • POLYMARKET_WALLET_ADDRESS
  • CHAINSTACK_NODE
  • HTTPS_PROXY (optional)
  • BANK_USD, MAX_TRADE_RISK_PCT, MAX_DAILY_RISK_PCT, MAX_TRADES_PER_DAY
  • SIGNAL_INTERVAL_SEC, MARKET_QUERY
  • POLYCLAW_PRIVATE_KEY (masked)
  • OPENROUTER_API_KEY (masked)
After the file is created, normalize_env_local.py is run to clean whitespace and validate the format.
8

Patch OpenClaw config and validate RPC

openclaw_patch.py writes a timestamped backup of ~/.openclaw/openclaw.json before applying any change. Then rpc_probe.py validates the Polygon RPC endpoint — if this fails, the script exits with a warning rather than starting services that would silently fail.
9

Prompt for wallet approval if LIVE_TRADING=1

If LIVE_TRADING=1 is set in .env.local, the script prompts you to type APPROVE to run polyclaw wallet approve. Pressing Enter skips this step. No approval prompt appears in dry-run mode.
10

Launch all services

Four windows open in sequence:
  1. OpenClaw Gatewaylaunch_openclaw_gateway.cmd (12-second startup delay before next window)
  2. OpenClaw TUIlaunch_openclaw_tui.cmd
  3. Kilo Workerlaunch_kilo_worker.cmd with model openai/gpt-5.1-codex-mini
  4. Kilo Interfacelaunch_kilo_interface.cmd with the same model
The main window then enters the trading loop, running candles_adapter.py, signal_engine.py, trade_gate.py, and market_reports.py on a SIGNAL_INTERVAL_SEC (default 300) cycle.

Individual Launcher Scripts

Each service can be started independently. Scripts are available in both CMD and shell (.sh) variants:
ScriptPurpose
launch_openclaw_gateway.cmd / .shStarts the OpenClaw gateway (required before TUI)
launch_openclaw_tui.cmd / .shStarts the OpenClaw TUI; reads token only from .env.local
launch_kilo_worker.cmd / .shStarts the Kilo worker with an isolated runtime profile
launch_kilo_interface.cmd / .shStarts the Kilo interactive shell
setup_local_qwen.cmd / .ps1Installs Ollama (via WinGet if available) and pulls qwen2.5:14b-instruct for local MemoryChewer roles
launch_openclaw_tui.* reads the OpenClaw token exclusively from .env.local. It does not scrape ~/.openclaw/openclaw.json or any other JSON config. This ensures the token is never written to a shell history file.launch_kilo_worker.sh stores the isolated Kilo profile under runtime/kilo-worker-* by default, so it does not disturb the primary ~/.local/share/kilo profile.

Running the Pipeline Directly

For scripted or CI-style runs, scripts/run_pipeline.py is the Windows-first entry point to the deterministic pipeline:
# One dry-run pass (safe to run any time)
uv run python scripts/run_pipeline.py dry-run

# Run the audit test subset (no secrets or network required)
uv run python scripts/run_pipeline.py audit

# Dry-run loop with a fixture (for local testing)
uv run python scripts/run_pipeline.py loop --fixture tests/fixtures/btc_market.json --max-cycles 2

# Live execution (requires LIVE_TRADING=1 in .env.local)
uv run python scripts/run_pipeline.py live --confirm-live

Secret Configuration Helpers

The scripts/ directory contains interactive helpers that write .env.local without echoing secret values. Each script uses Read-Host -AsSecureString or equivalent techniques to keep keys out of terminal output and shell history:
Always use the secret configuration scripts to populate .env.local rather than editing the file directly in a terminal. The scripts zero out in-memory secrets immediately after writing. Never commit .env.local to git — it is listed in .gitignore, and tests/test_secret_scanner.py fails the build if secret-like patterns appear in any tracked file.
ScriptPurpose
configure_all_secrets_env.pyConfigures all secrets in one interactive session
configure_openclaw_gateway_env.pyConfigures OpenClaw gateway credentials
configure_telegram_env.pyConfigures Telegram bot token and chat ID
configure_llm_endpoints_env.pyConfigures LLM API keys and endpoint URLs
Run any of these from the repository root:
uv run python scripts/configure_all_secrets_env.py

Portable Bundle

scripts/create_portable_bundle.ps1 packages a self-contained ZIP of the workspace for VPS deployment:
# Default: creates dist/kilo-claw-vps-YYYYMMDD-HHmmss.zip (no secrets)
pwsh -File scripts/create_portable_bundle.ps1

# Custom output directory and bundle name
pwsh -File scripts/create_portable_bundle.ps1 -OutputDir C:\deploy -BundleName my-bundle

# Include opaque secret-bearing files (handle resulting ZIP as sensitive material)
pwsh -File scripts/create_portable_bundle.ps1 -IncludeSecrets
See the Portable / VPS guide for the full VPS deployment workflow.

Build docs developers (and LLMs) love