Executor Service
Order placement and execution layer
The Executor consumes per-strategy signals from Redis streams, computes pricing and sizing per account, and places orders on the Polymarket CLOB. Each AccountExecutor handles its own signal consumption and order submission independently.
Per-Account Execution
Each AccountExecutor is bound to a trading account and one or more strategies. The service spawns one consume_signals task per (account, strategy, token) triple. Account bindings are reloaded every 60 seconds and on account mutations from the Gateway.
Pricing & Sizing
Pricing — Reference price (best_ask, best_bid, mid) from snapshot cache, plus offset and max deviation. Optional flat cut-off for fill quality.
Sizing — Two modes: fixed (static shares per trade) or compound (fraction of balance per trade).
Paper Trading
When paper_mode is enabled, the Executor simulates fills locally without touching the Polymarket CLOB. Maintains demo_balance in Postgres, tracks paper positions in-memory, and publishes the same exec:order_update and exec:position_update messages as live mode. Supports market roll detection for binary-option expiry transitions.
Live Trading
In live mode, orders are placed via the Polymarket CLOB REST API. Limit orders auto-cancel after TTL. Fill and cancel handlers use a collect-then-commit pattern for crash safety.
Signal Routing
Consumes BUY, EXIT, SCALE_IN, SCALE_OUT from streams. WAIT is ignored. Entry ladder support for multiple orders per level when use_ladder is enabled.