Skip to contents

Retrieves Level 1 market data (ticker information) for a specified trading symbol from the KuCoin API asynchronously.

Usage

get_ticker_impl(
  base_url = get_base_url(),
  symbol,
  .__coro_env_parent__ = <environment>
)

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

  1. Query Construction: Builds a query string with the symbol parameter using build_query().

  2. URL Assembly: Combines base_url, /api/v1/market/orderbook/level1, and the query string.

  3. HTTP Request: Sends a GET request with a 10-second timeout via httr::GET().

  4. Response Processing: Validates the response with process_kucoin_response() and extracts the "data" field.

  5. Data Conversion: Converts "data" to a data.table, adds symbol, renames time to time_ms, and adds a timestamp column via time_convert_from_kucoin().

API Endpoint

GET https://api.kucoin.com/api/v1/market/orderbook/level1

Usage

Utilised to obtain real-time ticker data (e.g., best bid/ask, last price) for a trading symbol.

Official Documentation

KuCoin Get Ticker

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()
} # }