Simplefunctions

Created By
spfunctions2 months ago
24/7 autonomous monitoring and edge detection for prediction markets (Kalshi & Polymarket). Features causal tree analysis, orderbook depth tracking, cross-venue comparison, and real-time alerts. Not one-time predictions — continuous autonomous monitoring with context management.
Overview

SimpleFunctions CLI (sf)

Prediction market intelligence CLI. Build causal thesis models, scan Kalshi/Polymarket for mispricings, detect edges, and trade — all from the terminal.

demo

Quick Start

npm install -g @spfunctions/cli
sf setup                            # interactive config wizard
sf list                             # see your theses
sf context <id> --json              # get thesis state as JSON

Setup

sf setup

This walks you through:

  1. SF API key (required) — get one at simplefunctions.dev
  2. Kalshi credentials (optional) — for positions, trading, and orderbook data
  3. Trading mode (optional) — enable sf buy/sf sell commands

Config is saved to ~/.sf/config.json. Environment variables override config values.

Manual

export SF_API_KEY=sf_live_xxx                    # required
export KALSHI_API_KEY_ID=xxx                     # optional, for positions/trading
export KALSHI_PRIVATE_KEY_PATH=~/.ssh/kalshi.pem # optional, for positions/trading

Verify

sf setup --check     # show current config status
sf list              # should show your theses

Commands

Thesis Management

CommandDescription
sf listList all theses with status, confidence, and update time
sf get <id>Full thesis details: causal tree, edges, positions, last evaluation
sf context <id>Compact context snapshot (primary command for agents)
sf create "thesis"Create a new thesis (waits for formation by default)
sf signal <id> "text"Inject a signal (news, observation) for next evaluation
sf evaluate <id>Trigger deep evaluation with heavy model
sf publish <id>Make thesis publicly viewable
sf unpublish <id>Remove from public view

Market Exploration (no auth required)

CommandDescription
sf scan "keywords"Search Kalshi markets by keyword
sf scan --series KXWTIMAXList all markets in a series
sf scan --market TICKERGet single market detail
sf exploreBrowse public theses

Portfolio & Trading (requires Kalshi credentials)

CommandDescription
sf edgesTop edges across all theses — what to trade now
sf positionsCurrent positions with P&L and edge overlay
sf balanceAccount balance
sf ordersResting (open) orders
sf fillsRecent trade fills
sf performanceP&L over time with thesis event annotations
sf settlementsSettled contracts with final P&L
sf liquidityMarket liquidity scanner by topic

Trading (requires sf setup --enable-trading)

CommandDescription
sf buy <ticker> <qty>Buy contracts
sf sell <ticker> <qty>Sell contracts
sf cancel [orderId]Cancel order(s)
sf rfq <ticker> <qty>Request for quote on large orders

Analysis

CommandDescription
sf whatif <id>What-if scenario: "if node X drops to 10%..."
sf feedEvaluation history stream
sf forecast <event>Market distribution forecast (P50/P75/P90)
sf dashboardInteractive TUI portfolio overview

Interactive Modes

CommandDescription
sf agent [id]Interactive agent with natural language + tool calling
sf telegramTelegram bot for monitoring and trading

JSON Output

Most commands support --json for machine-readable output:

sf list --json
sf context f582bf76 --json
sf edges --json
sf scan "oil" --json
sf get f582bf76 --json

For AI Agents

If you are an AI coding agent (Claude, GPT, OpenClaw, Cursor, etc.), follow these steps:

Step 1: Install and configure

npm install -g @spfunctions/cli
sf setup --key sf_live_YOUR_KEY_HERE

If sf setup is not available or you cannot run interactive commands:

export SF_API_KEY=sf_live_YOUR_KEY_HERE

Step 2: Verify it works

sf list

Expected output (table format):

ID          Status  Conf    Updated         Title
f582bf76    active   82%    Mar 12 11:13    Oil prices will exceed $100...
a1b2c3d4    active   65%    Mar 11 09:30    Fed will cut rates by June...

If you see theses, the CLI is working. If you see an error, check that SF_API_KEY is set correctly.

Step 3: Get thesis context (most important command)

sf context <thesisId> --json

This returns a JSON object with the complete thesis state:

{
  "thesisId": "f582bf76-3113-4208-b0c1-...",
  "thesis": "Oil prices will exceed $100 by end of 2026",
  "title": "Oil Bull Thesis",
  "status": "active",
  "confidence": 0.82,
  "causalTree": {
    "rootClaim": "Oil prices will exceed $100",
    "nodes": [
      {
        "id": "n1",
        "label": "Supply disruption",
        "probability": 0.75,
        "importance": 0.6,
        "depth": 0
      }
    ]
  },
  "edges": [
    {
      "marketId": "KXWTIMAX-26DEC31-T100",
      "market": "Will oil exceed $100 by Dec 2026?",
      "venue": "kalshi",
      "direction": "yes",
      "marketPrice": 35,
      "thesisPrice": 55,
      "edge": 20,
      "confidence": 0.8
    }
  ],
  "lastEvaluation": {
    "summary": "Supply concerns rising due to...",
    "newConfidence": 0.82,
    "confidenceDelta": 0.03
  }
}

Key fields:

  • confidence — overall thesis probability (0 to 1)
  • edges[].edge — mispricing size in cents (positive = market underpriced vs thesis)
  • edges[].marketPrice — current market price in cents (0-100)
  • edges[].thesisPrice — what the thesis model thinks the price should be
  • lastEvaluation.summary — human-readable summary of latest analysis

Step 4: Other useful commands

# Inject a signal for the thesis to consider in its next evaluation
sf signal <thesisId> "Breaking: OPEC announces production cut" --type news

# View top edges (mispricings) across all theses
sf edges --json

# Search Kalshi markets by keyword
sf scan "recession" --json

# Trigger a deep re-evaluation
sf evaluate <thesisId>

# What-if analysis: what happens if a node probability changes?
sf whatif <thesisId>

Common patterns for agents

Monitor a thesis:

sf context <id> --json    # poll periodically, check confidence changes

React to news:

sf signal <id> "Reuters: Iran nuclear deal collapses" --type news
sf evaluate <id>          # trigger re-evaluation after injecting signal
sf context <id> --json    # read updated state

Find trading opportunities:

sf edges --json           # get top mispricings sorted by edge size

Error handling

  • "API key required" — set SF_API_KEY env var or run sf setup --key <key>
  • "Thesis not found" — use sf list to get valid thesis IDs. IDs can be short prefixes (first 8 chars)
  • "Kalshi not configured" — positions/trading commands need Kalshi credentials via sf setup
  • Exit code 0 — success. Exit code 1 — error (message printed to stderr)

Local Development

cd cli
npm install
npm run dev -- list          # run without building
npm run build                # compile to dist/
npm run test                 # run unit tests
npm link                     # install as global 'sf' command

Server Config

{
  "mcpServers": {
    "simplefunctions": {
      "url": "https://simplefunctions.dev/api/mcp/mcp"
    }
  }
}
Project Info
Created At
2 months ago
Updated At
2 months ago
Author Name
spfunctions
Star
-
Language
-
License
-
Category

Recommend Servers

View All
Bring your real authenticated browser session to AI coding agents. Local-first MCP server + Chrome MV3 extension. No cloud. No telemetry.
@Cubenest

peek records the user's actual logged-in browser (DOM via rrweb, console events, network metadata, optional response bodies via opt-in Deep capture) through a Chrome MV3 extension. The extension ships events through a native-messaging stdio bridge to a local MCP server (peek-mcp), which persists them to a SQLite database at ~/.peek/sessions.db. AI coding agents (Claude Code, Cursor, Cline, Windsurf) read sessions from the database via 10 MCP tools: Tool What it does list_recent_sessions List recently recorded sessions (id, origin, ts, event count). get_session_summary LLM-readable narrative summary of a session. get_session_console_errors Console errors recorded in a session. get_session_network_errors Failed/notable network requests in a session. get_user_action_before_error Last N user actions before a console error. generate_playwright_repro Generate a runnable Playwright test from a session. get_dom_snapshot Reconstruct the DOM at a given timestamp. query_dom_history Timeline of attribute/text changes for a selector. request_authorization Side-panel consent for write actions (Level 3). execute_action Dispatch a UI action (gated by permission level + destructive blocklist). Why local-first matters Every other "browser session for AI" tool ships to a vendor cloud. peek's SQLite + extension live on the user's machine — no remote endpoints, no telemetry. The privacy policy (docs/peek/PRIVACY_POLICY.md) is the source of truth. Install # 1. Add the MCP server to Claude Code claude mcp add peek -- npx -y @peekdev/mcp # 2. Install the Chrome extension from the Chrome Web Store # (link added once the CWS listing is approved)

3 hours ago
Myrsu
@VidhiJav

2 days ago
Tavily Mcp
@tavily-ai

JavaScript
a year ago