Skip to main content
Glama
aahl

AkTools MCP Server

by aahl

获取加密货币杠杆多空比

okx_loan_ratios

Retrieve OKX cryptocurrency loan ratios: the cumulative amount of borrowed quote currency divided by borrowed base currency for a given symbol and time period.

Instructions

获取OKX加密货币借入计价货币与借入交易货币的累计数额比值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNo币种,格式: BTC 或 ETHBTC
periodNo时间粒度,仅支持: [5m/1H/1D] 注意大小写,仅分钟为小写m1h

Implementation Reference

  • The function that executes the okx_loan_ratios tool logic. It calls the OKX API endpoint /api/v5/rubik/stat/margin/loan-ratio with symbol and period params, processes the JSON response into a pandas DataFrame, transforms the columns ('时间' for time and '多空比' for ratio), converts types, and returns CSV data.
    @mcp.tool(
        title="获取加密货币杠杆多空比",
        description="获取OKX加密货币借入计价货币与借入交易货币的累计数额比值",
    )
    def okx_loan_ratios(
        symbol: str = Field("BTC", description="币种,格式: BTC 或 ETH"),
        period: str = Field("1h", description="时间粒度,仅支持: [5m/1H/1D] 注意大小写,仅分钟为小写m"),
    ):
        res = requests.get(
            f"{OKX_BASE_URL}/api/v5/rubik/stat/margin/loan-ratio",
            params={
                "ccy": symbol,
                "period": period,
            },
            timeout=20,
        )
        data = res.json() or {}
        dfs = pd.DataFrame(data.get("data", []))
        if dfs.empty:
            return pd.DataFrame()
        dfs.columns = ["时间", "多空比"]
        dfs["时间"] = pd.to_datetime(dfs["时间"], errors="coerce", unit="ms")
        dfs["多空比"] = pd.to_numeric(dfs["多空比"], errors="coerce")
        return dfs.to_csv(index=False, float_format="%.2f").strip()
  • The tool is registered via the @mcp.tool() decorator on the okx_loan_ratios function, with title '获取加密货币杠杆多空比' and a description in Chinese.
    @mcp.tool(
        title="获取加密货币杠杆多空比",
        description="获取OKX加密货币借入计价货币与借入交易货币的累计数额比值",
  • The input schema definitions: 'symbol' (str, default 'BTC') and 'period' (str, default '1h', supported values: 5m/1H/1D) defined via Pydantic Field annotations.
    def okx_loan_ratios(
        symbol: str = Field("BTC", description="币种,格式: BTC 或 ETH"),
        period: str = Field("1h", description="时间粒度,仅支持: [5m/1H/1D] 注意大小写,仅分钟为小写m"),
  • The OKX_BASE_URL constant used by the handler, defaulting to 'https://www.okx.com' with override via environment variable.
    OKX_BASE_URL = os.getenv("OKX_BASE_URL") or "https://www.okx.com"
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It does not disclose behavioral traits such as whether the tool is read-only, rate limits, data freshness, or any side effects. The description merely states the data being fetched.

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 a single, concise sentence that directly conveys the tool's purpose. It could be slightly more structured, but there is no fluff or wasted words.

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 that there is no output schema, the description could explain what the returned ratio represents and its units. It adequately covers the input parameters but lacks detail on output and usage context.

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

Parameters3/5

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

Schema description coverage is 100%, with both parameters having detailed descriptions in the schema (symbol format and period valid values). The tool description adds no additional meaning beyond the schema, so it meets the baseline score.

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

Purpose5/5

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

The description clearly states that the tool obtains the ratio of cumulative borrowed quote currency to borrowed trade currency on OKX, which matches the title indicating leverage long/short ratios. It is specific to OKX and distinct from sibling tools like okx_prices or okx_taker_volume.

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 other similar tools such as okx_prices or okx_taker_volume. There is no mention of context, prerequisites, or alternatives.

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/aahl/mcp-aktools'

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