ccxt 4.4.35__py2.py3-none-any.whl → 4.4.36__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +3 -1
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bybit.py +15 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/gate.py +14 -0
- ccxt/abstract/gateio.py +14 -0
- ccxt/async_support/__init__.py +3 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bitfinex2.py +18 -13
- ccxt/async_support/bitmex.py +103 -1
- ccxt/async_support/bitopro.py +21 -4
- ccxt/async_support/bitso.py +2 -1
- ccxt/async_support/bybit.py +21 -1
- ccxt/async_support/defx.py +1981 -0
- ccxt/async_support/deribit.py +27 -12
- ccxt/async_support/gate.py +14 -0
- ccxt/async_support/htx.py +11 -2
- ccxt/async_support/kraken.py +39 -41
- ccxt/base/exchange.py +1 -1
- ccxt/bitfinex2.py +18 -13
- ccxt/bitmex.py +103 -1
- ccxt/bitopro.py +21 -4
- ccxt/bitso.py +2 -1
- ccxt/bybit.py +21 -1
- ccxt/defx.py +1980 -0
- ccxt/deribit.py +27 -12
- ccxt/gate.py +14 -0
- ccxt/htx.py +11 -2
- ccxt/kraken.py +39 -41
- ccxt/pro/__init__.py +3 -1
- ccxt/pro/defx.py +832 -0
- ccxt/test/tests_async.py +15 -1
- ccxt/test/tests_sync.py +15 -1
- {ccxt-4.4.35.dist-info → ccxt-4.4.36.dist-info}/METADATA +7 -6
- {ccxt-4.4.35.dist-info → ccxt-4.4.36.dist-info}/RECORD +39 -35
- {ccxt-4.4.35.dist-info → ccxt-4.4.36.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.35.dist-info → ccxt-4.4.36.dist-info}/WHEEL +0 -0
- {ccxt-4.4.35.dist-info → ccxt-4.4.36.dist-info}/top_level.txt +0 -0
ccxt/deribit.py
CHANGED
@@ -220,6 +220,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
220
220
|
'enable_api_key': 1,
|
221
221
|
'get_access_log': 1,
|
222
222
|
'get_account_summary': 1,
|
223
|
+
'get_account_summaries': 1,
|
223
224
|
'get_affiliate_program_info': 1,
|
224
225
|
'get_email_language': 1,
|
225
226
|
'get_new_announcements': 1,
|
@@ -931,13 +932,20 @@ class deribit(Exchange, ImplicitAPI):
|
|
931
932
|
result: dict = {
|
932
933
|
'info': balance,
|
933
934
|
}
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
935
|
+
summaries = []
|
936
|
+
if 'summaries' in balance:
|
937
|
+
summaries = self.safe_list(balance, 'summaries')
|
938
|
+
else:
|
939
|
+
summaries = [balance]
|
940
|
+
for i in range(0, len(summaries)):
|
941
|
+
data = summaries[i]
|
942
|
+
currencyId = self.safe_string(data, 'currency')
|
943
|
+
currencyCode = self.safe_currency_code(currencyId)
|
944
|
+
account = self.account()
|
945
|
+
account['free'] = self.safe_string(data, 'available_funds')
|
946
|
+
account['used'] = self.safe_string(data, 'maintenance_margin')
|
947
|
+
account['total'] = self.safe_string(data, 'equity')
|
948
|
+
result[currencyCode] = account
|
941
949
|
return self.safe_balance(result)
|
942
950
|
|
943
951
|
def fetch_balance(self, params={}) -> Balances:
|
@@ -945,17 +953,24 @@ class deribit(Exchange, ImplicitAPI):
|
|
945
953
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
946
954
|
|
947
955
|
https://docs.deribit.com/#private-get_account_summary
|
956
|
+
https://docs.deribit.com/#private-get_account_summaries
|
948
957
|
|
949
958
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
959
|
+
:param str [params.code]: unified currency code of the currency for the balance, if defined 'privateGetGetAccountSummary' will be used, otherwise 'privateGetGetAccountSummaries' will be used
|
950
960
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
951
961
|
"""
|
952
962
|
self.load_markets()
|
953
|
-
code = self.
|
954
|
-
|
963
|
+
code = self.safe_string(params, 'code')
|
964
|
+
params = self.omit(params, 'code')
|
955
965
|
request: dict = {
|
956
|
-
'currency': currency['id'],
|
957
966
|
}
|
958
|
-
|
967
|
+
if code is not None:
|
968
|
+
request['currency'] = self.currency_id(code)
|
969
|
+
response = None
|
970
|
+
if code is None:
|
971
|
+
response = self.privateGetGetAccountSummaries(params)
|
972
|
+
else:
|
973
|
+
response = self.privateGetGetAccountSummary(self.extend(request, params))
|
959
974
|
#
|
960
975
|
# {
|
961
976
|
# "jsonrpc": "2.0",
|
@@ -998,7 +1013,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
998
1013
|
# "testnet": False
|
999
1014
|
# }
|
1000
1015
|
#
|
1001
|
-
result = self.
|
1016
|
+
result = self.safe_dict(response, 'result', {})
|
1002
1017
|
return self.parse_balance(result)
|
1003
1018
|
|
1004
1019
|
def create_deposit_address(self, code: str, params={}):
|
ccxt/gate.py
CHANGED
@@ -239,6 +239,7 @@ class gate(Exchange, ImplicitAPI):
|
|
239
239
|
'{settle}/contract_stats': 1,
|
240
240
|
'{settle}/index_constituents/{index}': 1,
|
241
241
|
'{settle}/liq_orders': 1,
|
242
|
+
'{settle}/risk_limit_tiers': 1,
|
242
243
|
},
|
243
244
|
},
|
244
245
|
'delivery': {
|
@@ -280,6 +281,7 @@ class gate(Exchange, ImplicitAPI):
|
|
280
281
|
'withdrawals': {
|
281
282
|
'post': {
|
282
283
|
'withdrawals': 20, # 1r/s cost = 20 / 1 = 20
|
284
|
+
'push': 1,
|
283
285
|
},
|
284
286
|
'delete': {
|
285
287
|
'withdrawals/{withdrawal_id}': 1,
|
@@ -291,6 +293,7 @@ class gate(Exchange, ImplicitAPI):
|
|
291
293
|
'withdrawals': 1,
|
292
294
|
'deposits': 1,
|
293
295
|
'sub_account_transfers': 1,
|
296
|
+
'order_status': 1,
|
294
297
|
'withdraw_status': 1,
|
295
298
|
'sub_account_balances': 2.5,
|
296
299
|
'sub_account_margin_balances': 2.5,
|
@@ -301,6 +304,7 @@ class gate(Exchange, ImplicitAPI):
|
|
301
304
|
'total_balance': 2.5,
|
302
305
|
'small_balance': 1,
|
303
306
|
'small_balance_history': 1,
|
307
|
+
'push': 1,
|
304
308
|
},
|
305
309
|
'post': {
|
306
310
|
'transfers': 2.5, # 8r/s cost = 20 / 8 = 2.5
|
@@ -343,11 +347,14 @@ class gate(Exchange, ImplicitAPI):
|
|
343
347
|
'risk_units': 20 / 15,
|
344
348
|
'unified_mode': 20 / 15,
|
345
349
|
'loan_margin_tiers': 20 / 15,
|
350
|
+
'leverage/user_currency_config': 20 / 15,
|
351
|
+
'leverage/user_currency_setting': 20 / 15,
|
346
352
|
},
|
347
353
|
'post': {
|
348
354
|
'account_mode': 20 / 15,
|
349
355
|
'loans': 200 / 15, # 15r/10s cost = 20 / 1.5 = 13.33
|
350
356
|
'portfolio_calculator': 20 / 15,
|
357
|
+
'leverage/user_currency_setting': 20 / 15,
|
351
358
|
},
|
352
359
|
'put': {
|
353
360
|
'unified_mode': 20 / 15,
|
@@ -527,9 +534,13 @@ class gate(Exchange, ImplicitAPI):
|
|
527
534
|
'orders': 20 / 15,
|
528
535
|
'orders/{order_id}': 20 / 15,
|
529
536
|
'my_trades': 20 / 15,
|
537
|
+
'mmp': 20 / 15,
|
530
538
|
},
|
531
539
|
'post': {
|
532
540
|
'orders': 20 / 15,
|
541
|
+
'countdown_cancel_all': 20 / 15,
|
542
|
+
'mmp': 20 / 15,
|
543
|
+
'mmp/reset': 20 / 15,
|
533
544
|
},
|
534
545
|
'delete': {
|
535
546
|
'orders': 20 / 15,
|
@@ -573,6 +584,7 @@ class gate(Exchange, ImplicitAPI):
|
|
573
584
|
'multi_collateral/currencies': 20 / 15,
|
574
585
|
'multi_collateral/ltv': 20 / 15,
|
575
586
|
'multi_collateral/fixed_rate': 20 / 15,
|
587
|
+
'multi_collateral/current_rate': 20 / 15,
|
576
588
|
},
|
577
589
|
'post': {
|
578
590
|
'collateral/orders': 20 / 15,
|
@@ -586,8 +598,10 @@ class gate(Exchange, ImplicitAPI):
|
|
586
598
|
'account': {
|
587
599
|
'get': {
|
588
600
|
'detail': 20 / 15,
|
601
|
+
'rate_limit': 20 / 15,
|
589
602
|
'stp_groups': 20 / 15,
|
590
603
|
'stp_groups/{stp_id}/users': 20 / 15,
|
604
|
+
'stp_groups/debit_fee': 20 / 15,
|
591
605
|
},
|
592
606
|
'post': {
|
593
607
|
'stp_groups': 20 / 15,
|
ccxt/htx.py
CHANGED
@@ -5091,17 +5091,23 @@ class htx(Exchange, ImplicitAPI):
|
|
5091
5091
|
params = self.omit(params, ['clientOrderId'])
|
5092
5092
|
if type == 'limit' or type == 'ioc' or type == 'fok' or type == 'post_only':
|
5093
5093
|
request['price'] = self.price_to_precision(symbol, price)
|
5094
|
+
reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False)
|
5094
5095
|
if not isStopLossTriggerOrder and not isTakeProfitTriggerOrder:
|
5095
|
-
reduceOnly = self.safe_value_2(params, 'reduceOnly', 'reduce_only', False)
|
5096
5096
|
if reduceOnly:
|
5097
5097
|
request['reduce_only'] = 1
|
5098
5098
|
request['lever_rate'] = self.safe_integer_n(params, ['leverRate', 'lever_rate', 'leverage'], 1)
|
5099
5099
|
if not isTrailingPercentOrder:
|
5100
5100
|
request['order_price_type'] = type
|
5101
|
+
hedged = self.safe_bool(params, 'hedged', False)
|
5102
|
+
if hedged:
|
5103
|
+
if reduceOnly:
|
5104
|
+
request['offset'] = 'close'
|
5105
|
+
else:
|
5106
|
+
request['offset'] = 'open'
|
5101
5107
|
broker = self.safe_value(self.options, 'broker', {})
|
5102
5108
|
brokerId = self.safe_string(broker, 'id')
|
5103
5109
|
request['channel_code'] = brokerId
|
5104
|
-
params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice'])
|
5110
|
+
params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice', 'hedged'])
|
5105
5111
|
return self.extend(request, params)
|
5106
5112
|
|
5107
5113
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
@@ -5115,6 +5121,8 @@ class htx(Exchange, ImplicitAPI):
|
|
5115
5121
|
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order # usdt-m swap cross trigger
|
5116
5122
|
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order # usdt-m swap isolated
|
5117
5123
|
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order # usdt-m swap isolated trigger
|
5124
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
5125
|
+
https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
5118
5126
|
https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures
|
5119
5127
|
https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger
|
5120
5128
|
|
@@ -5136,6 +5144,7 @@ class htx(Exchange, ImplicitAPI):
|
|
5136
5144
|
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
|
5137
5145
|
:param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
|
5138
5146
|
:param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
|
5147
|
+
:param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False
|
5139
5148
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
5140
5149
|
"""
|
5141
5150
|
self.load_markets()
|
ccxt/kraken.py
CHANGED
@@ -447,31 +447,43 @@ class kraken(Exchange, ImplicitAPI):
|
|
447
447
|
},
|
448
448
|
'precisionMode': TICK_SIZE,
|
449
449
|
'exceptions': {
|
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
|
-
|
450
|
+
'exact': {
|
451
|
+
'EQuery:Invalid asset pair': BadSymbol, # {"error":["EQuery:Invalid asset pair"]}
|
452
|
+
'EAPI:Invalid key': AuthenticationError,
|
453
|
+
'EFunding:Unknown withdraw key': InvalidAddress, # {"error":["EFunding:Unknown withdraw key"]}
|
454
|
+
'EFunding:Invalid amount': InsufficientFunds,
|
455
|
+
'EService:Unavailable': ExchangeNotAvailable,
|
456
|
+
'EDatabase:Internal error': ExchangeNotAvailable,
|
457
|
+
'EService:Busy': ExchangeNotAvailable,
|
458
|
+
'EQuery:Unknown asset': BadSymbol, # {"error":["EQuery:Unknown asset"]}
|
459
|
+
'EAPI:Rate limit exceeded': DDoSProtection,
|
460
|
+
'EOrder:Rate limit exceeded': DDoSProtection,
|
461
|
+
'EGeneral:Internal error': ExchangeNotAvailable,
|
462
|
+
'EGeneral:Temporary lockout': DDoSProtection,
|
463
|
+
'EGeneral:Permission denied': PermissionDenied,
|
464
|
+
'EGeneral:Invalid arguments:price': InvalidOrder,
|
465
|
+
'EOrder:Unknown order': InvalidOrder,
|
466
|
+
'EOrder:Invalid price:Invalid price argument': InvalidOrder,
|
467
|
+
'EOrder:Order minimum not met': InvalidOrder,
|
468
|
+
'EOrder:Insufficient funds': InsufficientFunds,
|
469
|
+
'EGeneral:Invalid arguments': BadRequest,
|
470
|
+
'ESession:Invalid session': AuthenticationError,
|
471
|
+
'EAPI:Invalid nonce': InvalidNonce,
|
472
|
+
'EFunding:No funding method': BadRequest, # {"error":"EFunding:No funding method"}
|
473
|
+
'EFunding:Unknown asset': BadSymbol, # {"error":["EFunding:Unknown asset"]}
|
474
|
+
'EService:Market in post_only mode': OnMaintenance, # {"error":["EService:Market in post_only mode"]}
|
475
|
+
'EGeneral:Too many requests': DDoSProtection, # {"error":["EGeneral:Too many requests"]}
|
476
|
+
'ETrade:User Locked': AccountSuspended, # {"error":["ETrade:User Locked"]}
|
477
|
+
},
|
478
|
+
'broad': {
|
479
|
+
':Invalid order': InvalidOrder,
|
480
|
+
':Invalid arguments:volume': InvalidOrder,
|
481
|
+
':Invalid arguments:viqc': InvalidOrder,
|
482
|
+
':Invalid nonce': InvalidNonce,
|
483
|
+
':IInsufficient funds': InsufficientFunds,
|
484
|
+
':Cancel pending': CancelPending,
|
485
|
+
':Rate limit exceeded': RateLimitExceeded,
|
486
|
+
},
|
475
487
|
},
|
476
488
|
})
|
477
489
|
|
@@ -3064,21 +3076,6 @@ class kraken(Exchange, ImplicitAPI):
|
|
3064
3076
|
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
3065
3077
|
if code == 520:
|
3066
3078
|
raise ExchangeNotAvailable(self.id + ' ' + str(code) + ' ' + reason)
|
3067
|
-
# todo: rewrite self for "broad" exceptions matching
|
3068
|
-
if body.find('Invalid order') >= 0:
|
3069
|
-
raise InvalidOrder(self.id + ' ' + body)
|
3070
|
-
if body.find('Invalid nonce') >= 0:
|
3071
|
-
raise InvalidNonce(self.id + ' ' + body)
|
3072
|
-
if body.find('Insufficient funds') >= 0:
|
3073
|
-
raise InsufficientFunds(self.id + ' ' + body)
|
3074
|
-
if body.find('Cancel pending') >= 0:
|
3075
|
-
raise CancelPending(self.id + ' ' + body)
|
3076
|
-
if body.find('Invalid arguments:volume') >= 0:
|
3077
|
-
raise InvalidOrder(self.id + ' ' + body)
|
3078
|
-
if body.find('Invalid arguments:viqc') >= 0:
|
3079
|
-
raise InvalidOrder(self.id + ' ' + body)
|
3080
|
-
if body.find('Rate limit exceeded') >= 0:
|
3081
|
-
raise RateLimitExceeded(self.id + ' ' + body)
|
3082
3079
|
if response is None:
|
3083
3080
|
return None
|
3084
3081
|
if body[0] == '{':
|
@@ -3089,6 +3086,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
3089
3086
|
message = self.id + ' ' + body
|
3090
3087
|
for i in range(0, len(response['error'])):
|
3091
3088
|
error = response['error'][i]
|
3092
|
-
self.throw_exactly_matched_exception(self.exceptions, error, message)
|
3089
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], error, message)
|
3090
|
+
self.throw_exactly_matched_exception(self.exceptions['broad'], error, message)
|
3093
3091
|
raise ExchangeError(message)
|
3094
3092
|
return None
|
ccxt/pro/__init__.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# ----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.4.
|
7
|
+
__version__ = '4.4.36'
|
8
8
|
|
9
9
|
# ----------------------------------------------------------------------------
|
10
10
|
|
@@ -46,6 +46,7 @@ from ccxt.pro.coinex import coinex # noqa
|
|
46
46
|
from ccxt.pro.coinone import coinone # noqa: F401
|
47
47
|
from ccxt.pro.cryptocom import cryptocom # noqa: F401
|
48
48
|
from ccxt.pro.currencycom import currencycom # noqa: F401
|
49
|
+
from ccxt.pro.defx import defx # noqa: F401
|
49
50
|
from ccxt.pro.deribit import deribit # noqa: F401
|
50
51
|
from ccxt.pro.exmo import exmo # noqa: F401
|
51
52
|
from ccxt.pro.gate import gate # noqa: F401
|
@@ -121,6 +122,7 @@ exchanges = [
|
|
121
122
|
'coinone',
|
122
123
|
'cryptocom',
|
123
124
|
'currencycom',
|
125
|
+
'defx',
|
124
126
|
'deribit',
|
125
127
|
'exmo',
|
126
128
|
'gate',
|