forked from nntaoli-project/goex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kucoin.go
793 lines (676 loc) · 19 KB
/
kucoin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
package kucoin
import (
"time"
"github.com/Kucoin/kucoin-go-sdk"
. "github.com/puper/goex"
log "github.com/puper/goex/internal/logger"
)
func New(apiKey, apiSecret, apiPassphrase string) *KuCoin {
return NewWithConfig(&APIConfig{
Endpoint: "https://api.kucoin.com",
ApiKey: apiKey,
ApiSecretKey: apiSecret,
ApiPassphrase: apiPassphrase,
})
}
func NewWithConfig(config *APIConfig) *KuCoin {
if config.Endpoint == "" {
config.Endpoint = "https://api.kucoin.com"
}
kc := &KuCoin{
baseUrl: config.Endpoint,
apiKey: config.ApiKey,
apiSecret: config.ApiSecretKey,
apiPassphrase: config.ApiPassphrase,
}
kc.service = kucoin.NewApiService(
kucoin.ApiBaseURIOption(kc.baseUrl),
kucoin.ApiKeyOption(kc.apiKey),
kucoin.ApiSecretOption(kc.apiSecret),
kucoin.ApiPassPhraseOption(kc.apiPassphrase),
)
return kc
}
type KuCoin struct {
apiKey string
apiSecret string
baseUrl string
apiPassphrase string
service *kucoin.ApiService
}
var inernalKlinePeriodConverter = map[KlinePeriod]string{
KLINE_PERIOD_1MIN: "1min",
KLINE_PERIOD_3MIN: "3min",
KLINE_PERIOD_5MIN: "5min",
KLINE_PERIOD_15MIN: "15min",
KLINE_PERIOD_30MIN: "30min",
KLINE_PERIOD_60MIN: "1hour",
KLINE_PERIOD_1H: "1hour",
KLINE_PERIOD_2H: "2hour",
KLINE_PERIOD_4H: "4hour",
KLINE_PERIOD_6H: "6hour",
KLINE_PERIOD_8H: "8hour",
KLINE_PERIOD_12H: "12hour",
KLINE_PERIOD_1DAY: "1day",
KLINE_PERIOD_1WEEK: "1week",
}
func (kc *KuCoin) GetExchangeName() string {
return KUCOIN
}
func (kc *KuCoin) GetTicker(currency CurrencyPair) (*Ticker, error) {
resp, err := kc.service.TickerLevel1(currency.ToSymbol("-"))
if err != nil {
log.Error("KuCoin GetTicker error:", err)
return nil, err
}
var model kucoin.TickerLevel1Model
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetTicker error:", err)
return nil, err
}
var ticker Ticker
ticker.Pair = currency
ticker.Date = uint64(model.Time / 1000)
ticker.Last = ToFloat64(model.Price)
ticker.Buy = ToFloat64(model.BestBid)
ticker.Sell = ToFloat64(model.BestAsk)
return &ticker, nil
}
func (kc *KuCoin) LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error) {
clientID := GenerateOrderClientId(32)
in := kucoin.CreateOrderModel{
ClientOid: clientID,
Side: "buy",
Symbol: currency.ToSymbol("-"),
Type: "limit",
Price: price,
Size: amount,
}
resp, err := kc.service.CreateOrder(&in)
if err != nil {
log.Error("KuCoin LimitBuy error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin LimitBuy error:", err)
return nil, err
}
var order Order
order.OrderID2 = model.Id
order.Cid = clientID
return &order, nil
}
func (kc *KuCoin) LimitSell(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error) {
clientID := GenerateOrderClientId(32)
in := kucoin.CreateOrderModel{
ClientOid: clientID,
Side: "sell",
Symbol: currency.ToSymbol("-"),
Type: "limit",
Price: price,
Size: amount,
}
resp, err := kc.service.CreateOrder(&in)
if err != nil {
log.Error("KuCoin LimitSell error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin LimitSell error:", err)
return nil, err
}
var order Order
order.OrderID2 = model.Id
order.Cid = clientID
return &order, nil
}
func (kc *KuCoin) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error) {
clientID := GenerateOrderClientId(32)
in := kucoin.CreateOrderModel{
ClientOid: clientID,
Side: "buy",
Symbol: currency.ToSymbol("-"),
Type: "market",
Price: price,
Size: amount,
}
resp, err := kc.service.CreateOrder(&in)
if err != nil {
log.Error("KuCoin MarketBuy error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin MarketBuy error:", err)
return nil, err
}
var order Order
order.OrderID2 = model.Id
order.Cid = clientID
return &order, nil
}
func (kc *KuCoin) MarketSell(amount, price string, currency CurrencyPair) (*Order, error) {
clientID := GenerateOrderClientId(32)
in := kucoin.CreateOrderModel{
ClientOid: clientID,
Side: "sell",
Symbol: currency.ToSymbol("-"),
Type: "market",
Price: price,
Size: amount,
}
resp, err := kc.service.CreateOrder(&in)
if err != nil {
log.Error("KuCoin MarketSell error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin MarketSell error:", err)
return nil, err
}
var order Order
order.OrderID2 = model.Id
order.Cid = clientID
return &order, nil
}
func (kc *KuCoin) CancelOrder(orderId string, currency CurrencyPair) (bool, error) {
var resp *kucoin.ApiResponse
var err error
if orderId != "" {
resp, err = kc.service.CancelOrder(orderId)
} else {
resp, err = kc.service.CancelOrder(currency.ToSymbol("-"))
}
if err != nil {
log.Error("KuCoin CancelOrder error:", err)
return false, err
}
var model kucoin.CancelOrderResultModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin CancelOrder error:", err)
return false, err
}
return true, nil
}
func (kc *KuCoin) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error) {
resp, err := kc.service.Order(orderId)
if err != nil {
log.Error("KuCoin GetOneOrder error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetOneOrder error:", err)
return nil, err
}
var order Order
order.Price = ToFloat64(model.Price)
order.Amount = ToFloat64(model.Size)
order.AvgPrice = ToFloat64(model.DealFunds) / ToFloat64(model.DealSize)
order.DealAmount = ToFloat64(model.DealSize)
order.Fee = ToFloat64(model.Fee)
order.Cid = model.ClientOid
order.OrderID2 = model.Id
order.OrderTime = int(model.CreatedAt / 1000)
order.Type = model.Type
order.Currency = NewCurrencyPair3(model.Symbol, "-")
if model.Side == "buy" {
if model.Type == "limit" {
order.Side = BUY
} else {
order.Side = BUY_MARKET
}
} else {
if model.Type == "limit" {
order.Side = SELL
} else {
order.Side = SELL_MARKET
}
}
if model.CancelExist {
if model.DealSize == "0" {
order.Status = ORDER_UNFINISH
} else {
order.Status = ORDER_PART_FINISH
}
} else {
if model.DealSize == "0" {
order.Status = ORDER_CANCEL
} else if model.DealSize == model.Side {
order.Status = ORDER_FINISH
}
}
return &order, nil
}
func (kc *KuCoin) GetUnfinishOrders(currency CurrencyPair) ([]Order, error) {
params := map[string]string{
"status": "active",
"symbol": currency.ToSymbol("-"),
}
resp, err := kc.service.Orders(params, nil)
if err != nil {
log.Error("KuCoin GetUnfinishOrders error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetUnfinishOrders error:", err)
return nil, err
}
var orders []Order
return orders, nil
}
func (kc *KuCoin) GetOrderHistorys(currency CurrencyPair, optional ...OptionalParameter) ([]Order, error) {
params := map[string]string{
"status": "done",
"symbol": currency.ToSymbol("-"),
}
pagination := kucoin.PaginationParam{}
if len(optional) > 0 {
pagination.CurrentPage = ToInt64(optional[0]["currentPage"])
pagination.PageSize = ToInt64(optional[0]["pageSize"])
}
resp, err := kc.service.Orders(params, &pagination)
if err != nil {
log.Error("KuCoin GetOrderHistorys error:", err)
return nil, err
}
var model kucoin.OrderModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetOrderHistorys error:", err)
return nil, err
}
var orders []Order
return orders, nil
}
func (kc *KuCoin) GetAccount() (*Account, error) {
accs, err := kc.Accounts("", "")
if err != nil {
log.Error("KuCoin GetAccount error:", err)
return nil, err
}
account := Account{}
account.Exchange = kc.GetExchangeName()
account.SubAccounts = make(map[Currency]SubAccount)
for _, v := range accs {
currency := NewCurrency(v.Currency, "").AdaptBccToBch()
// KuCoin同一币种可能有多种账户类型
if sub, exist := account.SubAccounts[currency]; !exist {
account.SubAccounts[currency] = SubAccount{
Currency: currency,
Amount: ToFloat64(v.Available),
ForzenAmount: ToFloat64(v.Holds),
}
} else {
account.SubAccounts[currency] = SubAccount{
Currency: currency,
Amount: sub.Amount + ToFloat64(v.Available),
ForzenAmount: sub.ForzenAmount + ToFloat64(v.Holds),
}
}
}
return &account, nil
}
func (kc *KuCoin) GetDepth(size int, currency CurrencyPair) (*Depth, error) {
dep := 20
if size > 20 {
dep = 100
}
resp, err := kc.service.AggregatedPartOrderBook(currency.ToSymbol("-"), int64(dep))
if err != nil {
log.Error("KuCoin GetDepth error:", err)
return nil, err
}
var model kucoin.PartOrderBookModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetDepth error:", err)
return nil, err
}
var depth Depth
depth.Pair = currency
depth.UTime = time.Now()
for i, ask := range model.Asks {
if i < size {
depth.AskList = append(depth.AskList, DepthRecord{
Price: ToFloat64(ask[0]),
Amount: ToFloat64(ask[1]),
})
}
}
for j, bid := range model.Bids {
if j < size {
depth.BidList = append(depth.BidList, DepthRecord{
Price: ToFloat64(bid[0]),
Amount: ToFloat64(bid[1]),
})
}
}
return &depth, nil
}
func (kc *KuCoin) GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error) {
resp, err := kc.service.KLines(currency.ToSymbol("-"), inernalKlinePeriodConverter[period], 0, 0)
if err != nil {
log.Error("KuCoin GetKlineRecords error:", err)
return nil, err
}
var model kucoin.KLinesModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetKlineRecords error:", err)
return nil, err
}
var kLines []Kline
for i, item := range model {
if i < size {
kLines = append(kLines, Kline{
Pair: currency,
Timestamp: ToInt64((*item)[0]),
Open: ToFloat64((*item)[1]),
Close: ToFloat64((*item)[2]),
High: ToFloat64((*item)[3]),
Low: ToFloat64((*item)[4]),
Vol: ToFloat64((*item)[6]),
})
}
}
return kLines, nil
}
func (kc *KuCoin) GetTrades(currency CurrencyPair, since int64) ([]Trade, error) {
resp, err := kc.service.TradeHistories(currency.ToSymbol("-"))
if err != nil {
log.Error("KuCoin GetTrades error:", err)
return nil, err
}
var model kucoin.TradeHistoriesModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin GetTrades error:", err)
return nil, err
}
var trades []Trade
for _, item := range model {
typo := BUY
if (*item).Side == "sell" {
typo = SELL
}
trades = append(trades, Trade{
Pair: currency,
Tid: ToInt64((*item).Sequence),
Type: typo,
Amount: ToFloat64((*item).Size),
Price: ToFloat64((*item).Price),
Date: ToInt64((*item).Time / 1000),
})
}
return trades, nil
}
// Account
// Accounts returns a list of accounts.
func (kc *KuCoin) Accounts(currency, typo string) (kucoin.AccountsModel, error) {
resp, err := kc.service.Accounts(currency, typo)
if err != nil {
log.Error("KuCoin Accounts error:", err)
return nil, err
}
var model kucoin.AccountsModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin Accounts error:", err)
return nil, err
}
return model, nil
}
// Account returns an account when you know the accountId.
func (kc *KuCoin) Account(accountId string) (*kucoin.AccountModel, error) {
resp, err := kc.service.Account(accountId)
if err != nil {
log.Error("KuCoin Accounts error:", err)
return nil, err
}
var model *kucoin.AccountModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin Accounts error:", err)
return nil, err
}
return model, nil
}
// SubAccountUsers returns a list of sub-account user.
func (kc *KuCoin) SubAccountUsers() (kucoin.SubAccountUsersModel, error) {
resp, err := kc.service.SubAccountUsers()
if err != nil {
log.Error("KuCoin SubAccountUsers error:", err)
return nil, err
}
var model kucoin.SubAccountUsersModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin SubAccountUsers error:", err)
return nil, err
}
return model, nil
}
// SubAccounts returns the aggregated balance of all sub-accounts of the current user.
func (kc *KuCoin) SubAccounts() (kucoin.SubAccountsModel, error) {
resp, err := kc.service.SubAccounts()
if err != nil {
log.Error("KuCoin SubAccounts error:", err)
return nil, err
}
var model kucoin.SubAccountsModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin SubAccounts error:", err)
return nil, err
}
return model, nil
}
// SubAccount returns the detail of a sub-account.
func (kc *KuCoin) SubAccount(subUserId string) (*kucoin.SubAccountModel, error) {
resp, err := kc.service.SubAccount(subUserId)
if err != nil {
log.Error("KuCoin SubAccount error:", err)
return nil, err
}
var model *kucoin.SubAccountModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin SubAccount error:", err)
return nil, err
}
return model, nil
}
// CreateAccount creates an account according to type(main|trade) and currency
// Parameter #1 typo is type of account.
func (kc *KuCoin) CreateAccount(typo, currency string) (*kucoin.AccountModel, error) {
resp, err := kc.service.CreateAccount(typo, currency)
if err != nil {
log.Error("KuCoin CreateAccount error:", err)
return nil, err
}
var model *kucoin.AccountModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin CreateAccount error:", err)
return nil, err
}
return model, nil
}
// The inner transfer interface is used for transferring assets between the accounts of a user and is free of charges.
// For example, a user could transfer assets from their main account to their trading account on the platform.
func (kc *KuCoin) InnerTransfer(currency, from, to, amount string) (string, error) {
resp, err := kc.service.InnerTransferV2(GenerateOrderClientId(32), currency, from, to, amount)
if err != nil {
log.Error("KuCoin InnerTransfer error:", err)
return "", err
}
var model *kucoin.InnerTransferResultModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin InnerTransfer error:", err)
return "", err
}
return model.OrderId, nil
}
// SubTransfer transfers between master account and sub-account.
func (kc *KuCoin) SubTransfer(currency, amount, direction, subUserId, accountType, subAccountType string) (string, error) {
params := map[string]string{
"clientOid": GenerateOrderClientId(32),
"currency": currency,
"amount": amount,
"direction": direction, // IN or OUT
"subUserId": subUserId, // the user ID of a sub-account
"accountType": accountType, // The account type of the master user: MAIN
"subAccountType": subAccountType, //The account type of the sub user: MAIN, TRADE or MARGIN
}
resp, err := kc.service.SubTransfer(params)
if err != nil {
log.Error("KuCoin SubTransfer error:", err)
return "", err
}
var model *kucoin.InnerTransferResultModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin SubTransfer error:", err)
return "", err
}
return model.OrderId, nil
}
// Deposits
// CreateDepositAddress creates a deposit address.
func (kc *KuCoin) CreateDepositAddress(currency, chain string) (*kucoin.DepositAddressModel, error) {
resp, err := kc.service.CreateDepositAddress(currency, chain)
if err != nil {
log.Error("KuCoin CreateDepositAddress error:", err)
return nil, err
}
var model *kucoin.DepositAddressModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin CreateDepositAddress error:", err)
return nil, err
}
return model, nil
}
// DepositAddresses returns the deposit address of currency for deposit.
// If return data is empty, you may need create a deposit address first.
func (kc *KuCoin) DepositAddresses(currency, chain string) (*kucoin.DepositAddressModel, error) {
resp, err := kc.service.DepositAddresses(currency, chain)
if err != nil {
log.Error("KuCoin DepositAddresses error:", err)
return nil, err
}
var model *kucoin.DepositAddressModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin DepositAddresses error:", err)
return nil, err
}
return model, nil
}
// Deposits returns a list of deposit.
func (kc *KuCoin) Deposits(currency, startAt, endAt, status string) (*kucoin.DepositsModel, error) {
params := map[string]string{
"currency": currency,
"startAt": startAt,
"endAt": endAt,
"status": status,
}
resp, err := kc.service.Deposits(params, nil)
if err != nil {
log.Error("KuCoin Deposits error:", err)
return nil, err
}
var model *kucoin.DepositsModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin Deposits error:", err)
return nil, err
}
return model, nil
}
// Withdrawals
// Deposits returns a list of deposit.
func (kc *KuCoin) Withdrawals(currency, startAt, endAt, status string) (*kucoin.WithdrawalsModel, error) {
params := map[string]string{
"currency": currency,
"startAt": startAt,
"endAt": endAt,
"status": status,
}
resp, err := kc.service.Withdrawals(params, nil)
if err != nil {
log.Error("KuCoin Withdrawals error:", err)
return nil, err
}
var model *kucoin.WithdrawalsModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin Withdrawals error:", err)
return nil, err
}
return model, nil
}
// ApplyWithdrawal applies a withdrawal.
func (kc *KuCoin) ApplyWithdrawal(currency, address, amount, memo, isInner, remark, chain string) (string, error) {
resp, err := kc.service.ApplyWithdrawal(currency, address, amount, map[string]string{
"memo": memo,
"remark": remark,
"chain": chain,
"isInner": isInner,
})
if err != nil {
log.Error("KuCoin ApplyWithdrawal error:", err)
return "", err
}
var model *kucoin.ApplyWithdrawalResultModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin ApplyWithdrawal error:", err)
return "", err
}
return model.WithdrawalId, nil
}
// WithdrawalQuotas returns the quotas of withdrawal.
func (kc *KuCoin) WithdrawalQuotas(currency, chain string) (*kucoin.WithdrawalQuotasModel, error) {
resp, err := kc.service.WithdrawalQuotas(currency, chain)
if err != nil {
log.Error("KuCoin WithdrawalQuotas error:", err)
return nil, err
}
var model *kucoin.WithdrawalQuotasModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin WithdrawalQuotas error:", err)
return nil, err
}
return model, nil
}
// CancelWithdrawal cancels a withdrawal by withdrawalId.
func (kc *KuCoin) CancelWithdrawal(withdrawalId string) (*kucoin.CancelWithdrawalResultModel, error) {
resp, err := kc.service.CancelWithdrawal(withdrawalId)
if err != nil {
log.Error("KuCoin CancelWithdrawal error:", err)
return nil, err
}
var model *kucoin.CancelWithdrawalResultModel
err = resp.ReadData(&model)
if err != nil {
log.Error("KuCoin CancelWithdrawal error:", err)
return nil, err
}
return model, nil
}