# Crypto Pairs Mean Reversion Scanner (`eraydiler/mean-reversion-pairs-scanner`) Actor

Identify statistical arbitrage opportunities in synthetic crypto pairs. Scans for extreme spread deviations (Mean Reversion) to find high-probability trade setups. Advanced Z-Score analysis, multi-timeframe support, and weekly trend confirmation.

- **URL**: https://apify.com/eraydiler/mean-reversion-pairs-scanner.md
- **Developed by:** [Eray Diler](https://apify.com/eraydiler) (community)
- **Categories:** Automation, Developer tools, Other
- **Features:** Limited permissions
- **Stats:** 7 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.32 / actor start

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

## Mean Reversion Pairs Scanner ↔️

**Find "rubber band" trades in synthetic crypto pairs.**

This advanced scanner identifies statistical arbitrage opportunities by analyzing the spread between two assets (like ETH vs. BTC). It looks for moments when the relationship between two assets stretches too far from its average (mean), signaling a high probability that it will "snap back" (revert).

***

### 🌟 What is Mean Reversion?

Imagine a rubber band connecting two prices. Sometimes market panic or excitement stretches this band too far.

- **Mean Reversion Trading** bets that the band will eventually relax back to its normal state.
- This scanner finds those "stretched" moments for you automatically.

***

### 🛠 How it works

1. **Synthetic Pairs:** It creates pairs from top coins (e.g., `ETH-BTC`, `SOL-ETH`).
2. **Moving Average (MA):** It calculates the average spread over time (e.g., 20 days).
3. **Z-Score Analysis:** It measures how far the current spread is from that average in terms of standard deviations (Z-Score).
4. **Signal Generation:** If the deviation is extreme (e.g., > 2 standard deviations), it generates a **LONG** or **SHORT** signal for the pair.

***

### 📥 Configuration (Input)

| Parameter | Default | Description |
| :--- | :--- | :--- |
| **Deviation %** | `5.0` | How far (in %) the price must be from the Moving Average to trigger a signal. |
| **MA Window** | `20` | The number of candles used to calculate the average. |
| **Timeframe** | `"1d"` | The candle size. `1d` (Daily) is recommended for reliable swing trades. Options: `1h`, `4h`, `1d`, `1w`. |
| **Use Median** | `false` | If true, uses Median instead of Mean (better for ignoring sudden price spikes). |
| **Confirm Weekly** | `true` | Checks the weekly trend to filter out bad signals (highly recommended). |

#### Example Input

```json
{
  "deviation_pct": 5.0,
  "ma_window": 20,
  "timeframe": "4h",
  "confirm_weekly": true
}
```

***

### 📤 Results (Output)

Each result contains the synthetic pair, its mean-reversion direction, and the measured ratio and deviation:

```json
{
  "symbol": "ETHUSDT/BTCUSDT",
  "base_pair": "ETHUSDT",
  "quote_pair": "BTCUSDT",
  "exchange": "Binance (Synthetic)",
  "timeframe": "1d",
  "ma_window": 20,
  "use_median": false,
  "ratio": 0.05,
  "ma": 0.045,
  "deviation_pct": 11.111,
  "deviation_daily_pct": 11.111,
  "deviation_weekly_pct": 8.5,
  "direction": "overbought",
  "type": "mean_reversion"
}
```

- **oversold** means the base/quote ratio is below its moving average by at least the configured threshold.
- **overbought** means the base/quote ratio is above its moving average by at least the configured threshold.

***

### 📦 About

Created by **Eray Diler** for **StrategyLab**.
**StrategyLab** is a software studio dedicated to building high-quality developer tools, financial scanners, and productivity apps for macOS & iOS. We craft solutions that help traders and developers find their edge.

# Actor input Schema

## `deviation_pct` (type: `number`):

Percentage deviation from MA to trigger signal.

## `ma_window` (type: `integer`):

Window size for Moving Average.

## `top_n` (type: `integer`):

Number of top market cap coins to scan.

## `timeframe` (type: `string`):

Timeframe for analysis (e.g., 1d, 1h).

## `use_median` (type: `boolean`):

Use median instead of mean for moving average.

## `confirm_weekly` (type: `boolean`):

Require weekly confirmation.

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

Select proxies to be used by your crawler.

## Actor input object example

```json
{
  "deviation_pct": 5,
  "ma_window": 20,
  "top_n": 30,
  "timeframe": "1d",
  "use_median": false,
  "confirm_weekly": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `signals` (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 = {
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("eraydiler/mean-reversion-pairs-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 = { "proxyConfiguration": { "useApifyProxy": True } }

# Run the Actor and wait for it to finish
run = client.actor("eraydiler/mean-reversion-pairs-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 '{
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call eraydiler/mean-reversion-pairs-scanner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eraydiler/mean-reversion-pairs-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/Uf0gMd4wviKlgNhBt/builds/Kq2pdhmveSHEinxdK/openapi.json
