ccxt 4.3.85__py2.py3-none-any.whl → 4.3.86__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/hashkey.py +67 -0
- ccxt/async_support/__init__.py +3 -1
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/binance.py +4 -2
- ccxt/async_support/bitfinex.py +2 -2
- ccxt/async_support/hashkey.py +4062 -0
- ccxt/async_support/hyperliquid.py +80 -62
- ccxt/async_support/indodax.py +29 -8
- ccxt/async_support/krakenfutures.py +10 -9
- ccxt/base/exchange.py +2 -2
- ccxt/binance.py +4 -2
- ccxt/bitfinex.py +2 -2
- ccxt/hashkey.py +4062 -0
- ccxt/hyperliquid.py +80 -62
- ccxt/indodax.py +29 -8
- ccxt/krakenfutures.py +10 -9
- ccxt/pro/__init__.py +3 -1
- ccxt/pro/ascendex.py +41 -5
- ccxt/pro/bingx.py +13 -12
- ccxt/pro/hashkey.py +783 -0
- ccxt/pro/hyperliquid.py +118 -1
- ccxt/pro/mexc.py +13 -7
- ccxt/pro/woo.py +1 -0
- ccxt/pro/woofipro.py +1 -0
- ccxt/pro/xt.py +1 -0
- ccxt/test/tests_async.py +13 -30
- ccxt/test/tests_sync.py +13 -30
- {ccxt-4.3.85.dist-info → ccxt-4.3.86.dist-info}/METADATA +8 -6
- {ccxt-4.3.85.dist-info → ccxt-4.3.86.dist-info}/RECORD +33 -29
- {ccxt-4.3.85.dist-info → ccxt-4.3.86.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.85.dist-info → ccxt-4.3.86.dist-info}/WHEEL +0 -0
- {ccxt-4.3.85.dist-info → ccxt-4.3.86.dist-info}/top_level.txt +0 -0
@@ -1067,24 +1067,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1067
1067
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1068
1068
|
"""
|
1069
1069
|
await self.load_markets()
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
symbol = market['symbol']
|
1074
|
-
order = {
|
1075
|
-
'symbol': symbol,
|
1076
|
-
'type': type,
|
1077
|
-
'side': side,
|
1078
|
-
'amount': amount,
|
1079
|
-
'price': price,
|
1080
|
-
'params': params,
|
1081
|
-
}
|
1082
|
-
globalParams: dict = {}
|
1083
|
-
if vaultAddress is not None:
|
1084
|
-
globalParams['vaultAddress'] = vaultAddress
|
1085
|
-
response = await self.create_orders([order], globalParams)
|
1086
|
-
first = self.safe_dict(response, 0)
|
1087
|
-
return first
|
1070
|
+
order, globalParams = self.parse_create_order_args(symbol, type, side, amount, price, params)
|
1071
|
+
orders = await self.create_orders([order], globalParams)
|
1072
|
+
return orders[0]
|
1088
1073
|
|
1089
1074
|
async def create_orders(self, orders: List[OrderRequest], params={}):
|
1090
1075
|
"""
|
@@ -1093,8 +1078,39 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1093
1078
|
:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
1094
1079
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1095
1080
|
"""
|
1096
|
-
self.check_required_credentials()
|
1097
1081
|
await self.load_markets()
|
1082
|
+
request = self.create_orders_request(orders, params)
|
1083
|
+
response = await self.privatePostExchange(request)
|
1084
|
+
#
|
1085
|
+
# {
|
1086
|
+
# "status": "ok",
|
1087
|
+
# "response": {
|
1088
|
+
# "type": "order",
|
1089
|
+
# "data": {
|
1090
|
+
# "statuses": [
|
1091
|
+
# {
|
1092
|
+
# "resting": {
|
1093
|
+
# "oid": 5063830287
|
1094
|
+
# }
|
1095
|
+
# }
|
1096
|
+
# ]
|
1097
|
+
# }
|
1098
|
+
# }
|
1099
|
+
# }
|
1100
|
+
#
|
1101
|
+
responseObj = self.safe_dict(response, 'response', {})
|
1102
|
+
data = self.safe_dict(responseObj, 'data', {})
|
1103
|
+
statuses = self.safe_list(data, 'statuses', [])
|
1104
|
+
return self.parse_orders(statuses, None)
|
1105
|
+
|
1106
|
+
def create_orders_request(self, orders, params={}) -> dict:
|
1107
|
+
"""
|
1108
|
+
create a list of trade orders
|
1109
|
+
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
|
1110
|
+
:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
1111
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1112
|
+
"""
|
1113
|
+
self.check_required_credentials()
|
1098
1114
|
defaultSlippage = self.safe_string(self.options, 'defaultSlippage')
|
1099
1115
|
defaultSlippage = self.safe_string(params, 'slippage', defaultSlippage)
|
1100
1116
|
hasClientOrderId = False
|
@@ -1197,28 +1213,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1197
1213
|
if vaultAddress is not None:
|
1198
1214
|
params = self.omit(params, 'vaultAddress')
|
1199
1215
|
request['vaultAddress'] = vaultAddress
|
1200
|
-
|
1201
|
-
#
|
1202
|
-
# {
|
1203
|
-
# "status": "ok",
|
1204
|
-
# "response": {
|
1205
|
-
# "type": "order",
|
1206
|
-
# "data": {
|
1207
|
-
# "statuses": [
|
1208
|
-
# {
|
1209
|
-
# "resting": {
|
1210
|
-
# "oid": 5063830287
|
1211
|
-
# }
|
1212
|
-
# }
|
1213
|
-
# ]
|
1214
|
-
# }
|
1215
|
-
# }
|
1216
|
-
# }
|
1217
|
-
#
|
1218
|
-
responseObj = self.safe_dict(response, 'response', {})
|
1219
|
-
data = self.safe_dict(responseObj, 'data', {})
|
1220
|
-
statuses = self.safe_list(data, 'statuses', [])
|
1221
|
-
return self.parse_orders(statuses, None)
|
1216
|
+
return request
|
1222
1217
|
|
1223
1218
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
1224
1219
|
"""
|
@@ -1417,30 +1412,10 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1417
1412
|
#
|
1418
1413
|
return response
|
1419
1414
|
|
1420
|
-
|
1421
|
-
"""
|
1422
|
-
edit a trade order
|
1423
|
-
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
|
1424
|
-
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
|
1425
|
-
:param str id: cancel order id
|
1426
|
-
:param str symbol: unified symbol of the market to create an order in
|
1427
|
-
:param str type: 'market' or 'limit'
|
1428
|
-
:param str side: 'buy' or 'sell'
|
1429
|
-
:param float amount: how much of currency you want to trade in units of base currency
|
1430
|
-
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1431
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1432
|
-
:param str [params.timeInForce]: 'Gtc', 'Ioc', 'Alo'
|
1433
|
-
:param bool [params.postOnly]: True or False whether the order is post-only
|
1434
|
-
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
|
1435
|
-
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
1436
|
-
:param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
1437
|
-
:param str [params.vaultAddress]: the vault address for order
|
1438
|
-
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1439
|
-
"""
|
1415
|
+
def edit_order_request(self, id: str, symbol: str, type: str, side: str, amount: Num = None, price: Num = None, params={}):
|
1440
1416
|
self.check_required_credentials()
|
1441
1417
|
if id is None:
|
1442
1418
|
raise ArgumentsRequired(self.id + ' editOrder() requires an id argument')
|
1443
|
-
await self.load_markets()
|
1444
1419
|
market = self.market(symbol)
|
1445
1420
|
type = type.upper()
|
1446
1421
|
isMarket = (type == 'MARKET')
|
@@ -1517,6 +1492,31 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1517
1492
|
if vaultAddress is not None:
|
1518
1493
|
params = self.omit(params, 'vaultAddress')
|
1519
1494
|
request['vaultAddress'] = vaultAddress
|
1495
|
+
return request
|
1496
|
+
|
1497
|
+
async def edit_order(self, id: str, symbol: str, type: str, side: str, amount: Num = None, price: Num = None, params={}):
|
1498
|
+
"""
|
1499
|
+
edit a trade order
|
1500
|
+
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
|
1501
|
+
:see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
|
1502
|
+
:param str id: cancel order id
|
1503
|
+
:param str symbol: unified symbol of the market to create an order in
|
1504
|
+
:param str type: 'market' or 'limit'
|
1505
|
+
:param str side: 'buy' or 'sell'
|
1506
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
1507
|
+
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1508
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1509
|
+
:param str [params.timeInForce]: 'Gtc', 'Ioc', 'Alo'
|
1510
|
+
:param bool [params.postOnly]: True or False whether the order is post-only
|
1511
|
+
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
|
1512
|
+
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
1513
|
+
:param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
|
1514
|
+
:param str [params.vaultAddress]: the vault address for order
|
1515
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1516
|
+
"""
|
1517
|
+
await self.load_markets()
|
1518
|
+
market = self.market(symbol)
|
1519
|
+
request = self.edit_order_request(id, symbol, type, side, amount, price, params)
|
1520
1520
|
response = await self.privatePostExchange(request)
|
1521
1521
|
#
|
1522
1522
|
# {
|
@@ -2605,3 +2605,21 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
2605
2605
|
}
|
2606
2606
|
body = self.json(params)
|
2607
2607
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
2608
|
+
|
2609
|
+
def parse_create_order_args(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
2610
|
+
market = self.market(symbol)
|
2611
|
+
vaultAddress = self.safe_string(params, 'vaultAddress')
|
2612
|
+
params = self.omit(params, 'vaultAddress')
|
2613
|
+
symbol = market['symbol']
|
2614
|
+
order = {
|
2615
|
+
'symbol': symbol,
|
2616
|
+
'type': type,
|
2617
|
+
'side': side,
|
2618
|
+
'amount': amount,
|
2619
|
+
'price': price,
|
2620
|
+
'params': params,
|
2621
|
+
}
|
2622
|
+
globalParams = {}
|
2623
|
+
if vaultAddress is not None:
|
2624
|
+
globalParams['vaultAddress'] = vaultAddress
|
2625
|
+
return [order, globalParams]
|
ccxt/async_support/indodax.py
CHANGED
@@ -17,6 +17,7 @@ from ccxt.base.errors import InsufficientFunds
|
|
17
17
|
from ccxt.base.errors import InvalidOrder
|
18
18
|
from ccxt.base.errors import OrderNotFound
|
19
19
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
20
|
+
from ccxt.base.precise import Precise
|
20
21
|
|
21
22
|
|
22
23
|
class indodax(Exchange, ImplicitAPI):
|
@@ -801,8 +802,6 @@ class indodax(Exchange, ImplicitAPI):
|
|
801
802
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
802
803
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
803
804
|
"""
|
804
|
-
if type != 'limit':
|
805
|
-
raise ExchangeError(self.id + ' createOrder() allows limit orders only')
|
806
805
|
await self.load_markets()
|
807
806
|
market = self.market(symbol)
|
808
807
|
request: dict = {
|
@@ -810,12 +809,34 @@ class indodax(Exchange, ImplicitAPI):
|
|
810
809
|
'type': side,
|
811
810
|
'price': price,
|
812
811
|
}
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
812
|
+
priceIsRequired = False
|
813
|
+
quantityIsRequired = False
|
814
|
+
if type == 'market':
|
815
|
+
if side == 'buy':
|
816
|
+
quoteAmount = None
|
817
|
+
cost = self.safe_number(params, 'cost')
|
818
|
+
params = self.omit(params, 'cost')
|
819
|
+
if cost is not None:
|
820
|
+
quoteAmount = self.cost_to_precision(symbol, cost)
|
821
|
+
else:
|
822
|
+
if price is None:
|
823
|
+
raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price).')
|
824
|
+
amountString = self.number_to_string(amount)
|
825
|
+
priceString = self.number_to_string(price)
|
826
|
+
costRequest = Precise.string_mul(amountString, priceString)
|
827
|
+
quoteAmount = self.cost_to_precision(symbol, costRequest)
|
828
|
+
request[market['quoteId']] = quoteAmount
|
829
|
+
else:
|
830
|
+
quantityIsRequired = True
|
831
|
+
elif type == 'limit':
|
832
|
+
priceIsRequired = True
|
833
|
+
quantityIsRequired = True
|
834
|
+
if priceIsRequired:
|
835
|
+
if price is None:
|
836
|
+
raise InvalidOrder(self.id + ' createOrder() requires a price argument for a ' + type + ' order')
|
837
|
+
request['price'] = price
|
838
|
+
if quantityIsRequired:
|
839
|
+
request[market['baseId']] = self.amount_to_precision(symbol, amount)
|
819
840
|
result = await self.privatePostTrade(self.extend(request, params))
|
820
841
|
data = self.safe_value(result, 'return', {})
|
821
842
|
id = self.safe_string(data, 'order_id')
|
@@ -1678,16 +1678,17 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
1678
1678
|
executions.append(item)
|
1679
1679
|
# Final order(after placement / editing / execution / canceling)
|
1680
1680
|
orderTrigger = self.safe_value(item, 'orderTrigger')
|
1681
|
-
details
|
1682
|
-
|
1683
|
-
isPrior = False
|
1684
|
-
fixed = True
|
1685
|
-
elif not fixed:
|
1686
|
-
orderPriorExecution = self.safe_value(item, 'orderPriorExecution')
|
1687
|
-
details = self.safe_value_2(item, 'orderPriorExecution', 'orderPriorEdit')
|
1688
|
-
price = self.safe_string(orderPriorExecution, 'limitPrice')
|
1681
|
+
if details is None:
|
1682
|
+
details = self.safe_value_2(item, 'new', 'order', orderTrigger)
|
1689
1683
|
if details is not None:
|
1690
|
-
isPrior =
|
1684
|
+
isPrior = False
|
1685
|
+
fixed = True
|
1686
|
+
elif not fixed:
|
1687
|
+
orderPriorExecution = self.safe_value(item, 'orderPriorExecution')
|
1688
|
+
details = self.safe_value_2(item, 'orderPriorExecution', 'orderPriorEdit')
|
1689
|
+
price = self.safe_string(orderPriorExecution, 'limitPrice')
|
1690
|
+
if details is not None:
|
1691
|
+
isPrior = True
|
1691
1692
|
trades = self.parse_trades(executions)
|
1692
1693
|
statusId = self.safe_string(order, 'status')
|
1693
1694
|
if details is None:
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.3.
|
7
|
+
__version__ = '4.3.86'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -5927,7 +5927,7 @@ class Exchange(object):
|
|
5927
5927
|
response = None
|
5928
5928
|
if method == 'fetchAccounts':
|
5929
5929
|
response = getattr(self, method)(params)
|
5930
|
-
elif method == 'getLeverageTiersPaginated':
|
5930
|
+
elif method == 'getLeverageTiersPaginated' or method == 'fetchPositions':
|
5931
5931
|
response = getattr(self, method)(symbol, params)
|
5932
5932
|
else:
|
5933
5933
|
response = getattr(self, method)(symbol, since, maxEntriesPerRequest, params)
|
ccxt/binance.py
CHANGED
@@ -3760,12 +3760,14 @@ class binance(Exchange, ImplicitAPI):
|
|
3760
3760
|
marketId = self.safe_string(ticker, 'symbol')
|
3761
3761
|
symbol = self.safe_symbol(marketId, market, None, marketType)
|
3762
3762
|
last = self.safe_string(ticker, 'lastPrice')
|
3763
|
+
wAvg = self.safe_string(ticker, 'weightedAvgPrice')
|
3763
3764
|
isCoinm = ('baseVolume' in ticker)
|
3764
3765
|
baseVolume = None
|
3765
3766
|
quoteVolume = None
|
3766
3767
|
if isCoinm:
|
3767
3768
|
baseVolume = self.safe_string(ticker, 'baseVolume')
|
3768
|
-
quoteVolume
|
3769
|
+
# 'volume' field in inverse markets is not quoteVolume, but traded amount(per contracts)
|
3770
|
+
quoteVolume = Precise.string_mul(baseVolume, wAvg)
|
3769
3771
|
else:
|
3770
3772
|
baseVolume = self.safe_string(ticker, 'volume')
|
3771
3773
|
quoteVolume = self.safe_string_2(ticker, 'quoteVolume', 'amount')
|
@@ -3779,7 +3781,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3779
3781
|
'bidVolume': self.safe_string(ticker, 'bidQty'),
|
3780
3782
|
'ask': self.safe_string(ticker, 'askPrice'),
|
3781
3783
|
'askVolume': self.safe_string(ticker, 'askQty'),
|
3782
|
-
'vwap':
|
3784
|
+
'vwap': wAvg,
|
3783
3785
|
'open': self.safe_string_2(ticker, 'openPrice', 'open'),
|
3784
3786
|
'close': last,
|
3785
3787
|
'last': last,
|
ccxt/bitfinex.py
CHANGED
@@ -832,7 +832,7 @@ class bitfinex(Exchange, ImplicitAPI):
|
|
832
832
|
def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
833
833
|
"""
|
834
834
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
835
|
-
:param str[]
|
835
|
+
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
836
836
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
837
837
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
838
838
|
"""
|
@@ -841,7 +841,7 @@ class bitfinex(Exchange, ImplicitAPI):
|
|
841
841
|
response = self.publicGetTickers(params)
|
842
842
|
result: dict = {}
|
843
843
|
for i in range(0, len(response)):
|
844
|
-
ticker = self.parse_ticker(
|
844
|
+
ticker = self.parse_ticker(response[i])
|
845
845
|
symbol = ticker['symbol']
|
846
846
|
result[symbol] = ticker
|
847
847
|
return self.filter_by_array_tickers(result, 'symbol', symbols)
|