# Crypto Funding Rate Arbitrage Scanner (`drizzly_twilight/crypto-funding-rate-arbitrage-scanner`) Actor

Scans perpetual futures funding rates across OKX, Gate.io, MEXC, HTX, KuCoin and Bitget, and returns cross-exchange funding-rate spreads ranked by annualized return. Find delta-neutral carry trades in seconds.

- **URL**: https://apify.com/drizzly_twilight/crypto-funding-rate-arbitrage-scanner.md
- **Developed by:** [Cid Aric](https://apify.com/drizzly_twilight) (community)
- **Categories:** Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 arbitrage opportunities

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

## Crypto Funding Rate Arbitrage Scanner

Scans perpetual-futures funding rates across **8 exchanges** and returns cross-exchange
spreads ranked by annualized return, so you can find delta-neutral carry trades in seconds.

Supported exchanges: `okx` `gate` `mexc` `htx` `kucoin` `bitget` `binance` `bybit`
(all public APIs — no API keys required).

### What it does

1. Pulls every USDT-margined perpetual contract from each selected exchange.
2. Normalizes inconsistent symbol formats (`BTC-USDT-SWAP`, `XBTUSDTM`, `BTC_USDT` → `BTC`).
3. Converts each funding rate into an annualized number using the venue's settlement interval.
4. Pairs up venues and ranks the spread: **short on the high-rate venue, long on the low-rate venue**.
5. Drops illiquid/stale contracts whose per-period rate is implausibly large.

### Input

All fields have defaults — press **Start** and it runs.

| Field | Default | Meaning |
|---|---|---|
| `exchanges` | all 8 | Venues to scan |
| `minAprPct` | `10` | Only return spreads above this annualized % |
| `maxAbsRatePct` | `0.5` | Discard contracts with a per-period rate above this (illiquid filter) |
| `topN` | `50` | Max rows in the dataset |

> **Note on Binance / Bybit:** they block some regions with HTTP 451/403. On Apify cloud
> (US/EU egress) they work. If one venue fails, it is recorded in the run summary and the
> remaining venues still return results.

### Output

One dataset item per opportunity:

| Field | Meaning |
|---|---|
| `base` | Coin (BTC, ETH, …) |
| `long_exchange` / `short_exchange` | Where to go long / short |
| `long_rate_pct` / `short_rate_pct` | Current funding rate per settlement period |
| `spread_pct_per_period` | Difference between the two rates |
| `apr_pct` | Annualized spread (before fees and slippage) |
| `funding_interval_h` | Settlement interval in hours |

### How much does it cost?

Pay-per-event. You only pay for the results you actually get.

| Event | Price |
|---|---|
| `apify-default-dataset-item` (per result) | **$0.002** |
| `apify-actor-start` (per run) | **$0.005** |

A typical run returning 50 ranked pairs costs about **$0.11**. Small runs are cheaper —
a run with 10 results costs about $0.03.

### How to use the results

1. Open a short on `short_exchange` and a long of equal notional on `long_exchange`.
2. Collect the funding payment each settlement while the spread holds.
3. **Real return = annualized spread − trading fees (open + close on both legs) − transfer costs − slippage.**
4. An `apr_pct` above ~200% is usually an illiquid micro-cap. Check order-book depth before sizing.

### Notes

- Not financial advice. Funding rates change continuously; always re-check before entering.
- Data comes from public exchange endpoints and is not guaranteed to be real-time or complete.

### Local run (no Apify account)

```bash
python3 src/logic.py
```

# Actor input Schema

## `exchanges` (type: `array`):

Which exchanges to scan. Defaults to the six that work from every region. Add binance or bybit only if your run has an IP those venues accept — they answer HTTP 451/403 from restricted regions. Valid: okx, gate, mexc, htx, kucoin, bitget, binance, bybit.

## `minAprPct` (type: `integer`):

Only return pairs whose annualized funding spread is above this value.

## `maxAbsRatePct` (type: `number`):

Filters out illiquid/stale contracts. 0.5 = 0.5% per 8h.

## `topN` (type: `integer`):

Maximum number of arbitrage opportunities written to the dataset, sorted by annualized return.

## Actor input object example

```json
{
  "exchanges": [
    "okx",
    "gate",
    "mexc",
    "htx",
    "kucoin",
    "bitget"
  ],
  "minAprPct": 10,
  "maxAbsRatePct": 0.5,
  "topN": 50
}
```

# Actor output Schema

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

Each row is one delta-neutral carry trade: long the perpetual on one exchange, short it on another, ranked by annualized return.

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

Number of symbols scanned, opportunities found, and the errors returned by exchange APIs that failed.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("drizzly_twilight/crypto-funding-rate-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("drizzly_twilight/crypto-funding-rate-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 '{}' |
apify call drizzly_twilight/crypto-funding-rate-arbitrage-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,drizzly_twilight/crypto-funding-rate-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/VCBb9Cvj3GlDl67gy/builds/8Roi609AS30DgA1Qw/openapi.json
