SimpleFunctions

Portfolio Autopilot.

Autonomous Kalshi portfolio management — your views, your strategies, your risk gates.

On a schedule you control, an LLM agent wakes up with your full context — views, strategies, risk limits, last tick's handoff note — calls 50+ tools, makes decisions, and writes a structured note for next time. Mechanical risk gates bound the blast radius; reasoning fills the space inside.

Realist oil painting in Joseph Wright of Derby chiaroscuro style — late-17th-century maritime chronometer maker assembling brass clockwork at his nighttime workbench

Harrison's chronometer — the original autonomous mechanism worth trusting while you sleep.

The tick — six steps

Every Portfolio Autopilot run flows through the same six steps. The shape is constant; the policy in each step is yours.

01

Read configuration

Active strategies, views, recent context notes, risk limits — every input the agent will reason against this tick.

02

Decrypt credentials

Your Kalshi API key is decrypted from industry-standard encryption — in-memory only, never written to disk.

03

Build instruction

Compose the agent's system prompt: views, mandate, preferences, risk limits, last 5 handoff notes, last 10 trades.

04

Run agent

LLM with comprehensive toolset (50+ tools — balance, positions, screening, web search, legislative data) reasons multi-turn over the brief.

05

Extract handoff

Structured handoff note for next tick — observations per position, decisions taken, things to watch, view updates.

06

Write state

Updated portfolio state, tick history, handoff note persisted. Next tick reads them back as rolling memory.

Views vs strategies

Two distinct concepts guide the agent. Views = what you believe about the world. Strategies = the rules the agent must obey. Both are authored by you.

Views
Strategies
What it is
Convictions about the world
Rules and constraints
Example
"Geopolitical risk in X is mispriced"
"No sports markets, max 20 positions"
Agent behavior
Trades in alignment with views
Mechanically enforced — agent cannot violate
Source
Authored by the user
Authored by the user
Lifecycle
Updated as conviction shifts
Stable until policy changes
Add a view
sf portfolio view add "Macro thesis" \
  "Analysis of the structural mispricing..." \
  --category geopolitical \
  --tickers KXTICKER1,KXTICKER2 \
  --conviction 5 \
  --horizon 2026-12-31
Add a strategy
sf portfolio strategy add \
  "Conservative yield" \
  "Focus on high-yield, low-spread markets, no sports" \
  --priority 3

Seven mechanical risk gates

Every order passes through seven hard gates before execution. Gates are mechanical — the LLM cannot bypass them. Exits (sells) are always allowed; gates only block new entries (except balance floor and single-order size, which always apply).

Gate
Blocks
What it does

Total exposure cap

entry

Hard ceiling on total notional across all positions

Per-market position limit

entry

Cap on size in any single Kalshi market

Daily loss ceiling

entry

New entries halted if daily P&L breaches threshold

Max position count

entry

Cap on number of distinct open positions

Balance floor

always

Cash floor — orders never push balance below configured minimum

Orders per tick

entry

Limits the number of new orders issued in a single tick

Single order size

always

Hard maximum on the size of any one order

All gate thresholds are configurable per user. The agent reads its limits in the instruction; the gates enforce them mechanically on every order.

Context continuity — handoff notes

Each tick is a fresh LLM invocation — no persistent session, no hidden state. The agent maintains continuity through structured handoff notes the next tick reads as input.

Tick instruction includesrolling input
- your active views (convictions)
- your strategies (rules)
- your preferences (categories, IY thresholds, etc.)
- your risk limits (enforced mechanically)
- last 5 handoff notes (rolling memory)
- last 10 trades

Setup — five steps

01

Enable

sf portfolio enable

02

Add views

sf portfolio view add "..."

03

Add strategies

sf portfolio strategy add "..."

04

Test (dry-run)

sf portfolio trigger

05

Go live

sf portfolio config --execution-mode live

Run the dry-run for several ticks before going live. Live mode places real Kalshi orders.

Where it fits

Sleep mode

Agent runs hourly while you sleep — wakes you only on important regime shifts via the handoff note.

Active oversight

Agent runs on tick, you review every handoff note and approve/reject before next tick.

Macro overlay

Strategy = "follow the macro views I author"; Views = updated weekly to reflect your latest read.

Tail-risk hedger

Strategy = "buy cheap binary tail protection above N% probability"; Views = exposures to hedge.

Security — BYOK encrypted credentials

Your Kalshi API key is encrypted with industry-standard encryption before storage. The encryption key exists only in the cloud runtime environment.

For each tick the key is decrypted in-memory, used to sign API requests, then immediately erased from process memory. The key never touches disk in plaintext.

At any time, run sf portfolio revoke to permanently delete your encrypted key from the database.

FAQ

What is Portfolio Autopilot?

Portfolio Autopilot is an autonomous LLM agent that manages your Kalshi prediction-market portfolio on a schedule you control. Each tick the agent reads your views, strategies, risk limits, and recent context, calls 50+ tools (balance, positions, screening, web search, legislative data), then makes decisions and writes a handoff note for the next tick.

How does it differ from a normal trading bot?

A normal bot follows fixed if-then rules. Portfolio Autopilot reasons multi-turn over your views and the current state, calls tools to investigate, and explains its decisions in a handoff note. It is bounded by mechanical risk gates the agent cannot bypass, but the reasoning inside those bounds is open-ended.

What's the difference between views and strategies?

Views are convictions about the world ("a specific risk is being systematically underpriced"); the agent trades in alignment with views and never against them. Strategies are rules and constraints ("focus on high-yield, low-spread markets, no sports, max 20 positions"); the agent must follow them — they are mechanically enforced.

How are risk gates enforced?

Seven hard gates run on every order before the venue sees it: total exposure cap, per-market position limit, daily loss ceiling, max position count, balance floor, orders per tick, single order size. Gates are mechanical — the LLM cannot bypass them. Exits (sells) are always allowed; gates only block new entries.

How does the agent maintain context across ticks?

Each tick is a fresh LLM invocation (no persistent session), but the agent reads the last 5 handoff notes plus the last 10 trades as input. The agent writes a structured handoff note at the end of each tick: key observations per position, decisions and reasoning, things to watch next tick, view updates. This is the rolling memory.

How is my Kalshi API key protected?

Your Kalshi API key is encrypted with industry-standard encryption before storage. The encryption key exists only in the cloud runtime environment. For each tick the key is decrypted in-memory, used to sign API requests, then immediately erased from process memory. sf portfolio revoke deletes your encrypted key from the database at any time.

How do I set it up?

sf portfolio enable opens an interactive wizard — upload your Kalshi API key, set the tick schedule, choose execution mode (dry-run or live). Then sf portfolio view add to author your convictions and sf portfolio strategy add for your rules. Test in dry-run first; switch to live with sf portfolio config --execution-mode live.

What tools can the agent call?

The agent has access to 50+ tools: balance and position checks, market screening, contract inspection, web search, government and economic data lookups, candidate market discovery, indicator calculations, and Kalshi-specific order primitives. The complete tool catalog is available via sf describe --all --json.

Can I see what the agent decided and why?

Yes. sf portfolio ticks --json --since 7d returns the recent ticks. sf portfolio tick <id> --json returns the full record for a single tick — handoff note, actions taken, risk gates evaluated, trades placed, P&L attribution.

How much does it cost?

Cost scales with tick frequency (every 15 minutes vs every 4 hours) and model selection. The two main components are LLM inference and minimal compute overhead. Test in dry-run mode first to see your typical cost profile before going live.

Is this only for Kalshi?

Today, yes — Portfolio Autopilot manages Kalshi positions. Polymarket support is on the roadmap; the architecture (intent layer + risk gates + handoff context) generalizes, but each venue requires venue-specific connection and order routing.

What if the agent makes a bad decision?

Risk gates limit blast radius — total exposure cap, daily loss ceiling, single order size, balance floor are mechanical fences. The agent's reasoning is open-ended within those fences. Review handoff notes regularly; if a tick looks wrong, the gates contained the damage and you can update views/strategies before the next tick.

Can I pause it?

sf portfolio disable stops the scheduler but keeps your credentials encrypted. sf portfolio enable resumes. sf portfolio revoke permanently deletes the encrypted credentials.

Related surfaces