Exchange Module
Exchange module handles operations related to exchange data retrieval.
To learn more about how to use the AI Agent SDK to interact with the wallet module, please visit AI Agent SDK Crypto.com Exchange.
8.1 Get All Tickers
Retrieves all available tickers from the Crypto.com Exchange (Chain agnostic).
Function Name
get_all_tickersExample Code
from crypto_com_developer_platform_client import Exchange tickers = Exchange.get_all_tickers() print(tickers)
Returns
A list of all available tickers and their information.Errors
ValueError: If the Exchange class is not initialized with a Client instance.Example Return
{'status': 'Success', 'data': [{'instrumentName': 'example-intrument-name', 'high': example-high, 'low': example-low, 'lastPrice': example-last-price, 'volume': example-volume, 'volumeValue': example-volume-value, 'priceChange': example-price-change, 'bestBid': example-best-bid, 'bestAsk': example-best-ask, 'openInterest': example-open-interest, 'timestamp': example-timestamp}, ...]}
Function Name
getAllTickersExample Code
import { Exchange } from '@crypto.com/developer-platform-client'; try { const tickers = await Exchange.getAllTickers(); console.log(tickers); } catch(err) { console.log(err); }
Returns
{Promise<ApiResponse<TickerResponse>>}: A promise that resolves to all available tickers.Errors
{Error}: Throws an error if the request fails.Example Return
{ status: 'Success', data: [ { instrumentName: example-name, high: example-high, low: example-low, lastPrice: example-last-price, volume: example-volume, volumeValue: example-volume-value, priceChange: example-price-change, bestBid: example-best-bit, bestAsk: example-best-ask, openInterest: example-open-interest, timestamp: example-timestamp } ... ] }
8.2 Get Ticker By Instrument
Retrieves ticker information for a specific trading instrument from the Crypto.com Exchange (Chain agnostic).
Function Name
get_ticker_by_instrumentArguments
instrument_name (str): The name of the instrument to get ticker information for.Example Code
from crypto_com_developer_platform_client import Exchange ticker = Exchange.get_ticker_by_instrument('example-instrument') print(ticker)
Returns
Ticker information for the specified instrument.Errors
ValueError: If instrument_name is None or empty.Example Return
{'status': 'Success', 'data': {'instrumentName': 'example-intrument-name', 'high': example-high, 'low': example-low, 'lastPrice': example-last-price, 'volume': example-volume, 'volumeValue': example-volume-value, 'priceChange': example-price-change, 'bestBid': example-best-bid, 'bestAsk': example-best-ask, 'openInterest': example-open-interest, 'timestamp': example-timestamp}}
Function Name
getTickerByInstrumentArguments
{string} instrumentName: The name of the trading instrument (e.g., 'BTC_USDT')Example Code
import { Exchange } from '@crypto.com/developer-platform-client'; try { const btcTicker = await Exchange.getTickerByInstrument('BTC_USDT'); console.log(btcTicker); } catch(err) { console.log(err); }
Returns
{Promise<ApiResponse<TickerData>>}: A promise that resolves to the ticker information.Errors
{Error}: Throws an error if the request fails.Example Return
{ status: 'Success', data: { instrumentName: example-name, high: example-high, low: example-low, lastPrice: example-last-price, volume: example-volume, volumeValue: example-volume-value, priceChange: example-price-change, bestBid: example-best-bid, bestAsk: example-best-ask, openInterest: example-open-interest, timestamp: example-timestamp } }
Last updated
Was this helpful?