finding-arbitrage-opportunities
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFinding Arbitrage Opportunities
寻找套利机会
Overview
概述
This skill detects and analyzes arbitrage opportunities across cryptocurrency exchanges and DeFi protocols. It aggregates prices from multiple sources, calculates net profit after fees and costs, and identifies both direct and triangular arbitrage paths.
本工具可检测并分析加密货币交易所及DeFi协议中的套利机会。它聚合多来源价格数据,计算扣除手续费及成本后的净利润,并识别直接套利与三角套利路径。
Prerequisites
前提条件
Before using this skill, ensure you have:
- Python 3.9+ with ,
httpx, andrichpackagesnetworkx - Internet access for API calls (no API keys required for basic use)
- Optional: Exchange API keys for real-time order book access
- Understanding of arbitrage concepts and trading fees
使用本工具前,请确保您具备以下条件:
- 安装有、
httpx和rich包的Python 3.9+环境networkx - 可访问互联网以调用API(基础使用无需API密钥)
- 可选:交易所API密钥(用于获取实时订单簿数据)
- 了解套利概念及交易手续费相关知识
Instructions
使用说明
Step 1: Configure Data Sources
步骤1:配置数据源
Configure your price sources in :
{baseDir}/config/settings.yamlyaml
undefined在中配置价格数据源:
{baseDir}/config/settings.yamlyaml
undefinedPrimary data sources
Primary data sources
data_sources:
coingecko:
enabled: true
base_url: "https://api.coingecko.com/api/v3"
rate_limit: 10 # calls per minute (free tier)
exchanges:
- binance
- coinbase
- kraken
- kucoin
- okx
Or use environment variables for API keys:
```bash
export BINANCE_API_KEY="your-key"
export COINBASE_API_KEY="your-key"data_sources:
coingecko:
enabled: true
base_url: "https://api.coingecko.com/api/v3"
rate_limit: 10 # calls per minute (free tier)
exchanges:
- binance
- coinbase
- kraken
- kucoin
- okx
或使用环境变量配置API密钥:
```bash
export BINANCE_API_KEY="your-key"
export COINBASE_API_KEY="your-key"Step 2: Quick Spread Scan
步骤2:快速价差扫描
Scan for arbitrage opportunities on a specific pair:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDCThis shows:
- Current prices on each exchange
- Spread percentage
- Estimated profit after fees
- Recommended action
扫描特定交易对的套利机会:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC该命令会展示:
- 各交易所当前价格
- 价差百分比
- 扣除手续费后的预估利润
- 建议操作
Step 3: Multi-Exchange Comparison
步骤3:多交易所对比
Compare prices across specific exchanges:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC \
--exchanges binance,coinbase,kraken,kucoin,okxOutput includes:
| Exchange | Bid | Ask | Spread | Net Profit |
|---|---|---|---|---|
| Binance | 2541.20 | 2541.50 | 0.01% | - |
| Coinbase | 2543.80 | 2544.10 | 0.01% | +$2.30 |
对比特定交易所间的价格:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC \
--exchanges binance,coinbase,kraken,kucoin,okx输出内容包括:
| Exchange | Bid | Ask | Spread | Net Profit |
|---|---|---|---|---|
| Binance | 2541.20 | 2541.50 | 0.01% | - |
| Coinbase | 2543.80 | 2544.10 | 0.01% | +$2.30 |
Step 4: DEX Price Comparison
步骤4:DEX价格对比
Scan decentralized exchanges for arbitrage:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC --dex-onlyCompares:
- Uniswap V3
- SushiSwap
- Curve
- Balancer
Includes gas cost estimates for on-chain execution.
扫描去中心化交易所的套利机会:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC --dex-only对比对象包括:
- Uniswap V3
- SushiSwap
- Curve
- Balancer
输出包含链上执行的Gas成本预估。
Step 5: Triangular Arbitrage Discovery
步骤5:三角套利发现
Find profitable circular paths within an exchange:
bash
python {baseDir}/scripts/arb_finder.py triangular binance --min-profit 0.5Example output:
Path: ETH → BTC → USDT → ETH
Gross: +0.82%
Fees: -0.30% (3 × 0.10%)
─────────────────────────────
Net: +0.52%寻找交易所内的盈利循环路径:
bash
python {baseDir}/scripts/arb_finder.py triangular binance --min-profit 0.5示例输出:
Path: ETH → BTC → USDT → ETH
Gross: +0.82%
Fees: -0.30% (3 × 0.10%)
─────────────────────────────
Net: +0.52%Step 6: Cross-Chain Opportunities
步骤6:跨链机会检测
Compare prices across different blockchains:
bash
python {baseDir}/scripts/arb_finder.py cross-chain USDC \
--chains ethereum,polygon,arbitrumShows:
- Price on each chain
- Bridge fees and times
- Net profit after bridging
对比不同区块链间的价格:
bash
python {baseDir}/scripts/arb_finder.py cross-chain USDC \
--chains ethereum,polygon,arbitrum展示内容:
- 各链上的价格
- 跨链桥手续费及耗时
- 扣除跨链成本后的净利润
Step 7: Real-Time Monitoring
步骤7:实时监控
Continuously monitor for opportunities:
bash
python {baseDir}/scripts/arb_finder.py monitor ETH USDC \
--threshold 0.5 \
--interval 5Alerts when spread exceeds threshold:
[ALERT] ETH/USDC spread 0.62% (Binance → Coinbase)
Buy: $2,541.20 | Sell: $2,556.98
Net Profit: +$12.34 (after fees)持续监控套利机会:
bash
python {baseDir}/scripts/arb_finder.py monitor ETH USDC \
--threshold 0.5 \
--interval 5当价差超过阈值时触发警报:
[ALERT] ETH/USDC spread 0.62% (Binance → Coinbase)
Buy: $2,541.20 | Sell: $2,556.98
Net Profit: +$12.34 (after fees)Step 8: Profit Calculator
步骤8:利润计算器
Calculate exact profit for a trade:
bash
python {baseDir}/scripts/arb_finder.py calc \
--buy-exchange binance \
--sell-exchange coinbase \
--pair ETH/USDC \
--amount 10Shows detailed breakdown:
- Gross profit
- Trading fees (both exchanges)
- Withdrawal fees
- Net profit
- Breakeven spread
计算特定交易的精确利润:
bash
python {baseDir}/scripts/arb_finder.py calc \
--buy-exchange binance \
--sell-exchange coinbase \
--pair ETH/USDC \
--amount 10展示详细拆解:
- 毛利润
- 交易手续费(两家交易所)
- 提现手续费
- 净利润
- 盈亏平衡价差
Step 9: JSON Export
步骤9:JSON导出
Export opportunities for bot integration:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC --output json > opportunities.json导出套利机会数据用于机器人集成:
bash
python {baseDir}/scripts/arb_finder.py scan ETH USDC --output json > opportunities.jsonOutput
输出说明
The scanner provides:
Quick Mode (default):
- Best opportunity with profit estimate
- Buy/sell recommendation
- Risk level indicator
Detailed Mode ():
--detailed- All exchange prices
- Fee breakdown
- Slippage estimates
- Historical spread context
Monitor Mode:
- Real-time updates
- Threshold alerts
- Trend indicators
扫描工具提供以下模式:
快速模式(默认):
- 最优套利机会及利润预估
- 买卖建议
- 风险等级标识
详细模式():
--detailed- 所有交易所价格
- 手续费拆解
- 滑点预估
- 历史价差背景
监控模式:
- 实时更新
- 阈值警报
- 趋势指标
Supported Exchanges
支持的交易所
Centralized Exchanges (CEX)
中心化交易所(CEX)
| Exchange | Maker Fee | Taker Fee | Withdrawal |
|---|---|---|---|
| Binance | 0.10% | 0.10% | Variable |
| Coinbase | 0.40% | 0.60% | Variable |
| Kraken | 0.16% | 0.26% | Variable |
| KuCoin | 0.10% | 0.10% | Variable |
| OKX | 0.08% | 0.10% | Variable |
| Exchange | Maker Fee | Taker Fee | Withdrawal |
|---|---|---|---|
| Binance | 0.10% | 0.10% | Variable |
| Coinbase | 0.40% | 0.60% | Variable |
| Kraken | 0.16% | 0.26% | Variable |
| KuCoin | 0.10% | 0.10% | Variable |
| OKX | 0.08% | 0.10% | Variable |
Decentralized Exchanges (DEX)
去中心化交易所(DEX)
| DEX | Fee Range | Gas (ETH) | Chains |
|---|---|---|---|
| Uniswap V3 | 0.01-1% | ~150k | ETH, Polygon, Arbitrum |
| SushiSwap | 0.30% | ~150k | Multi-chain |
| Curve | 0.04% | ~200k | ETH, Polygon, Arbitrum |
| Balancer | 0.01-10% | ~180k | ETH, Polygon, Arbitrum |
| DEX | Fee Range | Gas (ETH) | Chains |
|---|---|---|---|
| Uniswap V3 | 0.01-1% | ~150k | ETH, Polygon, Arbitrum |
| SushiSwap | 0.30% | ~150k | Multi-chain |
| Curve | 0.04% | ~200k | ETH, Polygon, Arbitrum |
| Balancer | 0.01-10% | ~180k | ETH, Polygon, Arbitrum |
Error Handling
错误处理
See for comprehensive error handling.
{baseDir}/references/errors.mdCommon issues:
- Rate Limited: Reduce polling frequency or use API key
- Stale Prices: Data older than 10s flagged with warning
- No Spread: All exchanges at similar prices (efficient market)
- Insufficient Liquidity: Trade size exceeds order book depth
详见中的完整错误处理指南。
{baseDir}/references/errors.md常见问题:
- 速率限制:降低轮询频率或使用API密钥
- 价格过期:超过10秒的旧数据会标记警告
- 无价差:所有交易所价格相近(有效市场)
- 流动性不足:交易规模超过订单簿深度
Examples
示例
See for detailed examples including:
{baseDir}/references/examples.md- ETH/USDC CEX arbitrage scan
- DEX triangular arbitrage discovery
- Cross-chain USDC opportunity
- Automated monitoring setup
详见中的详细示例,包括:
{baseDir}/references/examples.md- ETH/USDC CEX套利扫描
- DEX三角套利发现
- 跨链USDC机会
- 自动化监控设置
Educational Disclaimer
教育免责声明
FOR EDUCATIONAL PURPOSES ONLY
Arbitrage trading involves significant risks:
- Opportunities may disappear before execution
- Price data may be delayed or inaccurate
- Fees can exceed profits on small trades
- Market conditions change rapidly
This tool provides analysis only. Do not trade without understanding the risks.
仅用于教育目的
套利交易存在重大风险:
- 机会可能在执行前消失
- 价格数据可能延迟或不准确
- 小额交易的手续费可能超过利润
- 市场条件变化迅速
本工具仅提供分析内容。请在充分了解风险后再进行交易。
Resources
资源
- CoinGecko API - Free price data
- CCXT Library - Unified exchange API
- Uniswap Subgraph - DEX data
- Gas Tracker - Ethereum gas prices
- CoinGecko API - 免费价格数据
- CCXT Library - 统一交易所API
- Uniswap Subgraph - DEX数据
- Gas Tracker - Ethereum gas价格