Skip to main content
Glama
mixuechu

Binance MCP Server

by mixuechu

find_arbitrage_pairs

Identify cryptocurrency arbitrage opportunities by analyzing funding rates, trading volume, and directional stability on Binance.

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
min_funding_rateNo
min_avg_volumeNo
history_daysNo
stability_thresholdNo

Implementation Reference

  • The handler function implementing the 'find_arbitrage_pairs' tool logic. It fetches funding rates and volumes from Binance futures API, filters pairs based on criteria like minimum funding rate, volume, and stability of rate direction, and returns sorted list of opportunities. The @mcp.tool() decorator registers it as an MCP tool.
    @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"]))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions criteria (funding rate, volume, stability) but doesn't disclose computational cost, rate limits, data freshness, or what 'analyze' entails. The return statement is vague ('List of qualifying arbitrage opportunities') without format or structure details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by structured Args and Returns sections. Every sentence earns its place, though the Returns section is somewhat vague and could be more specific.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters with 0% schema coverage and no output schema, the description does a decent job explaining parameters but lacks completeness. It doesn't cover behavioral aspects like performance, errors, or output format details. For a tool that likely involves data analysis, more context on limitations or assumptions would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates well by explaining all four parameters in the Args section with meaningful context: 'Minimum funding rate to qualify', 'Minimum 24hr volume in USDT', etc. It adds semantic value beyond schema titles like 'Min Funding Rate', though it could elaborate on units or typical ranges.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find arbitrage pairs based on funding rate, volume, and rate direction stability.' It specifies the verb ('Find') and resource ('arbitrage pairs') with key criteria. However, it doesn't explicitly differentiate from siblings like 'execute_hedge_arbitrage_strategy' which might execute rather than find opportunities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_funding_rate_history' for raw data or 'execute_hedge_arbitrage_strategy' for acting on findings. There's no context about prerequisites, timing, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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