Tutorials

Step-by-step guides from first query to autonomous execution.


1. Your first prediction market query

No install, no auth. Just ask a question and get structured market data.

Try it in your browser:

curl https://simplefunctions.dev/api

Or install the CLI and search markets:

npm install -g @spfunctions/cli
sf scan "fed rate cut"     # search Kalshi + Polymarket
sf query "will iran..."    # LLM-enhanced search with answer
sf watch "gold"            # live price changes

Or launch the interactive agent — all tools, no setup:

sf agent
# Ask anything: "what's happening with tariffs?"
# "show me recession contracts"
# "any new markets today?"

2. Create a thesis and find edges

When you form a view, create a thesis. The system decomposes it into a causal tree, scans for related contracts across venues, and identifies mispricings.

# 1. Setup (one time, 2 minutes)
sf setup

# 2. Create a thesis
sf create "US-Iran war will not end quickly. Oil stays above $100."
# → Causal tree: 6 nodes
# → 12 edges detected across Kalshi + Polymarket
# → 24/7 monitoring started

# 3. See what the system found
sf context <id>        # full thesis snapshot
sf edges               # top mispriced contracts

# 4. Scenario analysis (instant, no LLM cost)
sf whatif <id> --set "n1=0.3"   # what if OPEC compliance drops?

# 5. The heartbeat engine runs every 15 minutes:
# - Scans news (including adversarial queries)
# - Refreshes prices from Kalshi + Polymarket
# - Evaluates signals against your causal tree
# - Checks kill conditions first
# - Updates track record

3. Declare intents and execute autonomously

Instead of placing orders manually, declare your intent with trigger conditions. The runtime daemon watches and executes when conditions align.

# 1. Declare an intent with trigger + soft condition
sf intent buy KXFEDDEC2509 500 --price 36 \
  --trigger below:40 \
  --soft "only if oil above $95 and no dovish fed signals"

# 2. Start the smart runtime
sf runtime start --smart --daemon
# → Polling every 30s [smart]
# → Evaluates hard triggers mechanically
# → LLM-gates soft conditions before executing

# 3. Set a wake condition (from inside sf agent)
> "wake me if the spread on KXFEDDEC widens past 5 cents"
# → Runtime evaluates this every cycle via LLM

# 4. Start Telegram for mobile alerts
sf telegram --daemon

# 5. Monitor
sf runtime status      # check daemon state
sf intent list         # see active intents
tail -f ~/.sf/runtime.log  # live log

See the Agent Runtime guide for the full architecture: message bus, wake conditions, cost tracking.

4. Connect your own agent via MCP

One line to give Claude Code, Cursor, or any MCP-compatible agent access to 29 prediction market tools.

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

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

# Or use the REST API directly
curl -H "Authorization: Bearer sf_live_xxx" \
  https://simplefunctions.dev/api/thesis/create \
  -d '{"rawThesis": "Fed cuts rates in September"}'

Full tool reference in the Agent Guide.