-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Expand file tree
/
Copy pathhashkey.ts
More file actions
4631 lines (4544 loc) · 213 KB
/
Copy pathhashkey.ts
File metadata and controls
4631 lines (4544 loc) · 213 KB
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
// ---------------------------------------------------------------------------
import { sha256 } from '@noble/hashes/sha2.js';
import Exchange from './abstract/hashkey.js';
import { AccountNotEnabled, AccountSuspended, ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ContractUnavailable, DDoSProtection, DuplicateOrderId, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidAddress, InvalidNonce, InvalidOrder, NotSupported, OperationFailed, OperationRejected, OrderImmediatelyFillable, OrderNotFillable, OrderNotFound, PermissionDenied, RateLimitExceeded, RequestTimeout } from './base/errors.js';
import { Precise } from './base/Precise.js';
import { TICK_SIZE } from './base/functions/number.js';
import type { Account, Balances, Bool, Currencies, Currency, CurrencyInterface, Dict, Fee, NullableDict, FundingRateHistory, LastPrice, LastPrices, Leverage, LeverageTier, LeverageTiers, MarginModification, Int, List, Market, MarketType, Num, OHLCV, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, SubType, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, LedgerEntry, FundingRate, FundingRates, DepositAddress, int, Status, Endpoint } from './base/types.js';
// ---------------------------------------------------------------------------
/**
* @class hashkey
* @augments Exchange
*/
export default class hashkey extends Exchange {
override describe (): any {
return this.deepExtend (super.describe (), {
'id': 'hashkey',
'name': 'HashKey Global',
'countries': [ 'BM' ], // Bermuda
'rateLimit': 100,
'version': 'v1',
'certified': true,
'pro': true,
'has': {
'CORS': undefined,
'spot': true,
'margin': false,
'swap': true,
'future': false,
'option': false,
'addMargin': true,
'borrowCrossMargin': false,
'borrowIsolatedMargin': false,
'borrowMargin': false,
'cancelAllOrders': true,
'cancelAllOrdersAfter': false,
'cancelOrder': true,
'cancelOrders': true,
'cancelWithdraw': false,
'closeAllPositions': false,
'closePosition': false,
'createConvertTrade': false,
'createDepositAddress': false,
'createMarketBuyOrderWithCost': true,
'createMarketOrder': true,
'createMarketOrderWithCost': false,
'createMarketSellOrderWithCost': false,
'createOrder': true,
'createOrders': true,
'createOrderWithTakeProfitAndStopLoss': false,
'createReduceOnlyOrder': true,
'createStopLimitOrder': true,
'createStopLossOrder': false,
'createStopMarketOrder': true,
'createStopOrder': true,
'createTakeProfitOrder': false,
'createTrailingAmountOrder': false,
'createTrailingPercentOrder': false,
'createTriggerOrder': true,
'fetchAccounts': true,
'fetchAllGreeks': false,
'fetchBalance': true,
'fetchBorrowInterest': false,
'fetchBorrowRate': false,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': false,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchCanceledAndClosedOrders': true,
'fetchCanceledOrders': true,
'fetchClosedOrder': true,
'fetchClosedOrders': false,
'fetchConvertCurrencies': false,
'fetchConvertQuote': false,
'fetchConvertTrade': false,
'fetchConvertTradeHistory': false,
'fetchCrossBorrowRate': false,
'fetchCrossBorrowRates': false,
'fetchCurrencies': true,
'fetchDepositAddress': true,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': false,
'fetchDeposits': true,
'fetchDepositsWithdrawals': false,
'fetchFundingHistory': false,
'fetchFundingInterval': false,
'fetchFundingIntervals': false,
'fetchFundingRate': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': true,
'fetchGreeks': false,
'fetchIndexOHLCV': false,
'fetchIsolatedBorrowRate': false,
'fetchIsolatedBorrowRates': false,
'fetchIsolatedPositions': false,
'fetchLastPrices': true,
'fetchLedger': true,
'fetchLeverage': true,
'fetchLeverages': false,
'fetchLeverageTiers': true,
'fetchLiquidations': false,
'fetchLongShortRatio': false,
'fetchLongShortRatioHistory': false,
'fetchMarginAdjustmentHistory': false,
'fetchMarginMode': false,
'fetchMarginModes': false,
'fetchMarketLeverageTiers': 'emulated',
'fetchMarkets': true,
'fetchMarkOHLCV': false,
'fetchMarkPrice': false,
'fetchMarkPrices': false,
'fetchMyLiquidations': false,
'fetchMySettlementHistory': false,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenInterest': false,
'fetchOpenInterestHistory': false,
'fetchOpenInterests': false,
'fetchOpenOrder': false,
'fetchOpenOrders': true,
'fetchOption': false,
'fetchOptionChain': false,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrders': false,
'fetchOrderTrades': false,
'fetchPosition': false,
'fetchPositionHistory': false,
'fetchPositionMode': false,
'fetchPositions': true,
'fetchPositionsForSymbol': true,
'fetchPositionsHistory': false,
'fetchPositionsRisk': false,
'fetchPremiumIndexOHLCV': false,
'fetchSettlementHistory': false,
'fetchStatus': true,
'fetchTicker': true,
'fetchTickers': true,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFee': true, // emulated for spot markets
'fetchTradingFees': true, // for spot markets only
'fetchTransactions': false,
'fetchTransfers': false,
'fetchUnderlyingAssets': false,
'fetchVolatilityHistory': false,
'fetchWithdrawals': true,
'reduceMargin': true,
'repayCrossMargin': false,
'repayIsolatedMargin': false,
'sandbox': false,
'setLeverage': true,
'setMargin': false,
'setMarginMode': true,
'setPositionMode': false,
'transfer': true,
'withdraw': true,
},
'timeframes': {
'1m': '1m',
'3m': '3m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1h',
'2h': '2h',
'4h': '4h',
'6h': '6h',
'8h': '8h',
'12h': '12h',
'1d': '1d',
'1w': '1w',
'1M': '1M',
},
'urls': {
'logo': 'https://github.com/user-attachments/assets/3dd65db2-5da9-4ecc-93ac-6d420f36261c',
'api': {
'public': 'https://api-glb.hashkey.com',
'private': 'https://api-glb.hashkey.com',
},
'test': {
'public': 'https://api-glb.sim.hashkeydev.com',
'private': 'https://api-glb.sim.hashkeydev.com',
},
'www': 'https://global.hashkey.com/',
'doc': 'https://hashkeyglobal-apidoc.readme.io/',
'fees': 'https://support.global.hashkey.com/hc/en-us/articles/13199900083612-HashKey-Global-Fee-Structure',
'referral': 'https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN',
},
'api': {
'public': {
'get': {
'api/v1/exchangeInfo': { 'cost': 5 } as Endpoint<Dict>,
'quote/v1/depth': { 'cost': 1 } as Endpoint<Dict>,
'quote/v1/trades': { 'cost': 1 } as Endpoint<List>,
'quote/v1/klines': { 'cost': 1 } as Endpoint<List>,
'quote/v1/ticker/24hr': { 'cost': 1 } as Endpoint<List>,
'quote/v1/ticker/price': { 'cost': 1 } as Endpoint<List>,
'quote/v1/ticker/bookTicker': { 'cost': 1 } as Endpoint<List>, // not unified
'quote/v1/depth/merged': { 'cost': 1 } as Endpoint<Dict>,
'quote/v1/markPrice': { 'cost': 1 } as Endpoint<Dict>,
'quote/v1/index': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/fundingRate': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/historyFundingRate': { 'cost': 1 } as Endpoint<List>,
'api/v1/ping': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/time': { 'cost': 1 } as Endpoint<Dict>,
},
},
'private': {
'get': {
'api/v1/spot/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/spot/openOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/spot/tradeOrders': { 'cost': 5 } as Endpoint<List>,
'api/v1/futures/leverage': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/openOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/userTrades': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/positions': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/historyOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/balance': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/liquidationAssignStatus': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/riskLimit': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/commissionRate': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/getBestOrder': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/coinInfo': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/vipInfo': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/trades': { 'cost': 5 } as Endpoint<List>,
'api/v1/account/type': { 'cost': 5 } as Endpoint<List>,
'api/v1/account/chainType': { 'cost': 1 } as Endpoint<List>,
'api/v1/account/checkApiKey': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/balanceFlow': { 'cost': 5 } as Endpoint<List>,
'api/v1/spot/subAccount/openOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/spot/subAccount/tradeOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/subAccount/trades': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/subAccount/openOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/subAccount/historyOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/futures/subAccount/userTrades': { 'cost': 1 } as Endpoint<List>,
'api/v1/account/deposit/address': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/depositOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/account/withdrawOrders': { 'cost': 1 } as Endpoint<List>,
'api/v1/affiliate/inviteeInfo': { 'cost': 1 } as Endpoint<List>,
},
'post': {
'api/v1/userDataStream': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/spot/orderTest': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/spot/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1.1/spot/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/spot/batchOrders': { 'cost': 5 } as Endpoint<Dict>,
'api/v1/futures/leverage': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/marginType': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/positionMargin': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/position/trading-stop': { 'cost': 3 } as Endpoint<Dict>,
'api/v1/futures/batchOrders': { 'cost': 5 } as Endpoint<Dict>,
'api/v1/account/assetTransfer': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/authAddress': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/account/withdraw': { 'cost': 1 } as Endpoint<Dict>,
},
'put': {
'api/v1/userDataStream': { 'cost': 1 } as Endpoint<Dict>,
},
'delete': {
'api/v1/spot/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/spot/openOrders': { 'cost': 5 } as Endpoint<List>,
'api/v1/spot/cancelOrderByIds': { 'cost': 5 } as Endpoint<Dict>,
'api/v1/spot/cancelAllOpenOrders': { 'cost': 5 } as Endpoint<Dict>,
'api/v1/futures/order': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/batchOrders': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/cancelOrderByIds': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/futures/cancelAllOpenOrders': { 'cost': 1 } as Endpoint<Dict>,
'api/v1/userDataStream': { 'cost': 1 } as Endpoint<Dict>,
},
},
},
'fees': {
'trading': {
'spot': {
'tierBased': true,
'percentage': true,
'feeSide': 'get',
'maker': this.parseNumber ('0.0012'),
'taker': this.parseNumber ('0.0012'),
'tiers': {
'maker': [
[ this.parseNumber ('0'), this.parseNumber ('0.0012') ],
[ this.parseNumber ('1000000'), this.parseNumber ('0.00080') ],
[ this.parseNumber ('5000000'), this.parseNumber ('0.00070') ],
[ this.parseNumber ('10000000'), this.parseNumber ('0.00060') ],
[ this.parseNumber ('50000000'), this.parseNumber ('0.00040') ],
[ this.parseNumber ('200000000'), this.parseNumber ('0.00030') ],
[ this.parseNumber ('400000000'), this.parseNumber ('0.00010') ],
[ this.parseNumber ('800000000'), this.parseNumber ('0.00') ],
],
'taker': [
[ this.parseNumber ('0'), this.parseNumber ('0.0012') ],
[ this.parseNumber ('1000000'), this.parseNumber ('0.00090') ],
[ this.parseNumber ('5000000'), this.parseNumber ('0.00085') ],
[ this.parseNumber ('10000000'), this.parseNumber ('0.00075') ],
[ this.parseNumber ('50000000'), this.parseNumber ('0.00065') ],
[ this.parseNumber ('200000000'), this.parseNumber ('0.00045') ],
[ this.parseNumber ('400000000'), this.parseNumber ('0.00040') ],
[ this.parseNumber ('800000000'), this.parseNumber ('0.00035') ],
],
},
},
'swap': {
'tierBased': true,
'percentage': true,
'feeSide': 'get',
'maker': this.parseNumber ('0.00025'),
'taker': this.parseNumber ('0.00060'),
'tiers': {
'maker': [
[ this.parseNumber ('0'), this.parseNumber ('0.00025') ],
[ this.parseNumber ('1000000'), this.parseNumber ('0.00016') ],
[ this.parseNumber ('5000000'), this.parseNumber ('0.00014') ],
[ this.parseNumber ('10000000'), this.parseNumber ('0.00012') ],
[ this.parseNumber ('50000000'), this.parseNumber ('0.000080') ],
[ this.parseNumber ('200000000'), this.parseNumber ('0.000060') ],
[ this.parseNumber ('400000000'), this.parseNumber ('0.000020') ],
[ this.parseNumber ('800000000'), this.parseNumber ('0.00') ],
],
'taker': [
[ this.parseNumber ('0'), this.parseNumber ('0.00060') ],
[ this.parseNumber ('1000000'), this.parseNumber ('0.00050') ],
[ this.parseNumber ('5000000'), this.parseNumber ('0.00045') ],
[ this.parseNumber ('10000000'), this.parseNumber ('0.00040') ],
[ this.parseNumber ('50000000'), this.parseNumber ('0.00035') ],
[ this.parseNumber ('200000000'), this.parseNumber ('0.00030') ],
[ this.parseNumber ('400000000'), this.parseNumber ('0.00025') ],
[ this.parseNumber ('800000000'), this.parseNumber ('0.00020') ],
],
},
},
},
},
'options': {
'broker': '10000700011',
'recvWindow': undefined,
'sandboxMode': false,
'networks': {
'BTC': 'BTC',
'ERC20': 'ETH',
'AVAX': 'AvalancheC',
'SOL': 'Solana',
'MATIC': 'Polygon',
'ATOM': 'Cosmos',
'DOT': 'Polkadot',
'LTC': 'LTC',
'OPTIMISM': 'Optimism',
'ARBITRUM': 'Arbitrum',
'DOGE': 'Dogecoin',
'TRC20': 'Tron',
'ZKSYNC': 'zkSync',
'TON': 'TON',
'KLAYTN': 'Klaytn',
'MERLINCHAIN': 'Merlin Chain',
},
'networksById': {
'BTC': 'BTC',
'Bitcoin': 'BTC',
'ETH': 'ERC20',
'ERC20': 'ERC20',
'AvalancheC': 'AVAX',
'AVAX C-Chain': 'AVAX',
'Solana': 'SOL',
'Cosmos': 'ATOM',
'Arbitrum': 'ARBITRUM',
'Polygon': 'MATIC',
'Optimism': 'OPTIMISM',
'Polkadot': 'DOT',
'LTC': 'LTC',
'Litecoin': 'LTC',
'Dogecoin': 'DOGE',
'Merlin Chain': 'MERLINCHAIN',
'zkSync': 'ZKSYNC',
'TRC20': 'TRC20',
'Tron': 'TRC20',
'TON': 'TON',
'BSC(BEP20)': 'BSC',
'Klaytn': 'KLAYTN',
},
'defaultNetwork': 'ERC20',
},
'features': {
'default': {
'sandbox': true,
'createOrder': {
'marginMode': false,
'triggerPrice': false,
'triggerPriceType': undefined,
'triggerDirection': false,
'stopLossPrice': false,
'takeProfitPrice': false,
'attachedStopLossTakeProfit': undefined,
'timeInForce': {
'IOC': true,
'FOK': true,
'PO': true,
'GTD': false,
},
'hedged': false,
'trailing': false,
'leverage': false,
'marketBuyByCost': true,
'marketBuyRequiresPrice': true, // todo fix
'selfTradePrevention': true, // todo implement
'iceberg': false,
},
'createOrders': {
'max': 20,
},
'fetchMyTrades': {
'marginMode': false,
'limit': 1000,
'daysBack': 30,
'untilDays': 30,
'symbolRequired': false,
},
'fetchOrder': {
'marginMode': false,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOpenOrders': {
'marginMode': false,
'limit': 1000,
'trigger': false,
'trailing': false,
'symbolRequired': false,
},
'fetchOrders': undefined,
'fetchClosedOrders': undefined, // todo
'fetchOHLCV': {
'limit': 1000,
},
},
'spot': {
'extends': 'default',
},
'forDerivatives': {
'extends': 'default',
'createOrder': {
'triggerPrice': true,
'selfTradePrevention': true,
},
'fetchOpenOrders': {
'trigger': true,
'limit': 500,
},
},
'swap': {
'linear': {
'extends': 'forDerivatives',
},
'inverse': undefined,
},
'future': {
'linear': undefined,
'inverse': undefined,
},
},
'commonCurrencies': {},
'exceptions': {
'exact': {
'0001': BadRequest, // Required field '%s' missing or invalid.
'0002': AuthenticationError, // Incorrect signature
'0003': RateLimitExceeded, // Rate limit exceeded
'0102': AuthenticationError, // Invalid APIKey
'0103': AuthenticationError, // APIKey expired
'0104': PermissionDenied, // The accountId defined is not permissible
'0201': ExchangeError, // Instrument not found
'0202': PermissionDenied, // Invalid IP
'0206': BadRequest, // Unsupported order type
'0207': BadRequest, // Invalid price
'0209': BadRequest, // Invalid price precision
'0210': BadRequest, // Price outside of allowed range
'0211': OrderNotFound, // Order not found
'0401': InsufficientFunds, // Insufficient asset
'0402': BadRequest, // Invalid asset
'-1000': ExchangeError, // An unknown error occurred while processing the request
'-1001': ExchangeError, // Internal error
'-100010': BadSymbol, // Invalid Symbols!
'-100012': BadSymbol, // Parameter symbol [String] missing!
'-1002': AuthenticationError, // Unauthorized operation
'-1004': BadRequest, // Bad request
'-1005': PermissionDenied, // No permission
'-1006': ExchangeError, // Execution status unknown
'-1007': RequestTimeout, // Timeout waiting for response from server
'-1014': InvalidOrder, // Unsupported order combination
'-1015': InvalidOrder, // Too many new orders
'-1020': OperationRejected, // Unsupported operation
'-1021': InvalidNonce, // Timestamp for this request is outside of the recvWindow
'-1024': BadRequest, // Duplicate request
'-1101': ExchangeNotAvailable, // Feature has been offline
'-1115': InvalidOrder, // Invalid timeInForce
'-1117': InvalidOrder, // Invalid order side
'-1123': InvalidOrder, // Invalid client order id
'-1124': InvalidOrder, // Invalid price
'-1126': InvalidOrder, // Invalid quantity
'-1129': BadRequest, // Invalid parameters, quantity and amount are not allowed to be sent at the same time.
'-1130': BadRequest, // Illegal parameter '%s'
'-1132': BadRequest, // Order price greater than the maximum
'-1133': BadRequest, // Order price lower than the minimum
'-1135': BadRequest, // Order quantity greater than the maximum
'-1136': BadRequest, // Order quantity lower than the minimum
'-1138': InvalidOrder, // Order has been partially cancelled
'-1137': InvalidOrder, // Order quantity precision too large
'-1139': OrderImmediatelyFillable, // Order has been filled
'-1140': InvalidOrder, // Order amount lower than the minimum
'-1141': DuplicateOrderId, // Duplicate order
'-1142': OrderNotFillable, // Order has been cancelled
'-1143': OrderNotFound, // Order not found on order book
'-1144': OperationRejected, // Order has been locked
'-1145': NotSupported, // Cancellation on this order type not supported
'-1146': RequestTimeout, // Order creation timeout
'-1147': RequestTimeout, // Order cancellation timeout
'-1148': InvalidOrder, // Order amount precision too large
'-1149': OperationRejected, // Order creation failed
'-1150': OperationFailed, // Order cancellation failed
'-1151': OperationRejected, // The trading pair is not open yet
'-1152': AccountNotEnabled, // User does not exist
'-1153': InvalidOrder, // Invalid price type
'-1154': InvalidOrder, // Invalid position side
'-1155': OperationRejected, // The trading pair is not available for api trading
'-1156': OperationFailed, // Limit maker order creation failed
'-1157': OperationFailed, // Modify futures margin failed
'-1158': OperationFailed, // Reduce margin is forbidden
'-1159': AccountNotEnabled, // Finance account already exists
'-1160': AccountNotEnabled, // Account does not exist
'-1161': OperationFailed, // Balance transfer failed
'-1162': ContractUnavailable, // Unsupport contract address
'-1163': InvalidAddress, // Illegal withdrawal address
'-1164': OperationFailed, // Withdraw failed
'-1165': ArgumentsRequired, // Withdrawal amount cannot be null
'-1166': OperationRejected, // Withdrawal amount exceeds the daily limit
'-1167': BadRequest, // Withdrawal amount less than the minimum
'-1168': BadRequest, // Illegal withdrawal amount
'-1169': PermissionDenied, // Withdraw not allowed
'-1170': PermissionDenied, // Deposit not allowed
'-1171': PermissionDenied, // Withdrawal address not in whitelist
'-1172': BadRequest, // Invalid from account id
'-1173': BadRequest, // Invalid to account i
'-1174': PermissionDenied, // Transfer not allowed between the same account
'-1175': BadRequest, // Invalid fiat deposit status
'-1176': BadRequest, // Invalid fiat withdrawal status
'-1177': InvalidOrder, // Invalid fiat order type
'-1178': AccountNotEnabled, // Brokerage account does not exist
'-1179': AccountSuspended, // Address owner is not true
'-1181': ExchangeError, // System error
'-1193': OperationRejected, // Order creation count exceeds the limit
'-1194': OperationRejected, // Market order creation forbidden
'-1195': BadRequest, // Market order long position cannot exceed %s above the market price
'-1196': BadRequest, // Market order short position cannot be below %s of the market price
'-1200': BadRequest, // Order buy quantity too small
'-1201': BadRequest, // Order buy quantity too large
'-1202': BadRequest, // Order sell quantity too small
'-1203': BadRequest, // Order sell quantity too large
'-1204': BadRequest, // From account must be a main account
'-1205': AccountNotEnabled, // Account not authorized
'-1206': BadRequest, // Order amount greater than the maximum
'-1207': BadRequest, // The status of deposit is invalid
'-1208': BadRequest, // The orderType of fiat is invalid
'-1209': BadRequest, // The status of withdraw is invalid
'-2001': ExchangeNotAvailable, // Platform is yet to open trading
'-2002': OperationFailed, // The number of open orders exceeds the limit 300
'-2003': OperationFailed, // Position size cannot meet target leverage
'-2004': OperationFailed, // Adjust leverage fail
'-2005': RequestTimeout, // Adjust leverage timeout
'-2010': OperationRejected, // New order rejected
'-2011': OperationRejected, // Order cancellation rejected
'-2016': OperationRejected, // API key creation exceeds the limit
'-2017': OperationRejected, // Open orders exceeds the limit of the trading pair
'-2018': OperationRejected, // Trade user creation exceeds the limit
'-2019': PermissionDenied, // Trader and omnibus user not allowed to login app
'-2020': PermissionDenied, // Not allowed to trade this trading pair
'-2021': PermissionDenied, // Not allowed to trade this trading pair
'-2022': OperationRejected, // Order batch size exceeds the limit
'-2023': AuthenticationError, // Need to pass KYC verification
'-2024': AccountNotEnabled, // Fiat account does not exist
'-2025': AccountNotEnabled, // Custody account not exist
'-2026': BadRequest, // Invalid type
'-2027': OperationRejected, // Exceed maximum time range of 30 days
'-2028': OperationRejected, // The search is limited to data within the last one month
'-2029': OperationRejected, // The search is limited to data within the last three months
'-2030': InsufficientFunds, // Insufficient margin
'-2031': NotSupported, // Leverage reduction is not supported in Isolated Margin Mode with open positions
'-2032': OperationRejected, // After the transaction, your %s position will account for %s of the total position, which poses concentration risk. Do you want to continue with the transaction?
'-2033': OperationFailed, // Order creation failed. Please verify if the order parameters comply with the trading rules
'-2034': InsufficientFunds, // Trade account holding limit is zero
'-2035': OperationRejected, // The sub account has been frozen and cannot transfer
'-2036': NotSupported, // We do not support queries for records exceeding 30 days
'-2037': ExchangeError, // Position and order data error
'-2038': InsufficientFunds, // Insufficient margin
'-2039': NotSupported, // Leverage reduction is not supported in Isolated Margin Mode with open positions
'-2040': ExchangeNotAvailable, // There is a request being processed. Please try again later
'-2041': BadRequest, // Token does not exist
'-2042': OperationRejected, // You have passed the trade limit, please pay attention to the risks
'-2043': OperationRejected, // Maximum allowed leverage reached, please lower your leverage
'-2044': BadRequest, // This order price is unreasonable to exceed (or be lower than) the liquidation price
'-2045': BadRequest, // Price too low, please order again!
'-2046': BadRequest, // Price too high, please order again!
'-2048': BadRequest, // Exceed the maximum number of conditional orders of %s
'-2049': BadRequest, // Create stop order buy price too big
'-2050': BadRequest, // Create stop order sell price too small
'-2051': OperationRejected, // Create order rejected
'-2052': OperationRejected, // Create stop profit-loss plan order reject
'-2053': OperationRejected, // Position not enough
'-2054': BadRequest, // Invalid long stop profit price
'-2055': BadRequest, // Invalid long stop loss price
'-2056': BadRequest, // Invalid short stop profit price
'-2057': BadRequest, // Invalid short stop loss price
'-3117': PermissionDenied, // Invalid permission
'-3143': PermissionDenied, // According to KYC and risk assessment, your trading account has exceeded the limit.
'-3144': PermissionDenied, // Currently, your trading account has exceeded its limit and is temporarily unable to perform transfers
'-3145': DDoSProtection, // Please DO NOT submit request too frequently
'-4001': BadRequest, // Invalid asset
'-4002': BadRequest, // Withdrawal amount less than Minimum Withdrawal Amount
'-4003': InsufficientFunds, // Insufficient Balance
'-4004': BadRequest, // Invalid bank account number
'-4005': BadRequest, // Assets are not listed
'-4006': AccountNotEnabled, // KYC is not certified
'-4007': NotSupported, // Withdrawal channels are not supported
'-4008': AccountNotEnabled, // This currency does not support this customer type
'-4009': PermissionDenied, // No withdrawal permission
'-4010': PermissionDenied, // Withdrawals on the same day exceed the maximum limit for a single day
'-4011': ExchangeError, // System error
'-4012': ExchangeError, // Parameter error
'-4013': OperationFailed, // Withdraw repeatly
},
'broad': {},
},
'precisionMode': TICK_SIZE,
});
}
/**
* @method
* @name hashkey#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://hashkeyglobal-apidoc.readme.io/reference/check-server-time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
override async fetchTime (params = {}): Promise<Int> {
const response = await this.publicGetApiV1Time (params);
//
// {
// "serverTime": 1721661553214
// }
//
return this.safeInteger (response, 'serverTime');
}
/**
* @method
* @name hashkey#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://hashkeyglobal-apidoc.readme.io/reference/test-connectivity
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
*/
override async fetchStatus (params = {}): Promise<Status> {
const response = await this.publicGetApiV1Ping (params);
//
// {}
//
return {
'status': 'ok',
'updated': undefined,
'eta': undefined,
'url': undefined,
'info': response,
};
}
/**
* @method
* @name hashkey#fetchMarkets
* @description retrieves data on all markets for the exchange
* @see https://hashkeyglobal-apidoc.readme.io/reference/exchangeinfo
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.symbol] the id of the market to fetch
* @returns {object[]} an array of objects representing market data
*/
override async fetchMarkets (params = {}): Promise<Market[]> {
const request: Dict = {};
const response = await this.publicGetApiV1ExchangeInfo (this.extend (request, params));
//
// {
// "timezone": "UTC",
// "serverTime": "1721661653952",
// "brokerFilters": [],
// "symbols": [
// {
// "symbol": "BTCUSDT",
// "symbolName": "BTCUSDT",
// "status": "TRADING",
// "baseAsset": "BTC",
// "baseAssetName": "BTC",
// "baseAssetPrecision": "0.00001",
// "quoteAsset": "USDT",
// "quoteAssetName": "USDT",
// "quotePrecision": "0.0000001",
// "retailAllowed": true,
// "piAllowed": true,
// "corporateAllowed": true,
// "omnibusAllowed": true,
// "icebergAllowed": false,
// "isAggregate": false,
// "allowMargin": false,
// "filters": [
// {
// "minPrice": "0.01",
// "maxPrice": "100000.00000000",
// "tickSize": "0.01",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.00001",
// "maxQty": "8",
// "stepSize": "0.00001",
// "marketOrderMinQty": "0.00001",
// "marketOrderMaxQty": "4",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "1",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "minAmount": "1",
// "maxAmount": "400000",
// "minBuyPrice": "0",
// "marketOrderMinAmount": "1",
// "marketOrderMaxAmount": "200000",
// "filterType": "TRADE_AMOUNT"
// },
// {
// "maxSellPrice": "0",
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "1710485700000",
// "noAllowMarketEndTime": "1710486000000",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ]
// }
// ],
// "options": [ ],
// "contracts": [
// {
// "filters": [
// {
// "minPrice": "0.1",
// "maxPrice": "100000.00000000",
// "tickSize": "0.1",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.001",
// "maxQty": "10",
// "stepSize": "0.001",
// "marketOrderMinQty": "0",
// "marketOrderMaxQty": "0",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "0",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "maxSellPrice": "999999",
// "buyPriceUpRate": "0.05",
// "sellPriceDownRate": "0.05",
// "maxEntrustNum": 200,
// "maxConditionNum": 200,
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.05",
// "sellPriceDownRate": "0.05",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "0",
// "noAllowMarketEndTime": "0",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ],
// "exchangeId": "301",
// "symbol": "BTCUSDT-PERPETUAL",
// "symbolName": "BTCUSDT-PERPETUAL",
// "status": "TRADING",
// "baseAsset": "BTCUSDT-PERPETUAL",
// "baseAssetPrecision": "0.001",
// "quoteAsset": "USDT",
// "quoteAssetPrecision": "0.1",
// "icebergAllowed": false,
// "inverse": false,
// "index": "USDT",
// "marginToken": "USDT",
// "marginPrecision": "0.0001",
// "contractMultiplier": "0.001",
// "underlying": "BTC",
// "riskLimits": [
// {
// "riskLimitId": "200000722",
// "quantity": "1000.00",
// "initialMargin": "0.10",
// "maintMargin": "0.005",
// "isWhite": false
// },
// {
// "riskLimitId": "200000723",
// "quantity": "2000.00",
// "initialMargin": "0.10",
// "maintMargin": "0.01",
// "isWhite": false
// }
// ]
// }
// ],
// "coins": [
// {
// "orgId": "9001",
// "coinId": "BTC",
// "coinName": "BTC",
// "coinFullName": "Bitcoin",
// "allowWithdraw": true,
// "allowDeposit": true,
// "tokenType": "CHAIN_TOKEN",
// "chainTypes": [
// {
// "chainType": "Bitcoin",
// "withdrawFee": "0",
// "minWithdrawQuantity": "0.002",
// "maxWithdrawQuantity": "0",
// "minDepositQuantity": "0.0005",
// "allowDeposit": true,
// "allowWithdraw": true
// }
// ]
// }
// ]
// }
//
const spotMarkets = this.safeList (response, 'symbols', []);
const swapMarkets = this.safeList (response, 'contracts', []);
let markets = this.arrayConcat (spotMarkets, swapMarkets);
if (this.isEmpty (markets)) {
markets = [ response ]; // if user provides params.symbol the exchange returns a single object instead of list of objects
}
return this.parseMarkets (markets);
}
override parseMarket (market: Dict): Market {
// spot
// {
// "symbol": "BTCUSDT",
// "symbolName": "BTCUSDT",
// "status": "TRADING",
// "baseAsset": "BTC",
// "baseAssetName": "BTC",
// "baseAssetPrecision": "0.00001",
// "quoteAsset": "USDT",
// "quoteAssetName": "USDT",
// "quotePrecision": "0.0000001",
// "retailAllowed": true,
// "piAllowed": true,
// "corporateAllowed": true,
// "omnibusAllowed": true,
// "icebergAllowed": false,
// "isAggregate": false,
// "allowMargin": false,
// "filters": [
// {
// "minPrice": "0.01",
// "maxPrice": "100000.00000000",
// "tickSize": "0.01",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.00001",
// "maxQty": "8",
// "stepSize": "0.00001",
// "marketOrderMinQty": "0.00001",
// "marketOrderMaxQty": "4",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "1",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "minAmount": "1",
// "maxAmount": "400000",
// "minBuyPrice": "0",
// "marketOrderMinAmount": "1",
// "marketOrderMaxAmount": "200000",
// "filterType": "TRADE_AMOUNT"
// },
// {
// "maxSellPrice": "0",
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.1",
// "sellPriceDownRate": "0.1",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "1710485700000",
// "noAllowMarketEndTime": "1710486000000",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ]
// }
//
// swap
// {
// "filters": [
// {
// "minPrice": "0.1",
// "maxPrice": "100000.00000000",
// "tickSize": "0.1",
// "filterType": "PRICE_FILTER"
// },
// {
// "minQty": "0.001",
// "maxQty": "10",
// "stepSize": "0.001",
// "marketOrderMinQty": "0",
// "marketOrderMaxQty": "0",
// "filterType": "LOT_SIZE"
// },
// {
// "minNotional": "0",
// "filterType": "MIN_NOTIONAL"
// },
// {
// "maxSellPrice": "999999",
// "buyPriceUpRate": "0.05",
// "sellPriceDownRate": "0.05",
// "maxEntrustNum": 200,
// "maxConditionNum": 200,
// "filterType": "LIMIT_TRADING"
// },
// {
// "buyPriceUpRate": "0.05",
// "sellPriceDownRate": "0.05",
// "filterType": "MARKET_TRADING"
// },
// {
// "noAllowMarketStartTime": "0",
// "noAllowMarketEndTime": "0",
// "limitOrderStartTime": "0",
// "limitOrderEndTime": "0",
// "limitMinPrice": "0",
// "limitMaxPrice": "0",
// "filterType": "OPEN_QUOTE"
// }
// ],
// "exchangeId": "301",
// "symbol": "BTCUSDT-PERPETUAL",
// "symbolName": "BTCUSDT-PERPETUAL",
// "status": "TRADING",
// "baseAsset": "BTCUSDT-PERPETUAL",
// "baseAssetPrecision": "0.001",
// "quoteAsset": "USDT",
// "quoteAssetPrecision": "0.1",
// "icebergAllowed": false,
// "inverse": false,