# Prediction Markets Arbitrage & L2 Slippage (`shoomaii/prediction-markets-arb`) Actor

Cross-venue Polymarket & Kalshi arbitrage scanner and L2 orderbook slippage API. Matches equivalent binary markets, walks live CLOB and Kalshi books, computes fee-adjusted net arb % and executable VWAP at $100/$1K/$10K, and flags UMA vs CFTC resolution risk.

- **URL**: https://apify.com/shoomaii/prediction-markets-arb.md
- **Developed by:** [Hyon](https://apify.com/shoomaii) (community)
- **Categories:** AI, Automation
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 matched arbitrage / depth records

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Prediction Markets Arbitrage & L2 Slippage

Real-time **Polymarket ↔ Kalshi** cross-venue arbitrage scanner and **L2 orderbook slippage calculator**.

Headline midpoint odds often look like "free arbitrage" until you walk the actual orderbook and factor in taker fees. This Actor matches equivalent binary markets across Polymarket and Kalshi, fetches live Level-2 orderbooks from Polymarket's CLOB and Kalshi's Trade API v2, and computes exact executable VWAP, fee-adjusted net edge %, maximum fillable USD depth, slippage at **$100 / $1,000 / $10,000**, and **UMA vs. CFTC resolution-source mismatch warnings**.

### What you get

- **Deterministic cross-venue matching:** Aligns equivalent binary markets across Polymarket and Kalshi using normalized entity/topic tokens, year verification, and numeric threshold checks (never pairs conflicting targets like `$100k` vs `$150k`).
- **Live L2 orderbook simulation:** Walks Polymarket CLOB `/book` ask ladders and Kalshi `/markets/{ticker}/orderbook` resting bid ladders (`1 - NO_bid = YES_ask`) to calculate exact executable VWAP and slippage in basis points.
- **Fee-adjusted net edge:** Evaluates both hedged directions (`Buy PM YES + Kalshi NO` and `Buy Kalshi YES + PM NO`), applies Kalshi's quadratic taker fee (`0.07 * p * (1 - p)`), and reports `grossEdgePct`, `netEdgePct`, `expectedNetProfitUsd`, and `maxExecutableUsd`.
- **Resolution-source risk guard:** Every matched pair includes `resolutionRiskWarning` highlighting UMA Optimistic Oracle (Polymarket) vs. CFTC-regulated Exchange Rules (Kalshi).
- **Direct L2 Depth endpoint (`/depth`):** Pass any Polymarket CLOB token ID or Kalshi ticker to get an instant $100 / $1K / $10K slippage profile.
- **Zero keys, zero proxies, zero browsers:** Uses official public Polymarket Gamma/CLOB and Kalshi Trade APIs directly.

### Example inputs

**Scan macro & crypto markets for executable arbitrage at $1,000 size:**

```json
{
  "keywords": ["Fed", "Bitcoin", "recession", "inflation"],
  "notionalUsd": 1000,
  "minMatchConfidence": 0.55,
  "minNetEdgePct": 0.25,
  "maxOpportunities": 15
}
```

**Inspect all matched Polymarket ↔ Kalshi pairs (even negative spread) to monitor basis tightening:**

```json
{
  "notionalUsd": 2500,
  "minMatchConfidence": 0.6,
  "minNetEdgePct": -100,
  "maxOpportunities": 25
}
```

### Server API & MCP Server (real-time HTTP)

Connect trading bots, dashboards, or MCP clients directly to `/mcp` (`find_prediction_market_arbitrage`, `get_orderbook_depth_slippage`) or call the REST API:

```bash
## Scan matched cross-venue arbitrage with live L2 books
curl -s "https://shoomaii--prediction-markets-arb.apify.actor/arbitrage?q=Fed,Bitcoin&notionalUsd=1000" \
  -H "Authorization: Bearer $APIFY_TOKEN"

## Direct L2 slippage profile for any Kalshi ticker or Polymarket CLOB token ID
curl -s "https://shoomaii--prediction-markets-arb.apify.actor/depth?platform=kalshi&marketId=KXFED-26DEC&side=yes" \
  -H "Authorization: Bearer $APIFY_TOKEN"
```

### Disclaimer

This Actor provides public market microstructure data for research and software engineering. It is not financial or investment advice. Always verify exact contract resolution criteria on both exchanges before trading.

# Actor input Schema

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

Optional list of keywords to focus matching (e.g. Fed, Bitcoin, Trump, NVIDIA). Leave empty to scan across all top markets.

## `notionalUsd` (type: `number`):

Target total hedged trade size in USD used to compute VWAP, net edge, and expected profit.

## `minMatchConfidence` (type: `number`):

Minimum cross-venue text/entity match confidence from 0.1 to 1.0 (default 0.55).

## `minNetEdgePct` (type: `number`):

Filter out pairs whose fee-adjusted net arbitrage edge is below this percentage (e.g. 0.5 for profitable arbs only, or -100 to inspect all matched pairs).

## `maxOpportunities` (type: `integer`):

Maximum number of matched opportunities to return (sorted by net edge descending).

## Actor input object example

```json
{
  "keywords": [
    "Fed",
    "Bitcoin",
    "Trump"
  ],
  "notionalUsd": 1000,
  "minMatchConfidence": 0.55,
  "minNetEdgePct": -100,
  "maxOpportunities": 15
}
```

# Actor output Schema

## `opportunities` (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",
        "Bitcoin",
        "Trump"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("shoomaii/prediction-markets-arb").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",
        "Bitcoin",
        "Trump",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("shoomaii/prediction-markets-arb").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",
    "Bitcoin",
    "Trump"
  ]
}' |
apify call shoomaii/prediction-markets-arb --silent --output-dataset

```

## MCP server setup

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

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/IE84SHl5vzX5jbAzo/builds/zTfMycdmYiL4v3Knr/openapi.json
