Skip to main content
Glama

market_tickers

Retrieve real-time cryptocurrency price data, trading volumes, and market rankings from OKX exchange to analyze market trends and make informed trading decisions.

Instructions

Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.Get the ranking of coins with the highest increase or the largest trading volume.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instTypeNoInstrument type: [SPOT/SWAP/FUTURES/OPTION]SPOT
instFamilyNoInstrument family。 Applicable to FUTURES/SWAP/OPTION
sortByNoSorting method: [change24h/changeMax/last/vol24h/...]change24h
limitNoNumber of results. Default: 30

Implementation Reference

  • The handler function for the 'market_tickers' tool. It retrieves ticker data from the OKX API, calculates 24h change and max change percentages, sorts the data based on the specified sortBy parameter, limits the results, adds a response schema description, and returns the processed response.
    def market_tickers( instType: str = Field("SPOT", description="Instrument type: [SPOT/SWAP/FUTURES/OPTION]"), instFamily: str = Field("", description="Instrument family。 Applicable to FUTURES/SWAP/OPTION"), sortBy: str = Field("change24h", description="Sorting method: [change24h/changeMax/last/vol24h/...]"), limit: int | str = Field(30, description="Number of results. Default: 30"), ): resp = ACCOUNT.get_tickers(instType=instType, instFamily=instFamily) or {} if int(resp.get("code", 0)): return resp data = resp.get("data", []) for item in data: try: item["change24h"] = round((float(item["last"]) - float(item["open24h"])) / float(item["open24h"]) * 100, 2) item["changeMax"] = round((float(item["high24h"]) - float(item["low24h"])) / float(item["low24h"]) * 100, 2) except Exception: continue data.sort(key=lambda x: float(x.get(sortBy) or 0), reverse=True) resp["data"] = data[:int(limit)] resp["_response_schema"] = """ instType String Instrument type instId String Instrument ID last String Last traded price lastSz String Last traded size. 0 represents there is no trading volume askPx String Best ask price askSz String Best ask size bidPx String Best bid price bidSz String Best bid size open24h String Open price in the past 24 hours high24h String Highest price in the past 24 hours low24h String Lowest price in the past 24 hours volCcy24h String 24h trading volume, with a unit of currency. If it is a derivatives contract, the value is the number of base currency. e.g. the unit is BTC for BTC-USD-SWAP and BTC-USDT-SWAP If it is SPOT/MARGIN, the value is the quantity in quote currency. vol24h String 24h trading volume, with a unit of contract. If it is a derivatives contract, the value is the number of contracts. If it is SPOT/MARGIN, the value is the quantity in base currency. sodUtc0 String Open price in the UTC 0 sodUtc8 String Open price in the UTC 8 change24h float Percentage change over 24 hours changeMax float 24-hour high and low percentage range """ return resp
  • Pydantic input schema and metadata (title, description) for the market_tickers tool, defining parameters like instType, instFamily, sortBy, limit with descriptions.
    @mcp.tool( title="Get market tickers", description="Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours." "Get the ranking of coins with the highest increase or the largest trading volume.", )
  • Registration of tools from account, trading, and market modules (including market_tickers) onto the FastMCP instance by calling their add_tools functions.
    account.add_tools(mcp) trading.add_tools(mcp) market.add_tools(mcp)

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-okx'

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