Sign In

prediction-market-context

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prediction-market-context

Real-time prediction market context for AI agents and LLMs. World state, uncertainty index, edges, and market data from 30,000+ markets.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

prediction-market-context

Real-time prediction market context for AI agents and LLMs. One function call gives your agent calibrated world awareness from 30,000+ prediction markets.

npm License: MIT

import { world } from 'prediction-market-context'

const state = await world()
console.log(state.index.uncertainty)  // 35 (0-100, how much markets disagree)
console.log(state.regimeSummary)      // "Risk-off: geo elevated, momentum negative"
console.log(state.actionableEdges)    // Markets where model price != market price
console.log(state.movers)             // What moved in the last 24h

Why

LLMs don't know what's happening today. Web search returns narratives and opinions. Prediction markets return calibrated probabilities backed by real money.

This package gives any AI agent instant world awareness:

  • Uncertainty Index — four numbers summarizing global market sentiment
  • Actionable Edges — markets where thesis-implied price diverges from market price
  • Market Movers — what changed in the last 24h across all tracked markets
  • Contagion Signals — when one market should move because another did
  • Regime Summary — one-line qualitative read on the current environment

All data sourced from Kalshi and Polymarket via SimpleFunctions.

Install

npm install prediction-market-context

Quick Start

Zero-config functions

import { world, index, edges, delta, market } from 'prediction-market-context'

// Full world state (~800 tokens, refreshes every 15 min)
const state = await world()

// Just the uncertainty index (4 numbers)
const { uncertainty, geopolitical, momentum, activity } = await index()

// Actionable edges (thesis price != market price)
const { edges: list } = await edges()

// What changed in the last hour (~30-50 tokens)
const changes = await delta('1h')

// Specific market detail with orderbook
const m = await market('KXFEDDECISION', { depth: true })

Client class (for custom config)

import { PredictionMarketClient } from 'prediction-market-context'

const client = new PredictionMarketClient({
  apiKey: process.env.SF_API_KEY,  // optional, enables portfolio overlay
  timeout: 10_000,                  // default 15s
})

const state = await client.world()
const idx = await client.index({ history: true })

Markdown output (for LLM system prompts)

const markdown = await world({ format: 'markdown' })
// Returns ~800 tokens of structured markdown, ready to inject into a system prompt

CLI

# World state
npx prediction-market-context world
npx prediction-market-context world --json

# What changed
npx prediction-market-context delta 1h

# Uncertainty index
npx prediction-market-context index
npx prediction-market-context index --history

# Edges
npx prediction-market-context edges

# Specific market
npx prediction-market-context market KXFEDDECISION

# Search
npx prediction-market-context search "oil prices"

Use with AI Frameworks

OpenAI

import OpenAI from 'openai'
import { world } from 'prediction-market-context'

const state = await world({ format: 'markdown' })

const response = await new OpenAI().chat.completions.create({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: `You are a market analyst.\n\n${state}` },
    { role: 'user', content: 'What are the key risks right now?' },
  ],
})

Anthropic (Claude)

import Anthropic from '@anthropic-ai/sdk'
import { world } from 'prediction-market-context'

const state = await world({ format: 'markdown' })

const response = await new Anthropic().messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  system: `You are a geopolitical analyst.\n\n${state}`,
  messages: [{ role: 'user', content: 'Summarize the current risk environment.' }],
})

LangChain

import { tool } from '@langchain/core/tools'
import { world, index } from 'prediction-market-context'

const worldTool = tool(async () => {
  return JSON.stringify(await world())
}, {
  name: 'get_world_state',
  description: 'Get real-time prediction market world state with uncertainty index, edges, and movers',
})

const indexTool = tool(async () => {
  return JSON.stringify(await index())
}, {
  name: 'get_uncertainty_index',
  description: 'Get the prediction market uncertainty index (0-100) with geopolitical risk and momentum',
})

As an MCP Tool

For full MCP server integration, use the SimpleFunctions MCP Server:

npx @spfunctions/cli --mcp

API Reference

FunctionReturnsDescription
world(options?)WorldState | stringFull world state. { format: 'markdown' } for LLM injection.
index(options?)UncertaintyIndexFour-signal uncertainty index. { history: true } for 24h data.
edges()EdgesResponseActionable edges with reasoning, causal path, absorption.
delta(since?)WorldDeltaIncremental changes. "1h", "6h", "24h", or ISO timestamp.
market(ticker, options?)MarketDetailSingle market detail. { depth: true } for orderbook.
markets(tickers, options?)MarketDetail[]Batch query up to 20 markets.
search(query)SearchResultSearch markets by topic.

Data

  • 30,000+ prediction markets tracked across Kalshi and Polymarket
  • 548 tickers with live orderbook snapshots
  • 10,000+ market changes detected daily
  • Refreshes every 15 minutes
  • Data available since 2026-03-19

License

MIT — SimpleFunctions

Keywords

prediction-markets

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts