# Polymarket & Kalshi Prediction Market Scanner (Arbitrage Gaps) (`shadowell/polymarket-kalshi-arbitrage-scanner`) Actor

Scrape active Polymarket and Kalshi prediction markets into one schema and match the same event across both platforms to surface YES-price gaps.

- **URL**: https://apify.com/shadowell/polymarket-kalshi-arbitrage-scanner.md
- **Developed by:** [FENG JIE](https://apify.com/shadowell) (community)
- **Categories:** Business, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 matched pair with price gaps

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Polymarket & Kalshi Prediction Market Scanner – Cross-Platform Arbitrage Gaps

Scrape **active Polymarket and Kalshi prediction markets** into one clean, unified dataset and automatically **match the same event across both platforms** to surface **YES-price gaps** – a starting point for **prediction market arbitrage**, odds comparison, research dashboards and alerts.

- ✅ Polymarket (Gamma API) + Kalshi (official Trade API v2) – public market data only, no login, no API keys
- ✅ One schema for both platforms: price, 24h volume, liquidity, end date, URL
- ✅ Cross-platform matching (keywords + end-date rules + fuzzy similarity) with `match_confidence`
- ✅ `price_gap` = Polymarket YES − Kalshi YES for every matched pair
- ✅ Filters: category, minimum 24h volume, max markets, matched-pairs-only mode
- ✅ Pay-per-event pricing, respects your maximum spend limit

### What can I use it for?

- Find **Polymarket vs Kalshi** price differences on the same question (elections, sports, esports, awards, politics…)
- Build a prediction-market odds comparison table or Google Sheet
- Monitor the most active prediction markets by 24h volume
- Feed research / quant models with normalized market probabilities

> ⚠️ A price gap is **not** guaranteed arbitrage. Resolution rules, end dates, fees, spreads, liquidity and platform/jurisdiction access differ. Always read both markets' rules before trading. This Actor is a data tool, not financial advice.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `categories` | string\[] | `[]` | Keep markets whose category/tags contain any of these words (e.g. `Politics`, `Sports`, `Crypto`, `Elections`). Empty = all. |
| `minVolume24h` | integer | `1000` | Minimum 24h volume (Polymarket: USD; Kalshi: contracts, $1 notional each). |
| `maxItemsPerPlatform` | integer | `500` | Max markets kept per platform (highest 24h volume first). |
| `onlyMatchedPairs` | boolean | `false` | Output only matched pairs (one row per pair, sorted by largest gap). |
| `matchThreshold` | string (0–1) | `0.6` | Minimum match confidence. |
| `maxEndDateDiffDays` | integer | `7` | Max end-date difference allowed for a match. |

### Output fields

`platform`, `market_id`, `question`, `category`, `yes_price`, `no_price`, `volume_24h`, `liquidity`, `end_date`, `url`, `fetched_at`, `matched_market_id`, `matched_platform`, `price_gap`, `match_confidence` (+ `matched_question`, `matched_url` on matched rows).

Notes:

- Polymarket `yes_price` = first outcome price from Gamma `outcomePrices` (for head-to-head sports markets the first outcome is the first-named team).
- Kalshi `yes_price` = mid of best YES bid/ask (falls back to last trade); `no_price` = 1 − yes.
- Kalshi has no liquidity field; `liquidity` holds **open interest (contracts)** for Kalshi rows.

#### Example output (real row from a test run on 2026-10-16)

```json
{
  "platform": "polymarket",
  "market_id": "559653",
  "question": "Will Alexandria Ocasio-Cortez win the 2028 Democratic presidential nomination?",
  "category": "United States",
  "yes_price": 0.166,
  "no_price": 0.834,
  "volume_24h": 10385.92,
  "liquidity": 367883.6745,
  "end_date": "2028-11-08T04:59:00Z",
  "url": "https://polymarket.com/event/democratic-presidential-nominee-2028",
  "fetched_at": "2026-10-16T03:20:49Z",
  "matched_market_id": "KXPRESNOMD-28-AOC",
  "matched_platform": "kalshi",
  "price_gap": 0.031,
  "match_confidence": 0.807,
  "matched_question": "Will Alexandria Ocasio-Cortez be the Democratic Presidential nominee in 2028?",
  "matched_url": "https://kalshi.com/markets/kxpresnomd"
}
```

More real examples: `sample_output_matched.json`.

### Pricing (pay per event)

| Event | When | Suggested price |
|---|---|---|
| `market_row` | a normalized market row without a match | $0.001 |
| `matched_gap` | a row/pair matched across Polymarket and Kalshi | $0.005 |

The Actor stops pushing results as soon as your **maximum total charge** would be exceeded.

### How matching works

1. Normalize text (accents, “U.S.” → “us”), drop stop-words, index Kalshi markets by keywords.
2. Candidates must share ≥2 distinctive keywords and have end dates within `maxEndDateDiffDays`.
3. Score = 0.6·keyword Jaccard + 0.25·rapidfuzz token-set ratio + 0.15·date proximity; penalized when numbers/strikes differ or when market types conflict (spread vs moneyline, nomination vs election…).
4. Greedy one-to-one assignment by best score.

### Run locally

```bash
pip install -r requirements.txt
mkdir -p storage/key_value_stores/default
echo '{"onlyMatchedPairs": true, "maxItemsPerPlatform": 1500}' > storage/key_value_stores/default/INPUT.json
python -m src            # or: apify run
./test_ppe_local.sh      # simulate pay-per-event with a $0.05 spend limit
```

### Data sources

- Polymarket Gamma API: https://docs.polymarket.com
- Kalshi Trade API v2: https://docs.kalshi.com

Not affiliated with Polymarket or Kalshi.

# Actor input Schema

## `categories` (type: `array`):

Only keep markets whose category/tags contain one of these words (case-insensitive), e.g. Politics, Sports, Crypto, Economics, Elections. Leave empty for all categories. Polymarket uses event tags, Kalshi uses its event category, so names differ slightly.

## `minVolume24h` (type: `integer`):

Skip markets with lower 24h volume. Polymarket: USD. Kalshi: contracts traded (each contract has $1 notional).

## `maxItemsPerPlatform` (type: `integer`):

Maximum number of markets kept from each platform (highest 24h volume first).

## `onlyMatchedPairs` (type: `boolean`):

If enabled, output one row per cross-platform matched pair (sorted by largest price gap) instead of every market.

## `matchThreshold` (type: `string`):

Minimum match_confidence (0-1) to accept a pair. Higher = fewer but safer matches.

## `maxEndDateDiffDays` (type: `integer`):

Two markets can only match if their end/close dates are within this many days.

## Actor input object example

```json
{
  "categories": [
    "Politics"
  ],
  "minVolume24h": 1000,
  "maxItemsPerPlatform": 500,
  "onlyMatchedPairs": false,
  "matchThreshold": "0.6",
  "maxEndDateDiffDays": 7
}
```

# Actor output Schema

## `markets` (type: `string`):

Dataset items: one normalized market row per item; matched rows include matched_market_id, price_gap and match_confidence.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "categories": [
        "Politics"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("shadowell/polymarket-kalshi-arbitrage-scanner").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "categories": ["Politics"] }

# Run the Actor and wait for it to finish
run = client.actor("shadowell/polymarket-kalshi-arbitrage-scanner").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "categories": [
    "Politics"
  ]
}' |
apify call shadowell/polymarket-kalshi-arbitrage-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,shadowell/polymarket-kalshi-arbitrage-scanner"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HNrdUHQ9LxlhQrstj/builds/naPu8iOTh74k34Jcr/openapi.json
