Skip to main content
Glama
al-one

MCP Server for stock and crypto

okx_loan_ratios

Calculate cumulative loan ratios for OKX cryptocurrency pairs to assess borrowing demand and market sentiment for informed trading decisions.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for 'okx_loan_ratios' tool. It fetches loan ratios data from OKX API for a given symbol and period, processes it into a pandas DataFrame with columns '时间' (time) and '多空比' (long/short ratio), and returns it as a CSV string. The @mcp.tool decorator also registers this function as a tool with title and description in Chinese, defining the input schema via Pydantic Field.
    @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()
  • Registration of the 'okx_loan_ratios' tool via FastMCP @mcp.tool decorator, including title, description, and input parameters schema.
    @mcp.tool( title="获取加密货币杠杆多空比",
  • Input schema for the tool: symbol (str, default 'BTC'), period (str, default '1h').
    symbol: str = Field("BTC", description="币种,格式: BTC 或 ETH"), period: str = Field("1h", description="时间粒度,仅支持: [5m/1H/1D] 注意大小写,仅分钟为小写m"), ):

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

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