or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

account-management.mdearn-products.mdindex.mdlending.mdmargin-trading.mdmarket-data.mdspot-trading.mdwebsocket.md

account-management.mddocs/

0

# Account Management

1

2

Comprehensive user account operations including balance management, transfers, deposits, withdrawals, sub-account management, and fee information. Provides complete access to account ledgers and transaction history.

3

4

## Capabilities

5

6

### Account Information

7

8

Access account balances and details.

9

10

```python { .api }

11

def get_account_list(currency: str = None, account_type: str = None):

12

"""

13

Get list of accounts.

14

15

Args:

16

currency (str, optional): Filter by currency

17

account_type (str, optional): Filter by account type ('main', 'trade', 'margin')

18

19

Returns:

20

list: Account information with balances

21

"""

22

23

def get_account(accountId: str):

24

"""

25

Get details for a specific account.

26

27

Args:

28

accountId (str): Account ID

29

30

Returns:

31

dict: Account details with balance information

32

"""

33

34

def create_account(account_type: str, currency: str):

35

"""

36

Create a new account.

37

38

Args:

39

account_type (str): Account type ('main', 'trade', 'margin')

40

currency (str): Currency code

41

42

Returns:

43

dict: Created account information

44

"""

45

46

def get_transferable(currency: str, account_type: str, **kwargs):

47

"""

48

Get transferable balance for an account.

49

50

Args:

51

currency (str): Currency code

52

account_type (str): Account type

53

54

Returns:

55

dict: Transferable balance information

56

"""

57

```

58

59

### Account History

60

61

Transaction history and ledger access.

62

63

```python { .api }

64

def get_account_ledger(**kwargs):

65

"""

66

Get account ledger (transaction history).

67

68

Args:

69

currency (str, optional): Filter by currency

70

direction (str, optional): Filter by direction ('in', 'out')

71

bizType (str, optional): Filter by business type

72

startAt (int, optional): Start time

73

endAt (int, optional): End time

74

currentPage (int, optional): Page number

75

pageSize (int, optional): Page size

76

77

Returns:

78

dict: Paginated ledger entries

79

"""

80

81

def get_account_hold(accountId: str, **kwargs):

82

"""

83

Get account holds (frozen funds).

84

85

Args:

86

accountId (str): Account ID

87

currentPage (int, optional): Page number

88

pageSize (int, optional): Page size

89

90

Returns:

91

dict: Account hold information

92

"""

93

```

94

95

### Internal Transfers

96

97

Transfer funds between accounts and users.

98

99

```python { .api }

100

def inner_transfer(currency: str, from_payer: str, to_payee: str, amount: str, clientOid: str = '', from_tag: str = None, to_tag: str = None):

101

"""

102

Transfer funds between accounts.

103

104

Args:

105

currency (str): Currency to transfer

106

from_payer (str): Source account type

107

to_payee (str): Destination account type

108

amount (str): Transfer amount

109

clientOid (str, optional): Client operation ID

110

from_tag (str, optional): Source tag for isolated margin

111

to_tag (str, optional): Destination tag for isolated margin

112

113

Returns:

114

dict: Transfer order ID

115

"""

116

117

def transfer_master_sub(currency: str, amount: str, direction: str, subUserId: str, clientOid: str = '', accountType: str = None, subAccountType: str = None):

118

"""

119

Transfer between master and sub-accounts.

120

121

Args:

122

currency (str): Currency to transfer

123

amount (str): Transfer amount

124

direction (str): Transfer direction ('OUT' master->sub, 'IN' sub->master)

125

subUserId (str): Sub-account user ID

126

clientOid (str, optional): Client operation ID

127

accountType (str, optional): Master account type

128

subAccountType (str, optional): Sub-account type

129

130

Returns:

131

dict: Transfer order ID

132

"""

133

134

def flex_transfer(clientOid: str, amount: str, fromAccountType: str, type: str, toAccountType: str, currency: str, fromUserId: str = None, fromAccountTag: str = None, toUserId: str = None, toAccountTag: str = None):

135

"""

136

Flexible transfer with advanced options.

137

138

Args:

139

clientOid (str): Client operation ID

140

amount (str): Transfer amount

141

fromAccountType (str): Source account type

142

type (str): Transfer type

143

toAccountType (str): Destination account type

144

currency (str): Currency to transfer

145

fromUserId (str, optional): Source user ID

146

fromAccountTag (str, optional): Source account tag

147

toUserId (str, optional): Destination user ID

148

toAccountTag (str, optional): Destination account tag

149

150

Returns:

151

dict: Transfer result

152

"""

153

```

154

155

### Deposits

156

157

Deposit address management and history.

158

159

```python { .api }

160

def create_deposit_address(currency: str, chain: str = None):

161

"""

162

Create a deposit address.

163

164

Args:

165

currency (str): Currency code

166

chain (str, optional): Blockchain network

167

168

Returns:

169

dict: Deposit address and memo/tag

170

"""

171

172

def get_deposit_address(currency: str, chain: str = None):

173

"""

174

Get deposit address.

175

176

Args:

177

currency (str): Currency code

178

chain (str, optional): Blockchain network

179

180

Returns:

181

dict: Deposit address information

182

"""

183

184

def get_deposit_addressv2(currency: str, chain: str = None):

185

"""

186

Get deposit addresses (v2 - supports multiple chains).

187

188

Args:

189

currency (str): Currency code

190

chain (str, optional): Specific blockchain network

191

192

Returns:

193

list: Deposit addresses for all or specified chains

194

"""

195

196

def get_deposit_list(**kwargs):

197

"""

198

Get deposit history.

199

200

Args:

201

currency (str, optional): Filter by currency

202

startAt (int, optional): Start time

203

endAt (int, optional): End time

204

status (str, optional): Deposit status

205

currentPage (int, optional): Page number

206

pageSize (int, optional): Page size

207

208

Returns:

209

dict: Paginated deposit history

210

"""

211

```

212

213

### Withdrawals

214

215

Withdrawal operations and history.

216

217

```python { .api }

218

def apply_withdrawal(currency: str, address: str, amount: float, **kwargs):

219

"""

220

Submit a withdrawal request.

221

222

Args:

223

currency (str): Currency to withdraw

224

address (str): Withdrawal address

225

amount (float): Withdrawal amount

226

memo (str, optional): Address memo/tag

227

isInner (bool, optional): Internal transfer flag

228

remark (str, optional): Withdrawal remark

229

chain (str, optional): Blockchain network

230

231

Returns:

232

dict: Withdrawal ID

233

"""

234

235

def cancel_withdrawal(withdrawalId: str):

236

"""

237

Cancel a pending withdrawal.

238

239

Args:

240

withdrawalId (str): Withdrawal ID to cancel

241

242

Returns:

243

dict: Cancellation result

244

"""

245

246

def get_withdrawal_list(**kwargs):

247

"""

248

Get withdrawal history.

249

250

Args:

251

currency (str, optional): Filter by currency

252

status (str, optional): Withdrawal status

253

startAt (int, optional): Start time

254

endAt (int, optional): End time

255

currentPage (int, optional): Page number

256

pageSize (int, optional): Page size

257

258

Returns:

259

dict: Paginated withdrawal history

260

"""

261

262

def get_withdrawal_quota(currency: str, chain: str = None):

263

"""

264

Get withdrawal quotas and limits.

265

266

Args:

267

currency (str): Currency code

268

chain (str, optional): Blockchain network

269

270

Returns:

271

dict: Withdrawal limits and available amounts

272

"""

273

```

274

275

### Sub-Account Management

276

277

Complete sub-account operations.

278

279

```python { .api }

280

def get_sub_user():

281

"""

282

Get list of sub-users.

283

284

Returns:

285

list: Sub-user information

286

"""

287

288

def create_sub_account(password: str, sub_name: str, access: str, **kwargs):

289

"""

290

Create a new sub-account.

291

292

Args:

293

password (str): Sub-account password (7-24 chars, letters+numbers)

294

sub_name (str): Sub-account name (7-32 chars, at least one number and letter)

295

access (str): Permission types ('Spot', 'Futures', 'Margin')

296

remarks (str, optional): Sub-account remarks

297

298

Returns:

299

dict: Created sub-account information

300

"""

301

302

def get_sub_account(subUserId: str):

303

"""

304

Get sub-account balance details.

305

306

Args:

307

subUserId (str): Sub-user ID

308

309

Returns:

310

dict: Sub-account balances across all account types

311

"""

312

313

def get_sub_accounts():

314

"""

315

Get aggregated balance of all sub-accounts.

316

317

Returns:

318

list: All sub-account balance information

319

"""

320

```

321

322

### Sub-Account API Management

323

324

API key management for sub-accounts.

325

326

```python { .api }

327

def get_sub_account_api_list(sub_name: str, **kwargs):

328

"""

329

Get sub-account API key list.

330

331

Args:

332

sub_name (str): Sub-account name

333

apiKey (str, optional): Filter by API key

334

335

Returns:

336

dict: API key information

337

"""

338

339

def create_apis_for_sub_account(sub_name: str, passphrase: str, remark: str, **kwargs):

340

"""

341

Create API keys for sub-account.

342

343

Args:

344

sub_name (str): Sub-account name

345

passphrase (str): API key passphrase (7-32 chars)

346

remark (str): API key remark (1-24 chars)

347

permission (str, optional): Permission level

348

ipWhitelist (str, optional): IP whitelist

349

expire (int, optional): Expiration time

350

351

Returns:

352

dict: Created API key details

353

"""

354

355

def modify_sub_account_apis(sub_name: str, api_key: str, passphrase: str, **kwargs):

356

"""

357

Modify sub-account API key settings.

358

359

Args:

360

sub_name (str): Sub-account name

361

api_key (str): API key to modify

362

passphrase (str): API key passphrase

363

permission (str, optional): New permission level

364

ipWhitelist (str, optional): New IP whitelist

365

expire (int, optional): New expiration time

366

367

Returns:

368

dict: Modified API key information

369

"""

370

371

def delete_sub_account_apis(sub_name: str, api_key: str, passphrase: str):

372

"""

373

Delete sub-account API key.

374

375

Args:

376

sub_name (str): Sub-account name

377

api_key (str): API key to delete

378

passphrase (str): API key passphrase

379

380

Returns:

381

dict: Deletion confirmation

382

"""

383

```

384

385

### Fee Information

386

387

Trading fee rates and calculations.

388

389

```python { .api }

390

def get_actual_fee(symbols: str):

391

"""

392

Get actual trading fee rates for symbols.

393

394

Args:

395

symbols (str): Comma-separated symbol list

396

397

Returns:

398

dict: Fee rates for each symbol

399

"""

400

401

def get_base_fee():

402

"""

403

Get base user trading fee rates.

404

405

Returns:

406

dict: Base maker and taker fee rates

407

"""

408

```

409

410

### High-Frequency Account

411

412

Specialized high-frequency trading account operations.

413

414

```python { .api }

415

def get_hf_account_ledgers(**kwargs):

416

"""

417

Get high-frequency account ledger.

418

419

Args:

420

currency (str, optional): Filter by currency

421

direction (str, optional): Filter by direction

422

bizType (str, optional): Filter by business type

423

lastId (str, optional): Last record ID for pagination

424

limit (int, optional): Number of records

425

startAt (int, optional): Start time

426

endAt (int, optional): End time

427

428

Returns:

429

list: HF account ledger entries

430

"""

431

432

def transfer_to_hf_account(client_oid: str, currency: str, from_payer: str, amount: str):

433

"""

434

Transfer funds to high-frequency trading account.

435

436

Args:

437

client_oid (str): Client operation ID

438

currency (str): Currency to transfer

439

from_payer (str): Source account type

440

amount (str): Transfer amount

441

442

Returns:

443

list: HF account information after transfer

444

"""

445

```

446

447

## Usage Examples

448

449

### Account Balance Management

450

451

```python

452

from kucoin.client import User

453

454

# Initialize user client

455

user = User(api_key, api_secret, api_passphrase, is_sandbox=False)

456

457

# Get all account balances

458

accounts = user.get_account_list()

459

for account in accounts:

460

if float(account['balance']) > 0:

461

print(f"{account['currency']}: {account['balance']} ({account['type']})")

462

463

# Get specific currency balance

464

btc_accounts = user.get_account_list(currency='BTC')

465

print(f"BTC Accounts: {len(btc_accounts)}")

466

```

467

468

### Internal Transfers

469

470

```python

471

# Transfer from main to trading account

472

transfer_result = user.inner_transfer(

473

currency='USDT',

474

from_payer='main',

475

to_payee='trade',

476

amount='100'

477

)

478

print(f"Transfer order: {transfer_result['orderId']}")

479

480

# Check account balances after transfer

481

trade_account = user.get_account_list(currency='USDT', account_type='trade')[0]

482

print(f"Trade account balance: {trade_account['balance']} USDT")

483

```

484

485

### Deposit Management

486

487

```python

488

# Create deposit address for Bitcoin

489

btc_deposit = user.create_deposit_address('BTC')

490

print(f"BTC Deposit Address: {btc_deposit['address']}")

491

492

# Get deposit history

493

deposits = user.get_deposit_list(currency='BTC', status='SUCCESS')

494

for deposit in deposits['items']:

495

print(f"Deposit: {deposit['amount']} BTC from {deposit['walletTxId']}")

496

```

497

498

### Withdrawal Operations

499

500

```python

501

# Check withdrawal quotas

502

quota = user.get_withdrawal_quota('BTC')

503

print(f"Available for withdrawal: {quota['availableAmount']} BTC")

504

print(f"Minimum withdrawal: {quota['withdrawMinSize']} BTC")

505

506

# Submit withdrawal (be very careful with real addresses!)

507

withdrawal = user.apply_withdrawal(

508

currency='BTC',

509

address='1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', # Example address - DO NOT USE

510

amount=0.001,

511

remark='Test withdrawal'

512

)

513

print(f"Withdrawal submitted: {withdrawal['withdrawalId']}")

514

```

515

516

### Sub-Account Management

517

518

```python

519

# Create a new sub-account

520

sub_account = user.create_sub_account(

521

password='SecurePass123',

522

sub_name='trading-bot-01',

523

access='Spot',

524

remarks='Automated trading bot'

525

)

526

print(f"Created sub-account: {sub_account['subName']}")

527

528

# Get sub-account balances

529

sub_balance = user.get_sub_account(sub_account['uid'])

530

print(f"Sub-account main balance: {sub_balance['mainAccounts']}")

531

532

# Create API keys for sub-account

533

api_keys = user.create_apis_for_sub_account(

534

sub_name='trading-bot-01',

535

passphrase='APIPassphrase123',

536

remark='Bot API keys',

537

permission='General'

538

)

539

print(f"API Key: {api_keys['apiKey']}")

540

```

541

542

## Types

543

544

```python { .api }

545

AccountInfo = dict

546

# {

547

# "id": str, # Account ID

548

# "currency": str, # Currency code

549

# "type": str, # Account type

550

# "balance": str, # Total balance

551

# "available": str, # Available balance

552

# "holds": str # Held balance

553

# }

554

555

LedgerEntry = dict

556

# {

557

# "id": str, # Entry ID

558

# "currency": str, # Currency

559

# "amount": str, # Change amount

560

# "fee": str, # Fee amount

561

# "balance": str, # Balance after change

562

# "bizType": str, # Business type

563

# "direction": str, # Direction ('in' or 'out')

564

# "createdAt": int, # Timestamp

565

# "context": dict # Business context

566

# }

567

568

DepositInfo = dict

569

# {

570

# "address": str, # Deposit address

571

# "memo": str, # Address memo/tag

572

# "amount": float, # Deposit amount

573

# "fee": float, # Deposit fee

574

# "currency": str, # Currency

575

# "isInner": bool, # Internal deposit flag

576

# "walletTxId": str, # Wallet transaction ID

577

# "status": str, # Deposit status

578

# "remark": str, # Deposit remark

579

# "createdAt": int, # Creation time

580

# "updatedAt": int # Update time

581

# }

582

583

WithdrawalInfo = dict

584

# {

585

# "id": str, # Withdrawal ID

586

# "address": str, # Withdrawal address

587

# "memo": str, # Address memo

588

# "currency": str, # Currency

589

# "amount": float, # Withdrawal amount

590

# "fee": float, # Withdrawal fee

591

# "walletTxId": str, # Wallet transaction ID

592

# "isInner": bool, # Internal withdrawal flag

593

# "status": str, # Withdrawal status

594

# "remark": str, # Withdrawal remark

595

# "createdAt": int, # Creation time

596

# "updatedAt": int # Update time

597

# }

598

599

SubAccountInfo = dict

600

# {

601

# "userId": str, # Sub-user ID

602

# "subName": str, # Sub-account name

603

# "remarks": str, # Sub-account remarks

604

# "mainAccounts": list, # Main account balances

605

# "tradeAccounts": list, # Trade account balances

606

# "marginAccounts": list # Margin account balances

607

# }

608

```