SimpleFunctions

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
Realist oil painting in Hopper / Homer style — 1880s telegraph station: single operator, brass key, structured protocol over the wire

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.

Operator (this page)
Agent (/agentic-cli)
Driver
Human typing commands at a terminal, possibly piped through a shell script
AI agent (Claude Code, Codex, custom runtime) calling the same binary as a tool surface
Output
Human-readable tables, ANSI colors, TUI dashboards (sf dashboard)
--json or --plain on every command for clean pipeable bytes
Loop
Operator decides next command based on the previous output
Agent reads, reasons, decides, calls — usually inside its own loop
Auth
sf login binds a session; BYOK credentials live in the operator's shell
Same auth, but the agent runs in a sandboxed environment with the operator's scoped key
Trading scope
Buy / sell / intent / cancel — direct or conditional
Same surface; agent typically uses sf intent + sf intent status with idempotency keys
Page
You are here
See /agentic-cli for the agent control-plane framing

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.

Verb
What it does
Example
search
Find markets across Kalshi and Polymarket by keyword or series
sf scan "iran oil"
market
Inspect a single market — orderbook depth, liquidity, history
sf book KXWTIMAX-T150
place
Submit a buy or sell directly, or as a conditional intent
sf buy KXWTIMAX-T150 200 --price 40
position
Pull current Kalshi + Polymarket positions, balance, resting orders
sf positions --json
fills
List fills for the account with timestamps and prices
sf fills --since 2026-04-29
history
Settled-market data for backtests and reconciliation
sf history KXFEDDEC-26
reconcile
Cross-check intents against venue fills; output JSON for fund-admin
sf reconcile --json | jq

60+ 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 list

List all theses

sf signal <id> "..."

Inject observation

sf evaluate <id>

Force deep evaluation

sf augment <id>

Evolve causal tree

sf edges

Top edges across all theses

sf whatif <id>

Scenario analysis (zero LLM)

sf status

Health check: API, auth, Kalshi, theses

Markets

sf scan "keywords"

Search Kalshi + Polymarket

sf scan --series TICKER

Browse series contracts

sf book <ticker>

Orderbook depth + liquidity

sf watch "query" [mode]

Live: orderbook, flow, cross-venue, all

sf watch "query" --smart

LLM-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 milestones

Upcoming Kalshi calendar events

sf history <ticker>

Settled market data

sf announcements

Exchange announcements

sf schedule

Exchange trading hours

Execution

sf buy <tkr> <qty> --price

Buy contracts

sf sell <tkr> <qty> --price

Sell 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 list

Active intents

sf intent status <id>

Detailed status with fills

sf runtime start [--smart]

Execution daemon (--smart for LLM)

sf runtime stop

Stop daemon

sf runtime status

Daemon state + active intents

Market Making

sf quoteengine start

Start WebSocket MM engine

sf quoteengine stop

Stop engine + cancel orders

sf quoteengine status

Engine state, bias, spread, P&L

sf quote create TICKER

Create quote (--spread, --size, --bias)

sf quote create --paper

Paper trading mode

sf quote create --thesis-id

Auto-bias from thesis edge

sf quote create --fade 2

Widen spread after fills

sf quote create --layers 3

Multi-level depth per side

sf quote list / pause / cancel

Manage active quotes

Portfolio

sf positions

Kalshi + Polymarket positions

sf balance

Account balance

sf orders

Resting orders

sf fills

Trade history

sf settlements

Settled contracts + P&L

sf performance

P&L sparklines + annotations

sf dashboard

Bloomberg-style TUI (j/k, Tab, b/s)

World & Intel

sf world

Real-time world model (no auth)

sf world --delta

What changed (~30 tokens)

sf ideas

S&T-style trade ideas

sf x "query"

X/Twitter search + sentiment

sf x-news "query"

X news stories

sf feed

Evaluation history stream

Agent & Social

sf agent

Interactive TUI agent — see /agentic-cli

sf agent --plain

Pipe-friendly plain text mode

sf telegram --daemon

Telegram bot (background)

sf scan "gold" --share

Shareable URL with rendering

sf context --share

Share 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
    done
reconcile → 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.

Browse library

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