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.
Authorization: Bearer sf_live_xxxsf setup handles this automatically| Access | Rate Limit |
|---|---|
| No auth (public endpoints) | 10 req/min |
| With API key | 60 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.
Context & Daily Data
Global market snapshot: edges, movers, highlights, traditional market prices.
Market Search & Data
Indices & Analytics
Legislation
Social & Sentiment
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
| Indicator | Full Name | What It Measures |
|---|---|---|
| IY | Implied Yield | Annualized return if held to expiry |
| LAS | Liquidity-Adjusted Spread | Spread normalized by depth |
| OR | Overround | How much the book is "over 100%" |
| CRI | Consensus Risk Index | How concentrated bets are |
| EE | Expected Edge | Theoretical edge vs fair value |
| TAU | Time to Expiry | Days 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.
get_world_state — ~800 token briefingscan_markets — keyword searchget_trade_ideas — sales desk pitchescreate_thesis — form causal treecreate_intent — arm a tradeget_context — market snapshotsearch_x — X/Twitter searchget_edges — top opportunities7. 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
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
Key Endpoints (Auth Required)
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.
| Gate | Scope |
|---|---|
| Total exposure cap | entry only |
| Per-market position limit | entry only |
| Daily loss ceiling | entry only |
| Max position count | entry only |
| Balance floor | always |
| Orders per tick | entry only |
| Single order size | always |
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.