Retrieve Sub-Account Summary Information (Implementation)
Source:R/impl_account_sub_account.R
get_subaccount_list_summary_impl.RdRetrieves a paginated summary of sub-accounts from KuCoin asynchronously and aggregates the results into a single data.table. This internal function is designed for use within an R6 class and is not intended for direct end-user consumption. It converts millisecond timestamps in the createdAt column to human-readable POSIXct datetime objects where present.
Usage
get_subaccount_list_summary_impl(
keys = get_api_keys(),
base_url = get_base_url(),
page_size = 100,
max_pages = Inf,
.__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 toget_api_keys().
- base_url
Character string representing the base URL for the API. Defaults to
get_base_url().- page_size
Integer specifying the number of results per page (minimum 1, maximum 100). Defaults to 100.
- max_pages
Numeric specifying the maximum number of pages to fetch (defaults to
Inf, fetching all available pages).
Value
Promise resolving to a data.table containing aggregated sub-account summary information, including:
userId(character): Unique identifier of the master account.uid(integer): Unique identifier of the sub-account.subName(character): Sub-account name.status(integer): Current status of the sub-account.type(integer): Type of sub-account.access(character): Permission type granted (e.g.,"All","Spot","Futures","Margin").createdAt(integer): Timestamp of creation in milliseconds.createdDatetime(POSIXct): Converted human-readable datetime.remarks(character): Remarks or notes associated with the sub-account.tradeTypes(character): Separated by;, the trade types available to the sub-account (e.g."Spot;Futures;Margin").openedTradeTypes(character): Separated by;, the trade types currently open to the sub-account.hostedStatus(character): Hosted status of the sub-account.
Details
Workflow Overview
Pagination Initialisation: Begins by setting an initial query with
currentPage = 1and the specifiedpage_size.Page Fetching: Defines an asynchronous helper function (
fetch_page) to send a GET request for a given page, constructing the URL with current query parameters and authentication headers.Automatic Pagination: Leverages
auto_paginateto repeatedly callfetch_page, aggregating results until all pages are retrieved ormax_pagesis reached.Aggregation and Datetime Conversion: Combines responses into a
data.tableusingdata.table::rbindlist(), convertingcreatedAttimestamps to POSIXct in a newcreatedDatetimecolumn if present.
Usage
Utilised internally to provide a comprehensive summary of all sub-accounts associated with a KuCoin master account.
Official Documentation
KuCoin Get Sub-Account List Summary Info
Raw Response Schema:
code(string): Status code, where"200000"indicates success.data(object): Contains pagination metadata and anitemsarray with sub-account summary details.
Example JSON response:
{
"code": "200000",
"data": {
"currentPage": 1,
"pageSize": 10,
"totalNum": 1,
"totalPage": 1,
"items": [
{
"userId": "63743f07e0c5230001761d08",
"uid": 169579801,
"subName": "testapi6",
"status": 2,
"type": 0,
"access": "All",
"createdAt": 1668562696000,
"remarks": "remarks",
"tradeTypes": ["Spot", "Futures", "Margin"],
"openedTradeTypes": ["Spot"],
"hostedStatus": null
}
]
}
}Examples
if (FALSE) { # \dontrun{
keys <- get_api_keys()
base_url <- "https://api.kucoin.com"
main_async <- coro::async(function() {
dt_all <- await(get_subaccount_list_summary_impl(
keys = keys,
base_url = base_url
))
print(dt_all)
dt_partial <- await(get_subaccount_list_summary_impl(
keys = keys,
base_url = base_url,
page_size = 50,
max_pages = 3
))
print(dt_partial)
})
main_async()
while (!later::loop_empty()) later::run_now(timeoutSecs = Inf, all = TRUE)
} # }