Skip to contents

Fetches detailed financial metrics for a specific spot account from the KuCoin API asynchronously. This internal function is designed for use within an R6 class and is not intended for direct end-user consumption, using the account ID.

Usage

get_spot_account_detail_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  accountId,
  .__coro_env_parent__ = <environment>
)

Arguments

keys

List containing API configuration parameters from get_api_keys(), including:

  • api_key: Character string; your KuCoin API key.

  • api_secret: Character string; your KuCoin API secret.

  • api_passphrase: Character string; your KuCoin API passphrase.

  • key_version: Character string; API key version (e.g., "2"). Defaults to get_api_keys().

base_url

Character string representing the base URL for the API. Defaults to get_base_url().

accountId

Character string; unique account ID (e.g., from get_spot_account_detail_impl()).

Value

Promise resolving to a data.table containing:

  • currency (character): Currency of the account.

  • balance (numeric): Total funds.

  • available (numeric): Available funds.

  • holds (numeric): Funds on hold.

Details

Workflow Overview

  1. URL Construction: Combines the base URL (from get_base_url() or provided base_url) with /api/v1/accounts/{accountId}, embedding accountId.

  2. Header Preparation: Constructs authentication headers using build_headers().

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

  4. Response Processing: Processes the response with process_kucoin_response(), converts the "data" field into a data.table, and handles empty responses with a typed empty table.

API Endpoint

GET https://api.kucoin.com/api/v1/accounts/{accountId}

Usage

Utilised internally by KucoinAccountAndFunding to detail a specific spot account.

Official Documentation

KuCoin Get Account Detail Spot

Examples

if (FALSE) { # \dontrun{
keys <- get_api_keys()
base_url <- "https://api.kucoin.com"
accountId <- "123456789"
main_async <- coro::async(function() {
  dt <- await(get_spot_account_detail_impl(keys = keys, base_url = base_url, accountId = accountId))
  print(dt)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }