Repository navigation
Expand file tree
/
Copy pathexmo.py
More file actions
2524 lines (2411 loc) · 112 KB
/
Copy pathexmo.py
File metadata and controls
2524 lines (2411 loc) · 112 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
# -*- coding: utf-8 -*-
# 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
from ccxt.base.exchange import Exchange
from ccxt.abstract.exmo import ImplicitAPI
import hashlib
from ccxt.base.types import Balances, Currencies, Currency, DepositAddress, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
from typing import List
from ccxt.base.errors import ExchangeError
from ccxt.base.errors import AuthenticationError
from ccxt.base.errors import PermissionDenied
from ccxt.base.errors import ArgumentsRequired
from ccxt.base.errors import BadRequest
from ccxt.base.errors import InsufficientFunds
from ccxt.base.errors import InvalidOrder
from ccxt.base.errors import OrderNotFound
from ccxt.base.errors import RateLimitExceeded
from ccxt.base.errors import OnMaintenance
from ccxt.base.errors import InvalidNonce
from ccxt.base.decimal_to_precision import TICK_SIZE
from ccxt.base.precise import Precise
class exmo(Exchange, ImplicitAPI):
def describe(self):
return self.deep_extend(super(exmo, self).describe(), {
'id': 'exmo',
'name': 'EXMO',
'countries': ['LT'], # Lithuania
'rateLimit': 100, # 10 requests per 1 second
'version': 'v1.1',
'has': {
'CORS': None,
'spot': True,
'margin': True,
'swap': False,
'future': False,
'option': False,
'addMargin': True,
'cancelOrder': True,
'cancelOrders': False,
'createDepositAddress': False,
'createOrder': True,
'createStopLimitOrder': True,
'createStopMarketOrder': True,
'createStopOrder': True,
'editOrder': True, # margin only
'fetchAccounts': False,
'fetchBalance': True,
'fetchCanceledOrders': True,
'fetchCurrencies': True,
'fetchDeposit': True,
'fetchDepositAddress': True,
'fetchDepositAddresses': False,
'fetchDepositAddressesByNetwork': False,
'fetchDeposits': True,
'fetchDepositsWithdrawals': True,
'fetchDepositWithdrawFee': 'emulated',
'fetchDepositWithdrawFees': True,
'fetchFundingHistory': False,
'fetchFundingRate': False,
'fetchFundingRateHistory': False,
'fetchFundingRates': False,
'fetchIndexOHLCV': False,
'fetchMarginMode': False,
'fetchMarkets': True,
'fetchMarkOHLCV': False,
'fetchMyTrades': True,
'fetchOHLCV': True,
'fetchOpenInterestHistory': False,
'fetchOpenOrders': True,
'fetchOrder': 'emulated',
'fetchOrderBook': True,
'fetchOrderBooks': True,
'fetchOrderTrades': True,
'fetchPosition': False,
'fetchPositionHistory': False,
'fetchPositionMode': False,
'fetchPositions': False,
'fetchPositionsHistory': False,
'fetchPositionsRisk': False,
'fetchPremiumIndexOHLCV': False,
'fetchTicker': True,
'fetchTickers': True,
'fetchTrades': True,
'fetchTradingFee': False,
'fetchTradingFees': True,
'fetchTransactionFees': True,
'fetchTransactions': 'emulated',
'fetchTransfer': False,
'fetchTransfers': False,
'fetchWithdrawal': True,
'fetchWithdrawals': True,
'reduceMargin': True,
'setMargin': False,
'transfer': False,
'withdraw': True,
},
'timeframes': {
'1m': '1',
'5m': '5',
'15m': '15',
'30m': '30',
'45m': '45',
'1h': '60',
'2h': '120',
'3h': '180',
'4h': '240',
'1d': 'D',
'1w': 'W',
'1M': 'M',
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpg',
'api': {
'public': 'https://api.exmo.com',
'private': 'https://api.exmo.com',
'web': 'https://exmo.me',
},
'www': 'https://exmo.me',
'referral': 'https://exmo.me/?ref=131685',
'doc': [
'https://exmo.me/en/api_doc?ref=131685',
],
'fees': 'https://exmo.com/en/docs/fees',
},
'api': {
'web': {
'get': [
'ctrl/feesAndLimits',
'en/docs/fees',
],
},
'public': {
'get': [
'currency',
'currency/list/extended',
'order_book',
'pair_settings',
'ticker',
'trades',
'candles_history',
'required_amount',
'payments/providers/crypto/list',
],
},
'private': {
'post': [
'user_info',
'order_create',
'order_cancel',
'stop_market_order_create',
'stop_market_order_cancel',
'user_open_orders',
'user_trades',
'user_cancelled_orders',
'order_trades',
'deposit_address',
'withdraw_crypt',
'withdraw_get_txid',
'excode_create',
'excode_load',
'code_check',
'wallet_history',
'wallet_operations',
'margin/user/order/create',
'margin/user/order/update',
'margin/user/order/cancel',
'margin/user/position/close',
'margin/user/position/margin_add',
'margin/user/position/margin_remove',
'margin/currency/list',
'margin/pair/list',
'margin/settings',
'margin/funding/list',
'margin/user/info',
'margin/user/order/list',
'margin/user/order/history',
'margin/user/order/trades',
'margin/user/order/max_quantity',
'margin/user/position/list',
'margin/user/position/margin_remove_info',
'margin/user/position/margin_add_info',
'margin/user/wallet/list',
'margin/user/wallet/history',
'margin/user/trade/list',
'margin/trades',
'margin/liquidation/feed',
],
},
},
'fees': {
'trading': {
'feeSide': 'get',
'tierBased': True,
'percentage': True,
'maker': self.parse_number('0.004'),
'taker': self.parse_number('0.004'),
},
'transaction': {
'tierBased': False,
'percentage': False, # fixed transaction fees for crypto, see fetchDepositWithdrawFees below
},
},
'options': {
'networks': {
'ETH': 'ERC20',
'TRX': 'TRC20',
},
'fetchTradingFees': {
'method': 'fetchPrivateTradingFees', # or 'fetchPublicTradingFees'
},
'margin': {
'fillResponseFromRequest': True,
},
},
'commonCurrencies': {
'GMT': 'GMT Token',
},
'precisionMode': TICK_SIZE,
'exceptions': {
'exact': {
'140333': InvalidOrder, # {"error":{"code":140333,"msg":"The number of characters after the point in the price exceeds the maximum number '8\u003e6'"}}
'140434': BadRequest,
'40005': AuthenticationError, # Authorization error, incorrect signature
'40009': InvalidNonce, #
'40015': ExchangeError, # API function do not exist
'40016': OnMaintenance, # {"result":false,"error":"Error 40016: Maintenance work in progress"}
'40017': AuthenticationError, # Wrong API Key
'40032': PermissionDenied, # {"result":false,"error":"Error 40032: Access is denied for self API key"}
'40033': PermissionDenied, # {"result":false,"error":"Error 40033: Access is denied, self resources are temporarily blocked to user"}
'40034': RateLimitExceeded, # {"result":false,"error":"Error 40034: Access is denied, rate limit is exceeded"}
'50052': InsufficientFunds,
'50054': InsufficientFunds,
'50304': OrderNotFound, # "Order was not found '123456789'"(fetching order trades for an order that does not have trades yet)
'50173': OrderNotFound, # "Order with id X was not found."(cancelling non-existent, closed and cancelled order)
'50277': InvalidOrder,
'50319': InvalidOrder, # Price by order is less than permissible minimum for self pair
'50321': InvalidOrder, # Price by order is more than permissible maximum for self pair
'50381': InvalidOrder, # {"result":false,"error":"Error 50381: More than 2 decimal places are not permitted for pair BTC_USD"}
},
'broad': {
'range period is too long': BadRequest,
'invalid syntax': BadRequest,
'API rate limit exceeded': RateLimitExceeded, # {"result":false,"error":"API rate limit exceeded for x.x.x.x. Retry after 60 sec.","history":[],"begin":1579392000,"end":1579478400}
},
},
})
def modify_margin_helper(self, symbol: str, amount, type, params={}):
self.load_markets()
market = self.market(symbol)
request: dict = {
'position_id': market['id'],
'quantity': amount,
}
response = None
if type == 'add':
response = self.privatePostMarginUserPositionMarginAdd(self.extend(request, params))
elif type == 'reduce':
response = self.privatePostMarginUserPositionMarginRemove(self.extend(request, params))
#
# {}
#
margin = self.parse_margin_modification(response, market)
options = self.safe_value(self.options, 'margin', {})
fillResponseFromRequest = self.safe_bool(options, 'fillResponseFromRequest', True)
if fillResponseFromRequest:
margin['type'] = type
margin['amount'] = amount
return margin
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
#
# {}
#
return {
'info': data,
'symbol': self.safe_symbol(None, market),
'type': None,
'marginMode': 'isolated',
'amount': None,
'total': None,
'code': self.safe_value(market, 'quote'),
'status': 'ok',
'timestamp': None,
'datetime': None,
}
def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
"""
remove margin from a position
https://documenter.getpostman.com/view/10287440/SzYXWKPi#eebf9f25-0289-4946-9482-89872c738449
:param str symbol: unified market symbol
:param float amount: the amount of margin to remove
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
"""
return self.modify_margin_helper(symbol, amount, 'reduce', params)
def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
"""
add margin
https://documenter.getpostman.com/view/10287440/SzYXWKPi#143ef808-79ca-4e49-9e79-a60ea4d8c0e3
:param str symbol: unified market symbol
:param float amount: amount of margin to add
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
"""
return self.modify_margin_helper(symbol, amount, 'add', params)
def fetch_trading_fees(self, params={}) -> TradingFees:
"""
fetch the trading fees for multiple markets
https://documenter.getpostman.com/view/10287440/SzYXWKPi#90927062-256c-4b03-900f-2b99131f9a54
https://documenter.getpostman.com/view/10287440/SzYXWKPi#7de7e75c-5833-45a8-b937-c2276d235aaa
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
"""
options = self.safe_value(self.options, 'fetchTradingFees', {})
defaultMethod = self.safe_string(options, 'method', 'fetchPrivateTradingFees')
method = self.safe_string(params, 'method', defaultMethod)
params = self.omit(params, 'method')
if method == 'fetchPrivateTradingFees':
return self.fetch_private_trading_fees(params)
else:
return self.fetch_public_trading_fees(params)
def fetch_private_trading_fees(self, params={}):
self.load_markets()
response = self.privatePostMarginPairList(params)
#
# {
# "pairs": [{
# "name": "EXM_USD",
# "buy_price": "0.02728391",
# "sell_price": "0.0276",
# "last_trade_price": "0.0276",
# "ticker_updated": "1646956050056696046",
# "is_fair_price": True,
# "max_price_precision": "8",
# "min_order_quantity": "1",
# "max_order_quantity": "50000",
# "min_order_price": "0.00000001",
# "max_order_price": "1000",
# "max_position_quantity": "50000",
# "trade_taker_fee": "0.05",
# "trade_maker_fee": "0",
# "liquidation_fee": "0.5",
# "max_leverage": "3",
# "default_leverage": "3",
# "liquidation_level": "5",
# "margin_call_level": "7.5",
# "position": "1",
# "updated": "1638976144797807397"
# }
# ...
# ]
# }
#
pairs = self.safe_value(response, 'pairs', [])
result: dict = {}
for i in range(0, len(pairs)):
pair = pairs[i]
marketId = self.safe_string(pair, 'name')
symbol = self.safe_symbol(marketId, None, '_')
makerString = self.safe_string(pair, 'trade_maker_fee')
takerString = self.safe_string(pair, 'trade_taker_fee')
maker = self.parse_number(Precise.string_div(makerString, '100'))
taker = self.parse_number(Precise.string_div(takerString, '100'))
result[symbol] = {
'info': pair,
'symbol': symbol,
'maker': maker,
'taker': taker,
'percentage': True,
'tierBased': True,
}
return result
def fetch_public_trading_fees(self, params={}):
self.load_markets()
response = self.publicGetPairSettings(params)
#
# {
# "BTC_USD": {
# "min_quantity": "0.00002",
# "max_quantity": "1000",
# "min_price": "1",
# "max_price": "150000",
# "max_amount": "500000",
# "min_amount": "1",
# "price_precision": "2",
# "commission_taker_percent": "0.3",
# "commission_maker_percent": "0.3"
# },
# }
#
result: dict = {}
for i in range(0, len(self.symbols)):
symbol = self.symbols[i]
market = self.market(symbol)
fee = self.safe_value(response, market['id'], {})
makerString = self.safe_string(fee, 'commission_maker_percent')
takerString = self.safe_string(fee, 'commission_taker_percent')
maker = self.parse_number(Precise.string_div(makerString, '100'))
taker = self.parse_number(Precise.string_div(takerString, '100'))
result[symbol] = {
'info': fee,
'symbol': symbol,
'maker': maker,
'taker': taker,
'percentage': True,
'tierBased': True,
}
return result
def parse_fixed_float_value(self, input):
if (input is None) or (input == '-'):
return None
if input == '':
return 0
isPercentage = (input.find('%') >= 0)
parts = input.split(' ')
value = parts[0].replace('%', '')
result = float(value)
if (result > 0) and isPercentage:
raise ExchangeError(self.id + ' parseFixedFloatValue() detected an unsupported non-zero percentage-based fee ' + input)
return result
def fetch_transaction_fees(self, codes: Strings = None, params={}):
"""
@deprecated
please use fetchDepositWithdrawFees instead
https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2
:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction fees structures <https://docs.ccxt.com/#/?id=fees-structure>`
"""
self.load_markets()
cryptoList = self.publicGetPaymentsProvidersCryptoList(params)
#
# {
# "BTC":[
# {"type":"deposit", "name":"BTC", "currency_name":"BTC", "min":"0.001", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 0.001 BTC. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1},
# {"type":"withdraw", "name":"BTC", "currency_name":"BTC", "min":"0.001", "max":"350", "enabled":true,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"0.0005 BTC", "currency_confirmations":6}
# ],
# "ETH":[
# {"type":"withdraw", "name":"ETH", "currency_name":"ETH", "min":"0.01", "max":"500", "enabled":true,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"0.004 ETH", "currency_confirmations":4},
# {"type":"deposit", "name":"ETH", "currency_name":"ETH", "min":"0.01", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 0.01 ETH. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1}
# ],
# "USDT":[
# {"type":"deposit", "name":"USDT(OMNI)", "currency_name":"USDT", "min":"10", "max":"0", "enabled":false,"comment":"Minimum deposit amount is 10 USDT", "commission_desc":"0%", "currency_confirmations":2},
# {"type":"withdraw", "name":"USDT(OMNI)", "currency_name":"USDT", "min":"10", "max":"100000", "enabled":false,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"5 USDT", "currency_confirmations":6},
# {"type":"deposit", "name":"USDT(ERC20)", "currency_name":"USDT", "min":"10", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 10 USDT", "commission_desc":"0%", "currency_confirmations":2},
# {
# "type":"withdraw",
# "name":"USDT(ERC20)",
# "currency_name":"USDT",
# "min":"55",
# "max":"200000",
# "enabled":true,
# "comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales. Recommendation: Due to the high load of ERC20 network, using TRC20 address for withdrawal is recommended.",
# "commission_desc":"10 USDT",
# "currency_confirmations":6
# },
# {"type":"deposit", "name":"USDT(TRC20)", "currency_name":"USDT", "min":"10", "max":"100000", "enabled":true,"comment":"Minimum deposit amount is 10 USDT. Only TRON main network supported", "commission_desc":"0%", "currency_confirmations":2},
# {"type":"withdraw", "name":"USDT(TRC20)", "currency_name":"USDT", "min":"10", "max":"150000", "enabled":true,"comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales. Only TRON main network supported.", "commission_desc":"1 USDT", "currency_confirmations":6}
# ],
# "XLM":[
# {"type":"deposit", "name":"XLM", "currency_name":"XLM", "min":"1", "max":"1000000", "enabled":true,"comment":"Attention! A deposit without memo(invoice) will not be credited. Minimum deposit amount is 1 XLM. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1},
# {"type":"withdraw", "name":"XLM", "currency_name":"XLM", "min":"21", "max":"1000000", "enabled":true,"comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales.", "commission_desc":"0.01 XLM", "currency_confirmations":1}
# ],
# }
#
result: dict = {}
cryptoListKeys = list(cryptoList.keys())
for i in range(0, len(cryptoListKeys)):
code = cryptoListKeys[i]
if codes is not None and not self.in_array(code, codes):
continue
result[code] = {
'deposit': None,
'withdraw': None,
}
currency = self.currency(code)
currencyId = self.safe_string(currency, 'id')
providers = self.safe_value(cryptoList, currencyId, [])
for j in range(0, len(providers)):
provider = providers[j]
typeInner = self.safe_string(provider, 'type')
commissionDesc = self.safe_string(provider, 'commission_desc')
fee = self.parse_fixed_float_value(commissionDesc)
result[code][typeInner] = fee
result[code]['info'] = providers
# cache them for later use
self.options['transactionFees'] = result
return result
def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
"""
fetch deposit and withdraw fees
https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2
:param str[]|None codes: list of unified currency codes
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a list of `transaction fees structures <https://docs.ccxt.com/#/?id=fees-structure>`
"""
self.load_markets()
response = self.publicGetPaymentsProvidersCryptoList(params)
#
# {
# "USDT": [
# {
# "type": "deposit", # or "withdraw"
# "name": "USDT(ERC20)",
# "currency_name": "USDT",
# "min": "10",
# "max": "0",
# "enabled": True,
# "comment": "Minimum deposit amount is 10 USDT",
# "commission_desc": "0%",
# "currency_confirmations": 2
# },
# ...
# ],
# ...
# }
#
result = self.parse_deposit_withdraw_fees(response, codes)
# cache them for later use
self.options['transactionFees'] = result
return result
def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
#
# [
# {
# "type": "deposit", # or "withdraw"
# "name": "BTC",
# "currency_name": "BTC",
# "min": "0.001",
# "max": "0",
# "enabled": True,
# "comment": "Minimum deposit amount is 0.001 BTC. We do not support BSC and BEP20 network, please consider self when sending funds",
# "commission_desc": "0%",
# "currency_confirmations": 1
# },
# ...
# ]
#
result = self.deposit_withdraw_fee(fee)
for i in range(0, len(fee)):
provider = fee[i]
type = self.safe_string(provider, 'type')
networkId = self.safe_string(provider, 'name')
networkCode = self.network_id_to_code(networkId, self.safe_string(currency, 'code'))
commissionDesc = self.safe_string(provider, 'commission_desc')
splitCommissionDesc = []
percentage = None
if commissionDesc is not None:
splitCommissionDesc = commissionDesc.split('%')
splitCommissionDescLength = len(splitCommissionDesc)
percentage = splitCommissionDescLength >= 2
network = self.safe_value(result['networks'], networkCode)
if network is None:
result['networks'][networkCode] = {
'withdraw': {
'fee': None,
'percentage': None,
},
'deposit': {
'fee': None,
'percentage': None,
},
}
result['networks'][networkCode][type] = {
'fee': self.parse_fixed_float_value(self.safe_string(splitCommissionDesc, 0)),
'percentage': percentage,
}
return self.assign_default_deposit_withdraw_fees(result)
def fetch_currencies(self, params={}) -> Currencies:
"""
fetches all available currencies on an exchange
https://documenter.getpostman.com/view/10287440/SzYXWKPi#7cdf0ca8-9ff6-4cf3-aa33-bcec83155c49
https://documenter.getpostman.com/view/10287440/SzYXWKPi#4190035d-24b1-453d-833b-37e0a52f88e2
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
"""
#
currencyList = self.publicGetCurrencyListExtended(params)
#
# [
# {"name":"VLX","description":"Velas"},
# {"name":"RUB","description":"Russian Ruble"},
# {"name":"BTC","description":"Bitcoin"},
# {"name":"USD","description":"US Dollar"}
# ]
#
cryptoList = self.publicGetPaymentsProvidersCryptoList(params)
#
# {
# "BTC":[
# {"type":"deposit", "name":"BTC", "currency_name":"BTC", "min":"0.001", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 0.001 BTC. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1},
# {"type":"withdraw", "name":"BTC", "currency_name":"BTC", "min":"0.001", "max":"350", "enabled":true,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"0.0005 BTC", "currency_confirmations":6}
# ],
# "ETH":[
# {"type":"withdraw", "name":"ETH", "currency_name":"ETH", "min":"0.01", "max":"500", "enabled":true,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"0.004 ETH", "currency_confirmations":4},
# {"type":"deposit", "name":"ETH", "currency_name":"ETH", "min":"0.01", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 0.01 ETH. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1}
# ],
# "USDT":[
# {"type":"deposit", "name":"USDT(OMNI)", "currency_name":"USDT", "min":"10", "max":"0", "enabled":false,"comment":"Minimum deposit amount is 10 USDT", "commission_desc":"0%", "currency_confirmations":2},
# {"type":"withdraw", "name":"USDT(OMNI)", "currency_name":"USDT", "min":"10", "max":"100000", "enabled":false,"comment":"Do not withdraw directly to the Crowdfunding or ICO address account will not be credited with tokens from such sales.", "commission_desc":"5 USDT", "currency_confirmations":6},
# {"type":"deposit", "name":"USDT(ERC20)", "currency_name":"USDT", "min":"10", "max":"0", "enabled":true,"comment":"Minimum deposit amount is 10 USDT", "commission_desc":"0%", "currency_confirmations":2},
# {"type":"withdraw", "name":"USDT(ERC20)", "currency_name":"USDT", "min":"55", "max":"200000", "enabled":true, "comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales. Recommendation: Due to the high load of ERC20 network, using TRC20 address for withdrawal is recommended.", "commission_desc":"10 USDT", "currency_confirmations":6},
# {"type":"deposit", "name":"USDT(TRC20)", "currency_name":"USDT", "min":"10", "max":"100000", "enabled":true,"comment":"Minimum deposit amount is 10 USDT. Only TRON main network supported", "commission_desc":"0%", "currency_confirmations":2},
# {"type":"withdraw", "name":"USDT(TRC20)", "currency_name":"USDT", "min":"10", "max":"150000", "enabled":true,"comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales. Only TRON main network supported.", "commission_desc":"1 USDT", "currency_confirmations":6}
# ],
# "XLM":[
# {"type":"deposit", "name":"XLM", "currency_name":"XLM", "min":"1", "max":"1000000", "enabled":true,"comment":"Attention! A deposit without memo(invoice) will not be credited. Minimum deposit amount is 1 XLM. We do not support BSC and BEP20 network, please consider self when sending funds", "commission_desc":"0%", "currency_confirmations":1},
# {"type":"withdraw", "name":"XLM", "currency_name":"XLM", "min":"21", "max":"1000000", "enabled":true,"comment":"Caution! Do not withdraw directly to a crowdfund or ICO address, account will not be credited with tokens from such sales.", "commission_desc":"0.01 XLM", "currency_confirmations":1}
# ],
# }
#
result: dict = {}
for i in range(0, len(currencyList)):
currency = currencyList[i]
currencyId = self.safe_string(currency, 'name')
name = self.safe_string(currency, 'description')
providers = self.safe_value(cryptoList, currencyId)
active = False
type = 'crypto'
limits: dict = {
'deposit': {
'min': None,
'max': None,
},
'withdraw': {
'min': None,
'max': None,
},
}
fee = None
depositEnabled = None
withdrawEnabled = None
if providers is None:
active = True
type = 'fiat'
else:
for j in range(0, len(providers)):
provider = providers[j]
typeInner = self.safe_string(provider, 'type')
minValue = self.safe_string(provider, 'min')
maxValue = self.safe_string(provider, 'max')
if Precise.string_eq(maxValue, '0.0'):
maxValue = None
activeProvider = self.safe_value(provider, 'enabled')
if typeInner == 'deposit':
if activeProvider and not depositEnabled:
depositEnabled = True
elif not activeProvider:
depositEnabled = False
elif typeInner == 'withdraw':
if activeProvider and not withdrawEnabled:
withdrawEnabled = True
elif not activeProvider:
withdrawEnabled = False
if activeProvider:
active = True
limitMin = self.number_to_string(limits[typeInner]['min'])
if (limits[typeInner]['min'] is None) or (Precise.string_lt(minValue, limitMin)):
limits[typeInner]['min'] = minValue
limits[typeInner]['max'] = maxValue
if typeInner == 'withdraw':
commissionDesc = self.safe_string(provider, 'commission_desc')
fee = self.parse_fixed_float_value(commissionDesc)
code = self.safe_currency_code(currencyId)
result[code] = {
'id': currencyId,
'code': code,
'name': name,
'type': type,
'active': active,
'deposit': depositEnabled,
'withdraw': withdrawEnabled,
'fee': fee,
'precision': self.parse_number('1e-8'),
'limits': limits,
'info': providers,
'networks': {},
}
return result
def fetch_markets(self, params={}) -> List[Market]:
"""
retrieves data on all markets for exmo
https://documenter.getpostman.com/view/10287440/SzYXWKPi#7de7e75c-5833-45a8-b937-c2276d235aaa
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
"""
response = self.publicGetPairSettings(params)
#
# {
# "BTC_USD":{
# "min_quantity":"0.0001",
# "max_quantity":"1000",
# "min_price":"1",
# "max_price":"30000",
# "max_amount":"500000",
# "min_amount":"1",
# "price_precision":8,
# "commission_taker_percent":"0.4",
# "commission_maker_percent":"0.4"
# },
# }
#
marginPairsDict: dict = {}
if self.check_required_credentials(False):
marginPairs = self.privatePostMarginPairList(params)
#
# {
# "pairs": [
# {
# "buy_price": "55978.85",
# "default_leverage": "3",
# "is_fair_price": True,
# "last_trade_price": "55999.23",
# "liquidation_fee": "2",
# "liquidation_level": "10",
# "margin_call_level": "15",
# "max_leverage": "3",
# "max_order_price": "150000",
# "max_order_quantity": "1",
# "max_position_quantity": "1",
# "max_price_precision": 2,
# "min_order_price": "1",
# "min_order_quantity": "0.00002",
# "name": "BTC_USD",
# "position": 1,
# "sell_price": "55985.51",
# "ticker_updated": "1619019818936107989",
# "trade_maker_fee": "0",
# "trade_taker_fee": "0.05",
# "updated": "1619008608955599013"
# }
# ]
# }
#
pairs = self.safe_value(marginPairs, 'pairs')
marginPairsDict = self.index_by(pairs, 'name')
keys = list(response.keys())
result = []
for i in range(0, len(keys)):
id = keys[i]
market = response[id]
marginMarket = self.safe_value(marginPairsDict, id)
symbol = id.replace('_', '/')
baseId, quoteId = symbol.split('/')
base = self.safe_currency_code(baseId)
quote = self.safe_currency_code(quoteId)
takerString = self.safe_string(market, 'commission_taker_percent')
makerString = self.safe_string(market, 'commission_maker_percent')
maxQuantity = self.safe_string(market, 'max_quantity')
marginMaxQuantity = self.safe_string(marginMarket, 'max_order_quantity')
result.append({
'id': id,
'symbol': symbol,
'base': base,
'quote': quote,
'settle': None,
'baseId': baseId,
'quoteId': quoteId,
'settleId': None,
'type': 'spot',
'spot': True,
'margin': marginMarket is not None,
'swap': False,
'future': False,
'option': False,
'active': None,
'contract': False,
'linear': None,
'inverse': None,
'taker': self.parse_number(Precise.string_div(takerString, '100')),
'maker': self.parse_number(Precise.string_div(makerString, '100')),
'contractSize': None,
'expiry': None,
'expiryDatetime': None,
'strike': None,
'optionType': None,
'precision': {
'amount': self.parse_number('1e-8'),
'price': self.parse_number(self.parse_precision(self.safe_string(market, 'price_precision'))),
},
'limits': {
'leverage': {
'min': None,
'max': self.safe_number(market, 'leverage'),
},
'amount': {
'min': self.safe_number(market, 'min_quantity'),
'max': self.parse_number(Precise.string_max(maxQuantity, marginMaxQuantity)),
},
'price': {
'min': self.safe_number(market, 'min_price'),
'max': self.safe_number(market, 'max_price'),
},
'cost': {
'min': self.safe_number(market, 'min_amount'),
'max': self.safe_number(market, 'max_amount'),
},
},
'created': None,
'info': market,
})
return result
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
"""
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
https://documenter.getpostman.com/view/10287440/SzYXWKPi#65eeb949-74e5-4631-9184-c38387fe53e8
:param str symbol: unified symbol of the market to fetch OHLCV data for
:param str timeframe: the length of time each candle represents
:param int [since]: timestamp in ms of the earliest candle to fetch
:param int [limit]: the maximum amount of candles to fetch
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int[][]: A list of candles ordered, open, high, low, close, volume
"""
self.load_markets()
market = self.market(symbol)
request: dict = {
'symbol': market['id'],
'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
}
maxLimit = 3000
duration = self.parse_timeframe(timeframe)
now = self.milliseconds()
if since is None:
if limit is None:
limit = 1000 # cap default at generous amount
else:
limit = min(limit, maxLimit)
request['from'] = self.parse_to_int(now / 1000) - limit * duration - 1
request['to'] = self.parse_to_int(now / 1000)
else:
request['from'] = self.parse_to_int(since / 1000) - 1
if limit is None:
limit = maxLimit
else:
limit = min(limit, maxLimit)
to = self.sum(since, limit * duration * 1000)
request['to'] = self.parse_to_int(to / 1000)
response = self.publicGetCandlesHistory(self.extend(request, params))
#
# {
# "candles":[
# {"t":1584057600000,"o":0.02235144,"c":0.02400233,"h":0.025171,"l":0.02221,"v":5988.34031761},
# {"t":1584144000000,"o":0.0240373,"c":0.02367413,"h":0.024399,"l":0.0235,"v":2027.82522329},
# {"t":1584230400000,"o":0.02363458,"c":0.02319242,"h":0.0237948,"l":0.02223196,"v":1707.96944997},
# ]
# }
#
candles = self.safe_list(response, 'candles', [])
return self.parse_ohlcvs(candles, market, timeframe, since, limit)
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
#
# {
# "t":1584057600000,
# "o":0.02235144,
# "c":0.02400233,
# "h":0.025171,
# "l":0.02221,
# "v":5988.34031761
# }
#
return [
self.safe_integer(ohlcv, 't'),
self.safe_number(ohlcv, 'o'),
self.safe_number(ohlcv, 'h'),
self.safe_number(ohlcv, 'l'),
self.safe_number(ohlcv, 'c'),
self.safe_number(ohlcv, 'v'),
]
def parse_balance(self, response) -> Balances:
result: dict = {'info': response}
wallets = self.safe_value(response, 'wallets')
if wallets is not None:
currencyIds = list(wallets.keys())
for i in range(0, len(currencyIds)):
currencyId = currencyIds[i]
item = wallets[currencyId]
currency = self.safe_currency_code(currencyId)
account = self.account()
account['used'] = self.safe_string(item, 'used')
account['free'] = self.safe_string(item, 'free')
account['total'] = self.safe_string(item, 'balance')
result[currency] = account
else:
free = self.safe_value(response, 'balances', {})
used = self.safe_value(response, 'reserved', {})
currencyIds = list(free.keys())
for i in range(0, len(currencyIds)):
currencyId = currencyIds[i]
code = self.safe_currency_code(currencyId)
account = self.account()
if currencyId in free:
account['free'] = self.safe_string(free, currencyId)
if currencyId in used:
account['used'] = self.safe_string(used, currencyId)
result[code] = account
return self.safe_balance(result)
def fetch_balance(self, params={}) -> Balances:
"""
query for balance and get the amount of funds available for trading or funds locked in orders
https://documenter.getpostman.com/view/10287440/SzYXWKPi#59c5160f-27a1-4d9a-8cfb-7979c7ffaac6
https://documenter.getpostman.com/view/10287440/SzYXWKPi#c8388df7-1f9f-4d41-81c4-5a387d171dc6
:param dict [params]: extra parameters specific to the exchange API endpoint
:param str [params.marginMode]: *isolated* fetches the isolated margin balance
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
"""
self.load_markets()
marginMode = None
marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params)
if marginMode == 'cross':
raise BadRequest(self.id + ' does not support cross margin')
response = None
if marginMode == 'isolated':
response = self.privatePostMarginUserWalletList(params)
#
# {
# "wallets": {
# "USD": {
# "balance": "1000",
# "free": "600",
# "used": "400"
# }
# }
# }
#
else:
response = self.privatePostUserInfo(params)
#
# {
# "uid":131685,
# "server_date":1628999600,
# "balances":{
# "EXM":"0",
# "USD":"0",
# "EUR":"0",
# "GBP":"0",
# },
# }
#
return self.parse_balance(response)
def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
"""
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
https://documenter.getpostman.com/view/10287440/SzYXWKPi#c60c51a8-e683-4f45-a000-820723d37871
:param str symbol: unified symbol of the market to fetch the order book for
:param int [limit]: the maximum amount of order book entries to return
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
"""
self.load_markets()
market = self.market(symbol)
request: dict = {
'pair': market['id'],
}
if limit is not None:
request['limit'] = limit
response = self.publicGetOrderBook(self.extend(request, params))
result = self.safe_dict(response, market['id'])
return self.parse_order_book(result, market['symbol'], None, 'bid', 'ask')