SimpleFunctions

SimpleFunctions

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.

Category
访问服务器

README

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

Interactive (recommended)

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

Command Description
sf list List 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)

Command Description
sf scan "keywords" Search Kalshi markets by keyword
sf scan --series KXWTIMAX List all markets in a series
sf scan --market TICKER Get single market detail
sf explore Browse public theses

Portfolio & Trading (requires Kalshi credentials)

Command Description
sf edges Top edges across all theses — what to trade now
sf positions Current positions with P&L and edge overlay
sf balance Account balance
sf orders Resting (open) orders
sf fills Recent trade fills
sf performance P&L over time with thesis event annotations
sf settlements Settled contracts with final P&L
sf liquidity Market liquidity scanner by topic

Trading (requires sf setup --enable-trading)

Command Description
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

Command Description
sf whatif <id> What-if scenario: "if node X drops to 10%..."
sf feed Evaluation history stream
sf forecast <event> Market distribution forecast (P50/P75/P90)
sf dashboard Interactive TUI portfolio overview

Interactive Modes

Command Description
sf agent [id] Interactive agent with natural language + tool calling
sf telegram Telegram 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选