Skip to main content
Glama

find_arbitrage_pairs

Identify arbitrage opportunities on Binance by analyzing funding rates, trading volume, and rate direction stability. Set custom thresholds for funding rates, volume, and historical consistency to filter qualifying pairs.

Instructions

Find arbitrage pairs based on funding rate, volume, and rate direction stability.

Args: min_funding_rate: Minimum funding rate to qualify. min_avg_volume: Minimum 24hr volume in USDT. history_days: How many days of history to analyze. stability_threshold: Minimum proportion of funding rates in same direction.

Returns: List of qualifying arbitrage opportunities.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
history_daysNo
min_avg_volumeNo
min_funding_rateNo
stability_thresholdNo

Implementation Reference

  • The main handler function for the 'find_arbitrage_pairs' tool. Decorated with @mcp.tool() for automatic registration. Fetches current funding rates, historical data for stability analysis, and 24hr volume to identify qualifying arbitrage pairs based on specified thresholds.
    @mcp.tool() def find_arbitrage_pairs( min_funding_rate: float = 0.0005, min_avg_volume: float = 1_000_000, history_days: int = 7, stability_threshold: float = 0.8 ) -> list[dict[str, Any]]: """ Find arbitrage pairs based on funding rate, volume, and rate direction stability. Args: min_funding_rate: Minimum funding rate to qualify. min_avg_volume: Minimum 24hr volume in USDT. history_days: How many days of history to analyze. stability_threshold: Minimum proportion of funding rates in same direction. Returns: List of qualifying arbitrage opportunities. """ current_url = "https://fapi.binance.com/fapi/v1/premiumIndex" history_url = "https://fapi.binance.com/fapi/v1/fundingRate" candidates = [] response = requests.get(current_url) if response.status_code != 200: return [{"error": "Failed to fetch current funding data"}] for pair in response.json(): try: symbol = pair["symbol"] current_rate = float(pair["lastFundingRate"]) if abs(current_rate) < min_funding_rate: continue history_params = { "symbol": symbol, "limit": history_days * 3 } history_resp = requests.get(history_url, params=history_params) if history_resp.status_code != 200: continue rates = [float(x["fundingRate"]) for x in history_resp.json()] same_dir = sum(1 for r in rates if (r > 0 and current_rate > 0) or (r < 0 and current_rate < 0)) stability = same_dir / len(rates) if rates else 0 ticker_url = f"https://fapi.binance.com/fapi/v1/ticker/24hr?symbol={symbol}" ticker_resp = requests.get(ticker_url) if ticker_resp.status_code != 200: continue volume = float(ticker_resp.json().get("quoteVolume", 0)) if volume > min_avg_volume and stability >= stability_threshold: candidates.append({ "symbol": symbol, "current_funding_rate": current_rate, "avg_volume": volume, "stability": round(stability, 2) }) except Exception: continue return sorted(candidates, key=lambda x: -abs(x["current_funding_rate"]))

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mixuechu/binance-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server