This isn't API documentation. This is a person sitting down, opening a terminal, and having a running prediction market agent 15 minutes later.
No filler. Every step does something. Every decision point is explained.
Prerequisites
You need three things:
- Node.js 18+ —
node --versionshould show 18 or higher - A Kalshi account — free at kalshi.com, you need the API keys from Settings → API
- An OpenRouter API key — for the LLM that powers thesis analysis
That's it. No Docker, no databases, no cloud setup.
Step 1: Install the CLI
npm install -g @spfunctions/cli
Verify the installation:
sf --version
# @spfunctions/cli 1.2.x
The sf command is now available globally. Everything runs through this single binary.
Step 2: Configure Your Keys
sf setup
This launches an interactive setup that asks for:
- Kalshi API Key & Secret — from your Kalshi dashboard under Settings → API Keys
- OpenRouter API Key — from openrouter.ai/keys
Keys are stored locally in ~/.sfrc. They never leave your machine. The CLI calls Kalshi and OpenRouter directly — there's no SimpleFunctions server in between.
Step 3: Your First Scan
sf scan
This is where it gets interesting. The scan command:
- Pulls all active markets from Kalshi and Polymarket
- Groups them by event (e.g., all recession contracts together)
- Runs a fast LLM pass to identify which markets have potential structural mispricing
You'll see output like:
Scanning 847 active markets...
Grouped into 234 events.
Found 12 candidates with potential edge:
1. US Recession 2026 Kalshi YES @ 35¢ Candidate: causal chain analysis suggests mispricing
2. Fed Rate Cut Jun 2026 Kalshi YES @ 22¢ Candidate: market lagging employment data
3. Oil > $90 by Sep 2026 Poly YES @ 41¢ Candidate: supply constraint underpriced
...
Why 12 out of 847? Because the scan isn't random filtering. It's running a quick causal plausibility check: "Is there a reason the market price might be wrong?" Most markets are efficiently priced. The scan surfaces the ones where a causal argument exists for mispricing.
Step 4: Build a Thesis
Pick a candidate from the scan. Let's say "US Recession 2026" caught your eye. Now build a thesis:
sf thesis create
The agent mode kicks in. It asks you for your directional view and why. You might say:
"I think the US-Iran conflict will persist, keeping Hormuz blocked, oil elevated, and pushing the economy toward recession."
The agent then:
- Decomposes your view into a causal tree — a chain of testable sub-claims, each with a probability
- Maps each node to verifiable real-world signals
- Identifies which prediction market contracts correspond to which nodes
- Calculates the thesis-implied probability vs market price for each contract
The output is a structured thesis with nodes like:
n1 War persists 88%
├── n1.1 US initiated strikes 99%
├── n1.2 Iran continues retaliation 85%
└── n1.3 No diplomatic exit 82%
n2 Hormuz blocked 97%
n3 Oil stays elevated 64%
n4 Recession 45%
Thesis-implied: 45% | Market: 35% | Edge: +10 points
Step 5: Detect Edge
The edge isn't "I think recession will happen." The edge is the gap between what your causal model implies and what the market is pricing.
sf edge --thesis iran-war
This compares every node in your causal tree against current market prices and shows you where the divergence lives:
| Contract | Your Thesis | Market Price | Edge |
|---|---|---|---|
| Recession 2026 YES | 45% | 35% | +10 |
| Oil > $90 Q3 YES | 64% | 41% | +23 |
| Fed Cut Jun NO | 78% | 65% | +13 |
The key insight: the edge is distributed across the causal chain. The recession contract has 10 points of edge, but the oil contract has 23 points. Your thesis says oil is the bigger mispricing — and it's upstream in the causal chain, meaning it has fewer dependencies.
Step 6: Create a Strategy
sf strategy create --thesis iran-war
A strategy is a set of conditions that define when to enter, when to exit, and what to size. The agent helps you define:
- Entry conditions: "thesis confidence > 65% AND market price < 40¢ AND edge > 8 points"
- Exit conditions: "thesis confidence < 40% OR edge < 3 points"
- Position sizing: Kelly criterion or fixed fractional (the agent walks you through this)
The strategy is stored and ready for monitoring.
Step 7: Start the Heartbeat
sf monitor --strategy iran-recession
Now your agent is alive. Every 15 minutes it:
- Fetches latest market prices
- Searches for news related to your causal tree nodes
- Re-evaluates node confidences based on new information
- Checks strategy conditions
- Sends you a notification if any condition triggers
You'll get a notification like:
[SIGNAL] Strategy iran-recession triggered
Reason: CPI data exceeded expectations, n3 confidence updated 64% → 71%
Edge: thesis 48% vs market 36% = +12 points
Action: Consider entry per strategy conditions
The agent monitors. You decide whether to execute. The division of labor is clean: it watches 24/7, you make the final call.
What You Have Now
In 15 minutes you've set up:
- A scanner that identifies mispriced prediction market contracts
- A thesis engine that structures your thinking into a testable causal model
- An edge detector that quantifies the gap between your model and market prices
- A monitoring agent that watches 24/7 and alerts you to opportunities
This isn't a trading bot. It's an intelligence system that does the hard work of watching, thinking, and quantifying — so you can focus on the decisions that matter.
Next Steps
- Read Position Sizing for Prediction Markets to understand how to size your trades using Kelly criterion with causal model confidence
- Read 5 Patterns That Kill Prediction Market Traders to understand the cognitive biases the agent protects you from
- Read Running a 24/7 Trading Agent for the full operational picture