-
Notifications
You must be signed in to change notification settings - Fork 2
/
okx.js
5768 lines (5675 loc) · 262 KB
/
okx.js
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
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'use strict';
// ---------------------------------------------------------------------------
const Exchange = require ('./base/Exchange');
const { ExchangeError, ExchangeNotAvailable, OnMaintenance, ArgumentsRequired, BadRequest, AccountSuspended, InvalidAddress, PermissionDenied, InsufficientFunds, InvalidNonce, InvalidOrder, OrderNotFound, AuthenticationError, RequestTimeout, BadSymbol, RateLimitExceeded, NetworkError, CancelPending, NotSupported, AccountNotEnabled } = require ('./base/errors');
const { TICK_SIZE } = require ('./base/functions/number');
const Precise = require ('./base/Precise');
// ---------------------------------------------------------------------------
module.exports = class okx extends Exchange {
describe () {
return this.deepExtend (super.describe (), {
'id': 'okx',
'name': 'OKX',
'countries': [ 'CN', 'US' ],
'version': 'v5',
'rateLimit': 100,
'pro': true,
'certified': true,
'has': {
'CORS': undefined,
'spot': true,
'margin': true,
'swap': true,
'future': true,
'option': undefined,
'addMargin': true,
'borrowMargin': true,
'cancelAllOrders': false,
'cancelOrder': true,
'cancelOrders': true,
'createDepositAddress': false,
'createOrder': true,
'createPostOnlyOrder': true,
'createReduceOnlyOrder': true,
'createStopLimitOrder': true,
'createStopMarketOrder': true,
'createStopOrder': true,
'fetchAccounts': true,
'fetchBalance': true,
'fetchBidsAsks': undefined,
'fetchBorrowInterest': true,
'fetchBorrowRate': true,
'fetchBorrowRateHistories': true,
'fetchBorrowRateHistory': true,
'fetchBorrowRates': true,
'fetchBorrowRatesPerSymbol': false,
'fetchCanceledOrders': true,
'fetchClosedOrder': undefined,
'fetchClosedOrders': true,
'fetchCurrencies': true,
'fetchDeposit': true,
'fetchDepositAddress': true,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': true,
'fetchDeposits': true,
'fetchFundingHistory': true,
'fetchFundingRate': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': false,
'fetchIndexOHLCV': true,
'fetchL3OrderBook': false,
'fetchLedger': true,
'fetchLedgerEntry': undefined,
'fetchLeverage': true,
'fetchLeverageTiers': false,
'fetchMarketLeverageTiers': true,
'fetchMarkets': true,
'fetchMarkOHLCV': true,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenInterest': true,
'fetchOpenInterestHistory': true,
'fetchOpenOrder': undefined,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrderBooks': false,
'fetchOrders': false,
'fetchOrderTrades': true,
'fetchPermissions': undefined,
'fetchPosition': true,
'fetchPositions': true,
'fetchPositionsRisk': false,
'fetchPremiumIndexOHLCV': false,
'fetchStatus': true,
'fetchTicker': true,
'fetchTickers': true,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFee': true,
'fetchTradingFees': false,
'fetchTradingLimits': false,
'fetchTransactionFee': false,
'fetchTransactionFees': false,
'fetchTransactions': false,
'fetchTransfer': true,
'fetchTransfers': false,
'fetchWithdrawal': true,
'fetchWithdrawals': true,
'fetchWithdrawalWhitelist': false,
'reduceMargin': true,
'repayMargin': true,
'setLeverage': true,
'setMargin': false,
'setMarginMode': true,
'setPositionMode': true,
'signIn': false,
'transfer': true,
'withdraw': true,
},
'timeframes': {
'1m': '1m',
'3m': '3m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1H',
'2h': '2H',
'4h': '4H',
'6h': '6H',
'12h': '12H',
'1d': '1D',
'1w': '1W',
'1M': '1M',
'3M': '3M',
'6M': '6M',
'1y': '1Y',
},
'hostname': 'www.okx.com', // or aws.okx.com
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/152485636-38b19e4a-bece-4dec-979a-5982859ffc04.jpg',
'api': {
'rest': 'https://{hostname}',
},
'www': 'https://www.okx.com',
'doc': 'https://www.okx.com/docs-v5/en/',
'fees': 'https://www.okx.com/pages/products/fees.html',
'referral': 'https://www.okx.com/join/1888677',
'test': {
'rest': 'https://{hostname}',
},
},
'api': {
'public': {
'get': {
'market/tickers': 1,
'market/ticker': 1,
'market/index-tickers': 1,
'market/books': 1,
'market/books-lite': 1.66,
'market/candles': 0.5,
'market/history-candles': 1,
'market/history-mark-price-candles': 2,
'market/history-index-candles': 2,
'market/index-candles': 1,
'market/mark-price-candles': 1,
'market/trades': 1,
'market/platform-24-volume': 10,
'market/open-oracle': 40,
'market/index-components': 1,
'market/option/instrument-family-trades': 1,
// 'market/oracle',
'public/instruments': 1,
'public/delivery-exercise-history': 0.5,
'public/open-interest': 1,
'public/funding-rate': 1,
'public/funding-rate-history': 1,
'public/price-limit': 1,
'public/opt-summary': 1,
'public/estimated-price': 2,
'public/discount-rate-interest-free-quota': 10,
'public/time': 2,
'public/liquidation-orders': 0.5,
'public/mark-price': 2,
// 'public/tier',
'public/position-tiers': 2,
'public/underlying': 1,
'public/interest-rate-loan-quota': 10,
'public/vip-interest-rate-loan-quota': 10,
'rubik/stat/trading-data/support-coin': 4,
'rubik/stat/taker-volume': 4,
'rubik/stat/margin/loan-ratio': 4,
// long/short
'rubik/stat/contracts/long-short-account-ratio': 4,
'rubik/stat/contracts/open-interest-volume': 4,
'rubik/stat/option/open-interest-volume': 4,
// put/call
'rubik/stat/option/open-interest-volume-ratio': 4,
'rubik/stat/option/open-interest-volume-expiry': 4,
'rubik/stat/option/open-interest-volume-strike': 4,
'rubik/stat/option/taker-block-volume': 4,
'system/status': 100,
'asset/lending-rate-summary': 5 / 3,
'asset/lending-rate-history': 5 / 3,
'market/exchange-rate': 20,
},
},
'private': {
'get': {
'account/account-position-risk': 2,
'account/balance': 2,
'account/positions': 2,
'account/bills': 5 / 3,
'account/bills-archive': 5 / 3,
'account/config': 4,
'account/max-size': 1,
'account/max-avail-size': 1,
'account/leverage-info': 1,
'account/max-loan': 1,
'account/trade-fee': 4,
'account/interest-accrued': 4,
'account/interest-rate': 4,
'account/max-withdrawal': 1,
'account/risk-state': 2,
'account/borrow-repay-history': 4,
'account/quick-margin-borrow-repay-history': 4,
'account/interest-limits': 4,
'account/vip-interest-accrued': 4,
'account/vip-loan-order-list': 4,
'account/vip-loan-order-detail': 4,
'asset/asset-valuation': 1 / 5,
'asset/deposit-address': 5 / 3,
'asset/balances': 5 / 3,
'asset/transfer-state': 10,
'asset/deposit-history': 5 / 3,
'asset/withdrawal-history': 5 / 3,
'asset/currencies': 5 / 3,
'asset/bills': 5 / 3,
'asset/piggy-balance': 5 / 3,
'asset/deposit-lightning': 5,
'asset/lending-history': 5 / 3,
'asset/saving-balance': 5 / 3,
'asset/non-tradable-assets': 5 / 3,
'trade/order': 1 / 3,
'trade/orders-pending': 1,
'trade/orders-history': 0.5,
'trade/orders-history-archive': 1,
'trade/fills': 1 / 3,
'trade/fills-history': 2,
'trade/orders-algo-pending': 1,
'trade/orders-algo-history': 1,
'account/subaccount/balances': 10,
'asset/subaccount/bills': 5 / 3,
'users/subaccount/list': 10,
'users/subaccount/apikey': 10,
'users/entrust-subaccount-list': 10,
// broker
'broker/nd/info': 10,
'broker/nd/subaccount-info': 10,
'asset/broker/nd/subaccount-deposit-address': 4,
'asset/broker/nd/subaccount-deposit-history': 4,
'broker/nd/rebate-daily': 1,
'broker/nd/subaccount/apikey': 10,
'broker/nd/rebate-per-orders': 300,
'asset/broker/nd/subaccount-withdrawal-history': 4,
// convert
'asset/convert/currencies': 5 / 3,
'asset/convert/currency-pair': 5 / 3,
'asset/convert/estimate-quote': 5,
'asset/convert/trade': 5,
'asset/convert/history': 5 / 3,
// options
'account/greeks': 2,
// earn
'finance/staking-defi/offers': 1,
'finance/staking-defi/orders-active': 1,
'finance/staking-defi/orders-history': 1,
'rfq/counterparties': 4,
'rfq/maker-instrument-settings': 4,
'rfq/rfqs': 10,
'rfq/quotes': 10,
'rfq/trades': 4,
'rfq/public-trades': 4,
// copytrading
'copytrading/current-subpositions': 10,
'copytrading/subpositions-history': 10,
'copytrading/instruments': 10,
'copytrading/profit-sharing-details': 10,
'copytrading/total-profit-sharing': 10,
'copytrading/unrealized-profit-sharing-details': 10,
// grid trading
'tradingBot/grid/orders-algo-pending': 1,
'tradingBot/grid/orders-algo-history': 1,
'tradingBot/grid/orders-algo-details': 1,
'tradingBot/grid/sub-orders': 1,
'tradingBot/grid/positions': 1,
'tradingBot/grid/ai-param': 1,
},
'post': {
'account/set-position-mode': 4,
'account/set-leverage': 1,
'account/position/margin-balance': 1,
'account/set-greeks': 4,
'account/set-isolated-mode': 4,
'account/set-riskOffset-type': 2,
'account/simulated_margin': 10,
'account/borrow-repay': 5 / 3,
'account/quick-margin-borrow-repay': 4,
'account/activate-option': 4,
'asset/transfer': 10,
'asset/withdrawal': 5 / 3,
'asset/purchase_redempt': 5 / 3,
'asset/withdrawal-lightning': 5,
'asset/set-lending-rate': 5 / 3,
'asset/cancel-withdrawal': 5 / 3,
'asset/convert-dust-assets': 10,
'trade/order': 1 / 3,
'trade/batch-orders': 1 / 15,
'trade/cancel-order': 1 / 3,
'trade/cancel-batch-orders': 1 / 15,
'trade/amend-order': 1 / 3,
'trade/amend-batch-orders': 1 / 3,
'trade/close-position': 1,
'trade/order-algo': 1,
'trade/cancel-algos': 1,
'trade/cancel-advance-algos': 1,
'users/subaccount/delete-apikey': 10,
'users/subaccount/modify-apikey': 10,
'users/subaccount/apikey': 10,
'asset/subaccount/transfer': 10,
'asset/subaccount/set-transfer-out': 10,
// broker
'broker/nd/create-subaccount': 10,
'broker/nd/delete-subaccount': 10,
'broker/nd/set-subaccount-level': 4,
'broker/nd/set-subaccount-fee-rate': 4,
'asset/broker/nd/subaccount-deposit-address': 4,
'broker/nd/subaccount/apikey': 10,
'broker/nd/subaccount/delete-apikey': 10,
'broker/nd/subaccount/modify-apikey': 10,
'broker/nd/rebate-per-orders': 36000,
// earn
'finance/staking-defi/purchase': 3,
'finance/staking-defi/redeem': 3,
'finance/staking-defi/cancel': 3,
'rfq/create-rfq': 4,
'rfq/cancel-rfq': 4,
'rfq/cancel-batch-rfqs': 10,
'rfq/cancel-all-rfqs': 10,
'rfq/execute-quote': 10,
'rfq/maker-instrument-settings': 4,
'rfq/mmp-reset': 4,
'rfq/create-quote': 0.4,
'rfq/cancel-quote': 0.4,
'rfq/cancel-batch-quotes': 10,
'rfq/cancel-all-quotes': 10,
// copytrading
'copytrading/algo-order': 20,
'copytrading/close-subposition': 10,
'copytrading/set-instruments': 10,
// grid trading
'tradingBot/grid/order-algo': 1,
'tradingBot/grid/amend-order-algo': 1,
'tradingBot/grid/stop-order-algo': 1,
'tradingBot/grid/withdraw-income': 1,
'tradingBot/grid/compute-margin-balance': 1,
'tradingBot/grid/margin-balance': 1,
},
},
},
'fees': {
'trading': {
'taker': this.parseNumber ('0.0015'),
'maker': this.parseNumber ('0.0010'),
},
'spot': {
'taker': this.parseNumber ('0.0015'),
'maker': this.parseNumber ('0.0010'),
},
'future': {
'taker': this.parseNumber ('0.0005'),
'maker': this.parseNumber ('0.0002'),
},
'swap': {
'taker': this.parseNumber ('0.00050'),
'maker': this.parseNumber ('0.00020'),
},
},
'requiredCredentials': {
'apiKey': true,
'secret': true,
'password': true,
},
'exceptions': {
'exact': {
// Public error codes from 50000-53999
// General Class
'1': ExchangeError, // Operation failed
'2': ExchangeError, // Bulk operation partially succeeded
'50000': BadRequest, // Body can not be empty
'50001': OnMaintenance, // Matching engine upgrading. Please try again later
'50002': BadRequest, // Json data format error
'50004': RequestTimeout, // Endpoint request timeout (does not indicate success or failure of order, please check order status)
'50005': ExchangeNotAvailable, // API is offline or unavailable
'50006': BadRequest, // Invalid Content_Type, please use "application/json" format
'50007': AccountSuspended, // Account blocked
'50008': AuthenticationError, // User does not exist
'50009': AccountSuspended, // Account is suspended due to ongoing liquidation
'50010': ExchangeError, // User ID can not be empty
'50011': RateLimitExceeded, // Request too frequent
'50012': ExchangeError, // Account status invalid
'50013': ExchangeNotAvailable, // System is busy, please try again later
'50014': BadRequest, // Parameter {0} can not be empty
'50015': ExchangeError, // Either parameter {0} or {1} is required
'50016': ExchangeError, // Parameter {0} does not match parameter {1}
'50017': ExchangeError, // The position is frozen due to ADL. Operation restricted
'50018': ExchangeError, // Currency {0} is frozen due to ADL. Operation restricted
'50019': ExchangeError, // The account is frozen due to ADL. Operation restricted
'50020': ExchangeError, // The position is frozen due to liquidation. Operation restricted
'50021': ExchangeError, // Currency {0} is frozen due to liquidation. Operation restricted
'50022': ExchangeError, // The account is frozen due to liquidation. Operation restricted
'50023': ExchangeError, // Funding fee frozen. Operation restricted
'50024': BadRequest, // Parameter {0} and {1} can not exist at the same time
'50025': ExchangeError, // Parameter {0} count exceeds the limit {1}
'50026': ExchangeNotAvailable, // System error, please try again later.
'50027': PermissionDenied, // The account is restricted from trading
'50028': ExchangeError, // Unable to take the order, please reach out to support center for details
'50044': BadRequest, // Must select one broker type
// API Class
'50100': ExchangeError, // API frozen, please contact customer service
'50101': AuthenticationError, // Broker id of APIKey does not match current environment
'50102': InvalidNonce, // Timestamp request expired
'50103': AuthenticationError, // Request header "OK_ACCESS_KEY" can not be empty
'50104': AuthenticationError, // Request header "OK_ACCESS_PASSPHRASE" can not be empty
'50105': AuthenticationError, // Request header "OK_ACCESS_PASSPHRASE" incorrect
'50106': AuthenticationError, // Request header "OK_ACCESS_SIGN" can not be empty
'50107': AuthenticationError, // Request header "OK_ACCESS_TIMESTAMP" can not be empty
'50108': ExchangeError, // Exchange ID does not exist
'50109': ExchangeError, // Exchange domain does not exist
'50110': PermissionDenied, // Invalid IP
'50111': AuthenticationError, // Invalid OK_ACCESS_KEY
'50112': AuthenticationError, // Invalid OK_ACCESS_TIMESTAMP
'50113': AuthenticationError, // Invalid signature
'50114': AuthenticationError, // Invalid authorization
'50115': BadRequest, // Invalid request method
// Trade Class
'51000': BadRequest, // Parameter {0} error
'51001': BadSymbol, // Instrument ID does not exist
'51002': BadSymbol, // Instrument ID does not match underlying index
'51003': BadRequest, // Either client order ID or order ID is required
'51004': InvalidOrder, // Order amount exceeds current tier limit
'51005': InvalidOrder, // Order amount exceeds the limit
'51006': InvalidOrder, // Order price out of the limit
'51007': InvalidOrder, // Order placement failed. Order amount should be at least 1 contract (showing up when placing an order with less than 1 contract)
'51008': InsufficientFunds, // Order placement failed due to insufficient balance
'51009': AccountSuspended, // Order placement function is blocked by the platform
'51010': AccountNotEnabled, // Account level too low {"code":"1","data":[{"clOrdId":"uJrfGFth9F","ordId":"","sCode":"51010","sMsg":"The current account mode does not support this API interface. ","tag":""}],"msg":"Operation failed."}
'51011': InvalidOrder, // Duplicated order ID
'51012': BadSymbol, // Token does not exist
'51014': BadSymbol, // Index does not exist
'51015': BadSymbol, // Instrument ID does not match instrument type
'51016': InvalidOrder, // Duplicated client order ID
'51017': ExchangeError, // Borrow amount exceeds the limit
'51018': ExchangeError, // User with option account can not hold net short positions
'51019': ExchangeError, // No net long positions can be held under isolated margin mode in options
'51020': InvalidOrder, // Order amount should be greater than the min available amount
'51021': BadSymbol, // Contract to be listed
'51022': BadSymbol, // Contract suspended
'51023': ExchangeError, // Position does not exist
'51024': AccountSuspended, // Unified accountblocked
'51025': ExchangeError, // Order count exceeds the limit
'51026': BadSymbol, // Instrument type does not match underlying index
'51027': BadSymbol, // Contract expired
'51028': BadSymbol, // Contract under delivery
'51029': BadSymbol, // Contract is being settled
'51030': BadSymbol, // Funding fee is being settled
'51031': InvalidOrder, // This order price is not within the closing price range
'51100': InvalidOrder, // Trading amount does not meet the min tradable amount
'51101': InvalidOrder, // Entered amount exceeds the max pending order amount (Cont) per transaction
'51102': InvalidOrder, // Entered amount exceeds the max pending count
'51103': InvalidOrder, // Entered amount exceeds the max pending order count of the underlying asset
'51104': InvalidOrder, // Entered amount exceeds the max pending order amount (Cont) of the underlying asset
'51105': InvalidOrder, // Entered amount exceeds the max order amount (Cont) of the contract
'51106': InvalidOrder, // Entered amount exceeds the max order amount (Cont) of the underlying asset
'51107': InvalidOrder, // Entered amount exceeds the max holding amount (Cont)
'51108': InvalidOrder, // Positions exceed the limit for closing out with the market price
'51109': InvalidOrder, // No available offer
'51110': InvalidOrder, // You can only place a limit order after Call Auction has started
'51111': BadRequest, // Maximum {0} orders can be placed in bulk
'51112': InvalidOrder, // Close order size exceeds your available size
'51113': RateLimitExceeded, // Market-price liquidation requests too frequent
'51115': InvalidOrder, // Cancel all pending close-orders before liquidation
'51116': InvalidOrder, // Order price or trigger price exceeds {0}
'51117': InvalidOrder, // Pending close-orders count exceeds limit
'51118': InvalidOrder, // Total amount should exceed the min amount per order
'51119': InsufficientFunds, // Order placement failed due to insufficient balance
'51120': InvalidOrder, // Order quantity is less than {0}, please try again
'51121': InvalidOrder, // Order count should be the integer multiples of the lot size
'51122': InvalidOrder, // Order price should be higher than the min price {0}
'51124': InvalidOrder, // You can only place limit orders during call auction
'51125': InvalidOrder, // Currently there are reduce + reverse position pending orders in margin trading. Please cancel all reduce + reverse position pending orders and continue
'51126': InvalidOrder, // Currently there are reduce only pending orders in margin trading.Please cancel all reduce only pending orders and continue
'51127': InsufficientFunds, // Available balance is 0
'51128': InvalidOrder, // Multi-currency margin account can not do cross-margin trading
'51129': InvalidOrder, // The value of the position and buy order has reached the position limit, and no further buying is allowed
'51130': BadSymbol, // Fixed margin currency error
'51131': InsufficientFunds, // Insufficient balance
'51132': InvalidOrder, // Your position amount is negative and less than the minimum trading amount
'51133': InvalidOrder, // Reduce-only feature is unavailable for the spot transactions by multi-currency margin account
'51134': InvalidOrder, // Closing failed. Please check your holdings and pending orders
'51135': InvalidOrder, // Your closing price has triggered the limit price, and the max buy price is {0}
'51136': InvalidOrder, // Your closing price has triggered the limit price, and the min sell price is {0}
'51137': InvalidOrder, // Your opening price has triggered the limit price, and the max buy price is {0}
'51138': InvalidOrder, // Your opening price has triggered the limit price, and the min sell price is {0}
'51139': InvalidOrder, // Reduce-only feature is unavailable for the spot transactions by simple account
'51156': BadRequest, // You're leading trades in long/short mode and can't use this API endpoint to close positions
'51159': BadRequest, // You're leading trades in buy/sell mode. If you want to place orders using this API endpoint, the orders must be in the same direction as your existing positions and open orders.
'51162': InvalidOrder, // You have {instrument} open orders. Cancel these orders and try again
'51163': InvalidOrder, // You hold {instrument} positions. Close these positions and try again
'51166': InvalidOrder, // Currently, we don't support leading trades with this instrument
'51201': InvalidOrder, // Value of per market order cannot exceed 100,000 USDT
'51202': InvalidOrder, // Market - order amount exceeds the max amount
'51203': InvalidOrder, // Order amount exceeds the limit {0}
'51204': InvalidOrder, // The price for the limit order can not be empty
'51205': InvalidOrder, // Reduce-Only is not available
'51250': InvalidOrder, // Algo order price is out of the available range
'51251': InvalidOrder, // Algo order type error (when user place an iceberg order)
'51252': InvalidOrder, // Algo order price is out of the available range
'51253': InvalidOrder, // Average amount exceeds the limit of per iceberg order
'51254': InvalidOrder, // Iceberg average amount error (when user place an iceberg order)
'51255': InvalidOrder, // Limit of per iceberg order: Total amount/1000 < x <= Total amount
'51256': InvalidOrder, // Iceberg order price variance error
'51257': InvalidOrder, // Trail order callback rate error
'51258': InvalidOrder, // Trail - order placement failed. The trigger price of a sell order should be higher than the last transaction price
'51259': InvalidOrder, // Trail - order placement failed. The trigger price of a buy order should be lower than the last transaction price
'51260': InvalidOrder, // Maximum {0} pending trail - orders can be held at the same time
'51261': InvalidOrder, // Each user can hold up to {0} pending stop - orders at the same time
'51262': InvalidOrder, // Maximum {0} pending iceberg orders can be held at the same time
'51263': InvalidOrder, // Maximum {0} pending time-weighted orders can be held at the same time
'51264': InvalidOrder, // Average amount exceeds the limit of per time-weighted order
'51265': InvalidOrder, // Time-weighted order limit error
'51267': InvalidOrder, // Time-weighted order strategy initiative rate error
'51268': InvalidOrder, // Time-weighted order strategy initiative range error
'51269': InvalidOrder, // Time-weighted order interval error, the interval should be {0}<= x<={1}
'51270': InvalidOrder, // The limit of time-weighted order price variance is 0 < x <= 1%
'51271': InvalidOrder, // Sweep ratio should be 0 < x <= 100%
'51272': InvalidOrder, // Price variance should be 0 < x <= 1%
'51273': InvalidOrder, // Total amount should be more than {0}
'51274': InvalidOrder, // Total quantity of time-weighted order must be larger than single order limit
'51275': InvalidOrder, // The amount of single stop-market order can not exceed the upper limit
'51276': InvalidOrder, // Stop - Market orders cannot specify a price
'51277': InvalidOrder, // TP trigger price can not be higher than the last price
'51278': InvalidOrder, // SL trigger price can not be lower than the last price
'51279': InvalidOrder, // TP trigger price can not be lower than the last price
'51280': InvalidOrder, // SL trigger price can not be higher than the last price
'51321': InvalidOrder, // You're leading trades. Currently, we don't support leading trades with arbitrage, iceberg, or TWAP bots
'51322': InvalidOrder, // You're leading trades that have been filled at market price. We've canceled your open stop orders to close your positions
'51323': BadRequest, // You're already leading trades with take profit or stop loss settings. Cancel your existing stop orders to proceed
'51324': BadRequest, // As a lead trader, you hold positions in {instrument}. To close your positions, place orders in the amount that equals the available amount for closing
'51325': InvalidOrder, // As a lead trader, you must use market price when placing stop orders
'51327': InvalidOrder, // closeFraction is only available for futures and perpetual swaps
'51328': InvalidOrder, // closeFraction is only available for reduceOnly orders
'51329': InvalidOrder, // closeFraction is only available in NET mode
'51330': InvalidOrder, // closeFraction is only available for stop market orders
'51400': OrderNotFound, // Cancellation failed as the order does not exist
'51401': OrderNotFound, // Cancellation failed as the order is already canceled
'51402': OrderNotFound, // Cancellation failed as the order is already completed
'51403': InvalidOrder, // Cancellation failed as the order type does not support cancellation
'51404': InvalidOrder, // Order cancellation unavailable during the second phase of call auction
'51405': ExchangeError, // Cancellation failed as you do not have any pending orders
'51406': ExchangeError, // Canceled - order count exceeds the limit {0}
'51407': BadRequest, // Either order ID or client order ID is required
'51408': ExchangeError, // Pair ID or name does not match the order info
'51409': ExchangeError, // Either pair ID or pair name ID is required
'51410': CancelPending, // Cancellation failed as the order is already under cancelling status
'51500': ExchangeError, // Either order price or amount is required
'51501': ExchangeError, // Maximum {0} orders can be modified
'51502': InsufficientFunds, // Order modification failed for insufficient margin
'51503': ExchangeError, // Order modification failed as the order does not exist
'51506': ExchangeError, // Order modification unavailable for the order type
'51508': ExchangeError, // Orders are not allowed to be modified during the call auction
'51509': ExchangeError, // Modification failed as the order has been canceled
'51510': ExchangeError, // Modification failed as the order has been completed
'51511': ExchangeError, // Modification failed as the order price did not meet the requirement for Post Only
'51600': ExchangeError, // Status not found
'51601': ExchangeError, // Order status and order ID cannot exist at the same time
'51602': ExchangeError, // Either order status or order ID is required
'51603': OrderNotFound, // Order does not exist
'51732': AuthenticationError, // Required user KYC level not met
'51733': AuthenticationError, // User is under risk control
'51734': AuthenticationError, // User KYC Country is not supported
'51735': ExchangeError, // Sub-account is not supported
'51736': InsufficientFunds, // Insufficient {ccy} balance
// Data class
'52000': ExchangeError, // No updates
// SPOT/MARGIN error codes 54000-54999
'54000': ExchangeError, // Margin transactions unavailable
'54001': ExchangeError, // Only Multi-currency margin account can be set to borrow coins automatically
// FUNDING error codes 58000-58999
'58000': ExchangeError, // Account type {0} does not supported when getting the sub-account balance
'58001': AuthenticationError, // Incorrect trade password
'58002': PermissionDenied, // Please activate Savings Account first
'58003': ExchangeError, // Currency type is not supported by Savings Account
'58004': AccountSuspended, // Account blocked (transfer & withdrawal endpoint: either end of the account does not authorize the transfer)
'58005': ExchangeError, // The redeemed amount must be no greater than {0}
'58006': ExchangeError, // Service unavailable for token {0}
'58007': ExchangeError, // Abnormal Assets interface. Please try again later
'58100': ExchangeError, // The trading product triggers risk control, and the platform has suspended the fund transfer-out function with related users. Please wait patiently
'58101': AccountSuspended, // Transfer suspended (transfer endpoint: either end of the account does not authorize the transfer)
'58102': RateLimitExceeded, // Too frequent transfer (transfer too frequently)
'58103': ExchangeError, // Parent account user id does not match sub-account user id
'58104': ExchangeError, // Since your P2P transaction is abnormal, you are restricted from making fund transfers. Please contact customer support to remove the restriction
'58105': ExchangeError, // Since your P2P transaction is abnormal, you are restricted from making fund transfers. Please transfer funds on our website or app to complete identity verification
'58106': ExchangeError, // Please enable the account for spot contract
'58107': ExchangeError, // Please enable the account for futures contract
'58108': ExchangeError, // Please enable the account for option contract
'58109': ExchangeError, // Please enable the account for swap contract
'58110': ExchangeError, // The contract triggers risk control, and the platform has suspended the fund transfer function of it. Please wait patiently
'58111': ExchangeError, // Funds transfer unavailable as the perpetual contract is charging the funding fee. Please try again later
'58112': ExchangeError, // Your fund transfer failed. Please try again later
'58114': ExchangeError, // Transfer amount must be more than 0
'58115': ExchangeError, // Sub-account does not exist
'58116': ExchangeError, // Transfer amount exceeds the limit
'58117': ExchangeError, // Account assets are abnormal, please deal with negative assets before transferring
'58125': BadRequest, // Non-tradable assets can only be transferred from sub-accounts to main accounts
'58126': BadRequest, // Non-tradable assets can only be transferred between funding accounts
'58200': ExchangeError, // Withdrawal from {0} to {1} is unavailable for this currency
'58201': ExchangeError, // Withdrawal amount exceeds the daily limit
'58202': ExchangeError, // The minimum withdrawal amount for NEO is 1, and the amount must be an integer
'58203': InvalidAddress, // Please add a withdrawal address
'58204': AccountSuspended, // Withdrawal suspended
'58205': ExchangeError, // Withdrawal amount exceeds the upper limit
'58206': ExchangeError, // Withdrawal amount is lower than the lower limit
'58207': InvalidAddress, // Withdrawal failed due to address error
'58208': ExchangeError, // Withdrawal failed. Please link your email
'58209': ExchangeError, // Withdrawal failed. Withdraw feature is not available for sub-accounts
'58210': ExchangeError, // Withdrawal fee exceeds the upper limit
'58211': ExchangeError, // Withdrawal fee is lower than the lower limit (withdrawal endpoint: incorrect fee)
'58212': ExchangeError, // Withdrawal fee should be {0}% of the withdrawal amount
'58213': AuthenticationError, // Please set trading password before withdrawal
'58221': BadRequest, // Missing label of withdrawal address.
'58222': BadRequest, // Illegal withdrawal address.
'58224': BadRequest, // This type of crypto does not support on-chain withdrawing to OKX addresses. Please withdraw through internal transfers.
'58227': BadRequest, // Withdrawal of non-tradable assets can be withdrawn all at once only
'58228': BadRequest, // Withdrawal of non-tradable assets requires that the API Key must be bound to an IP
'58229': InsufficientFunds, // Insufficient funding account balance to pay fees {fee} USDT
'58300': ExchangeError, // Deposit-address count exceeds the limit
'58350': InsufficientFunds, // Insufficient balance
// Account error codes 59000-59999
'59000': ExchangeError, // Your settings failed as you have positions or open orders
'59001': ExchangeError, // Switching unavailable as you have borrowings
'59100': ExchangeError, // You have open positions. Please cancel all open positions before changing the leverage
'59101': ExchangeError, // You have pending orders with isolated positions. Please cancel all the pending orders and adjust the leverage
'59102': ExchangeError, // Leverage exceeds the maximum leverage. Please adjust the leverage
'59103': InsufficientFunds, // Leverage is too low and no sufficient margin in your account. Please adjust the leverage
'59104': ExchangeError, // The leverage is too high. The borrowed position has exceeded the maximum position of this leverage. Please adjust the leverage
'59105': ExchangeError, // Leverage can not be less than {0}. Please adjust the leverage
'59106': ExchangeError, // The max available margin corresponding to your order tier is {0}. Please adjust your margin and place a new order
'59107': ExchangeError, // You have pending orders under the service, please modify the leverage after canceling all pending orders
'59108': InsufficientFunds, // Low leverage and insufficient margin, please adjust the leverage
'59109': ExchangeError, // Account equity less than the required margin amount after adjustment. Please adjust the leverage
'59128': InvalidOrder, // As a lead trader, you can't lead trades in {instrument} with leverage higher than {num}
'59200': InsufficientFunds, // Insufficient account balance
'59201': InsufficientFunds, // Negative account balance
'59216': BadRequest, // The position doesn't exist. Please try again
'59300': ExchangeError, // Margin call failed. Position does not exist
'59301': ExchangeError, // Margin adjustment failed for exceeding the max limit
'59313': ExchangeError, // Unable to repay. You haven't borrowed any {ccy} {ccyPair} in Quick margin mode.
'59401': ExchangeError, // Holdings already reached the limit
'59500': ExchangeError, // Only the APIKey of the main account has permission
'59501': ExchangeError, // Only 50 APIKeys can be created per account
'59502': ExchangeError, // Note name cannot be duplicate with the currently created APIKey note name
'59503': ExchangeError, // Each APIKey can bind up to 20 IP addresses
'59504': ExchangeError, // The sub account does not support the withdrawal function
'59505': ExchangeError, // The passphrase format is incorrect
'59506': ExchangeError, // APIKey does not exist
'59507': ExchangeError, // The two accounts involved in a transfer must be two different sub accounts under the same parent account
'59508': AccountSuspended, // The sub account of {0} is suspended
// WebSocket error Codes from 60000-63999
'60001': AuthenticationError, // "OK_ACCESS_KEY" can not be empty
'60002': AuthenticationError, // "OK_ACCESS_SIGN" can not be empty
'60003': AuthenticationError, // "OK_ACCESS_PASSPHRASE" can not be empty
'60004': AuthenticationError, // Invalid OK_ACCESS_TIMESTAMP
'60005': AuthenticationError, // Invalid OK_ACCESS_KEY
'60006': InvalidNonce, // Timestamp request expired
'60007': AuthenticationError, // Invalid sign
'60008': AuthenticationError, // Login is not supported for public channels
'60009': AuthenticationError, // Login failed
'60010': AuthenticationError, // Already logged in
'60011': AuthenticationError, // Please log in
'60012': BadRequest, // Illegal request
'60013': BadRequest, // Invalid args
'60014': RateLimitExceeded, // Requests too frequent
'60015': NetworkError, // Connection closed as there was no data transmission in the last 30 seconds
'60016': ExchangeNotAvailable, // Buffer is full, cannot write data
'60017': BadRequest, // Invalid url path
'60018': BadRequest, // The {0} {1} {2} {3} {4} does not exist
'60019': BadRequest, // Invalid op {op}
'63999': ExchangeError, // Internal system error
'70010': BadRequest, // Timestamp parameters need to be in Unix timestamp format in milliseconds.
'70013': BadRequest, // endTs needs to be bigger than or equal to beginTs.
'70016': BadRequest, // Please specify your instrument settings for at least one instType.
},
'broad': {
'Internal Server Error': ExchangeNotAvailable, // {"code":500,"data":{},"detailMsg":"","error_code":"500","error_message":"Internal Server Error","msg":"Internal Server Error"}
'server error': ExchangeNotAvailable, // {"code":500,"data":{},"detailMsg":"","error_code":"500","error_message":"server error 1236805249","msg":"server error 1236805249"}
},
},
'httpExceptions': {
'429': ExchangeNotAvailable, // https://github.com/ccxt/ccxt/issues/9612
},
'precisionMode': TICK_SIZE,
'options': {
'defaultNetwork': 'ERC20',
'networks': {
'ETH': 'ERC20',
'TRX': 'TRC20',
'OMNI': 'Omni',
'SOLANA': 'Solana',
'POLYGON': 'Polygon',
'OEC': 'OEC',
'ALGO': 'ALGO', // temporarily unavailable
'OPTIMISM': 'Optimism',
'ARBITRUM': 'Arbitrum one',
'AVALANCHE': 'Avalanche C-Chain',
},
'fetchOpenInterestHistory': {
'timeframes': {
'5m': '5m',
'1h': '1H',
'1d': '1D',
'5M': '5m',
'1H': '1H',
'1D': '1D',
},
},
'fetchOHLCV': {
// 'type': 'Candles', // Candles or HistoryCandles, IndexCandles, MarkPriceCandles
'timezone': 'UTC', // UTC, HK
},
'createOrder': 'privatePostTradeBatchOrders', // or 'privatePostTradeOrder' or 'privatePostTradeOrderAlgo'
'createMarketBuyOrderRequiresPrice': false,
'fetchMarkets': [ 'spot', 'future', 'swap', 'option' ], // spot, future, swap, option
'defaultType': 'spot', // 'funding', 'spot', 'margin', 'future', 'swap', 'option'
// 'fetchBalance': {
// 'type': 'spot', // 'funding', 'trading', 'spot'
// },
'fetchLedger': {
'method': 'privateGetAccountBills', // privateGetAccountBillsArchive, privateGetAssetBills
},
// 1 = SPOT, 3 = FUTURES, 5 = MARGIN, 6 = FUNDING, 9 = SWAP, 12 = OPTION, 18 = Unified account
'fetchOrder': {
'method': 'privateGetTradeOrder', // privateGetTradeOrdersAlgoHistory
},
'fetchOpenOrders': {
'method': 'privateGetTradeOrdersPending', // privateGetTradeOrdersAlgoPending
},
'cancelOrders': {
'method': 'privatePostTradeCancelBatchOrders', // privatePostTradeCancelAlgos
},
'fetchCanceledOrders': {
'method': 'privateGetTradeOrdersHistory', // privateGetTradeOrdersAlgoHistory
},
'fetchClosedOrders': {
'method': 'privateGetTradeOrdersHistory', // privateGetTradeOrdersAlgoHistory
},
'algoOrderTypes': {
'conditional': true,
'trigger': true,
'oco': true,
'move_order_stop': true,
'iceberg': true,
'twap': true,
},
'accountsByType': {
'spot': '1',
'future': '3',
'futures': '3',
'margin': '5',
'funding': '6',
'swap': '9',
'option': '12',
'trading': '18', // unified trading account
},
'accountsById': {
'1': 'spot',
'3': 'future',
'5': 'margin',
'6': 'funding',
'9': 'swap',
'12': 'option',
'18': 'trading', // unified trading account
},
'exchangeType': {
'spot': 'SPOT',
'margin': 'MARGIN',
'swap': 'SWAP',
'future': 'FUTURES',
'futures': 'FUTURES', // deprecated
'option': 'OPTION',
'SPOT': 'SPOT',
'MARGIN': 'MARGIN',
'SWAP': 'SWAP',
'FUTURES': 'FUTURES',
'OPTION': 'OPTION',
},
'brokerId': 'e847386590ce4dBC',
},
'commonCurrencies': {
// the exchange refers to ERC20 version of Aeternity (AEToken)
'AE': 'AET', // https://github.com/ccxt/ccxt/issues/4981
'BOX': 'DefiBox',
'HOT': 'Hydro Protocol',
'HSR': 'HC',
'MAG': 'Maggie',
'SBTC': 'Super Bitcoin',
'TRADE': 'Unitrade',
'YOYO': 'YOYOW',
'WIN': 'WinToken', // https://github.com/ccxt/ccxt/issues/5701
},
});
}
handleMarketTypeAndParams (methodName, market = undefined, params = {}) {
const instType = this.safeString (params, 'instType');
params = this.omit (params, 'instType');
const type = this.safeString (params, 'type');
if ((type === undefined) && (instType !== undefined)) {
params['type'] = instType;
}
return super.handleMarketTypeAndParams (methodName, market, params);
}
convertToInstrumentType (type) {
const exchangeTypes = this.safeValue (this.options, 'exchangeType', {});
return this.safeString (exchangeTypes, type, type);
}
async fetchStatus (params = {}) {
/**
* @method
* @name okx#fetchStatus
* @description the latest known information on the availability of the exchange API
* @param {object} params extra parameters specific to the okx api endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/en/latest/manual.html#exchange-status-structure}
*/
const response = await this.publicGetSystemStatus (params);
//
// Note, if there is no maintenance around, the 'data' array is empty
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "begin": "1621328400000",
// "end": "1621329000000",
// "href": "https://www.okx.com/support/hc/en-us/articles/360060882172",
// "scheDesc": "",
// "serviceType": "1", // 0 WebSocket, 1 Spot/Margin, 2 Futures, 3 Perpetual, 4 Options, 5 Trading service
// "state": "scheduled", // ongoing, completed, canceled
// "system": "classic", // classic, unified
// "title": "Classic Spot System Upgrade"
// },
// ]
// }
//
const data = this.safeValue (response, 'data', []);
const dataLength = data.length;
const update = {
'updated': undefined,
'status': (dataLength === 0) ? 'ok' : 'maintenance',
'eta': undefined,
'url': undefined,
'info': response,
};
for (let i = 0; i < data.length; i++) {
const event = data[i];
const state = this.safeString (event, 'state');
if (state === 'ongoing') {
update['eta'] = this.safeInteger (event, 'end');
update['status'] = 'maintenance';
}
}
return update;
}
async fetchTime (params = {}) {
/**
* @method
* @name okx#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @param {object} params extra parameters specific to the okx api endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
const response = await this.publicGetPublicTime (params);
//
// {
// "code": "0",
// "data": [
// {"ts": "1621247923668"}
// ],
// "msg": ""
// }
//
const data = this.safeValue (response, 'data', []);
const first = this.safeValue (data, 0, {});
return this.safeInteger (first, 'ts');
}
async fetchAccounts (params = {}) {
/**
* @method
* @name okx#fetchAccounts
* @description fetch all the accounts associated with a profile
* @param {object} params extra parameters specific to the okx api endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/en/latest/manual.html#account-structure} indexed by the account type
*/
const response = await this.privateGetAccountConfig (params);
//
// {
// "code": "0",
// "data": [
// {
// "acctLv": "2",
// "autoLoan": false,
// "ctIsoMode": "automatic",
// "greeksType": "PA",
// "level": "Lv1",
// "levelTmp": "",
// "mgnIsoMode": "automatic",
// "posMode": "long_short_mode",
// "uid": "88018754289672195"
// }
// ],
// "msg": ""
// }
//
const data = this.safeValue (response, 'data', []);
const result = [];
for (let i = 0; i < data.length; i++) {
const account = data[i];
const accountId = this.safeString (account, 'uid');
const type = this.safeString (account, 'acctLv');
result.push ({
'id': accountId,
'type': type,
'currency': undefined,
'info': account,
});
}
return result;
}
async fetchMarkets (params = {}) {
/**
* @method
* @name okx#fetchMarkets
* @description retrieves data on all markets for okx
* @param {object} params extra parameters specific to the exchange api endpoint
* @returns {[object]} an array of objects representing market data
*/
const types = this.safeValue (this.options, 'fetchMarkets');
let promises = [];
let result = [];
for (let i = 0; i < types.length; i++) {
promises.push (this.fetchMarketsByType (types[i], params));
}
// why not both ¯\_(ツ)_/¯
promises = await Promise.all (promises);
for (let i = 0; i < promises.length; i++) {
result = this.arrayConcat (result, promises[i]);
}
return result;
}
parseMarkets (markets) {
const result = [];
for (let i = 0; i < markets.length; i++) {
result.push (this.parseMarket (markets[i]));
}
return result;
}
parseMarket (market) {
//
// {
// "alias": "", // this_week, next_week, quarter, next_quarter
// "baseCcy": "BTC",
// "category": "1",
// "ctMult": "",
// "ctType": "", // inverse, linear
// "ctVal": "",
// "ctValCcy": "",
// "expTime": "",
// "instId": "BTC-USDT", // BTC-USD-210521, CSPR-USDT-SWAP, BTC-USD-210517-44000-C
// "instType": "SPOT", // SPOT, FUTURES, SWAP, OPTION
// "lever": "10",
// "listTime": "1548133413000",
// "lotSz": "0.00000001",
// "minSz": "0.00001",
// "optType": "",
// "quoteCcy": "USDT",
// "settleCcy": "",
// "state": "live",
// "stk": "",
// "tickSz": "0.1",