# Polymarket vs Kalshi Arbitrage Finder (Fee-Adjusted) (`donzely/prediction-market-arbitrage`) Actor

Match the same event on Polymarket and Kalshi and get bid/ask, implied odds, price gap, fee-adjusted arbitrage, order-book max size and profit, annualized return, match confidence and resolution-rule warnings. Data only, no trading.

- **URL**: https://apify.com/donzely/prediction-market-arbitrage.md
- **Developed by:** [Grzegorz Pryjma](https://apify.com/donzely) (community)
- **Categories:** Automation, Developer tools, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 matched market pairs

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 vs Kalshi Arbitrage Finder (Fee-Adjusted)

Find the **same real-world event on Polymarket and Kalshi**, compare prices side by side, and see whether a **fee-adjusted arbitrage** exists: buy YES on one exchange and NO on the other for less than $1 in total, so one leg pays out $1 whatever happens.

The actor scans **all open markets on both exchanges** (100,000+ Polymarket outcomes and 35,000+ Kalshi markets) through their public APIs. It matches equivalent markets even when the titles differ ("Will Gavin Newsom win the 2028 Democratic presidential nomination?" vs "2028 Democratic nominee? — Gavin Newsom"). For every matched pair it calculates:

- best **YES/NO bid and ask** on both exchanges and the **implied probabilities**
- **raw price gap** in percentage points
- **arbitrage after fees**, using Kalshi's fee formula (with the per-series multiplier) and each Polymarket market's own fee schedule
- **maximum size and maximum profit**, by walking both **order books** level by level while the trade is still profitable
- **days to resolution** and **annualized return**
- **match confidence** (0–1) and **warnings**: different resolution dates, different deadlines in the rules, "at least" vs "above" thresholds, low liquidity, wide bid/ask, tail prices and more

> **Disclaimer: data and analytics only. This is not financial advice. No trading is executed.** The actor only reads public market data. Prediction-market contracts on two venues can resolve differently even when they look identical. Always read both resolution rules before you trade. Check also whether you may legally use each exchange where you live: Polymarket's international exchange is not available to US persons, and Kalshi is a CFTC-regulated US exchange.

### Who it is for

- **Arbitrage traders** looking for cross-exchange spreads without reading 140,000 markets by hand
- **Market makers and quants** who need a mapping between Polymarket and Kalshi tickers (`marketId`, `yesTokenId` ↔ `ticker`)
- **Researchers and journalists** comparing how two exchanges price elections, the Fed, sports, crypto, weather and culture
- **Bots and AI agents** that need a clean JSON feed of cross-venue odds (schedule it every few minutes)

### How the matching works

1. **Normalization.** Text is lowercased, accents are stripped, and common synonyms are unified ("Pro Basketball" → NBA, "Federal Reserve"/"FOMC" → Fed, "presidential"/"presidency" → president, "second" → 2nd, "first round" → round one).
2. **Entity, number and date extraction.** The actor extracts thresholds ($2B = 2,000,000,000, 3.2%, 60+ wins), years and seasons (2026-27), ranks (1st/3rd, "third-most"), dates in the question (Nov 24), direction (above/below/between) and the outcome name: the candidate, team or answer in Kalshi's `yes_sub_title` or Polymarket's `groupItemTitle`.
3. **Candidate search.** Polymarket outcomes are looked up in an inverted index of Kalshi markets using their rarest words.
4. **Scoring.** The score combines IDF-weighted word overlap, checked in both directions so that a short title cannot "fit" inside a long one. On top of that:
   - the outcome or team must agree. Kalshi team initials such as "Los Angeles C" are resolved against the full team names.
   - numbers, ranks, years and dates must agree
   - the market type must agree: draw vs win, half-time vs full-time, album vs artist, last place vs top 4
   - large differences in resolution date or price lower the confidence
5. **One-to-one assignment.** The best matches are assigned greedily, so one Kalshi market is never paired with two Polymarket markets.

**Limits.** Matching is heuristic, not a legal comparison of contracts. Pairs with confidence ≥ 0.75 are usually the same question. Between 0.6 and 0.75, check the warnings. Some equivalent markets are missed, for example when one exchange words a question very differently. Spread/handicap markets are excluded on purpose, because their lines rarely correspond exactly. Weather markets may use different weather stations. Rotten Tomatoes, box-office and similar markets often differ in "at least" vs "above" (flagged as `THRESHOLD_INCLUSIVITY`).

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `keywords` | string\[] | – | Only pairs whose title on either exchange contains one of these phrases (e.g. `fed`, `bitcoin`, `democratic nominee`, `nba`). |
| `categories` | string\[] | all | `politics`, `sports`, `crypto`, `economics`, `tech`, `culture`, `weather`, `world`, `other` |
| `onlyArbitrage` | boolean | `false` | Only pairs that are profitable after fees. Real arbitrage is rare, so this often returns 0 rows. |
| `minSpreadPct` | number | `0` | Minimum gap between the two implied probabilities, in percentage points. |
| `minConfidence` | number | `0.6` | Minimum match confidence (0.3–1). |
| `minLiquidityUsd` | integer | `1000` | Minimum liquidity on each side. |
| `maxDaysToResolution` | integer | `180` | Only markets that resolve within N days. |
| `maxPairs` | integer | `50` | Maximum rows, sorted by fee-adjusted edge (best first). |
| `kalshiTakerFeeRate` | number | `0.07` | Kalshi taker fee coefficient: fee = ⌈rate × multiplier × C × P × (1−P)⌉ to the cent. |
| `polymarketFeeRate` | number | per market | Override Polymarket's taker fee rate. Set it to 0 if you trade as maker. |
| `extraCostPerContract` | number | `0` | Buffer for slippage or transfer costs, in USD per $1 contract pair. |
| `includeRules` | boolean | `true` | Add the first 600 characters of both resolution rules. |

An empty input `{}` works: it scans everything with the defaults above and logs a warning.

Example:

```json
{ "keywords": ["fed", "president", "bitcoin", "recession"], "minConfidence": 0.6, "maxPairs": 50 }
```

### Output

One row per matched pair. Abridged example:

```json
{
  "eventTitle": "Will \"Avengers: Doomsday\" score at least 90 on the Rotten Tomatoes Tomatometer?",
  "matchConfidence": 0.766,
  "isArbitrage": true,
  "strategy": "BUY_NO_ON_POLYMARKET_AND_YES_ON_KALSHI",
  "netEdgePerContract": 0.0573,
  "netReturnPct": 6.08,
  "annualizedReturnPct": 80.95,
  "rawSpreadPct": 12,
  "polymarketImpliedProb": 0.305,
  "kalshiImpliedProb": 0.185,
  "costPerContract": 0.93,
  "feesPerContract": 0.0127,
  "maxContracts": 1803,
  "maxProfitUsd": 62.77,
  "capitalRequiredUsd": 1740.23,
  "sizeSource": "orderbook",
  "daysToResolution": 27.41,
  "warnings": [
    "THRESHOLD_INCLUSIVITY: Polymarket counts a value equal to the threshold as YES (\"at least\"), Kalshi requires strictly \"above\" it; an exact hit resolves the legs differently",
    "VERIFY_RULES: always compare both resolution rules before trading"
  ],
  "polymarket": { "title": "...", "outcome": "90+", "url": "https://polymarket.com/event/...", "marketId": "5178324", "yesTokenId": "1786...", "yesBid": 0.26, "yesAsk": 0.35, "noBid": 0.65, "noAsk": 0.74, "liquidityUsd": 1355, "endDate": "2026-12-21", "takerFeeRate": 0.01, "rules": "..." },
  "kalshi": { "title": "Avengers: Doomsday Rotten Tomatoes score?", "outcome": "Above 90", "url": "https://kalshi.com/markets/kxrt", "ticker": "KXRT-AVE-90", "yesBid": 0.18, "yesAsk": 0.19, "noBid": 0.81, "noAsk": 0.82, "yesAskSize": 113299, "closeDate": "2026-12-21", "feeMultiplier": 1, "rules": "..." },
  "legs": { "polymarketSide": "NO", "polymarketPrice": 0.74, "kalshiSide": "YES", "kalshiPrice": 0.19, "avgPolymarketPriceAtMaxSize": 0.7626, "avgKalshiPriceAtMaxSize": 0.19 },
  "matchDetails": { "textSimilarity": 0.731, "outcomeMatch": null },
  "checkedAt": "2026-11-24T14:10:23.818Z"
}
```

Key fields:

- `netEdgePerContract`: $1 minus the cost of both legs minus fees, per contract pair, at the top of the book.
- `maxContracts` / `maxProfitUsd`: walked from both order books. The value is `null` when the pair is not profitable, so no books are fetched.
- `rawSpreadPct`: Polymarket mid minus Kalshi mid, in percentage points.

A run summary (counts, filters, notes) is saved in the key-value store under `SUMMARY`.

### Fees modelled

- **Kalshi:** taker fee = round up to the next cent of `0.07 × multiplier × contracts × P × (1−P)`. The multiplier (1, 0.5 or 0) comes from each series' fee schedule, and series that also charge maker fees are flagged.
- **Polymarket:** taker fee = `rate × shares × p × (1−p)`. The rate comes from each market's `feeSchedule` (e.g. 0.05 sports and election politics, 0.01 economics, crypto and culture, 0 geopolitics). Makers pay nothing, so set `polymarketFeeRate: 0` if you plan to rest orders.
- Not modelled: deposit/withdrawal costs, USDC conversion, gas, cost of capital and taxes. Use `extraCostPerContract` to add a buffer.

### Pricing

**$0.003 per matched pair** returned (pay per event). Runs that return no pairs are free. A default run (50 pairs) costs about $0.15.

### Speed and limits

- A full scan takes about 3–4 minutes at the default 1 GB memory; keyword or category runs finish much faster.
- It reads public endpoints only: Polymarket Gamma API and CLOB order books, and the Kalshi trade API v2. Requests are paced below the published rate limits, with back-off on HTTP 429/5xx.
- Prices change every second, so treat results as a snapshot and re-check both books before trading.
- Multi-leg Kalshi combos (`KXMVE…`) and Polymarket spread markets are skipped.

### FAQ

**Why do I get 0 rows with `onlyArbitrage: true`?** True cross-exchange arbitrage after fees is rare and disappears quickly. Run with `onlyArbitrage: false` to see the closest spreads, or schedule the actor every few minutes.

**A pair looks wrong. What should I do?** Raise `minConfidence` to 0.75. Read the `warnings` (`MATCH: ...`, `RESOLUTION_DATE_DIFFERS`, `RULES_DEADLINE_DIFFERS`, `EDGE_SUSPICIOUSLY_LARGE`).

**Does it place trades?** No. It is read-only and needs no API keys or accounts.

**Can I get only elections or only sport?** Yes. Use `categories` and/or `keywords`.

# Actor input Schema

## `keywords` (type: `array`):

Only return pairs whose title on either exchange contains one of these phrases (all words of a phrase must appear), e.g. "fed", "bitcoin", "democratic nominee", "nba". Leave empty to scan everything.

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

Limit the scan to these categories: politics, sports, crypto, economics, tech, culture, weather, world, other. Empty = all.

## `onlyArbitrage` (type: `boolean`):

Return only pairs where buying YES on one exchange and NO on the other costs less than $1 after fees. Real arbitrage is rare and short-lived, so this often returns 0 rows; leave off to also see the closest spreads.

## `minSpreadPct` (type: `number`):

Minimum difference between the two implied probabilities (mid prices), in percentage points. 0 = no filter.

## `minConfidence` (type: `number`):

How sure the matcher must be that both markets describe the same event. 0.6 is balanced, 0.75+ is strict.

## `minLiquidityUsd` (type: `integer`):

Skip markets with less liquidity than this (Polymarket liquidity; Kalshi approximate open interest or 24h volume).

## `maxDaysToResolution` (type: `integer`):

Only markets that resolve within this many days.

## `maxPairs` (type: `integer`):

Maximum number of matched pairs in the output (sorted by fee-adjusted edge). You pay per returned pair.

## `kalshiTakerFeeRate` (type: `number`):

Kalshi fee = round up to the cent of rate x series multiplier x contracts x P x (1-P). Default 0.07 from Kalshi's fee schedule.

## `polymarketFeeRate` (type: `number`):

Leave empty to use each market's own fee schedule from the Polymarket API (fee = rate x shares x p x (1-p), e.g. 0.05 sports/politics-elections, 0.01 economics/crypto, 0 geopolitics). Set 0 if you trade as maker.

## `extraCostPerContract` (type: `number`):

Optional buffer for slippage, deposits/withdrawals or capital cost, subtracted from each $1 contract pair.

## `includeRules` (type: `boolean`):

Add the first 600 characters of both resolution rules to each row so you can compare them.

## `proxyConfiguration` (type: `object`):

Not needed: both exchanges have public APIs.

## Actor input object example

```json
{
  "keywords": [
    "fed",
    "president",
    "bitcoin",
    "recession"
  ],
  "categories": [],
  "onlyArbitrage": false,
  "minSpreadPct": 0,
  "minConfidence": 0.6,
  "minLiquidityUsd": 1000,
  "maxDaysToResolution": 180,
  "maxPairs": 50,
  "kalshiTakerFeeRate": 0.07,
  "extraCostPerContract": 0,
  "includeRules": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "keywords": [
        "fed",
        "president",
        "bitcoin",
        "recession"
    ],
    "categories": [],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("donzely/prediction-market-arbitrage").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 = {
    "keywords": [
        "fed",
        "president",
        "bitcoin",
        "recession",
    ],
    "categories": [],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("donzely/prediction-market-arbitrage").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 '{
  "keywords": [
    "fed",
    "president",
    "bitcoin",
    "recession"
  ],
  "categories": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call donzely/prediction-market-arbitrage --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,donzely/prediction-market-arbitrage"
        }
    }
}
```

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/uuP54DBflKumHD2HP/builds/TWvz0eFEZT9yQeHQ1/openapi.json
