User Manual

Everything you need to go from zero to autonomous. Install, query, trade, automate.


1. Install the CLI

Two options. Global install gives you the sf command everywhere.npx runs it without installing.

# Option A: global install
npm install -g @spfunctions/cli

# Option B: run directly
npx -y @spfunctions/cli query "fed rate"

Then run the setup wizard:

sf setup
# ~2 minutes. Prompts for Kalshi/Polymarket API keys (optional),
# trading preferences, and MCP connection.

Config is stored at ~/.sf/config.json. You can edit it directly.


2. Authentication & API Keys

Most read endpoints work without auth. Writing (theses, trades, portfolio) requires a key.

Use it: Authorization: Bearer sf_live_xxx
CLI auth: sf setup handles this automatically
AccessRate Limit
No auth (public endpoints)10 req/min
With API key60 req/min

3. Your First Query

Ask a question in natural language. SF searches Kalshi, Polymarket, X/Twitter, and traditional markets, then synthesizes a response.

# CLI
sf query "will the fed cut rates in 2026?"

# REST
curl "https://simplefunctions.dev/api/public/query?q=fed+rate+cut&mode=full&limit=5"

# JSON output (for piping to other tools)
sf query "gold price" --json

For raw market search without LLM synthesis:

sf scan "iran oil"
sf scan --market KXOIL-100DEC25    # single market
sf scan --series KXOIL              # browse all events in series

4. Data Endpoints

All public endpoints work without auth. Base URL: https://simplefunctions.dev

World Model

Real-time world state in ~800 tokens. Designed for agent system prompts.

GET /api/agent/world — full world state (markdown or JSON)
GET /api/agent/world/delta?since=1h — only what changed
GET /api/agent/inspect/{ticker} — deep single-market inspection

Context & Daily Data

Global market snapshot: edges, movers, highlights, traditional market prices.

GET /api/public/context — full snapshot
GET /api/public/context?compact=true — edges + highlights only
GET /api/public/highlights — market highlights
GET /api/public/ideas — trade ideas (sales desk style)

Market Search & Data

GET /api/public/scan?q=oil — search Kalshi + Polymarket
GET /api/public/market/{ticker} — single market profile
GET /api/public/trad-markets?topic=energy — traditional markets (SPY, VIX, GLD, etc.)
GET /api/public/newmarkets — recently listed markets
GET /api/public/calendar — upcoming Kalshi events
GET /api/public/databento — historical OHLCV (futures, equities)

Indices & Analytics

GET /api/public/index — SF Index (disagreement, breadth, geoRisk, activity)
GET /api/public/index/history?days=7 — index time series
GET /api/public/contagion?topic=iran — cross-market contagion
GET /api/public/diff?topic=oil&window=24h — market deltas
GET /api/public/regime/scan — regime analysis

Legislation

GET /api/public/legislation — bills with market cross-reference
GET /api/public/legislation/{billId} — single bill detail
GET /api/public/congress/members — congress member data
GET /api/public/query-gov?q=tariff — LLM query over gov data

Social & Sentiment

GET /api/public/x?q=oil — X/Twitter search
GET /api/public/x/volume?q=iran — discussion volume trend
GET /api/public/theses — published community theses
GET /api/public/skills — agent skills library

5. Screening & Indicators

Filter markets by quantitative indicators. Useful for finding opportunities the crowd hasn't priced.

# CLI: high-yield, tight-spread markets
sf screen --iy-min 200 --las-max 0.1

# Markets with no thesis coverage (contrarian hunting)
sf screen --without-thesis --venue polymarket

# Arbitrage opportunities
sf screen --or-min 0.05

# REST
GET /api/public/screen?iy_min=200&las_max=0.1&sort=iy&limit=20
IndicatorFull NameWhat It Measures
IYImplied YieldAnnualized return if held to expiry
LASLiquidity-Adjusted SpreadSpread normalized by depth
OROverroundHow much the book is "over 100%"
CRIConsensus Risk IndexHow concentrated bets are
EEExpected EdgeTheoretical edge vs fair value
TAUTime to ExpiryDays until settlement

6. Connect to Claude (MCP Server)

One command gives Claude access to 40+ prediction market tools. Works with Claude Code, Cursor, Cline, and any MCP-compatible client.

# Claude Code
claude mcp add simplefunctions --url https://simplefunctions.dev/api/mcp/mcp

# Cursor / Cline — add to settings:
{
  "mcpServers": {
    "simplefunctions": {
      "url": "https://simplefunctions.dev/api/mcp/mcp"
    }
  }
}

Once connected, Claude can search markets, create theses, inject signals, screen for opportunities, execute trades, and monitor positions — all through natural language.

Example tools available:
get_world_state — ~800 token briefing
scan_markets — keyword search
get_trade_ideas — sales desk pitches
create_thesis — form causal tree
create_intent — arm a trade
get_context — market snapshot
search_x — X/Twitter search
get_edges — top opportunities

7. The Agent

Interactive agent with access to every tool. Ask questions in natural language, give compound instructions, set up monitoring — it handles multi-step reasoning across market data, execution, and research.

# Launch agent (TUI mode)
sf agent

# Launch with a specific thesis loaded
sf agent <thesis-id>

# Plain mode (for piping / scripts)
sf agent --plain

Slash Commands Inside the Agent

/tree — show causal tree
/edges — show current edges
/pos — show positions
/eval — trigger evaluation
/buy TICKER QTY PRICE — buy contracts
/sell TICKER QTY PRICE — sell contracts
/cancel — cancel orders
/switch <id> — switch thesis context
/compact — compress context
/model <name> — change model

Daemon Mode

The agent can run as a background daemon — scanning for triggers, monitoring positions, and sending Telegram alerts.

sf runtime start --daemon --smart
sf runtime status
sf runtime stop

8. Theses & Positions

A thesis is a structured conviction. You write it in natural language, and SF builds a causal tree, maps it to prediction markets, and monitors it 24/7.

# Create a thesis (sync — waits for formation)
sf create "Iran sanctions relief will fail because..."

# Check state
sf context <id> --json

# Inject a signal (news, observation)
sf signal <id> "Iran IAEA report released, no progress on enrichment caps"

# Force re-evaluation
sf evaluate <id>

# Track a position against it
sf positions

Thesis Lifecycle

create
1. you write raw thesis text
2. SF builds causal tree (nodes + probabilities)
3. SF maps nodes to prediction markets (edges)
4. heartbeat engine starts monitoring 24/7
monitor
- news scan (targeted queries + adversarial)
- price refresh (Kalshi + Polymarket)
- signal evaluation against causal tree
- kill condition check
- confidence + node probability updates

Key Endpoints (Auth Required)

POST /api/thesis/create — create + form thesis
GET /api/thesis/:id/context — full state (primary read)
GET /api/thesis/:id/changes?since=ISO — lightweight delta
POST /api/thesis/:id/signal — inject observation
POST /api/thesis/:id/evaluate — force evaluation
POST /api/thesis/:id/augment — review + merge nodes

9. Execution & Intents

Three ways to trade, from manual to autonomous.

Direct Orders

sf buy KXTICKER1 100 --price 42    # 3-second countdown before execution
sf sell KXTICKER1 100 --price 55
sf cancel                           # cancel all resting orders

Intents (Conditional)

Declare what you want to happen and under what conditions. The runtime watches and executes.

sf intent buy KXTICKER1 500 --price 40 --trigger below:40
sf intent list
sf intent cancel <id>

Portfolio Autopilot (Fully Autonomous)

See section 10 below.


10. Portfolio Autopilot

A cloud agent that wakes on your schedule, reads your views and strategies, scans the market, and trades autonomously — constrained by mechanical risk gates it cannot bypass.

Step 1: Enable

sf portfolio enable
# Interactive wizard:
#   - Upload Kalshi API key (encrypted before storage)
#   - Set schedule (hourly, daily, custom)
#   - Choose mode: dry-run (default) or live

Step 2: Define Your Views

Views are your convictions. The agent trades in alignment with them — it will never take positions that contradict your views.

sf portfolio view add \
  "Recession risk is underpriced" \
  "Labor market data is lagging. Real consumer spending..." \
  --category macro \
  --conviction 5 \
  --horizon 2026-12-31 \
  --tickers KXTICKER1,KXTICKER2

Step 3: Set Strategies

Strategies are rules the agent must follow. They are mechanically enforced.

sf portfolio strategy add \
  "Conservative yield" \
  "Focus on high-yield, low-spread markets. No sports. Max 20 positions." \
  --priority 3

Step 4: Test in Dry-Run

sf portfolio trigger
# Runs a full tick without placing real orders.
# Review what the agent would have done.

Step 5: Go Live

sf portfolio config --execution-mode live
# Only after reviewing several dry-run ticks.
# Live mode places real orders on Kalshi.

Risk Gates

Every order passes through 7 hard gates before execution. The LLM cannot bypass them. Exits (sells) are always allowed.

GateScope
Total exposure capentry only
Per-market position limitentry only
Daily loss ceilingentry only
Max position countentry only
Balance flooralways
Orders per tickentry only
Single order sizealways

All limits are configurable. The agent sees them in its instruction; the gates enforce them mechanically on every order.

Context Continuity

Each tick is a fresh LLM invocation. Continuity comes from handoff notes — at the end of each tick, the agent writes a structured note covering observations, decisions, and things to watch. The next tick reads the last 5 notes as context.

Security

Your Kalshi API key is encrypted before storage. The encryption key exists only in the cloud runtime. Decrypted in-memory per tick, then immediately erased. sf portfolio revoke permanently deletes it.


11. Risks & Caveats

Live Trading

sf buy, sf sell, and Portfolio Autopilot in live mode place real orders with real money. There is a 3-second countdown on direct orders. Portfolio Autopilot in dry-run mode does not execute. Always review dry-run ticks before going live.

No Guaranteed Fills

Prediction markets are thin. Prices can move between intent creation and execution. Spreads can widen. An armed intent may fill at a worse price than you expected, or not fill at all.

LLM Costs

Query synthesis, agent mode, smart daemons, and Portfolio Autopilot all consume LLM inference. Costs scale with frequency and model selection. Set a budget cap in ~/.sf/config.json to prevent runaway spend. If the cap is exceeded, smart features fall back to mechanical mode.

Credential Security

Your exchange API keys are stored locally by the CLI and encrypted in the cloud for Portfolio Autopilot. Never commit ~/.sf/config.json to version control. Use sf portfolio revoke to permanently delete cloud-stored credentials.

Data Freshness

Public endpoints are updated continuously but may have slight lag. For time-sensitive decisions, use GET /api/thesis/:id/changes?since=ISO to poll for deltas instead of re-fetching full state.

Past Performance

Backtest results and historical edge data do not guarantee future returns. Prediction markets have unique risks: binary outcomes, event cancellation, regulatory changes.