KucoinTransfer: Internal Transfer Management
KucoinTransfer: Internal Transfer Management
Details
Provides methods for transferring funds between KuCoin accounts (main, trade, margin, etc.) and between master and sub-accounts. Inherits from KucoinBase.
Purpose and Scope
Fund Movement: Transfer funds between account types (e.g., main → trade) so that deposited funds can be used for HF spot trading.
Sub-Account Funding: Move funds between master and sub-accounts.
Balance Queries: Check how much of a currency is available for transfer from a specific account type.
Usage
All methods require authentication (valid API key, secret, passphrase).
The API key must have FlexTransfers (universal transfer) permission for
add_transfer(). The get_transferable() method requires only General permission.
# Synchronous usage
transfer <- KucoinTransfer$new()
balance <- transfer$get_transferable(currency = "USDT", type = "MAIN")
# Asynchronous usage
transfer_async <- KucoinTransfer$new(async = TRUE)
coro::async(function() {
balance <- await(transfer_async$get_transferable(currency = "USDT", type = "MAIN"))
print(balance)
})()Account Types
KuCoin uses separate accounts for different purposes:
"MAIN": Funding account — deposits land here by default."TRADE": Spot trading account — required for HF orders."MARGIN": Cross-margin account."ISOLATED": Isolated-margin account (requiresfromAccountTag/toAccountTagfor symbol)."CONTRACT": Futures account.
Transfer Types
"INTERNAL": Between your own accounts (e.g., MAIN → TRADE)."PARENT_TO_SUB": From master to sub-account."SUB_TO_PARENT": From sub-account to master.
Super class
kucoin::KucoinBase -> KucoinTransfer
Methods
Inherited methods
Method add_transfer()
Add Transfer (Universal)
Transfers funds between account types within your own KuCoin account, or between master and sub-accounts. This is essential for trading bots because deposits land in the main account, but HF spot orders require funds in the trade account.
Workflow
Build Body: Constructs JSON body with required transfer parameters.
Request: Authenticated POST to the universal transfer endpoint.
Parsing: Returns
data.tablewith the transfer order ID.
Automated Trading Usage
Bot Startup: Transfer deposited funds from MAIN to TRADE before placing orders.
Profit Harvesting: Move profits from TRADE to MAIN before withdrawing.
Sub-Account Funding: Distribute funds to sub-accounts running independent strategies.
Idempotency: Use
clientOid(UUID) to prevent duplicate transfers on retry.
curl
curl --location --request POST 'https://api.kucoin.com/api/v3/accounts/universal-transfer' \
--header 'Content-Type: application/json' \
--header 'KC-API-KEY: your-api-key' \
--header 'KC-API-SIGN: your-signature' \
--header 'KC-API-TIMESTAMP: 1729176273859' \
--header 'KC-API-PASSPHRASE: your-passphrase' \
--header 'KC-API-KEY-VERSION: 2' \
--data-raw '{"clientOid":"64ccc0f164781800010d8c09","currency":"USDT","amount":"10","type":"INTERNAL","fromAccountType":"MAIN","toAccountType":"TRADE"}'Usage
KucoinTransfer$add_transfer(
clientOid,
currency,
amount,
type,
fromAccountType,
toAccountType,
fromUserId = NULL,
fromAccountTag = NULL,
toUserId = NULL,
toAccountTag = NULL
)Arguments
clientOidCharacter; unique client order ID for idempotency (max 128 bits, e.g., UUID).
currencyCharacter; currency code (e.g.,
"BTC","USDT").amountCharacter; transfer amount (positive, multiple of currency precision).
typeCharacter; transfer type:
"INTERNAL","PARENT_TO_SUB", or"SUB_TO_PARENT".fromAccountTypeCharacter; source account type:
"MAIN","TRADE","CONTRACT","MARGIN","ISOLATED","MARGIN_V2","ISOLATED_V2".toAccountTypeCharacter; destination account type (same options as
fromAccountType).fromUserIdCharacter or NULL; source user ID (required for
"SUB_TO_PARENT"transfers).fromAccountTagCharacter or NULL; symbol for ISOLATED/ISOLATED_V2 source accounts (e.g.,
"BTC-USDT").toUserIdCharacter or NULL; destination user ID (required for
"PARENT_TO_SUB"transfers).toAccountTagCharacter or NULL; symbol for ISOLATED/ISOLATED_V2 destination accounts (e.g.,
"BTC-USDT").
Returns
data.table (or promise<data.table> if constructed with async = TRUE) with columns:
order_id(character): The transfer order identifier.
Examples
\dontrun{
transfer <- KucoinTransfer$new()
# Move USDT from main to trade account for spot trading
result <- transfer$add_transfer(
clientOid = "64ccc0f164781800010d8c09",
currency = "USDT",
amount = "100",
type = "INTERNAL",
fromAccountType = "MAIN",
toAccountType = "TRADE"
)
print(result$order_id)
# Transfer BTC from master to sub-account
result <- transfer$add_transfer(
clientOid = "unique-uuid-here",
currency = "BTC",
amount = "0.01",
type = "PARENT_TO_SUB",
fromAccountType = "MAIN",
toAccountType = "MAIN",
toUserId = "sub-user-id-here"
)
}
Method get_transferable()
Get Transferable Balance
Retrieves the amount of a currency that is available for transfer out of a
specific account type. Use this before calling add_transfer() to verify
sufficient funds are available.
Workflow
Request: Authenticated GET with
currencyandtype(required) and optionaltagquery parameters.Parsing: Returns a
data.tablewith balance breakdown.
Automated Trading Usage
Pre-Flight Check: Verify
transferableamount before initiating a transfer.Balance Awareness: Monitor
holdsto understand how much is locked in open orders.Fund Routing: Check transferable amounts across account types to optimise fund allocation.
curl
curl --location --request GET \
'https://api.kucoin.com/api/v1/accounts/transferable?currency=USDT&type=MAIN' \
--header 'KC-API-KEY: your-api-key' \
--header 'KC-API-SIGN: your-signature' \
--header 'KC-API-TIMESTAMP: 1729176273859' \
--header 'KC-API-PASSPHRASE: your-passphrase' \
--header 'KC-API-KEY-VERSION: 2'Arguments
currencyCharacter; currency code (e.g.,
"BTC","USDT").typeCharacter; account type:
"MAIN","TRADE","MARGIN","ISOLATED","MARGIN_V2","ISOLATED_V2".tagCharacter or NULL; trading pair symbol required for
"ISOLATED"account type (e.g.,"BTC-USDT").
Returns
data.table (or promise<data.table> if constructed with async = TRUE) with columns:
currency(character): Currency code.balance(character): Total funds in the account.available(character): Funds available to withdraw or trade.holds(character): Funds on hold (locked in open orders).transferable(character): Funds available for transfer.
Examples
\dontrun{
transfer <- KucoinTransfer$new()
# Check transferable USDT in main account
balance <- transfer$get_transferable(currency = "USDT", type = "MAIN")
print(balance[, .(currency, balance, transferable)])
# Check transferable BTC in trade account
trade_bal <- transfer$get_transferable(currency = "BTC", type = "TRADE")
print(trade_bal$transferable)
}
Examples
if (FALSE) { # \dontrun{
# Synchronous
transfer <- KucoinTransfer$new()
balance <- transfer$get_transferable(currency = "USDT", type = "MAIN")
print(balance)
# Asynchronous
transfer_async <- KucoinTransfer$new(async = TRUE)
main <- coro::async(function() {
balance <- await(transfer_async$get_transferable(currency = "USDT", type = "MAIN"))
print(balance)
})
main()
while (!later::loop_empty()) later::run_now()
} # }
## ------------------------------------------------
## Method `KucoinTransfer$add_transfer`
## ------------------------------------------------
if (FALSE) { # \dontrun{
transfer <- KucoinTransfer$new()
# Move USDT from main to trade account for spot trading
result <- transfer$add_transfer(
clientOid = "64ccc0f164781800010d8c09",
currency = "USDT",
amount = "100",
type = "INTERNAL",
fromAccountType = "MAIN",
toAccountType = "TRADE"
)
print(result$order_id)
# Transfer BTC from master to sub-account
result <- transfer$add_transfer(
clientOid = "unique-uuid-here",
currency = "BTC",
amount = "0.01",
type = "PARENT_TO_SUB",
fromAccountType = "MAIN",
toAccountType = "MAIN",
toUserId = "sub-user-id-here"
)
} # }
## ------------------------------------------------
## Method `KucoinTransfer$get_transferable`
## ------------------------------------------------
if (FALSE) { # \dontrun{
transfer <- KucoinTransfer$new()
# Check transferable USDT in main account
balance <- transfer$get_transferable(currency = "USDT", type = "MAIN")
print(balance[, .(currency, balance, transferable)])
# Check transferable BTC in trade account
trade_bal <- transfer$get_transferable(currency = "BTC", type = "TRADE")
print(trade_bal$transferable)
} # }