Retrieves Level 1 market data (ticker information) for a specified trading symbol from the KuCoin API asynchronously.
Arguments
- base_url
Character string; base URL for the KuCoin API. Defaults to
get_base_url().- symbol
Character string; trading symbol (e.g.,
"BTC-USDT").
Value
Promise resolving to a data.table containing:
symbol(character): Trading symbol.timestamp(POSIXct): Snapshot timestamp in UTC.time_ms(integer): Snapshot timestamp in milliseconds.sequence(character): Update sequence identifier.price(character): Last traded price.size(character): Last traded size.bestBid(character): Best bid price.bestBidSize(character): Best bid size.bestAsk(character): Best ask price.bestAskSize(character): Best ask size.
Details
Workflow Overview
Query Construction: Builds a query string with the
symbolparameter usingbuild_query().URL Assembly: Combines
base_url,/api/v1/market/orderbook/level1, and the query string.HTTP Request: Sends a GET request with a 10-second timeout via
httr::GET().Response Processing: Validates the response with
process_kucoin_response()and extracts the"data"field.Data Conversion: Converts
"data"to adata.table, addssymbol, renamestimetotime_ms, and adds atimestampcolumn viatime_convert_from_kucoin().
Usage
Utilised to obtain real-time ticker data (e.g., best bid/ask, last price) for a trading symbol.
Examples
if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
ticker <- await(get_ticker_impl(symbol = "BTC-USDT"))
print(ticker)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }