Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt

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

Every order — autopilot, CLI agent, web terminal trade ticket, intent executor — runs through these gates. They fail-closed on every violation: the order is rejected with a structured reason, never silently downsized.

Gate checks (entry orders)

CheckFailing condition
Min balancebalance_cents < min_balance_cents
Single-order caporder_cost_cents > max_single_order_cents
Total exposure(current_exposure + order_cost) > max_total_exposure_cents
Daily loss cap|daily_realized_pnl| > max_daily_loss_cents (if PnL is negative)
Position countopen_positions >= max_positions
Orders this tickorders_this_tick >= max_orders_per_tick
Cooldown after lossticks_since_last_loss < cooldown_after_loss_ticks

Gate checks (exit orders)

Exit orders skip the position-count and exposure gates (they reduce exposure), but still respect single-order cap and daily-loss cap.

Configuration

Per-user limits live in portfolio_config. Update with:
sf portfolio config max_total_exposure_cents 500000
sf portfolio config max_per_market_cents 150000
Defaults:
max_total_exposure_cents:    300000  ($3,000)
max_per_market_cents:        100000  ($1,000)
max_daily_loss_cents:        15000   ($150)
max_positions:               20
min_balance_cents:           10000   ($100)
max_orders_per_tick:         3
max_single_order_cents:      20000   ($200)
cooldown_after_loss_ticks:   4

Drawdown halt

Two thresholds beyond per-trade gates:
  • drawdown_warn_cents (default $300) — emits a health_alert but doesn’t halt.
  • max_drawdown_halt_cents (default $500) — auto-flips execution_mode to halted. Recoverable only by manual sf portfolio config executionMode live.

Source

  • cli/src/risk-gates.ts — gate evaluator.
  • cli/src/commands/agent.ts — pre-place_order gate call.
  • src/trigger/portfolio-tick.ts — env-var injection for autopilot.

Next steps

Portfolio autopilot

The autopilot runtime calling these gates.

Trade intents

Gate also runs on intent submission.