返回顶部
b

binance-stat-arb-monitor币安统计套利监控

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
196
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

binance-stat-arb-monitor

Binance Stat Arb Monitor

概述

统计套利监控工具,基于Binance USDT永续合约市场数据,监控ETH/BTC价格比率的偏离程度,当出现均值回归机会时生成交易信号并推送通知。

策略说明

什么是统计套利?

统计套利是一种基于数学模型的量化交易策略,利用资产价格的统计相关性进行套利。其核心假设是:两个相关资产的价格比率会围绕均值波动,当偏离均值时,未来有回归均值的趋势。

ETH/BTC比率策略

  1. 1. 观察ETH/BTC价格比率
- 比率 = ETH价格 / BTC价格 - 历史均值约0.0293(数据来源:Binance ETHUSDT/BTCUSDT)
  1. 2. 计算z-score
- z = (当前比率 - 历史均值) / 历史标准差 - z-score衡量当前价格偏离均值的程度(标准差倍数)
  1. 3. 交易信号逻辑
- z-score < -3.0:ETH相对BTC偏低 → 做多ETH + 做空BTC - z-score > +3.0:ETH相对BTC偏高 → 做空ETH + 做多BTC - z-score回归至±1.0:平仓止盈 - z-score触及±4.5:止损

快速开始

1. 配置

bash

复制配置模板


cp config.example.json config.json

编辑配置(必须)

vim config.json

2. 安装依赖

bash
pip install -r requirements.txt

3. 运行监控

bash

手动运行一次


python scripts/monitor.py

或设置定时任务(每5分钟检查)

/5 * cd /path/to/skill && python scripts/monitor.py >> /var/log/stat_arb.log 2>&1

4. 查看输出

bash

查看最新信号


cat data/latest_signal.json

查看信号历史

cat data/signals.json

配置

config.json完整配置

json
{
binance: {
base_url: https://fapi.binance.com,
timeout: 10
},
strategy: {
symbol1: ETHUSDT,
symbol2: BTCUSDT,
lookback_period: 720,
interval: 1h,
entry_threshold: 3.0,
exit_threshold: 1.0,
stop_loss: 4.5,
minzscorefor_signal: 2.5,
positionsizeusd: 1000
},
notification: {
enabled: true,
telegram: {
enabled: true,
bottoken: YOURBOT_TOKEN,
chatid: YOURCHANNELCHATID
},
feishu: {
enabled: false,
webhook_url:
}
},
storage: {
data_dir: data,
signals_file: data/signals.json,
latestfile: data/latestsignal.json,
log_file: data/monitor.log
}
}

配置说明

配置项类型说明
binance.base_urlstringBinance API地址(测试网:https://demo-fapi.binance.com)
strategy.symbol1
string | 分子交易对(ETHUSDT) | | strategy.symbol2 | string | 分母交易对(BTCUSDT) | | strategy.lookback_period | int | 历史数据点数(720 = 30天x24小时) | | strategy.interval | string | K线间隔(1h, 4h, 1d) | | strategy.entry_threshold | float | 开仓阈值(z-score绝对值) | | strategy.exit_threshold | float | 平仓阈值(z-score回归点) | | strategy.stop_loss | float | 止损阈值 | | strategy.minzscorefor_signal | float | 最小信号阈值(避免噪音) | | notification.telegram.bot_token | string | Telegram Bot Token(@BotFather创建) | | notification.telegram.chatid | string | Channel Chat ID(@usernametoidbot获取) |

Telegram Bot设置

1. 创建Bot

  1. 1. 打开Telegram,搜索@BotFather
  2. 发送/newbot创建新机器人
  3. 获取Bot Token

2. 获取Channel Chat ID

  1. 1. 创建Telegram Channel
  2. 将Bot添加为管理员
  3. 使用@usernametoidbot获取Channel的chatid(格式:-100xxxxxxxxxx)

3. 配置

将Token和Chat ID填入config.json

输出格式

Signal JSON

json
{
timestamp: 2026-03-14T19:00:00+08:00,
signal_type: OPEN,
direction: LONGETHSHORT_BTC,
zscore: -3.51,
ratio: 0.029257,
mean: 0.029305,
std: 0.000315,
threshold: {
entry: 3.0,
exit: 1.0,
stop_loss: 4.5
},
prices: {
eth: 2063.45,
btc: 70528.50
},
recommendation: {
action: LONG ETH-PERP + SHORT BTC-PERP,
eth_entry: 2063.45,
btc_entry: 70528.50,
positionsizeusd: 1000
},
estimate: {
expected_return: 0.00118,
fees_taker: 0.00140,
net_pnl: -0.00022
},
strength: 4,
volatility: normal
}

Telegram消息格式

🟢 [OPEN] 统计套利开仓信号

ETH/BTC z-score: -3.51 (偏低,均值回归概率大)
比率: 0.029257 (均值: 0.029305)
动态阈值: 开仓 ±3.00 / 止损 ±4.50
z波动率: 0.65 正常

建议操作:
• LONG ETH-PERP (市价) @ ~$2,063.45
• SHORT BTC-PERP (市价) @ ~$70,528.50

预估 (每腿 $1000):
预期利润: $1.18 (0.118%)
手续费: $1.40 (taker x4)
净利润: $-0.22

信号强度: ★★★★☆

风险提示

⚠️ 重要风险提示

  1. 1. 统计套利并非无风险策略
  2. 极端市场条件下价差可能持续扩大
  3. 手续费对收益影响显著
  4. 建议使用测试网充分验证后再实盘
  5. 本工具仅供参考,不构成投资建议

API参考

Binance期货API(公共接口)

接口说明认证
/fapi/v1/ticker/price当前价格
/fapi/v1/klines
K线数据 | 否 | | /fapi/v1/premiumIndex | 资金费率 | 否 | | /fapi/v1/fundingRate | 资金费率历史 | 否 | | /fapi/v1/openInterest | 未平仓合约 | 否 | | /fapi/v1/ticker/24hr | 24小时行情 | 否 |

详细文档:https://binance-docs.github.io/apidocs/futures/cn/

文件结构

binance-stat-arb-monitor/
├── SKILL.md # 本文档
├── config.example.json # 配置模板
├── config.json # 运行时配置(不提交)
├── requirements.txt # Python依赖
├── scripts/
│ ├── init.py
│ ├── monitor.py # 主入口
│ ├── fetcher.py # Binance API获取
│ ├── calculator.py # z-score计算
│ ├── formatter.py # 消息格式化
│ └── notifier.py # 通知推送
├── references/
│ ├── statarbtheory.md # 策略理论
│ └── binance_api.md # API参考
└── data/
├── signals.json # 信号历史

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 binance-stat-arb-monitor-1776094384 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 binance-stat-arb-monitor-1776094384 技能

通过命令行安装

skillhub install binance-stat-arb-monitor-1776094384

下载

⬇ 下载 binance-stat-arb-monitor v1.0.0(免费)

文件大小: 18.69 KB | 发布时间: 2026-4-15 11:53

v1.0.0 最新 2026-4-15 11:53
Binance Stat Arb Monitor v1.0.0

- 首发版本:监控 Binance ETH/BTC 永续合约统计套利机会
- 实时计算价格比率 z-score,生成均值回归交易信号(开仓/平仓/止损)
- 支持通过 Telegram Channel 或飞书推送交易信号通知
- 自动记录信号历史,便于回测与分析
- 配置灵活,支持自定义交易参数和通知渠道

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部