Kalshi CLI for prediction market trading.
Operator-grade command-line for Kalshi — search, screen, place, monitor, reconcile.
Sixty-plus commands across Kalshi and Polymarket from the terminal. Every command supports--jsonfor clean pipes into jq, Python, or another sf call. BYOK credentials, dry-run safety, idempotent intents, local audit trail. The Kalshi CLI is the human operator's terminal-resident workflow; the agent-driven framing of the same surface lives at/agentic-cli.
npm install -g @spfunctions/climacOS · Linux · WSL
Telegraph station, 1880s — single operator, structured protocol, world on the wire.
Operator CLI vs agent CLI
Same binary, two framings. This page is the human operator's view: typing commands, piping through shell, reading dashboards. The agent-driven view of the same surface lives at /agentic-cli.
Core surface — seven verbs
The Kalshi CLI is built around seven core verbs. Anything you do through the terminal eventually composes from these. The full reference (60+ commands) expands each verb with category-specific subcommands.
searchsf scan "iran oil"marketsf book KXWTIMAX-T150placesf buy KXWTIMAX-T150 200 --price 40positionsf positions --jsonfillssf fills --since 2026-04-29historysf history KXFEDDEC-26reconcilesf reconcile --json | jq60+ commands — full reference
Detailed docs →Sixty-plus commands organized into seven categories. Every command supports--jsonand accepts piped input where it makes sense.
Thesis
sf create "thesis"Build causal tree + scan markets
sf context [id]Market snapshot or thesis context
sf listList all theses
sf signal <id> "..."Inject observation
sf evaluate <id>Force deep evaluation
sf augment <id>Evolve causal tree
sf edgesTop edges across all theses
sf whatif <id>Scenario analysis (zero LLM)
sf statusHealth check: API, auth, Kalshi, theses
Markets
sf scan "keywords"Search Kalshi + Polymarket
sf scan --series TICKERBrowse series contracts
sf book <ticker>Orderbook depth + liquidity
sf watch "query" [mode]Live: orderbook, flow, cross-venue, all
sf watch "query" --smartLLM-filtered alerts + news divergence
sf query "question"LLM-enhanced search (no auth)
sf forecast <event>P50/P75/P90 distribution
sf liquidity [topic]Orderbook scanner by topic + horizon
sf milestonesUpcoming Kalshi calendar events
sf history <ticker>Settled market data
sf announcementsExchange announcements
sf scheduleExchange trading hours
Execution
sf buy <tkr> <qty> --priceBuy contracts
sf sell <tkr> <qty> --priceSell contracts
sf cancel <orderId>Cancel order (--all for all)
sf intent buy <tkr> <qty>Intent with trigger + soft condition
sf intent sell <tkr> <qty>Sell intent
sf intent listActive intents
sf intent status <id>Detailed status with fills
sf runtime start [--smart]Execution daemon (--smart for LLM)
sf runtime stopStop daemon
sf runtime statusDaemon state + active intents
Market Making
sf quoteengine startStart WebSocket MM engine
sf quoteengine stopStop engine + cancel orders
sf quoteengine statusEngine state, bias, spread, P&L
sf quote create TICKERCreate quote (--spread, --size, --bias)
sf quote create --paperPaper trading mode
sf quote create --thesis-idAuto-bias from thesis edge
sf quote create --fade 2Widen spread after fills
sf quote create --layers 3Multi-level depth per side
sf quote list / pause / cancelManage active quotes
Portfolio
sf positionsKalshi + Polymarket positions
sf balanceAccount balance
sf ordersResting orders
sf fillsTrade history
sf settlementsSettled contracts + P&L
sf performanceP&L sparklines + annotations
sf dashboardBloomberg-style TUI (j/k, Tab, b/s)
World & Intel
sf worldReal-time world model (no auth)
sf world --deltaWhat changed (~30 tokens)
sf ideasS&T-style trade ideas
sf x "query"X/Twitter search + sentiment
sf x-news "query"X news stories
sf feedEvaluation history stream
Agent & Social
sf agentInteractive TUI agent — see /agentic-cli
sf agent --plainPipe-friendly plain text mode
sf telegram --daemonTelegram bot (background)
sf scan "gold" --shareShareable URL with rendering
sf context --shareShare thesis context snapshot
BYOK auth and safety
The Kalshi CLI is BYOK — bring your own venue credentials. SimpleFunctions never custodies a Kalshi or Polymarket private key. Five operating defaults keep the terminal-resident workflow safe to script.
BYOK credentials
Kalshi (and optional Polymarket) keys live on the operator's machine. The CLI binds them to the local session via sf login + sf setup. SimpleFunctions servers never see the venue private key — only the operator's SF API token, which scopes what the CLI is allowed to do.
Dry-run by default
Trading commands respect --dry-run. sf intent ships a dry-run mode that flows the full pipeline (risk gates, normalization, route) without submitting to the venue. Use it once before flipping a strategy live.
Idempotency keys
Every sf intent accepts an --idem key. Replays of the same key resolve to the same intent record — safe to retry, safe to script, safe to wire into shell loops without double-fills.
Local audit trail
Every command is logged with timestamp, exit code, and (for trading commands) the venue response. Pulled by sf history and exportable to JSON / CSV.
Read-mostly defaults
Most commands (sf world, sf scan, sf query, sf book, sf forecast) require zero credentials. Trading-side commands fail closed when no key is bound — no silent ghost-trading.
Two minutes to first call
Install, login, run. Read-only commands work with just an SF key — venue credentials only become necessary when you flip to trading or portfolio surfaces.
macOS / Linux / WSL — first run~2 min# 1. Install
$ npm install -g @spfunctions/cli
# 2. Bind a session — opens browser
$ sf login
# 3. Read-only — no venue credential needed
$ sf world
$ sf scan "fed rate cut" --json | jq '.markets[] | {ticker, yes_price}'
# 4. Wire venue credentials — only needed for trading + portfolio
$ sf setup
? Kalshi API key: **********
? Polymarket key: (skip)
? Enable trading: yes
# 5. First trade — dry-run before live
$ sf intent buy KXFEDDEC-26-Y 10 --price 0.49 --trigger price_below:0.49 \
--idem first-test --dry-run
# Same call without --dry-run flips it live.Pipe and JSON workflows
The Kalshi CLI is built to compose. Three concrete patterns operators reach for daily.
screen → placescan + intent# Screen for tight-spread Fed markets,
# then buy the cheapest YES.
sf scan "fed rate" --json \
| jq -r '
.markets
| map(select(.spread < 0.03))
| sort_by(.yes_price)[0]
| .ticker' \
| xargs -I {} sf intent buy {} 10 \
--price 0.50 \
--trigger immediate \
--idem $(date +%s)watch → reactorderbook + cancel# Watch the orderbook for a spread blow-out,
# cancel resting orders if it widens past 5¢.
sf book KXWTIMAX-T150 --json --stream \
| while read -r line; do
spread=$(echo "$line" | jq -r '.spread')
if (( $(echo "$spread > 0.05" | bc -l) )); then
sf cancel --all --market KXWTIMAX-T150
echo "spread $spread — pulled quotes"
fi
donereconcile → fund-adminJSON to Parquet# End-of-day reconcile, write Parquet
# for the fund-admin pipeline.
sf reconcile --since today --json \
| python -c "
import sys, json, pandas as pd
rows = json.loads(sys.stdin.read())
pd.DataFrame(rows).to_parquet(
f'reconcile-{__import__(\"datetime\").date.today()}.parquet'
)"Read next from the library
Matched from SimpleFunctions blog, opinions, technical guides, concepts, and learn pages.
Your First Prediction Market Trade: End-to-End CLI Walkthrough
Step-by-step CLI tutorial for your first prediction market trade. Install, scan, create a thesis, find edges, check liquidity, place an order, and monitor — all from the command line.
Automated Prediction Market Trading: Architecture and Cost Breakdown
Detailed cost breakdown for automated prediction market trading. LLM evaluation costs, Tavily API spend, Kalshi fees, and total monthly cost per thesis. Compare DIY agent vs SimpleFunctions.
Command-Line Interface (CLI)
Trade prediction markets from the terminal. Scan for edge, manage theses, view orderbooks, and execute strategies.
Why the Best Trading Terminal Is a Command Line
Dashboards are decision-degradation machines. The next generation of trading infrastructure looks less like TradingView and more like a terminal.
Kalshi vs Polymarket: Which Prediction Market Should You Trade?
In-depth comparison of Kalshi and Polymarket for prediction market traders. Regulatory structure, liquidity, fees, API tooling, and cross-venue trading with SimpleFunctions.
How I track my macro thesis across 49 Kalshi contracts without checking the screen
How I use a causal tree and 15-minute heartbeat to monitor 49 Kalshi contracts for my Iran-oil-recession macro thesis without watching the screen.
FAQ
What is the Kalshi CLI?
A command-line tool for trading prediction markets on Kalshi and Polymarket from the terminal. Sixty-plus commands across thesis management, market search, screening, orderbook inspection, execution (direct + intent-driven), market making, portfolio, and world state — every command supports --json. Distributed as @spfunctions/cli on npm.
How do I install it?
npm install -g @spfunctions/cli. Requires Node 18+. Works on macOS, Linux, and Windows (WSL recommended for Windows). After install, sf login opens a browser to bind a session; sf setup wires Kalshi and (optionally) Polymarket credentials.
How does authentication work?
Two layers. The SimpleFunctions API key authorizes the CLI against the platform (read-mostly surfaces work with the SF key alone). Trading and portfolio surfaces additionally need a Kalshi (and optional Polymarket) credential bound via sf setup; those venue keys live on the operator's machine and are never transmitted to SimpleFunctions servers.
What is the difference between sf place and sf query?
sf query (and sf scan, sf book, sf forecast, sf world) are read-only commands that return market data, search results, or world snapshots. sf buy / sf sell / sf intent are execution commands that submit orders to the venue. The first group needs no venue credential; the second requires sf setup --enable-trading.
How does sf intent stay idempotent?
Every sf intent accepts an --idem key. The platform stores the intent record keyed by that string; replaying the same key with the same payload returns the existing record instead of creating a new one. Safe to wire into shell loops, retry on network blips, or replay from logs without double-fills.
Does every command support --json?
Yes. Every command emits JSON when --json is passed. Output is stable and documented; pipe through jq for transformation, into Python for analysis, or into another sf invocation for chaining. The CLI is built to be scriptable, not just interactive.
Is there a dry-run mode?
Yes. sf intent ships a dry-run mode that flows the full pipeline (risk gates, normalization, route resolution) without submitting to the venue. sf quote create --paper does the same for market making. Dry-run output is identical in shape to live output, so you can validate scripts before flipping strategies live.
How does this compare to Kalshi's web UI?
The web UI is point-and-click. The Kalshi CLI is scriptable. Anything you would do across multiple browser tabs (screen for a series, place 20 contingent orders, watch a basket of cross-venue spreads, reconcile fills against intents) collapses into a few piped commands. The CLI is the right surface for traders who want a terminal-resident workflow.
How is this different from the agentic CLI?
Same binary, different framing. The Kalshi CLI page covers the human-driven operator workflow — typing commands at a terminal, piping through shell, watching ANSI dashboards. The agentic CLI page covers the AI-agent-driven flow — Claude Code, Codex, or a custom agent calling the same surface as a tool, usually with --json output and idempotency keys. Read /agentic-cli for the agent framing.
Does the CLI work with Polymarket?
Yes. sf scan, sf book, sf watch cross-venue, sf positions, and sf history all cover Kalshi and Polymarket symmetrically. Configure Polymarket credentials with sf setup --polymarket. Some Polymarket-specific quirks (USDC funding, on-chain confirmations) are surfaced as warning lines on relevant commands.
Which platforms are supported?
macOS (Apple Silicon and Intel), Linux (x86-64 and arm64), and Windows via WSL. Native Windows works for read-only commands; trading and TUI commands run more reliably under WSL because of terminal-input semantics. Node 18+ required across all platforms.
Where is the source?
The npm package @spfunctions/cli is the distribution. A display-only mirror is on GitHub at github.com/spfunctions/simplefunctions-cli for reference and issue filing. The full source for the operator runtime is private; the CLI is the operator-facing entry point.
Related surfaces
Agentic CLI
Same binary, agent framing — Claude Code, Codex, custom runtimes calling sf as a tool surface.
Prediction market execution
Intents, triggers, routing, monitoring — the execution surface sf intent talks to.
Trading terminal
TUI dashboard companion to the CLI — sf dashboard launches it.
Real-time data API
Sub-second WebSocket + REST — the live feed sf watch consumes.
Agentic usage
Patterns for AI agents on top of the same CLI surface.
Portfolio Autopilot
Hosted LLM-driven autonomous policy on top of intents and risk gates.
Institutional infrastructure
Audit log, reconciliation, BYOK posture for funds and trading desks.