Repository navigation
Expand file tree
/
Copy pathbitmart.php
More file actions
5094 lines (5011 loc) · 243 KB
/
Copy pathbitmart.php
File metadata and controls
5094 lines (5011 loc) · 243 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
<?php
namespace ccxt;
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
use Exception; // a common import
use ccxt\abstract\bitmart as Exchange;
class bitmart extends Exchange {
public function describe() {
return $this->deep_extend(parent::describe(), array(
'id' => 'bitmart',
'name' => 'BitMart',
'countries' => array( 'US', 'CN', 'HK', 'KR' ),
// 150 per 5 seconds = 30 per second
// rateLimit = 1000ms / 30 ~= 33.334
'rateLimit' => 33.34,
'version' => 'v2',
'certified' => true,
'pro' => true,
'has' => array(
'CORS' => null,
'spot' => true,
'margin' => true,
'swap' => true,
'future' => false,
'option' => false,
'borrowCrossMargin' => false,
'borrowIsolatedMargin' => true,
'cancelAllOrders' => true,
'cancelOrder' => true,
'cancelOrders' => true,
'createMarketBuyOrderWithCost' => true,
'createMarketOrderWithCost' => false,
'createMarketSellOrderWithCost' => false,
'createOrder' => true,
'createOrders' => true,
'createPostOnlyOrder' => true,
'createStopLimitOrder' => false,
'createStopMarketOrder' => false,
'createStopOrder' => false,
'createTrailingPercentOrder' => true,
'fetchBalance' => true,
'fetchBorrowInterest' => true,
'fetchBorrowRateHistories' => false,
'fetchBorrowRateHistory' => false,
'fetchCanceledOrders' => true,
'fetchClosedOrders' => true,
'fetchCrossBorrowRate' => false,
'fetchCrossBorrowRates' => false,
'fetchCurrencies' => true,
'fetchDeposit' => true,
'fetchDepositAddress' => true,
'fetchDepositAddresses' => false,
'fetchDepositAddressesByNetwork' => false,
'fetchDeposits' => true,
'fetchDepositWithdrawFee' => true,
'fetchDepositWithdrawFees' => false,
'fetchFundingHistory' => null,
'fetchFundingRate' => true,
'fetchFundingRateHistory' => false,
'fetchFundingRates' => false,
'fetchIsolatedBorrowRate' => true,
'fetchIsolatedBorrowRates' => true,
'fetchLiquidations' => false,
'fetchMarginMode' => false,
'fetchMarkets' => true,
'fetchMyLiquidations' => true,
'fetchMyTrades' => true,
'fetchOHLCV' => true,
'fetchOpenInterest' => true,
'fetchOpenInterestHistory' => false,
'fetchOpenOrders' => true,
'fetchOrder' => true,
'fetchOrderBook' => true,
'fetchOrders' => false,
'fetchOrderTrades' => true,
'fetchPosition' => true,
'fetchPositionMode' => false,
'fetchPositions' => true,
'fetchStatus' => true,
'fetchTicker' => true,
'fetchTickers' => true,
'fetchTime' => true,
'fetchTrades' => true,
'fetchTradingFee' => true,
'fetchTradingFees' => false,
'fetchTransactionFee' => true,
'fetchTransactionFees' => false,
'fetchTransfer' => false,
'fetchTransfers' => true,
'fetchWithdrawAddressesByNetwork' => false,
'fetchWithdrawal' => true,
'fetchWithdrawals' => true,
'reduceMargin' => false,
'repayCrossMargin' => false,
'repayIsolatedMargin' => true,
'setLeverage' => true,
'setMarginMode' => false,
'transfer' => true,
'withdraw' => true,
),
'hostname' => 'bitmart.com', // bitmart.info, bitmart.news for Hong Kong users
'urls' => array(
'logo' => 'https://github.com/user-attachments/assets/0623e9c4-f50e-48c9-82bd-65c3908c3a14',
'api' => array(
'spot' => 'https://api-cloud.{hostname}',
'swap' => 'https://api-cloud-v2.{hostname}', // bitmart.info for Hong Kong users
),
'www' => 'https://www.bitmart.com/',
'doc' => 'https://developer-pro.bitmart.com/',
'referral' => array(
'url' => 'http://www.bitmart.com/?r=rQCFLh',
'discount' => 0.3,
),
'fees' => 'https://www.bitmart.com/fee/en',
),
'requiredCredentials' => array(
'apiKey' => true,
'secret' => true,
'uid' => true,
),
'api' => array(
'public' => array(
'get' => array(
'system/time' => 3, // 10 times/sec => 30/10 = 3
'system/service' => 3,
// spot markets
'spot/v1/currencies' => 7.5,
'spot/v1/symbols' => 7.5,
'spot/v1/symbols/details' => 5,
'spot/quotation/v3/tickers' => 6, // 10 times/2 sec = 5/s => 30/5 = 6
'spot/quotation/v3/ticker' => 4, // 15 times/2 sec = 7.5/s => 30/7.5 = 4
'spot/quotation/v3/lite-klines' => 5, // should be 4 but errors
'spot/quotation/v3/klines' => 7, // should be 6 but errors
'spot/quotation/v3/books' => 4, // 15 times/2 sec = 7.5/s => 30/7.5 = 4
'spot/quotation/v3/trades' => 4, // 15 times/2 sec = 7.5/s => 30/7.5 = 4
'spot/v1/ticker' => 5,
'spot/v2/ticker' => 30,
'spot/v1/ticker_detail' => 5, // 12 times/2 sec = 6/s => 30/6 = 5
'spot/v1/steps' => 30,
'spot/v1/symbols/kline' => 6, // should be 5 but errors
'spot/v1/symbols/book' => 5,
'spot/v1/symbols/trades' => 5,
// contract markets
'contract/v1/tickers' => 15,
'contract/public/details' => 5,
'contract/public/depth' => 5,
'contract/public/open-interest' => 30,
'contract/public/funding-rate' => 30,
'contract/public/kline' => 6, // should be 5 but errors
'account/v1/currencies' => 30,
),
),
'private' => array(
'get' => array(
// sub-account
'account/sub-account/v1/transfer-list' => 7.5,
'account/sub-account/v1/transfer-history' => 7.5,
'account/sub-account/main/v1/wallet' => 5,
'account/sub-account/main/v1/subaccount-list' => 7.5,
'account/contract/sub-account/main/v1/wallet' => 5,
'account/contract/sub-account/main/v1/transfer-list' => 7.5,
'account/contract/sub-account/v1/transfer-history' => 7.5,
// account
'account/v1/wallet' => 5,
'account/v1/currencies' => 30,
'spot/v1/wallet' => 5,
'account/v1/deposit/address' => 30,
'account/v1/withdraw/charge' => 32, // should be 30 but errors
'account/v2/deposit-withdraw/history' => 7.5,
'account/v1/deposit-withdraw/detail' => 7.5,
// order
'spot/v1/order_detail' => 1,
'spot/v2/orders' => 5,
'spot/v1/trades' => 5,
// newer order endpoint
'spot/v2/trades' => 4,
'spot/v3/orders' => 5,
'spot/v2/order_detail' => 1,
// margin
'spot/v1/margin/isolated/borrow_record' => 1,
'spot/v1/margin/isolated/repay_record' => 1,
'spot/v1/margin/isolated/pairs' => 30,
'spot/v1/margin/isolated/account' => 5,
'spot/v1/trade_fee' => 30,
'spot/v1/user_fee' => 30,
// broker
'spot/v1/broker/rebate' => 1,
// contract
'contract/private/assets-detail' => 5,
'contract/private/order' => 1.2,
'contract/private/order-history' => 10,
'contract/private/position' => 10,
'contract/private/get-open-orders' => 1.2,
'contract/private/current-plan-order' => 1.2,
'contract/private/trades' => 10,
'contract/private/position-risk' => 10,
'contract/private/affilate/rebate-list' => 10,
'contract/private/affilate/trade-list' => 10,
),
'post' => array(
// sub-account endpoints
'account/sub-account/main/v1/sub-to-main' => 30,
'account/sub-account/sub/v1/sub-to-main' => 30,
'account/sub-account/main/v1/main-to-sub' => 30,
'account/sub-account/sub/v1/sub-to-sub' => 30,
'account/sub-account/main/v1/sub-to-sub' => 30,
'account/contract/sub-account/main/v1/sub-to-main' => 7.5,
'account/contract/sub-account/main/v1/main-to-sub' => 7.5,
'account/contract/sub-account/sub/v1/sub-to-main' => 7.5,
// account
'account/v1/withdraw/apply' => 7.5,
// transaction and trading
'spot/v1/submit_order' => 1,
'spot/v1/batch_orders' => 1,
'spot/v2/cancel_order' => 1,
'spot/v1/cancel_orders' => 15,
'spot/v4/query/order' => 1, // 60 times/2 sec = 30/s => 30/30 = 1
'spot/v4/query/client-order' => 1, // 60 times/2 sec = 30/s => 30/30 = 1
'spot/v4/query/open-orders' => 5, // 12 times/2 sec = 6/s => 30/6 = 5
'spot/v4/query/history-orders' => 5, // 12 times/2 sec = 6/s => 30/6 = 5
'spot/v4/query/trades' => 5, // 12 times/2 sec = 6/s => 30/6 = 5
'spot/v4/query/order-trades' => 5, // 12 times/2 sec = 6/s => 30/6 = 5
'spot/v4/cancel_orders' => 3,
'spot/v4/cancel_all' => 90,
'spot/v4/batch_orders' => 3,
// newer endpoint
'spot/v3/cancel_order' => 1,
'spot/v2/batch_orders' => 1,
'spot/v2/submit_order' => 1,
// margin
'spot/v1/margin/submit_order' => 1,
'spot/v1/margin/isolated/borrow' => 30,
'spot/v1/margin/isolated/repay' => 30,
'spot/v1/margin/isolated/transfer' => 30,
// contract
'account/v1/transfer-contract-list' => 60,
'account/v1/transfer-contract' => 60,
'contract/private/submit-order' => 2.5,
'contract/private/cancel-order' => 1.5,
'contract/private/cancel-orders' => 30,
'contract/private/submit-plan-order' => 2.5,
'contract/private/cancel-plan-order' => 1.5,
'contract/private/submit-leverage' => 2.5,
'contract/private/submit-tp-sl-order' => 2.5,
'contract/private/modify-plan-order' => 2.5,
'contract/private/modify-preset-plan-order' => 2.5,
'contract/private/modify-tp-sl-order' => 2.5,
),
),
),
'timeframes' => array(
'1m' => 1,
'3m' => 3,
'5m' => 5,
'15m' => 15,
'30m' => 30,
'45m' => 45,
'1h' => 60,
'2h' => 120,
'3h' => 180,
'4h' => 240,
'1d' => 1440,
'1w' => 10080,
'1M' => 43200,
),
'fees' => array(
'trading' => array(
'tierBased' => true,
'percentage' => true,
'taker' => $this->parse_number('0.0040'),
'maker' => $this->parse_number('0.0035'),
'tiers' => array(
'taker' => array(
array( $this->parse_number('0'), $this->parse_number('0.0020') ),
array( $this->parse_number('10'), $this->parse_number('0.18') ),
array( $this->parse_number('50'), $this->parse_number('0.0016') ),
array( $this->parse_number('250'), $this->parse_number('0.0014') ),
array( $this->parse_number('1000'), $this->parse_number('0.0012') ),
array( $this->parse_number('5000'), $this->parse_number('0.0010') ),
array( $this->parse_number('25000'), $this->parse_number('0.0008') ),
array( $this->parse_number('50000'), $this->parse_number('0.0006') ),
),
'maker' => array(
array( $this->parse_number('0'), $this->parse_number('0.001') ),
array( $this->parse_number('10'), $this->parse_number('0.0009') ),
array( $this->parse_number('50'), $this->parse_number('0.0008') ),
array( $this->parse_number('250'), $this->parse_number('0.0007') ),
array( $this->parse_number('1000'), $this->parse_number('0.0006') ),
array( $this->parse_number('5000'), $this->parse_number('0.0005') ),
array( $this->parse_number('25000'), $this->parse_number('0.0004') ),
array( $this->parse_number('50000'), $this->parse_number('0.0003') ),
),
),
),
),
'precisionMode' => TICK_SIZE,
'exceptions' => array(
'exact' => array(
// general errors
'30000' => '\\ccxt\\ExchangeError', // 404, Not found
'30001' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-KEY is empty
'30002' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-KEY not found
'30003' => '\\ccxt\\AccountSuspended', // 401, Header X-BM-KEY has frozen
'30004' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-SIGN is empty
'30005' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-SIGN is wrong
'30006' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-TIMESTAMP is empty
'30007' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-TIMESTAMP range. Within a minute
'30008' => '\\ccxt\\AuthenticationError', // 401, Header X-BM-TIMESTAMP invalid format
'30010' => '\\ccxt\\PermissionDenied', // 403, IP is forbidden. We recommend enabling IP whitelist for API trading. After that reauth your account
'30011' => '\\ccxt\\AuthenticationError', // 403, Header X-BM-KEY over expire time
'30012' => '\\ccxt\\AuthenticationError', // 403, Header X-BM-KEY is forbidden to request it
'30013' => '\\ccxt\\RateLimitExceeded', // 429, Request too many requests
'30014' => '\\ccxt\\ExchangeNotAvailable', // 503, Service unavailable
'30016' => '\\ccxt\\OnMaintenance', // 200, Service maintenance, the function is temporarily unavailable
'30017' => '\\ccxt\\RateLimitExceeded', // 418, Your account request is temporarily rejected due to violation of current limiting rules
'30018' => '\\ccxt\\BadRequest', // 503, Request Body requires JSON format
'30019' => '\\ccxt\\PermissionDenied', // 200, You do not have the permissions to perform this operation
// funding account & sub account errors
'60000' => '\\ccxt\\BadRequest', // 400, Invalid request (maybe the body is empty, or the int parameter passes string data)
'60001' => '\\ccxt\\BadRequest', // 400, Asset account type does not exist
'60002' => '\\ccxt\\BadRequest', // 400, currency does not exist
'60003' => '\\ccxt\\ExchangeError', // 400, Currency has been closed recharge channel, if there is any problem, please consult customer service
'60004' => '\\ccxt\\ExchangeError', // 400, Currency has been closed withdraw channel, if there is any problem, please consult customer service
'60005' => '\\ccxt\\ExchangeError', // 400, Minimum amount is %s
'60006' => '\\ccxt\\ExchangeError', // 400, Maximum withdraw precision is %d
'60007' => '\\ccxt\\InvalidAddress', // 400, Only withdrawals from added addresses are allowed
'60008' => '\\ccxt\\InsufficientFunds', // 400, Balance not enough
'60009' => '\\ccxt\\ExchangeError', // 400, Beyond the limit
'60010' => '\\ccxt\\ExchangeError', // 400, Withdraw id or deposit id not found
'60011' => '\\ccxt\\InvalidAddress', // 400, Address is not valid
'60012' => '\\ccxt\\ExchangeError', // 400, This action is not property_exists($this, supported) currency(If IOTA, HLX recharge and withdraw calls are prohibited)
'60020' => '\\ccxt\\PermissionDenied', // 403, Your account is not allowed to recharge
'60021' => '\\ccxt\\PermissionDenied', // 403, Your account is not allowed to withdraw
'60022' => '\\ccxt\\PermissionDenied', // 403, No withdrawals for 24 hours
'60026' => '\\ccxt\\PermissionDenied', // 403, Sub-account does not have permission to operate
'60027' => '\\ccxt\\PermissionDenied', // 403, Only supports sub-account calls
'60028' => '\\ccxt\\AccountSuspended', // 403, Account is disabled for security reasons, please contact customer service
'60029' => '\\ccxt\\AccountSuspended', // 403, The account is frozen by the master account, please contact the master account to unfreeze the account
'60030' => '\\ccxt\\BadRequest', // 405, Method Not Allowed
'60031' => '\\ccxt\\BadRequest', // 415, Unsupported Media Type
'60050' => '\\ccxt\\ExchangeError', // 500, User account not found
'60051' => '\\ccxt\\ExchangeError', // 500, Internal Server Error
'61001' => '\\ccxt\\InsufficientFunds', // array("message":"Balance not enough","code":61001,"trace":"b85ea1f8-b9af-4001-ac5f-9e061fe93d78","data":array())
'61003' => '\\ccxt\\BadRequest', // 400, array("message":"sub-account not found","code":61003,"trace":"b35ec2fd-0bc9-4ef2-a3c0-6f78d4f335a4","data":array())
'61004' => '\\ccxt\\BadRequest', // 400, Duplicate requests (such an existing requestNo)
'61005' => '\\ccxt\\BadRequest', // 403, Asset transfer between accounts is not available
'61006' => '\\ccxt\\NotSupported', // 403, The sub-account api only supports organization accounts
'61007' => '\\ccxt\\ExchangeError', // 403, Please complete your institution verification to enable withdrawal function.
'61008' => '\\ccxt\\ExchangeError', // 403, Suspend transfer out
// spot public errors
'70000' => '\\ccxt\\ExchangeError', // 200, no data
'70001' => '\\ccxt\\BadRequest', // 200, request param can not be null
'70002' => '\\ccxt\\BadSymbol', // 200, symbol is invalid
'70003' => '\\ccxt\\NetworkError', // array("code":70003,"trace":"81a9d57b63be4819b65d3065e6a4682b.105.17105295323593915","message":"net error, please try later","data":null)
'71001' => '\\ccxt\\BadRequest', // 200, after is invalid
'71002' => '\\ccxt\\BadRequest', // 200, before is invalid
'71003' => '\\ccxt\\BadRequest', // 200, request after or before is invalid
'71004' => '\\ccxt\\BadRequest', // 200, request kline count limit
'71005' => '\\ccxt\\BadRequest', // 200, request step error
// spot & margin errors
'50000' => '\\ccxt\\BadRequest', // 400, Bad Request
'50001' => '\\ccxt\\BadSymbol', // 400, Symbol not found
'50002' => '\\ccxt\\BadRequest', // 400, From Or To format error
'50003' => '\\ccxt\\BadRequest', // 400, Step format error
'50004' => '\\ccxt\\BadRequest', // 400, Kline size over 500
'50005' => '\\ccxt\\OrderNotFound', // 400, Order Id not found
'50006' => '\\ccxt\\InvalidOrder', // 400, Minimum size is %s
'50007' => '\\ccxt\\InvalidOrder', // 400, Maximum size is %s
'50008' => '\\ccxt\\InvalidOrder', // 400, Minimum price is %s
'50009' => '\\ccxt\\InvalidOrder', // 400, Minimum count*price is %s
'50010' => '\\ccxt\\InvalidOrder', // 400, RequestParam size is required
'50011' => '\\ccxt\\InvalidOrder', // 400, RequestParam price is required
'50012' => '\\ccxt\\InvalidOrder', // 400, RequestParam notional is required
'50013' => '\\ccxt\\InvalidOrder', // 400, Maximum limit*offset is %d
'50014' => '\\ccxt\\BadRequest', // 400, RequestParam limit is required
'50015' => '\\ccxt\\BadRequest', // 400, Minimum limit is 1
'50016' => '\\ccxt\\BadRequest', // 400, Maximum limit is %d
'50017' => '\\ccxt\\BadRequest', // 400, RequestParam offset is required
'50018' => '\\ccxt\\BadRequest', // 400, Minimum offset is 1
'50019' => '\\ccxt\\ExchangeError', // 400, Invalid status. validate status is [1=Failed, 2=Success, 3=Frozen Failed, 4=Frozen Success, 5=Partially Filled, 6=Fully Fulled, 7=Canceling, 8=Canceled] '50020' => '\\ccxt\\InsufficientFunds', // 400, Balance not enough
'50020' => '\\ccxt\\InsufficientFunds', // 400, Balance not enough
'50021' => '\\ccxt\\BadRequest', // 400, Invalid %s
'50022' => '\\ccxt\\ExchangeNotAvailable', // 400, Service unavailable
'50023' => '\\ccxt\\BadSymbol', // 400, This Symbol can't place order by api
'50024' => '\\ccxt\\BadRequest', // 400, Order book size over 200
'50025' => '\\ccxt\\BadRequest', // 400, Maximum price is %s
'50026' => '\\ccxt\\BadRequest', // 400, The buy order price cannot be higher than the open price
'50027' => '\\ccxt\\BadRequest', // 400, The sell order price cannot be lower than the open price
'50028' => '\\ccxt\\BadRequest', // 400, Missing parameters
'50029' => '\\ccxt\\InvalidOrder', // 400, array("message":"param not match : size * price >=1000","code":50029,"trace":"f931f030-b692-401b-a0c5-65edbeadc598","data":array())
'50030' => '\\ccxt\\OrderNotFound', // 400, array("message":"Order is already canceled","code":50030,"trace":"8d6f64ee-ad26-45a4-9efd-1080f9fca1fa","data":array())
'50031' => '\\ccxt\\OrderNotFound', // 400, Order is already completed
'50032' => '\\ccxt\\OrderNotFound', // 400, array("message":"Order does not exist","code":50032,"trace":"8d6b482d-4bf2-4e6c-aab2-9dcd22bf2481","data":array())
'50033' => '\\ccxt\\InvalidOrder', // 400, The order quantity should be greater than 0 and less than or equal to 10
// below Error codes used interchangeably for both failed postOnly and IOC orders depending on market price and order side
'50034' => '\\ccxt\\InvalidOrder', // 400, array("message":"The price is high and there is no matching depth","code":50034,"trace":"ebfae59a-ba69-4735-86b2-0ed7b9ca14ea","data":array())
'50035' => '\\ccxt\\InvalidOrder', // 400, array("message":"The price is low and there is no matching depth","code":50035,"trace":"677f01c7-8b88-4346-b097-b4226c75c90e","data":array())
'50036' => '\\ccxt\\ExchangeError', // 400, Cancel failed, order is not revocable status
'50037' => '\\ccxt\\BadRequest', // 400, The maximum length of clientOrderId cannot exceed 32
'50038' => '\\ccxt\\BadRequest', // 400, ClientOrderId only allows a combination of numbers and letters
'50039' => '\\ccxt\\BadRequest', // 400, Order_id and clientOrderId cannot be empty at the same time
'50040' => '\\ccxt\\BadSymbol', // 400, Symbol Not Available
'50041' => '\\ccxt\\ExchangeError', // 400, Out of query time range
'50042' => '\\ccxt\\BadRequest', // 400, clientOrderId is duplicate
'51000' => '\\ccxt\\BadSymbol', // 400, Currency not found
'51001' => '\\ccxt\\ExchangeError', // 400, Margin Account not Opened
'51002' => '\\ccxt\\ExchangeError', // 400, Margin Account Not Available
'51003' => '\\ccxt\\ExchangeError', // 400, Account Limit
'51004' => '\\ccxt\\InsufficientFunds', // 400, array("message":"Exceed the maximum number of borrows available.","code":51004,"trace":"4030b753-9beb-44e6-8352-1633c5edcd47","data":array())
'51005' => '\\ccxt\\InvalidOrder', // 400, Less than the minimum borrowable amount
'51006' => '\\ccxt\\InvalidOrder', // 400, Exceeds the amount to be repaid
'51007' => '\\ccxt\\BadRequest', // 400, order_mode not found
'51008' => '\\ccxt\\ExchangeError', // 400, Operation is limited, please try again later
'51009' => '\\ccxt\\InvalidOrder', // 400, Parameter mismatch => limit order/market order quantity should be greater than the minimum number of should buy/sell
'51010' => '\\ccxt\\InvalidOrder', // 400, Parameter mismatch => limit order price should be greater than the minimum buy price
'51011' => '\\ccxt\\InvalidOrder', // 400, array("message":"param not match : size * price >=5","code":51011,"trace":"525e1d27bfd34d60b2d90ba13a7c0aa9.74.16696421352220797","data":array())
'51012' => '\\ccxt\\InvalidOrder', // 400, Parameter mismatch => limit order price should be greater than the minimum buy price
'51013' => '\\ccxt\\InvalidOrder', // 400, Parameter mismatch => Limit order quantity * price should be greater than the minimum transaction amount
'51014' => '\\ccxt\\InvalidOrder', // 400, Participation mismatch => the number of market order buy orders should be greater than the minimum buyable amount
'51015' => '\\ccxt\\InvalidOrder', // 400, Parameter mismatch => the price of market order buy order placed is too small
'52000' => '\\ccxt\\BadRequest', // 400, Unsupported OrderMode Type
'52001' => '\\ccxt\\BadRequest', // 400, Unsupported Trade Type
'52002' => '\\ccxt\\BadRequest', // 400, Unsupported Side Type
'52003' => '\\ccxt\\BadRequest', // 400, Unsupported Query State Type
'52004' => '\\ccxt\\BadRequest', // 400, End time must be greater than or equal to Start time
'53000' => '\\ccxt\\AccountSuspended', // 403, Your account is frozen due to security policies. Please contact customer service
'53001' => '\\ccxt\\AccountSuspended', // 403, array("message":"Your kyc country is restricted. Please contact customer service.","code":53001,"trace":"8b445940-c123-4de9-86d7-73c5be2e7a24","data":array())
'53002' => '\\ccxt\\PermissionDenied', // 403, Your account has not yet completed the kyc advanced certification, please complete first
'53003' => '\\ccxt\\PermissionDenied', // 403 No permission, please contact the main account
'53005' => '\\ccxt\\PermissionDenied', // 403 Don't have permission to access the interface
'53006' => '\\ccxt\\PermissionDenied', // 403 Please complete your personal verification(Starter)
'53007' => '\\ccxt\\PermissionDenied', // 403 Please complete your personal verification(Advanced)
'53008' => '\\ccxt\\PermissionDenied', // 403 Services is not available in your countries and areas
'53009' => '\\ccxt\\PermissionDenied', // 403 Your account has not yet completed the qr code certification, please complete first
'53010' => '\\ccxt\\PermissionDenied', // 403 This account is restricted from borrowing
'57001' => '\\ccxt\\BadRequest', // 405, Method Not Allowed
'58001' => '\\ccxt\\BadRequest', // 415, Unsupported Media Type
'59001' => '\\ccxt\\ExchangeError', // 500, User account not found
'59002' => '\\ccxt\\ExchangeError', // 500, Internal Server Error
'59003' => '\\ccxt\\ExchangeError', // 500, Spot wallet call fail
'59004' => '\\ccxt\\ExchangeError', // 500, Margin wallet service call exception
'59005' => '\\ccxt\\PermissionDenied', // 500, Margin wallet service restricted
'59006' => '\\ccxt\\ExchangeError', // 500, Transfer fail
'59007' => '\\ccxt\\ExchangeError', // 500, Get symbol risk data fail
'59008' => '\\ccxt\\ExchangeError', // 500, Trading order failure
'59009' => '\\ccxt\\ExchangeError', // 500, Loan success,but trading order failure
'59010' => '\\ccxt\\InsufficientFunds', // 500, Insufficient loan amount.
'59011' => '\\ccxt\\ExchangeError', // 500, The Get Wallet Balance service call fail, please try again later
// contract errors
'40001' => '\\ccxt\\ExchangeError', // 400, Cloud account not found
'40002' => '\\ccxt\\ExchangeError', // 400, out_trade_no not found
'40003' => '\\ccxt\\ExchangeError', // 400, out_trade_no already existed
'40004' => '\\ccxt\\ExchangeError', // 400, Cloud account count limit
'40005' => '\\ccxt\\ExchangeError', // 400, Transfer vol precision error
'40006' => '\\ccxt\\PermissionDenied', // 400, Invalid ip error
'40007' => '\\ccxt\\BadRequest', // 400, Parse parameter error
'40008' => '\\ccxt\\InvalidNonce', // 400, Check nonce error
'40009' => '\\ccxt\\BadRequest', // 400, Check ver error
'40010' => '\\ccxt\\BadRequest', // 400, Not found func error
'40011' => '\\ccxt\\BadRequest', // 400, Invalid request
'40012' => '\\ccxt\\ExchangeError', // 500, System error
'40013' => '\\ccxt\\ExchangeError', // 400, Access too often" CLIENT_TIME_INVALID, "Please check your system time.
'40014' => '\\ccxt\\BadSymbol', // 400, This contract is offline
'40015' => '\\ccxt\\BadSymbol', // 400, This contract's exchange has been paused
'40016' => '\\ccxt\\InvalidOrder', // 400, This order would trigger user position liquidate
'40017' => '\\ccxt\\InvalidOrder', // 400, It is not possible to open and close simultaneously in the same position
'40018' => '\\ccxt\\InvalidOrder', // 400, Your position is closed
'40019' => '\\ccxt\\ExchangeError', // 400, Your position is in liquidation delegating
'40020' => '\\ccxt\\InvalidOrder', // 400, Your position volume is not enough
'40021' => '\\ccxt\\ExchangeError', // 400, The position is not exsit
'40022' => '\\ccxt\\ExchangeError', // 400, The position is not isolated
'40023' => '\\ccxt\\ExchangeError', // 400, The position would liquidate when sub margin
'40024' => '\\ccxt\\ExchangeError', // 400, The position would be warnning of liquidation when sub margin
'40025' => '\\ccxt\\ExchangeError', // 400, The position’s margin shouldn’t be lower than the base limit
'40026' => '\\ccxt\\ExchangeError', // 400, You cross margin position is in liquidation delegating
'40027' => '\\ccxt\\InsufficientFunds', // 400, You contract account available balance not enough
'40028' => '\\ccxt\\PermissionDenied', // 400, Your plan order's count is more than system maximum limit.
'40029' => '\\ccxt\\InvalidOrder', // 400, The order's leverage is too large.
'40030' => '\\ccxt\\InvalidOrder', // 400, The order's leverage is too small.
'40031' => '\\ccxt\\InvalidOrder', // 400, The deviation between current price and trigger price is too large.
'40032' => '\\ccxt\\InvalidOrder', // 400, The plan order's life cycle is too long.
'40033' => '\\ccxt\\InvalidOrder', // 400, The plan order's life cycle is too short.
'40034' => '\\ccxt\\BadSymbol', // 400, This contract is not found
'40035' => '\\ccxt\\OrderNotFound', // 400, The order is not exist
'40036' => '\\ccxt\\InvalidOrder', // 400, The order status is invalid
'40037' => '\\ccxt\\OrderNotFound', // 400, The order id is not exist
'40038' => '\\ccxt\\BadRequest', // 400, The k-line step is invalid
'40039' => '\\ccxt\\BadRequest', // 400, The timestamp is invalid
'40040' => '\\ccxt\\InvalidOrder', // 400, The order leverage is invalid
'40041' => '\\ccxt\\InvalidOrder', // 400, The order side is invalid
'40042' => '\\ccxt\\InvalidOrder', // 400, The order type is invalid
'40043' => '\\ccxt\\InvalidOrder', // 400, The order precision is invalid
'40044' => '\\ccxt\\InvalidOrder', // 400, The order range is invalid
'40045' => '\\ccxt\\InvalidOrder', // 400, The order open type is invalid
'40046' => '\\ccxt\\PermissionDenied', // 403, The account is not opened futures
'40047' => '\\ccxt\\PermissionDenied', // 403, Services is not available in you countries and areas
'40048' => '\\ccxt\\InvalidOrder', // 403, ClientOrderId only allows a combination of numbers and letters
'40049' => '\\ccxt\\InvalidOrder', // 403, The maximum length of clientOrderId cannot exceed 32
'40050' => '\\ccxt\\InvalidOrder', // 403, Client OrderId duplicated with existing orders
),
'broad' => array(),
),
'commonCurrencies' => array(
'$GM' => 'GOLDMINER',
'$HERO' => 'Step Hero',
'$PAC' => 'PAC',
'BP' => 'BEYOND',
'GDT' => 'Gorilla Diamond',
'GLD' => 'Goldario',
'MVP' => 'MVP Coin',
'TRU' => 'Truebit', // conflict with TrueFi
),
'options' => array(
'defaultNetwork' => 'ERC20',
'defaultNetworks' => array(
'USDT' => 'ERC20',
),
'networks' => array(
'ERC20' => 'ERC20',
'SOL' => 'SOL',
'BTC' => 'BTC',
'TRC20' => 'TRC20',
// todo => should be TRX after unification
// 'TRC20' => array( 'TRC20', 'trc20', 'TRON' ), // todo => after unification i.e. TRON is returned from fetchDepositAddress
// 'ERC20' => array( 'ERC20', 'ERC-20', 'ERC20 ' ), // todo => after unification
'OMNI' => 'OMNI',
'XLM' => 'XLM',
'EOS' => 'EOS',
'NEO' => 'NEO',
'BTM' => 'BTM',
'BCH' => 'BCH',
'LTC' => 'LTC',
'BSV' => 'BSV',
'XRP' => 'XRP',
// 'VECHAIN' => array( 'VET', 'Vechain' ), // todo => after unification
'PLEX' => 'PLEX',
'XCH' => 'XCH',
// 'AVALANCHE_C' => array( 'AVAX', 'AVAX-C' ), // todo => after unification
'NEAR' => 'NEAR',
'FIO' => 'FIO',
'SCRT' => 'SCRT',
'IOTX' => 'IOTX',
'ALGO' => 'ALGO',
'ATOM' => 'ATOM',
'DOT' => 'DOT',
'ADA' => 'ADA',
'DOGE' => 'DOGE',
'XYM' => 'XYM',
'GLMR' => 'GLMR',
'MOVR' => 'MOVR',
'ZIL' => 'ZIL',
'INJ' => 'INJ',
'KSM' => 'KSM',
'ZEC' => 'ZEC',
'NAS' => 'NAS',
// 'POLYGON' => array( 'MATIC', 'Polygon', 'POLYGON' ), // todo => after unification
'HRC20' => 'HECO',
'XDC' => 'XDC',
'ONE' => 'ONE',
'LAT' => 'LAT',
'CSPR' => 'Casper',
'ICP' => 'Computer',
'XTZ' => 'XTZ',
'MINA' => 'MINA',
// 'BEP20' => array( 'BEP20', 'BSC_BNB', 'bep20' ), // todo => after unification
'THETA' => 'THETA',
'AKT' => 'AKT',
'AR' => 'AR',
'CELO' => 'CELO',
'FIL' => 'FIL',
'NULS' => 'NULS',
'ETC' => 'ETC',
'DASH' => 'DASH',
'DGB' => 'DGB',
'BEP2' => 'BEP2',
'GRIN' => 'GRIN',
'WAVES' => 'WAVES',
'ABBC' => 'ABBC',
'ACA' => 'ACA',
'QTUM' => 'QTUM',
'PAC' => 'PAC',
// 'TERRACLASSIC' => 'LUNC', // TBD
// 'TERRA' => 'Terra', // TBD
// 'HEDERA' => array( 'HBAR', 'Hedera', 'Hedera Mainnet' ), // todo => after unification
'TLOS' => 'TLOS',
'KARDIA' => 'KardiaChain',
'FUSE' => 'FUSE',
'TRC10' => 'TRC10',
'FIRO' => 'FIRO',
'FTM' => 'Fantom',
// 'KLAYTN' => array( 'klaytn', 'KLAY', 'Klaytn' ), // todo => after unification
// 'ELROND' => array( 'EGLD', 'Elrond eGold', 'MultiversX' ), // todo => after unification
'EVER' => 'EVER',
'KAVA' => 'KAVA',
'HYDRA' => 'HYDRA',
'PLCU' => 'PLCU',
'BRISE' => 'BRISE',
// 'CRC20' => array( 'CRO', 'CRO_Chain' ), // todo => after unification
// 'CONFLUX' => array( 'CFX eSpace', 'CFX' ), // todo => after unification
'OPTIMISM' => 'OPTIMISM',
'REEF' => 'REEF',
'SYS' => 'SYS', // NEVM is different
'VITE' => 'VITE',
'STX' => 'STX',
'SXP' => 'SXP',
'BITCI' => 'BITCI',
// 'ARBITRUM' => array( 'ARBI', 'Arbitrum' ), // todo => after unification
'XRD' => 'XRD',
'ASTR' => 'ASTAR',
'ZEN' => 'HORIZEN',
'LTO' => 'LTO',
'ETHW' => 'ETHW',
'ETHF' => 'ETHF',
'IOST' => 'IOST',
// 'CHILIZ' => array( 'CHZ', 'CHILIZ' ), // todo => after unification
'APT' => 'APT',
// 'FLOW' => array( 'FLOW', 'Flow' ), // todo => after unification
'ONT' => 'ONT',
'EVMOS' => 'EVMOS',
'XMR' => 'XMR',
'OASYS' => 'OAS',
'OSMO' => 'OSMO',
'OMAX' => 'OMAX Chain',
'DESO' => 'DESO',
'BFIC' => 'BFIC',
'OHO' => 'OHO',
'CS' => 'CS',
'CHEQ' => 'CHEQ',
'NODL' => 'NODL',
'NEM' => 'XEM',
'FRA' => 'FRA',
'ERGO' => 'ERG',
// todo => below will be uncommented after unification
// 'BITCOINHD' => 'BHD',
// 'CRUST' => 'CRU',
// 'MINTME' => 'MINTME',
// 'ZENITH' => 'ZENITH',
// 'ZENIQ' => 'ZENIQ', // "ZEN-20" is different
// 'BITCOINVAULT' => 'BTCV',
// 'MOBILECOIN' => 'MBX',
// 'PINETWORK' => 'PI',
// 'PI' => 'PI',
// 'REBUS' => 'REBUS',
// 'XODEX' => 'XODEX',
// 'ULTRONGLOW' => 'UTG'
// 'QIBLOCKCHAIN' => 'QIE',
// 'XIDEN' => 'XDEN',
// 'PHAETON' => 'PHAE',
// 'REDLIGHT' => 'REDLC',
// 'VERITISE' => 'VTS',
// 'VERIBLOCK' => 'VBK',
// 'RAMESTTA' => 'RAMA',
// 'BITICA' => 'BDCC',
// 'CROWNSOVEREIGN' => 'CSOV',
// 'DRAC' => 'DRC20',
// 'QCHAIN' => 'QDT',
// 'KINGARU' => 'KRU',
// 'PROOFOFMEMES' => 'POM',
// 'CUBE' => 'CUBE',
// 'CADUCEUS' => 'CMP',
// 'VEIL' => 'VEIL',
// 'ENERGYWEB' => 'EWT',
// 'CYPHERIUM' => 'CPH',
// 'LBRY' => 'LBC',
// 'ETHERCOIN' => 'ETE',
// undetermined chains:
// LEX (for LexThum), TAYCAN (for TRICE), SFL (probably TAYCAN), OMNIA (for APEX), NAC (for NAC), KAG (Kinesis), CEM (crypto emergency), XVM (for Venidium), NEVM (for NEVM), IGT20 (for IGNITE), FILM (FILMCredits), CC (CloudCoin), MERGE (MERGE), LTNM (Bitcoin latinum), PLUGCN ( PlugChain), DINGO (dingo), LED (LEDGIS), AVAT (AVAT), VSOL (Vsolidus), EPIC (EPIC cash), NFC (netflowcoin), mrx (Metrix Coin), Idena (idena network), PKT (PKT Cash), BondDex (BondDex), XBN (XBN), KALAM (Kalamint), REV (RChain), KRC20 (MyDeFiPet), ARC20 (Hurricane Token), GMD (Coop network), BERS (Berith), ZEBI (Zebi), BRC (Baer Chain), DAPS (DAPS Coin), APL (Gold Secured Currency), NDAU (NDAU), WICC (WICC), UPG (Unipay God), TSL (TreasureSL), MXW (Maxonrow), CLC (Cifculation), SMH (SMH Coin), XIN (CPCoin), RDD (ReddCoin), OK (Okcash), KAR (KAR), CCX (ConcealNetwork),
),
'defaultType' => 'spot', // 'spot', 'swap'
'fetchBalance' => array(
'type' => 'spot', // 'spot', 'swap', 'account'
),
'accountsByType' => array(
'spot' => 'spot',
'swap' => 'swap',
),
'createMarketBuyOrderRequiresPrice' => true,
'brokerId' => 'CCXTxBitmart000',
),
'features' => array(
'default' => array(
'sandbox' => false,
'createOrder' => array(
'marginMode' => true,
'triggerPrice' => false,
'triggerPriceType' => null,
'triggerDirection' => false,
'stopLossPrice' => false,
'takeProfitPrice' => false,
'attachedStopLossTakeProfit' => null,
'timeInForce' => array(
'IOC' => true,
'FOK' => false,
'PO' => true,
'GTD' => false,
),
'hedged' => false,
'trailing' => false,
'marketBuyRequiresPrice' => true,
'marketBuyByCost' => true,
// exchange-supported features
// 'leverage' => true,
// 'selfTradePrevention' => false,
// 'twap' => false,
// 'iceberg' => false,
// 'oco' => false,
),
'createOrders' => array(
'max' => 10,
),
'fetchMyTrades' => array(
'marginMode' => true,
'limit' => 200,
'daysBack' => null,
'untilDays' => 99999,
),
'fetchOrder' => array(
'marginMode' => false,
'trigger' => false,
'trailing' => false,
),
'fetchOpenOrders' => array(
'marginMode' => true,
'limit' => 200,
'trigger' => false,
'trailing' => false,
),
'fetchOrders' => null,
'fetchClosedOrders' => array(
'marginMode' => true,
'limit' => 200,
'daysBackClosed' => null,
'daysBackCanceled' => null,
'untilDays' => null,
'trigger' => false,
'trailing' => false,
),
'fetchOHLCV' => array(
'limit' => 1000, // variable timespans for recent endpoint, 200 for historical
),
),
'forDerivatives' => array(
'extends' => 'default',
'createOrder' => array(
'marginMode' => true,
'triggerPrice' => true,
'triggerPriceType' => array(
'last' => true,
'mark' => true,
'index' => false,
),
'triggerDirection' => true, // todo => implementation broken
'stopLossPrice' => true,
'takeProfitPrice' => true,
'attachedStopLossTakeProfit' => array(
'triggerPriceType' => array(
'last' => true,
'mark' => true,
'index' => false,
),
'limitPrice' => false,
),
'timeInForce' => array(
'IOC' => true,
'FOK' => true,
'PO' => true,
'GTD' => false,
),
'hedged' => false,
'trailing' => true,
'marketBuyRequiresPrice' => true,
'marketBuyByCost' => true,
// exchange-supported features
// 'selfTradePrevention' => true,
// 'twap' => false,
// 'iceberg' => false,
// 'oco' => false,
),
'fetchMyTrades' => array(
'marginMode' => true,
'limit' => null,
'daysBack' => null,
'untilDays' => 99999,
),
'fetchOrder' => array(
'marginMode' => false,
'trigger' => false,
'trailing' => true,
),
'fetchOpenOrders' => array(
'marginMode' => false,
'limit' => 100,
'trigger' => true,
'trailing' => false,
),
'fetchClosedOrders' => array(
'marginMode' => true,
'limit' => 200,
'daysBackClosed' => null,
'daysBackCanceled' => null,
'untilDays' => null,
'trigger' => false,
'trailing' => false,
),
'fetchOHLCV' => array(
'limit' => 500,
),
),
'spot' => array(
'extends' => 'default',
),
'swap' => array(
'linear' => array(
'extends' => 'forDerivatives',
),
'inverse' => array(
'extends' => 'forDerivatives',
),
),
'future' => array(
'linear' => null,
'inverse' => null,
),
),
));
}
public function fetch_time($params = array ()) {
/**
* fetches the current integer timestamp in milliseconds from the exchange server
* @param {array} [$params] extra parameters specific to the exchange API endpoint
* @return {int} the current integer timestamp in milliseconds from the exchange server
*/
$response = $this->publicGetSystemTime ($params);
//
// {
// "message":"OK",
// "code":1000,
// "trace":"c4e5e5b7-fe9f-4191-89f7-53f6c5bf9030",
// "data":{
// "server_time":1599843709578
// }
// }
//
$data = $this->safe_dict($response, 'data', array());
return $this->safe_integer($data, 'server_time');
}
public function fetch_status($params = array ()) {
/**
* the latest known information on the availability of the exchange API
* @param {array} [$params] extra parameters specific to the exchange API endpoint
* @return {array} a ~@link https://docs.ccxt.com/#/?id=exchange-$status-structure $status structure~
*/
$options = $this->safe_dict($this->options, 'fetchStatus', array());
$defaultType = $this->safe_string($this->options, 'defaultType');
$type = $this->safe_string($options, 'type', $defaultType);
$type = $this->safe_string($params, 'type', $type);
$params = $this->omit($params, 'type');
$response = $this->publicGetSystemService ($params);
//
// {
// "message" => "OK",
// "code" => 1000,
// "trace" => "1d3f28b0-763e-4f78-90c4-5e3ad19dc595",
// "data" => {
// "service" => array(
// array(
// "title" => "Spot API Stop",
// "service_type" => "spot",
// "status" => 2,
// "start_time" => 1648639069125,
// "end_time" => 1648639069125
// ),
// {
// "title" => "Contract API Stop",
// "service_type" => "contract",
// "status" => 2,
// "start_time" => 1648639069125,
// "end_time" => 1648639069125
// }
// )
// }
// }
//
$data = $this->safe_dict($response, 'data', array());
$services = $this->safe_list($data, 'service', array());
$servicesByType = $this->index_by($services, 'service_type');
if ($type === 'swap') {
$type = 'contract';
}
$service = $this->safe_string($servicesByType, $type);
$status = null;
$eta = null;
if ($service !== null) {
$statusCode = $this->safe_integer($service, 'status');
if ($statusCode === 2) {
$status = 'ok';
} else {
$status = 'maintenance';
$eta = $this->safe_integer($service, 'end_time');
}
}
return array(
'status' => $status,
'updated' => null,
'eta' => $eta,
'url' => null,
'info' => $response,
);
}
public function fetch_spot_markets($params = array ()) {
$response = $this->publicGetSpotV1SymbolsDetails ($params);
//
// {
// "message":"OK",
// "code":1000,
// "trace":"a67c9146-086d-4d3f-9897-5636a9bb26e1",
// "data":{
// "symbols":array(
// array(
// "symbol" => "BTC_USDT",
// "symbol_id" => 53,
// "base_currency" => "BTC",
// "quote_currency" => "USDT",
// "base_min_size" => "0.000010000000000000000000000000",
// "base_max_size" => "100000000.000000000000000000000000000000",
// "price_min_precision" => -1,
// "price_max_precision" => 2,
// "quote_increment" => "0.00001", // Api docs says "The minimum order quantity is also the minimum order quantity increment", however I think they mistakenly use the term 'order quantity'
// "expiration" => "NA",
// "min_buy_amount" => "5.000000000000000000000000000000",
// "min_sell_amount" => "5.000000000000000000000000000000",
// "trade_status" => "trading"
// ),
// )
// }
// }
//
$data = $this->safe_dict($response, 'data', array());
$symbols = $this->safe_list($data, 'symbols', array());
$result = array();
for ($i = 0; $i < count($symbols); $i++) {
$market = $symbols[$i];
$id = $this->safe_string($market, 'symbol');
$numericId = $this->safe_integer($market, 'symbol_id');
$baseId = $this->safe_string($market, 'base_currency');
$quoteId = $this->safe_string($market, 'quote_currency');
$base = $this->safe_currency_code($baseId);
$quote = $this->safe_currency_code($quoteId);
$symbol = $base . '/' . $quote;
$minBuyCost = $this->safe_string($market, 'min_buy_amount');
$minSellCost = $this->safe_string($market, 'min_sell_amount');
$minCost = Precise::string_max($minBuyCost, $minSellCost);
$baseMinSize = $this->safe_number($market, 'base_min_size');
$result[] = array(
'id' => $id,
'numericId' => $numericId,
'symbol' => $symbol,
'base' => $base,
'quote' => $quote,
'settle' => null,
'baseId' => $baseId,
'quoteId' => $quoteId,
'settleId' => null,
'type' => 'spot',
'spot' => true,
'margin' => false,
'swap' => false,
'future' => false,
'option' => false,
'active' => true,
'contract' => false,
'linear' => null,
'inverse' => null,
'contractSize' => null,
'expiry' => null,
'expiryDatetime' => null,
'strike' => null,
'optionType' => null,
'precision' => array(
'amount' => $baseMinSize,
'price' => $this->parse_number($this->parse_precision($this->safe_string($market, 'price_max_precision'))),
),
'limits' => array(
'leverage' => array(
'min' => null,
'max' => null,
),
'amount' => array(
'min' => $baseMinSize,
'max' => $this->safe_number($market, 'base_max_size'),
),
'price' => array(