ccxt 4.4.82__py2.py3-none-any.whl → 4.4.85__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 +1 -5
- ccxt/abstract/blofin.py +8 -0
- ccxt/abstract/btcbox.py +1 -0
- ccxt/apex.py +2 -1
- ccxt/async_support/__init__.py +1 -5
- ccxt/async_support/apex.py +2 -1
- ccxt/async_support/base/exchange.py +26 -3
- ccxt/async_support/base/ws/cache.py +6 -1
- ccxt/async_support/bitget.py +1 -2
- ccxt/async_support/bitrue.py +14 -32
- ccxt/async_support/bitso.py +33 -0
- ccxt/async_support/bitstamp.py +33 -0
- ccxt/async_support/blofin.py +145 -14
- ccxt/async_support/btcbox.py +25 -5
- ccxt/async_support/bybit.py +16 -37
- ccxt/async_support/cex.py +2 -4
- ccxt/async_support/coinbase.py +56 -42
- ccxt/async_support/coinbaseexchange.py +141 -32
- ccxt/async_support/coincatch.py +14 -67
- ccxt/async_support/coinex.py +28 -29
- ccxt/async_support/coinlist.py +17 -16
- ccxt/async_support/coinmetro.py +20 -11
- ccxt/async_support/coinone.py +8 -10
- ccxt/async_support/coinsph.py +124 -2
- ccxt/async_support/cryptocom.py +109 -2
- ccxt/async_support/cryptomus.py +42 -80
- ccxt/async_support/delta.py +75 -36
- ccxt/async_support/derive.py +46 -10
- ccxt/async_support/ellipx.py +175 -77
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/gemini.py +3 -4
- ccxt/async_support/hitbtc.py +56 -65
- ccxt/async_support/hyperliquid.py +2 -2
- ccxt/async_support/kraken.py +27 -23
- ccxt/async_support/kucoinfutures.py +5 -0
- ccxt/async_support/lbank.py +1 -1
- ccxt/async_support/paradex.py +120 -4
- ccxt/base/exchange.py +21 -2
- ccxt/base/types.py +3 -0
- ccxt/bitget.py +1 -2
- ccxt/bitrue.py +14 -32
- ccxt/bitso.py +33 -0
- ccxt/bitstamp.py +33 -0
- ccxt/blofin.py +145 -14
- ccxt/btcbox.py +24 -5
- ccxt/bybit.py +16 -37
- ccxt/cex.py +2 -4
- ccxt/coinbase.py +56 -42
- ccxt/coinbaseexchange.py +141 -32
- ccxt/coincatch.py +14 -67
- ccxt/coinex.py +28 -29
- ccxt/coinlist.py +17 -16
- ccxt/coinmetro.py +20 -11
- ccxt/coinone.py +8 -10
- ccxt/coinsph.py +124 -2
- ccxt/cryptocom.py +109 -2
- ccxt/cryptomus.py +42 -80
- ccxt/delta.py +75 -36
- ccxt/derive.py +46 -10
- ccxt/ellipx.py +175 -77
- ccxt/gate.py +1 -1
- ccxt/gemini.py +3 -4
- ccxt/hitbtc.py +56 -65
- ccxt/hyperliquid.py +2 -2
- ccxt/kraken.py +27 -23
- ccxt/kucoinfutures.py +5 -0
- ccxt/lbank.py +1 -1
- ccxt/paradex.py +120 -4
- ccxt/pro/__init__.py +69 -3
- ccxt/pro/binance.py +31 -33
- ccxt/pro/bithumb.py +5 -3
- ccxt/pro/kraken.py +249 -79
- ccxt/pro/mexc.py +252 -7
- ccxt/pro/poloniex.py +6 -2
- {ccxt-4.4.82.dist-info → ccxt-4.4.85.dist-info}/METADATA +7 -9
- {ccxt-4.4.82.dist-info → ccxt-4.4.85.dist-info}/RECORD +79 -87
- ccxt/abstract/bl3p.py +0 -19
- ccxt/abstract/idex.py +0 -26
- ccxt/async_support/base/ws/fast_client.py +0 -97
- ccxt/async_support/bl3p.py +0 -543
- ccxt/async_support/idex.py +0 -1889
- ccxt/bl3p.py +0 -543
- ccxt/idex.py +0 -1889
- ccxt/pro/idex.py +0 -687
- {ccxt-4.4.82.dist-info → ccxt-4.4.85.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.82.dist-info → ccxt-4.4.85.dist-info}/WHEEL +0 -0
- {ccxt-4.4.82.dist-info → ccxt-4.4.85.dist-info}/top_level.txt +0 -0
ccxt/async_support/blofin.py
CHANGED
@@ -57,6 +57,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
57
57
|
'createStopMarketOrder': False,
|
58
58
|
'createStopOrder': False,
|
59
59
|
'createTakeProfitOrder': True,
|
60
|
+
'createTriggerOrder': True,
|
60
61
|
'editOrder': False,
|
61
62
|
'fetchAccounts': False,
|
62
63
|
'fetchBalance': True,
|
@@ -110,6 +111,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
110
111
|
'fetchOrders': False,
|
111
112
|
'fetchOrderTrades': True,
|
112
113
|
'fetchPosition': True,
|
114
|
+
'fetchPositionMode': True,
|
113
115
|
'fetchPositions': True,
|
114
116
|
'fetchPositionsForSymbol': False,
|
115
117
|
'fetchPositionsRisk': False,
|
@@ -137,8 +139,8 @@ class blofin(Exchange, ImplicitAPI):
|
|
137
139
|
'repayCrossMargin': False,
|
138
140
|
'setLeverage': True,
|
139
141
|
'setMargin': False,
|
140
|
-
'setMarginMode':
|
141
|
-
'setPositionMode':
|
142
|
+
'setMarginMode': True,
|
143
|
+
'setPositionMode': True,
|
142
144
|
'signIn': False,
|
143
145
|
'transfer': True,
|
144
146
|
'withdraw': False,
|
@@ -201,10 +203,14 @@ class blofin(Exchange, ImplicitAPI):
|
|
201
203
|
'account/positions': 1,
|
202
204
|
'account/leverage-info': 1,
|
203
205
|
'account/margin-mode': 1,
|
206
|
+
'account/position-mode': 1,
|
204
207
|
'account/batch-leverage-info': 1,
|
205
208
|
'trade/orders-tpsl-pending': 1,
|
209
|
+
'trade/orders-algo-pending': 1,
|
206
210
|
'trade/orders-history': 1,
|
207
211
|
'trade/orders-tpsl-history': 1,
|
212
|
+
'trade/orders-algo-history': 1, # todo new
|
213
|
+
'trade/order/price-range': 1,
|
208
214
|
'user/query-apikey': 1,
|
209
215
|
'affiliate/basic': 1,
|
210
216
|
'copytrading/instruments': 1,
|
@@ -221,8 +227,12 @@ class blofin(Exchange, ImplicitAPI):
|
|
221
227
|
'copytrading/trade/pending-tpsl-by-order': 1,
|
222
228
|
},
|
223
229
|
'post': {
|
230
|
+
'account/set-margin-mode': 1,
|
231
|
+
'account/set-position-mode': 1,
|
224
232
|
'trade/order': 1,
|
233
|
+
'trade/order-algo': 1,
|
225
234
|
'trade/cancel-order': 1,
|
235
|
+
'trade/cancel-algo': 1,
|
226
236
|
'account/set-leverage': 1,
|
227
237
|
'trade/batch-orders': 1,
|
228
238
|
'trade/order-tpsl': 1,
|
@@ -1135,7 +1145,11 @@ class blofin(Exchange, ImplicitAPI):
|
|
1135
1145
|
marginMode = None
|
1136
1146
|
marginMode, params = self.handle_margin_mode_and_params('createOrder', params, 'cross')
|
1137
1147
|
request['marginMode'] = marginMode
|
1148
|
+
triggerPrice = self.safe_string(params, 'triggerPrice')
|
1138
1149
|
timeInForce = self.safe_string(params, 'timeInForce', 'GTC')
|
1150
|
+
isHedged = self.safe_bool(params, 'hedged', False)
|
1151
|
+
if isHedged:
|
1152
|
+
request['positionSide'] = 'long' if (side == 'buy') else 'short'
|
1139
1153
|
isMarketOrder = type == 'market'
|
1140
1154
|
params = self.omit(params, ['timeInForce'])
|
1141
1155
|
ioc = (timeInForce == 'IOC') or (type == 'ioc')
|
@@ -1143,14 +1157,15 @@ class blofin(Exchange, ImplicitAPI):
|
|
1143
1157
|
if isMarketOrder or marketIOC:
|
1144
1158
|
request['orderType'] = 'market'
|
1145
1159
|
else:
|
1146
|
-
|
1160
|
+
key = 'orderPrice' if (triggerPrice is not None) else 'price'
|
1161
|
+
request[key] = self.price_to_precision(symbol, price)
|
1147
1162
|
postOnly = False
|
1148
1163
|
postOnly, params = self.handle_post_only(isMarketOrder, type == 'post_only', params)
|
1149
1164
|
if postOnly:
|
1150
1165
|
request['type'] = 'post_only'
|
1151
1166
|
stopLoss = self.safe_dict(params, 'stopLoss')
|
1152
1167
|
takeProfit = self.safe_dict(params, 'takeProfit')
|
1153
|
-
params = self.omit(params, ['stopLoss', 'takeProfit'])
|
1168
|
+
params = self.omit(params, ['stopLoss', 'takeProfit', 'hedged'])
|
1154
1169
|
isStopLoss = stopLoss is not None
|
1155
1170
|
isTakeProfit = takeProfit is not None
|
1156
1171
|
if isStopLoss or isTakeProfit:
|
@@ -1164,6 +1179,11 @@ class blofin(Exchange, ImplicitAPI):
|
|
1164
1179
|
request['tpTriggerPrice'] = self.price_to_precision(symbol, tpTriggerPrice)
|
1165
1180
|
tpPrice = self.safe_string(takeProfit, 'price', '-1')
|
1166
1181
|
request['tpOrderPrice'] = self.price_to_precision(symbol, tpPrice)
|
1182
|
+
elif triggerPrice is not None:
|
1183
|
+
request['orderType'] = 'trigger'
|
1184
|
+
request['triggerPrice'] = self.price_to_precision(symbol, triggerPrice)
|
1185
|
+
if isMarketOrder:
|
1186
|
+
request['orderPrice'] = '-1'
|
1167
1187
|
return self.extend(request, params)
|
1168
1188
|
|
1169
1189
|
def parse_order_status(self, status: Str):
|
@@ -1213,7 +1233,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
1213
1233
|
# "instType": "SWAP", # only in WS
|
1214
1234
|
# }
|
1215
1235
|
#
|
1216
|
-
id = self.
|
1236
|
+
id = self.safe_string_n(order, ['tpslId', 'orderId', 'algoId'])
|
1217
1237
|
timestamp = self.safe_integer(order, 'createTime')
|
1218
1238
|
lastUpdateTimestamp = self.safe_integer(order, 'updateTime')
|
1219
1239
|
lastTradeTimestamp = self.safe_integer(order, 'fillTime')
|
@@ -1307,12 +1327,14 @@ class blofin(Exchange, ImplicitAPI):
|
|
1307
1327
|
:param float amount: how much of currency you want to trade in units of base currency
|
1308
1328
|
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1309
1329
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1330
|
+
:param str [params.triggerPrice]: the trigger price for a trigger order
|
1310
1331
|
:param bool [params.reduceOnly]: a mark to reduce the position size for margin, swap and future orders
|
1311
1332
|
:param bool [params.postOnly]: True to place a post only order
|
1312
1333
|
:param str [params.marginMode]: 'cross' or 'isolated', default is 'cross'
|
1313
1334
|
:param float [params.stopLossPrice]: stop loss trigger price(will use privatePostTradeOrderTpsl)
|
1314
1335
|
:param float [params.takeProfitPrice]: take profit trigger price(will use privatePostTradeOrderTpsl)
|
1315
1336
|
:param str [params.positionSide]: *stopLossPrice/takeProfitPrice orders only* 'long' or 'short' or 'net' default is 'net'
|
1337
|
+
:param boolean [params.hedged]: if True, the positionSide will be set to long/short instead of net, default is False
|
1316
1338
|
:param str [params.clientOrderId]: a unique id for the order
|
1317
1339
|
:param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
1318
1340
|
:param float [params.takeProfit.triggerPrice]: take profit trigger price
|
@@ -1330,14 +1352,25 @@ class blofin(Exchange, ImplicitAPI):
|
|
1330
1352
|
method, params = self.handle_option_and_params(params, 'createOrder', 'method', 'privatePostTradeOrder')
|
1331
1353
|
isStopLossPriceDefined = self.safe_string(params, 'stopLossPrice') is not None
|
1332
1354
|
isTakeProfitPriceDefined = self.safe_string(params, 'takeProfitPrice') is not None
|
1355
|
+
isTriggerOrder = self.safe_string(params, 'triggerPrice') is not None
|
1333
1356
|
isType2Order = (isStopLossPriceDefined or isTakeProfitPriceDefined)
|
1334
1357
|
response = None
|
1358
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly')
|
1359
|
+
if reduceOnly is not None:
|
1360
|
+
params['reduceOnly'] = 'true' if reduceOnly else 'false'
|
1335
1361
|
if tpsl or (method == 'privatePostTradeOrderTpsl') or isType2Order:
|
1336
1362
|
tpslRequest = self.create_tpsl_order_request(symbol, type, side, amount, price, params)
|
1337
1363
|
response = await self.privatePostTradeOrderTpsl(tpslRequest)
|
1364
|
+
elif isTriggerOrder or (method == 'privatePostTradeOrderAlgo'):
|
1365
|
+
triggerRequest = self.create_order_request(symbol, type, side, amount, price, params)
|
1366
|
+
response = await self.privatePostTradeOrderAlgo(triggerRequest)
|
1338
1367
|
else:
|
1339
1368
|
request = self.create_order_request(symbol, type, side, amount, price, params)
|
1340
1369
|
response = await self.privatePostTradeOrder(request)
|
1370
|
+
if isTriggerOrder or (method == 'privatePostTradeOrderAlgo'):
|
1371
|
+
dataDict = self.safe_dict(response, 'data', {})
|
1372
|
+
triggerOrder = self.parse_order(dataDict, market)
|
1373
|
+
return triggerOrder
|
1341
1374
|
data = self.safe_list(response, 'data', [])
|
1342
1375
|
first = self.safe_dict(data, 0)
|
1343
1376
|
order = self.parse_order(first, market)
|
@@ -1387,7 +1420,8 @@ class blofin(Exchange, ImplicitAPI):
|
|
1387
1420
|
:param str id: order id
|
1388
1421
|
:param str symbol: unified symbol of the market the order was made in
|
1389
1422
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1390
|
-
:param boolean [params.trigger]: True if cancelling a trigger/conditional
|
1423
|
+
:param boolean [params.trigger]: True if cancelling a trigger/conditional
|
1424
|
+
:param boolean [params.tpsl]: True if cancelling a tpsl order
|
1391
1425
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1392
1426
|
"""
|
1393
1427
|
if symbol is None:
|
@@ -1397,20 +1431,27 @@ class blofin(Exchange, ImplicitAPI):
|
|
1397
1431
|
request: dict = {
|
1398
1432
|
'instId': market['id'],
|
1399
1433
|
}
|
1400
|
-
isTrigger = self.safe_bool_n(params, ['
|
1434
|
+
isTrigger = self.safe_bool_n(params, ['trigger'], False)
|
1435
|
+
isTpsl = self.safe_bool_2(params, 'tpsl', 'TPSL', False)
|
1401
1436
|
clientOrderId = self.safe_string(params, 'clientOrderId')
|
1402
1437
|
if clientOrderId is not None:
|
1403
1438
|
request['clientOrderId'] = clientOrderId
|
1404
1439
|
else:
|
1405
|
-
if not isTrigger:
|
1440
|
+
if not isTrigger and not isTpsl:
|
1406
1441
|
request['orderId'] = str(id)
|
1407
|
-
|
1442
|
+
elif isTpsl:
|
1408
1443
|
request['tpslId'] = str(id)
|
1444
|
+
elif isTrigger:
|
1445
|
+
request['algoId'] = str(id)
|
1409
1446
|
query = self.omit(params, ['orderId', 'clientOrderId', 'stop', 'trigger', 'tpsl'])
|
1410
|
-
if
|
1447
|
+
if isTpsl:
|
1411
1448
|
tpslResponse = await self.cancel_orders([id], symbol, params)
|
1412
1449
|
first = self.safe_dict(tpslResponse, 0)
|
1413
1450
|
return first
|
1451
|
+
elif isTrigger:
|
1452
|
+
triggerResponse = await self.privatePostTradeCancelAlgo(self.extend(request, query))
|
1453
|
+
triggerData = self.safe_dict(triggerResponse, 'data')
|
1454
|
+
return self.parse_order(triggerData, market)
|
1414
1455
|
response = await self.privatePostTradeCancelOrder(self.extend(request, query))
|
1415
1456
|
data = self.safe_list(response, 'data', [])
|
1416
1457
|
order = self.safe_dict(data, 0)
|
@@ -1449,6 +1490,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
1449
1490
|
|
1450
1491
|
https://blofin.com/docs#get-active-orders
|
1451
1492
|
https://blofin.com/docs#get-active-tpsl-orders
|
1493
|
+
https://docs.blofin.com/index.html#get-active-algo-orders
|
1452
1494
|
|
1453
1495
|
:param str symbol: unified market symbol
|
1454
1496
|
:param int [since]: the earliest time in ms to fetch open orders for
|
@@ -1471,13 +1513,17 @@ class blofin(Exchange, ImplicitAPI):
|
|
1471
1513
|
request['instId'] = market['id']
|
1472
1514
|
if limit is not None:
|
1473
1515
|
request['limit'] = limit # default 100, max 100
|
1474
|
-
isTrigger = self.safe_bool_n(params, ['stop', 'trigger'
|
1516
|
+
isTrigger = self.safe_bool_n(params, ['stop', 'trigger'], False)
|
1517
|
+
isTpSl = self.safe_bool_2(params, 'tpsl', 'TPSL', False)
|
1475
1518
|
method: Str = None
|
1476
1519
|
method, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersPending')
|
1477
1520
|
query = self.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL'])
|
1478
1521
|
response = None
|
1479
|
-
if
|
1522
|
+
if isTpSl or (method == 'privateGetTradeOrdersTpslPending'):
|
1480
1523
|
response = await self.privateGetTradeOrdersTpslPending(self.extend(request, query))
|
1524
|
+
elif isTrigger or (method == 'privateGetTradeOrdersAlgoPending'):
|
1525
|
+
request['orderType'] = 'trigger'
|
1526
|
+
response = await self.privateGetTradeOrdersAlgoPending(self.extend(request, query))
|
1481
1527
|
else:
|
1482
1528
|
response = await self.privateGetTradeOrdersPending(self.extend(request, query))
|
1483
1529
|
data = self.safe_list(response, 'data', [])
|
@@ -2118,6 +2164,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
2118
2164
|
:param str symbol: unified market symbol
|
2119
2165
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2120
2166
|
:param str [params.marginMode]: 'cross' or 'isolated'
|
2167
|
+
:param str [params.positionSide]: 'long' or 'short' - required for hedged mode in isolated margin
|
2121
2168
|
:returns dict: response from the exchange
|
2122
2169
|
"""
|
2123
2170
|
if symbol is None:
|
@@ -2239,13 +2286,97 @@ class blofin(Exchange, ImplicitAPI):
|
|
2239
2286
|
data = self.safe_dict(response, 'data', {})
|
2240
2287
|
return self.parse_margin_mode(data, market)
|
2241
2288
|
|
2242
|
-
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
2289
|
+
def parse_margin_mode(self, marginMode: dict, market: Market = None) -> MarginMode:
|
2243
2290
|
return {
|
2244
2291
|
'info': marginMode,
|
2245
|
-
'symbol': market
|
2292
|
+
'symbol': self.safe_string(market, 'symbol'),
|
2246
2293
|
'marginMode': self.safe_string(marginMode, 'marginMode'),
|
2247
2294
|
}
|
2248
2295
|
|
2296
|
+
async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
2297
|
+
"""
|
2298
|
+
set margin mode to 'cross' or 'isolated'
|
2299
|
+
|
2300
|
+
https://docs.blofin.com/index.html#set-margin-mode
|
2301
|
+
|
2302
|
+
:param str marginMode: 'cross' or 'isolated'
|
2303
|
+
:param str [symbol]: unified market symbol(not used in blofin setMarginMode)
|
2304
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2305
|
+
:returns dict: response from the exchange
|
2306
|
+
"""
|
2307
|
+
self.check_required_argument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated'])
|
2308
|
+
await self.load_markets()
|
2309
|
+
market = None
|
2310
|
+
if symbol is not None:
|
2311
|
+
market = self.market(symbol)
|
2312
|
+
request: dict = {
|
2313
|
+
'marginMode': marginMode,
|
2314
|
+
}
|
2315
|
+
response = await self.privatePostAccountSetMarginMode(self.extend(request, params))
|
2316
|
+
#
|
2317
|
+
# {
|
2318
|
+
# "code": "0",
|
2319
|
+
# "msg": "success",
|
2320
|
+
# "data": {
|
2321
|
+
# "marginMode": "isolated"
|
2322
|
+
# }
|
2323
|
+
# }
|
2324
|
+
#
|
2325
|
+
data = self.safe_dict(response, 'data', {})
|
2326
|
+
return self.parse_margin_mode(data, market)
|
2327
|
+
|
2328
|
+
async def fetch_position_mode(self, symbol: Str = None, params={}):
|
2329
|
+
"""
|
2330
|
+
fetchs the position mode, hedged or one way
|
2331
|
+
|
2332
|
+
https://docs.blofin.com/index.html#get-position-mode
|
2333
|
+
|
2334
|
+
:param str [symbol]: unified symbol of the market to fetch the position mode for(not used in blofin fetchPositionMode)
|
2335
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2336
|
+
:returns dict: an object detailing whether the market is in hedged or one-way mode
|
2337
|
+
"""
|
2338
|
+
response = await self.privateGetAccountPositionMode(params)
|
2339
|
+
data = self.safe_dict(response, 'data', {})
|
2340
|
+
positionMode = self.safe_string(data, 'positionMode')
|
2341
|
+
#
|
2342
|
+
# {
|
2343
|
+
# "code": "0",
|
2344
|
+
# "msg": "success",
|
2345
|
+
# "data": {
|
2346
|
+
# "positionMode": "long_short_mode"
|
2347
|
+
# }
|
2348
|
+
# }
|
2349
|
+
#
|
2350
|
+
return {
|
2351
|
+
'info': data,
|
2352
|
+
'hedged': positionMode == 'long_short_mode',
|
2353
|
+
}
|
2354
|
+
|
2355
|
+
async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
|
2356
|
+
"""
|
2357
|
+
set hedged to True or False for a market
|
2358
|
+
|
2359
|
+
https://docs.blofin.com/index.html#set-position-mode
|
2360
|
+
|
2361
|
+
:param bool hedged: set to True to use hedged mode, False for one-way mode
|
2362
|
+
:param str [symbol]: not used by blofin setPositionMode()
|
2363
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2364
|
+
:returns dict: response from the exchange
|
2365
|
+
"""
|
2366
|
+
request: dict = {
|
2367
|
+
'positionMode': 'long_short_mode' if hedged else 'net_mode',
|
2368
|
+
}
|
2369
|
+
#
|
2370
|
+
# {
|
2371
|
+
# "code": "0",
|
2372
|
+
# "msg": "success",
|
2373
|
+
# "data": {
|
2374
|
+
# "positionMode": "net_mode"
|
2375
|
+
# }
|
2376
|
+
# }
|
2377
|
+
#
|
2378
|
+
return await self.privatePostAccountSetPositionMode(self.extend(request, params))
|
2379
|
+
|
2249
2380
|
def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
2250
2381
|
if response is None:
|
2251
2382
|
return None # fallback to default error handler
|
ccxt/async_support/btcbox.py
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.btcbox import ImplicitAPI
|
8
|
+
import asyncio
|
8
9
|
import hashlib
|
9
10
|
import json
|
10
11
|
from ccxt.base.types import Any, Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
|
@@ -115,6 +116,18 @@ class btcbox(Exchange, ImplicitAPI):
|
|
115
116
|
'wallet',
|
116
117
|
],
|
117
118
|
},
|
119
|
+
'webApi': {
|
120
|
+
'get': [
|
121
|
+
'ajax/coin/coinInfo',
|
122
|
+
],
|
123
|
+
},
|
124
|
+
},
|
125
|
+
'options': {
|
126
|
+
'fetchMarkets': {
|
127
|
+
'webApiEnable': True, # fetches from WEB
|
128
|
+
'webApiRetries': 3,
|
129
|
+
},
|
130
|
+
'amountPrecision': '0.0001', # exchange has only few pairs and all of them
|
118
131
|
},
|
119
132
|
'features': {
|
120
133
|
'spot': {
|
@@ -198,9 +211,12 @@ class btcbox(Exchange, ImplicitAPI):
|
|
198
211
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
199
212
|
:returns dict[]: an array of objects representing market data
|
200
213
|
"""
|
201
|
-
|
214
|
+
promise1 = self.publicGetTickers()
|
215
|
+
promise2 = self.fetch_web_endpoint('fetchMarkets', 'webApiGetAjaxCoinCoinInfo', True)
|
216
|
+
response1, response2 = await asyncio.gather(*[promise1, promise2])
|
202
217
|
#
|
203
|
-
|
218
|
+
result2Data = self.safe_dict(response2, 'data', {})
|
219
|
+
marketIds = list(response1.keys())
|
204
220
|
markets = []
|
205
221
|
for i in range(0, len(marketIds)):
|
206
222
|
marketId = marketIds[i]
|
@@ -209,9 +225,11 @@ class btcbox(Exchange, ImplicitAPI):
|
|
209
225
|
quote = self.safe_string(symbolParts, 1)
|
210
226
|
quoteId = quote.lower()
|
211
227
|
id = baseCurr.lower()
|
212
|
-
res =
|
228
|
+
res = response1[marketId]
|
213
229
|
symbol = baseCurr + '/' + quote
|
214
230
|
fee = self.parse_number('0.0005') if (id == 'BTC') else self.parse_number('0.0010')
|
231
|
+
details = self.safe_dict(result2Data, id, {})
|
232
|
+
tradeDetails = self.safe_dict(details, 'trade', {})
|
215
233
|
markets.append(self.safe_market_structure({
|
216
234
|
'id': id,
|
217
235
|
'uppercaseId': None,
|
@@ -257,10 +275,10 @@ class btcbox(Exchange, ImplicitAPI):
|
|
257
275
|
},
|
258
276
|
},
|
259
277
|
'precision': {
|
260
|
-
'price':
|
278
|
+
'price': self.parse_number(self.parse_precision(self.safe_string(tradeDetails, 'pricedecimal'))),
|
261
279
|
'amount': None,
|
262
280
|
},
|
263
|
-
'active':
|
281
|
+
'active': self.safe_string(tradeDetails, 'enable') == '1',
|
264
282
|
'created': None,
|
265
283
|
'info': res,
|
266
284
|
}))
|
@@ -717,6 +735,8 @@ class btcbox(Exchange, ImplicitAPI):
|
|
717
735
|
if api == 'public':
|
718
736
|
if params:
|
719
737
|
url += '?' + self.urlencode(params)
|
738
|
+
elif api == 'webApi':
|
739
|
+
url = self.urls['www'] + '/' + path
|
720
740
|
else:
|
721
741
|
self.check_required_credentials()
|
722
742
|
nonce = str(self.nonce())
|
ccxt/async_support/bybit.py
CHANGED
@@ -1635,78 +1635,57 @@ class bybit(Exchange, ImplicitAPI):
|
|
1635
1635
|
name = self.safe_string(currency, 'name')
|
1636
1636
|
chains = self.safe_list(currency, 'chains', [])
|
1637
1637
|
networks: dict = {}
|
1638
|
-
minPrecision = None
|
1639
|
-
minWithdrawFeeString = None
|
1640
|
-
minWithdrawString = None
|
1641
|
-
minDepositString = None
|
1642
|
-
deposit = False
|
1643
|
-
withdraw = False
|
1644
1638
|
for j in range(0, len(chains)):
|
1645
1639
|
chain = chains[j]
|
1646
1640
|
networkId = self.safe_string(chain, 'chain')
|
1647
1641
|
networkCode = self.network_id_to_code(networkId)
|
1648
|
-
precision = self.parse_number(self.parse_precision(self.safe_string(chain, 'minAccuracy')))
|
1649
|
-
minPrecision = precision if (minPrecision is None) else min(minPrecision, precision)
|
1650
|
-
depositAllowed = self.safe_integer(chain, 'chainDeposit') == 1
|
1651
|
-
deposit = depositAllowed if (depositAllowed) else deposit
|
1652
|
-
withdrawAllowed = self.safe_integer(chain, 'chainWithdraw') == 1
|
1653
|
-
withdraw = withdrawAllowed if (withdrawAllowed) else withdraw
|
1654
|
-
withdrawFeeString = self.safe_string(chain, 'withdrawFee')
|
1655
|
-
if withdrawFeeString is not None:
|
1656
|
-
minWithdrawFeeString = withdrawFeeString if (minWithdrawFeeString is None) else Precise.string_min(withdrawFeeString, minWithdrawFeeString)
|
1657
|
-
minNetworkWithdrawString = self.safe_string(chain, 'withdrawMin')
|
1658
|
-
if minNetworkWithdrawString is not None:
|
1659
|
-
minWithdrawString = minNetworkWithdrawString if (minWithdrawString is None) else Precise.string_min(minNetworkWithdrawString, minWithdrawString)
|
1660
|
-
minNetworkDepositString = self.safe_string(chain, 'depositMin')
|
1661
|
-
if minNetworkDepositString is not None:
|
1662
|
-
minDepositString = minNetworkDepositString if (minDepositString is None) else Precise.string_min(minNetworkDepositString, minDepositString)
|
1663
1642
|
networks[networkCode] = {
|
1664
1643
|
'info': chain,
|
1665
1644
|
'id': networkId,
|
1666
1645
|
'network': networkCode,
|
1667
|
-
'active':
|
1668
|
-
'deposit':
|
1669
|
-
'withdraw':
|
1670
|
-
'fee': self.
|
1671
|
-
'precision':
|
1646
|
+
'active': None,
|
1647
|
+
'deposit': self.safe_integer(chain, 'chainDeposit') == 1,
|
1648
|
+
'withdraw': self.safe_integer(chain, 'chainWithdraw') == 1,
|
1649
|
+
'fee': self.safe_number(chain, 'withdrawFee'),
|
1650
|
+
'precision': self.parse_number(self.parse_precision(self.safe_string(chain, 'minAccuracy'))),
|
1672
1651
|
'limits': {
|
1673
1652
|
'withdraw': {
|
1674
|
-
'min': self.
|
1653
|
+
'min': self.safe_number(chain, 'withdrawMin'),
|
1675
1654
|
'max': None,
|
1676
1655
|
},
|
1677
1656
|
'deposit': {
|
1678
|
-
'min': self.
|
1657
|
+
'min': self.safe_number(chain, 'depositMin'),
|
1679
1658
|
'max': None,
|
1680
1659
|
},
|
1681
1660
|
},
|
1682
1661
|
}
|
1683
|
-
result[code] = {
|
1662
|
+
result[code] = self.safe_currency_structure({
|
1684
1663
|
'info': currency,
|
1685
1664
|
'code': code,
|
1686
1665
|
'id': currencyId,
|
1687
1666
|
'name': name,
|
1688
|
-
'active':
|
1689
|
-
'deposit':
|
1690
|
-
'withdraw':
|
1691
|
-
'fee':
|
1692
|
-
'precision':
|
1667
|
+
'active': None,
|
1668
|
+
'deposit': None,
|
1669
|
+
'withdraw': None,
|
1670
|
+
'fee': None,
|
1671
|
+
'precision': None,
|
1693
1672
|
'limits': {
|
1694
1673
|
'amount': {
|
1695
1674
|
'min': None,
|
1696
1675
|
'max': None,
|
1697
1676
|
},
|
1698
1677
|
'withdraw': {
|
1699
|
-
'min':
|
1678
|
+
'min': None,
|
1700
1679
|
'max': None,
|
1701
1680
|
},
|
1702
1681
|
'deposit': {
|
1703
|
-
'min':
|
1682
|
+
'min': None,
|
1704
1683
|
'max': None,
|
1705
1684
|
},
|
1706
1685
|
},
|
1707
1686
|
'networks': networks,
|
1708
1687
|
'type': 'crypto', # atm exchange api provides only cryptos
|
1709
|
-
}
|
1688
|
+
})
|
1710
1689
|
return result
|
1711
1690
|
|
1712
1691
|
async def fetch_markets(self, params={}) -> List[Market]:
|
ccxt/async_support/cex.py
CHANGED
@@ -311,8 +311,6 @@ class cex(Exchange, ImplicitAPI):
|
|
311
311
|
id = self.safe_string(rawCurrency, 'currency')
|
312
312
|
code = self.safe_currency_code(id)
|
313
313
|
type = 'fiat' if self.safe_bool(rawCurrency, 'fiat') else 'crypto'
|
314
|
-
currencyDepositEnabled = self.safe_bool(rawCurrency, 'walletDeposit')
|
315
|
-
currencyWithdrawEnabled = self.safe_bool(rawCurrency, 'walletWithdrawal')
|
316
314
|
currencyPrecision = self.parse_number(self.parse_precision(self.safe_string(rawCurrency, 'precision')))
|
317
315
|
networks: dict = {}
|
318
316
|
rawNetworks = self.safe_dict(rawCurrency, 'blockchains', {})
|
@@ -350,8 +348,8 @@ class cex(Exchange, ImplicitAPI):
|
|
350
348
|
'name': None,
|
351
349
|
'type': type,
|
352
350
|
'active': None,
|
353
|
-
'deposit':
|
354
|
-
'withdraw':
|
351
|
+
'deposit': self.safe_bool(rawCurrency, 'walletDeposit'),
|
352
|
+
'withdraw': self.safe_bool(rawCurrency, 'walletWithdrawal'),
|
355
353
|
'fee': None,
|
356
354
|
'precision': currencyPrecision,
|
357
355
|
'limits': {
|
ccxt/async_support/coinbase.py
CHANGED
@@ -1833,45 +1833,46 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1833
1833
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1834
1834
|
:returns dict: an associative dictionary of currencies
|
1835
1835
|
"""
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
# name: 'Isle of Man Pound',
|
1844
|
-
# min_size: '0.01'
|
1845
|
-
# },
|
1846
|
-
#
|
1847
|
-
# crypto
|
1848
|
-
#
|
1849
|
-
# {
|
1850
|
-
# asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
1851
|
-
# code: 'AERO',
|
1852
|
-
# name: 'Aerodrome Finance',
|
1853
|
-
# color: '#0433FF',
|
1854
|
-
# sort_index: '340',
|
1855
|
-
# exponent: '8',
|
1856
|
-
# type: 'crypto',
|
1857
|
-
# address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
1858
|
-
# }
|
1836
|
+
promises = [
|
1837
|
+
self.v2PublicGetCurrencies(params),
|
1838
|
+
self.v2PublicGetCurrenciesCrypto(params),
|
1839
|
+
self.v2PublicGetExchangeRates(params),
|
1840
|
+
]
|
1841
|
+
promisesResult = await asyncio.gather(*promises)
|
1842
|
+
fiatResponse = self.safe_dict(promisesResult, 0, {})
|
1859
1843
|
#
|
1844
|
+
# [
|
1845
|
+
# "data": [
|
1846
|
+
# {
|
1847
|
+
# id: 'IMP',
|
1848
|
+
# name: 'Isle of Man Pound',
|
1849
|
+
# min_size: '0.01'
|
1850
|
+
# },
|
1851
|
+
# ...
|
1860
1852
|
#
|
1861
|
-
|
1862
|
-
# "data":{
|
1863
|
-
# "currency":"USD",
|
1864
|
-
# "rates":{
|
1865
|
-
# "AED":"3.67",
|
1866
|
-
# "AFN":"78.21",
|
1867
|
-
# "ALL":"110.42",
|
1868
|
-
# "AMD":"474.18",
|
1869
|
-
# "ANG":"1.75",
|
1870
|
-
# ...
|
1871
|
-
# },
|
1872
|
-
# }
|
1873
|
-
# }
|
1853
|
+
cryptoResponse = self.safe_dict(promisesResult, 1, {})
|
1874
1854
|
#
|
1855
|
+
# [
|
1856
|
+
# "data": [
|
1857
|
+
# {
|
1858
|
+
# asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
1859
|
+
# code: 'AERO',
|
1860
|
+
# name: 'Aerodrome Finance',
|
1861
|
+
# color: '#0433FF',
|
1862
|
+
# sort_index: '340',
|
1863
|
+
# exponent: '8',
|
1864
|
+
# type: 'crypto',
|
1865
|
+
# address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
1866
|
+
# },
|
1867
|
+
# ...
|
1868
|
+
#
|
1869
|
+
ratesResponse = self.safe_dict(promisesResult, 2, {})
|
1870
|
+
fiatData = self.safe_list(fiatResponse, 'data', [])
|
1871
|
+
cryptoData = self.safe_list(cryptoResponse, 'data', [])
|
1872
|
+
ratesData = self.safe_dict(ratesResponse, 'data', {})
|
1873
|
+
rates = self.safe_dict(ratesData, 'rates', {})
|
1874
|
+
ratesIds = list(rates.keys())
|
1875
|
+
currencies = self.array_concat(fiatData, cryptoData)
|
1875
1876
|
result: dict = {}
|
1876
1877
|
networks: dict = {}
|
1877
1878
|
networksById: dict = {}
|
@@ -1883,18 +1884,19 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1883
1884
|
name = self.safe_string(currency, 'name')
|
1884
1885
|
self.options['networks'][code] = name.lower()
|
1885
1886
|
self.options['networksById'][code] = name.lower()
|
1886
|
-
|
1887
|
-
|
1887
|
+
type = 'crypto' if (assetId is not None) else 'fiat'
|
1888
|
+
result[code] = self.safe_currency_structure({
|
1889
|
+
'info': currency,
|
1888
1890
|
'id': id,
|
1889
1891
|
'code': code,
|
1890
|
-
'type':
|
1891
|
-
'name':
|
1892
|
+
'type': type,
|
1893
|
+
'name': name,
|
1892
1894
|
'active': True,
|
1893
1895
|
'deposit': None,
|
1894
1896
|
'withdraw': None,
|
1895
1897
|
'fee': None,
|
1896
1898
|
'precision': None,
|
1897
|
-
'networks': {},
|
1899
|
+
'networks': {}, # todo
|
1898
1900
|
'limits': {
|
1899
1901
|
'amount': {
|
1900
1902
|
'min': self.safe_number(currency, 'min_size'),
|
@@ -1905,11 +1907,23 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1905
1907
|
'max': None,
|
1906
1908
|
},
|
1907
1909
|
},
|
1908
|
-
}
|
1910
|
+
})
|
1909
1911
|
if assetId is not None:
|
1910
1912
|
lowerCaseName = name.lower()
|
1911
1913
|
networks[code] = lowerCaseName
|
1912
1914
|
networksById[lowerCaseName] = code
|
1915
|
+
# we have to add other currencies here( https://discord.com/channels/1220414409550336183/1220464770239430761/1372215891940479098 )
|
1916
|
+
for i in range(0, len(ratesIds)):
|
1917
|
+
currencyId = ratesIds[i]
|
1918
|
+
code = self.safe_currency_code(currencyId)
|
1919
|
+
if not (code in result):
|
1920
|
+
result[code] = self.safe_currency_structure({
|
1921
|
+
'info': {},
|
1922
|
+
'id': currencyId,
|
1923
|
+
'code': code,
|
1924
|
+
'type': 'crypto',
|
1925
|
+
'networks': {}, # todo
|
1926
|
+
})
|
1913
1927
|
self.options['networks'] = self.extend(networks, self.options['networks'])
|
1914
1928
|
self.options['networksById'] = self.extend(networksById, self.options['networksById'])
|
1915
1929
|
return result
|