Skip to content

LeoYeAI/agent-master-skills / skills/arbiscan-skill

arbiscan

Verified

Comprehensive crypto market scanner across Binance, OKX, Bybit, and Bitget. 12 scan types covering arbitrage (funding rate, basis, spot spread, futures spread), market monitoring (open interest, price movers, volume anomaly, stablecoin depeg, funding extreme), and trading signals (funding trend, long/short ratio, new listing detection). Read-only — no trading, no API keys needed.

scripts/funding_arb.py

View on GitHub
"""资金费率套利扫描"""

from config import TOP_SYMBOLS, EXCHANGES
from fetcher import fetch_all_funding_rates
from formatter import format_output, risk_level


def scan_funding_arbitrage(symbols: list = None, min_apy: float = 0) -> tuple:
    """
    扫描资金费率套利机会
    返回 (rows, headers)
    """
    if symbols is None:
        symbols = TOP_SYMBOLS

    headers = ["Symbol", "Long (低费率)", "Short (高费率)", "Rate Diff", "Est. APY%", "Risk", "Window"]
    rows = []

    print(f"[Funding Rate] 扫描 {len(symbols)} 个交易对...")
    for symbol in symbols:
        rates = fetch_all_funding_rates(symbol)
        if len(rates) < 2:
            continue

        # 找最低和最高费率
        min_ex = min(rates, key=rates.get)
        max_ex = max(rates, key=rates.get)
        diff = rates[max_ex] - rates[min_ex]

        if diff <= 0:
            continue

        # 年化计算:rate_diff * (365 * 24 / interval_hours) * 100
        interval = EXCHANGES[min_ex]["funding_interval_hours"]
        apy = diff * (365 * 24 / interval) * 100

        if apy < min_apy:
            continue

        risk = risk_level(apy, symbol)
        rows.append([
            f"{symbol}USDT",
            f"{EXCHANGES[min_ex]['name']} {rates[min_ex]*100:.4f}%",
            f"{EXCHANGES[max_ex]['name']} {rates[max_ex]*100:.4f}%",
            f"{diff*100:.4f}%",
            f"{apy:.1f}%",
            risk,
            f"~{interval}h",
        ])

    # 按年化降序排列
    rows.sort(key=lambda r: float(r[4].rstrip('%')), reverse=True)
    return rows, headers


def main():
    import argparse
    parser = argparse.ArgumentParser(description="Funding Rate Arbitrage Scanner")
    parser.add_argument("--min-apy", type=float, default=0, help="最低年化过滤")
    parser.add_argument("--format", choices=["table", "markdown", "json"], default="table")
    args = parser.parse_args()

    rows, headers = scan_funding_arbitrage(min_apy=args.min_apy)
    print(f"\n{'='*80}")
    print("  Funding Rate Arbitrage Opportunities")
    print(f"{'='*80}")
    print(format_output(rows, headers, args.format))
    print(f"\nFound {len(rows)} opportunities")


if __name__ == "__main__":
    main()
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall