ccxt 4.3.24__py2.py3-none-any.whl → 4.3.28__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/bitget.py +1 -0
- ccxt/abstract/bitmart.py +2 -1
- ccxt/ascendex.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +1 -1
- ccxt/async_support/base/exchange.py +2 -2
- ccxt/async_support/bingx.py +40 -7
- ccxt/async_support/bitget.py +1 -0
- ccxt/async_support/bitmart.py +57 -2
- ccxt/async_support/bybit.py +2 -2
- ccxt/async_support/coinbase.py +1 -1
- ccxt/async_support/coinex.py +42 -71
- ccxt/async_support/kraken.py +52 -7
- ccxt/async_support/krakenfutures.py +1 -1
- ccxt/async_support/phemex.py +16 -2
- ccxt/base/exchange.py +31 -27
- ccxt/bingx.py +40 -7
- ccxt/bitget.py +1 -0
- ccxt/bitmart.py +57 -2
- ccxt/bybit.py +2 -2
- ccxt/coinbase.py +1 -1
- ccxt/coinex.py +42 -71
- ccxt/kraken.py +52 -7
- ccxt/krakenfutures.py +1 -1
- ccxt/phemex.py +16 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +1 -1
- ccxt/pro/coinbase.py +5 -1
- ccxt/pro/cryptocom.py +9 -6
- ccxt/pro/kraken.py +7 -6
- ccxt/pro/okx.py +1 -1
- {ccxt-4.3.24.dist-info → ccxt-4.3.28.dist-info}/METADATA +4 -4
- {ccxt-4.3.24.dist-info → ccxt-4.3.28.dist-info}/RECORD +36 -36
- {ccxt-4.3.24.dist-info → ccxt-4.3.28.dist-info}/WHEEL +0 -0
- {ccxt-4.3.24.dist-info → ccxt-4.3.28.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/bitget.py
CHANGED
@@ -498,6 +498,7 @@ class ImplicitAPI:
|
|
498
498
|
private_earn_get_v2_earn_loan_borrow_history = privateEarnGetV2EarnLoanBorrowHistory = Entry('v2/earn/loan/borrow-history', ['private', 'earn'], 'GET', {'cost': 2})
|
499
499
|
private_earn_get_v2_earn_loan_debts = privateEarnGetV2EarnLoanDebts = Entry('v2/earn/loan/debts', ['private', 'earn'], 'GET', {'cost': 2})
|
500
500
|
private_earn_get_v2_earn_loan_reduces = privateEarnGetV2EarnLoanReduces = Entry('v2/earn/loan/reduces', ['private', 'earn'], 'GET', {'cost': 2})
|
501
|
+
private_earn_get_v2_earn_account_assets = privateEarnGetV2EarnAccountAssets = Entry('v2/earn/account/assets', ['private', 'earn'], 'GET', {'cost': 2})
|
501
502
|
private_earn_post_v2_earn_savings_subscribe = privateEarnPostV2EarnSavingsSubscribe = Entry('v2/earn/savings/subscribe', ['private', 'earn'], 'POST', {'cost': 2})
|
502
503
|
private_earn_post_v2_earn_savings_redeem = privateEarnPostV2EarnSavingsRedeem = Entry('v2/earn/savings/redeem', ['private', 'earn'], 'POST', {'cost': 2})
|
503
504
|
private_earn_post_v2_earn_sharkfin_subscribe = privateEarnPostV2EarnSharkfinSubscribe = Entry('v2/earn/sharkfin/subscribe', ['private', 'earn'], 'POST', {'cost': 2})
|
ccxt/abstract/bitmart.py
CHANGED
@@ -44,7 +44,7 @@ class ImplicitAPI:
|
|
44
44
|
private_get_spot_v1_order_detail = privateGetSpotV1OrderDetail = Entry('spot/v1/order_detail', 'private', 'GET', {'cost': 1})
|
45
45
|
private_get_spot_v2_orders = privateGetSpotV2Orders = Entry('spot/v2/orders', 'private', 'GET', {'cost': 5})
|
46
46
|
private_get_spot_v1_trades = privateGetSpotV1Trades = Entry('spot/v1/trades', 'private', 'GET', {'cost': 5})
|
47
|
-
private_get_spot_v2_trades = privateGetSpotV2Trades = Entry('spot/v2/trades', 'private', 'GET', {'cost':
|
47
|
+
private_get_spot_v2_trades = privateGetSpotV2Trades = Entry('spot/v2/trades', 'private', 'GET', {'cost': 4})
|
48
48
|
private_get_spot_v3_orders = privateGetSpotV3Orders = Entry('spot/v3/orders', 'private', 'GET', {'cost': 5})
|
49
49
|
private_get_spot_v2_order_detail = privateGetSpotV2OrderDetail = Entry('spot/v2/order_detail', 'private', 'GET', {'cost': 1})
|
50
50
|
private_get_spot_v1_margin_isolated_borrow_record = privateGetSpotV1MarginIsolatedBorrowRecord = Entry('spot/v1/margin/isolated/borrow_record', 'private', 'GET', {'cost': 1})
|
@@ -80,6 +80,7 @@ class ImplicitAPI:
|
|
80
80
|
private_post_spot_v4_query_history_orders = privatePostSpotV4QueryHistoryOrders = Entry('spot/v4/query/history-orders', 'private', 'POST', {'cost': 5})
|
81
81
|
private_post_spot_v4_query_trades = privatePostSpotV4QueryTrades = Entry('spot/v4/query/trades', 'private', 'POST', {'cost': 5})
|
82
82
|
private_post_spot_v4_query_order_trades = privatePostSpotV4QueryOrderTrades = Entry('spot/v4/query/order-trades', 'private', 'POST', {'cost': 5})
|
83
|
+
private_post_spot_v4_cancel_orders = privatePostSpotV4CancelOrders = Entry('spot/v4/cancel_orders', 'private', 'POST', {'cost': 3})
|
83
84
|
private_post_spot_v3_cancel_order = privatePostSpotV3CancelOrder = Entry('spot/v3/cancel_order', 'private', 'POST', {'cost': 1})
|
84
85
|
private_post_spot_v2_batch_orders = privatePostSpotV2BatchOrders = Entry('spot/v2/batch_orders', 'private', 'POST', {'cost': 1})
|
85
86
|
private_post_spot_v2_submit_order = privatePostSpotV2SubmitOrder = Entry('spot/v2/submit_order', 'private', 'POST', {'cost': 1})
|
ccxt/ascendex.py
CHANGED
@@ -1362,7 +1362,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1362
1362
|
'cost': feeCost,
|
1363
1363
|
'currency': feeCurrencyCode,
|
1364
1364
|
}
|
1365
|
-
stopPrice = self.
|
1365
|
+
stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
|
1366
1366
|
reduceOnly = None
|
1367
1367
|
execInst = self.safe_string(order, 'execInst')
|
1368
1368
|
if execInst == 'reduceOnly':
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/ascendex.py
CHANGED
@@ -1362,7 +1362,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
1362
1362
|
'cost': feeCost,
|
1363
1363
|
'currency': feeCurrencyCode,
|
1364
1364
|
}
|
1365
|
-
stopPrice = self.
|
1365
|
+
stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
|
1366
1366
|
reduceOnly = None
|
1367
1367
|
execInst = self.safe_string(order, 'execInst')
|
1368
1368
|
if execInst == 'reduceOnly':
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.3.
|
5
|
+
__version__ = '4.3.28'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -839,7 +839,7 @@ class Exchange(BaseExchange):
|
|
839
839
|
await self.cancelOrder(id, symbol)
|
840
840
|
return await self.create_order(symbol, type, side, amount, price, params)
|
841
841
|
|
842
|
-
async def edit_order_ws(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount:
|
842
|
+
async def edit_order_ws(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
843
843
|
await self.cancelOrderWs(id, symbol)
|
844
844
|
return await self.createOrderWs(symbol, type, side, amount, price, params)
|
845
845
|
|
ccxt/async_support/bingx.py
CHANGED
@@ -2079,6 +2079,10 @@ class bingx(Exchange, ImplicitAPI):
|
|
2079
2079
|
types = {
|
2080
2080
|
'trigger_market': 'market',
|
2081
2081
|
'trigger_limit': 'limit',
|
2082
|
+
'stop_limit': 'limit',
|
2083
|
+
'stop_market': 'market',
|
2084
|
+
'take_profit_market': 'market',
|
2085
|
+
'stop': 'limit',
|
2082
2086
|
}
|
2083
2087
|
return self.safe_string(types, type, type)
|
2084
2088
|
|
@@ -2282,6 +2286,25 @@ class bingx(Exchange, ImplicitAPI):
|
|
2282
2286
|
# side: 'SELL'
|
2283
2287
|
# }
|
2284
2288
|
# }
|
2289
|
+
# stop loss order
|
2290
|
+
# {
|
2291
|
+
# "symbol": "ETH-USDT",
|
2292
|
+
# "orderId": "1792461744476422144",
|
2293
|
+
# "price": "2775.65",
|
2294
|
+
# "StopPrice": "2778.42",
|
2295
|
+
# "origQty": "0.032359",
|
2296
|
+
# "executedQty": "0",
|
2297
|
+
# "cummulativeQuoteQty": "0",
|
2298
|
+
# "status": "NEW",
|
2299
|
+
# "type": "TAKE_STOP_LIMIT",
|
2300
|
+
# "side": "SELL",
|
2301
|
+
# "time": "1716191156868",
|
2302
|
+
# "updateTime": "1716191156868",
|
2303
|
+
# "origQuoteOrderQty": "0",
|
2304
|
+
# "fee": "0",
|
2305
|
+
# "feeAsset": "USDT",
|
2306
|
+
# "clientOrderID": ""
|
2307
|
+
# }
|
2285
2308
|
#
|
2286
2309
|
info = order
|
2287
2310
|
newOrder = self.safe_dict_2(order, 'newOrderResponse', 'orderOpenResponse')
|
@@ -2309,21 +2332,31 @@ class bingx(Exchange, ImplicitAPI):
|
|
2309
2332
|
stopLoss = self.safe_value(order, 'stopLoss')
|
2310
2333
|
stopLossPrice = None
|
2311
2334
|
if (stopLoss is not None) and (stopLoss != ''):
|
2312
|
-
stopLossPrice = self.
|
2335
|
+
stopLossPrice = self.omit_zero(self.safe_string(stopLoss, 'stopLoss'))
|
2313
2336
|
if (stopLoss is not None) and ((not isinstance(stopLoss, numbers.Real))) and (stopLoss != ''):
|
2314
2337
|
# stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
2315
2338
|
if isinstance(stopLoss, str):
|
2316
2339
|
stopLoss = self.parse_json(stopLoss)
|
2317
|
-
stopLossPrice = self.
|
2340
|
+
stopLossPrice = self.omit_zero(self.safe_string(stopLoss, 'stopPrice'))
|
2318
2341
|
takeProfit = self.safe_value(order, 'takeProfit')
|
2319
2342
|
takeProfitPrice = None
|
2320
2343
|
if takeProfit is not None and (takeProfit != ''):
|
2321
|
-
takeProfitPrice = self.
|
2344
|
+
takeProfitPrice = self.omit_zero(self.safe_string(takeProfit, 'takeProfit'))
|
2322
2345
|
if (takeProfit is not None) and ((not isinstance(takeProfit, numbers.Real))) and (takeProfit != ''):
|
2323
2346
|
# takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
2324
2347
|
if isinstance(takeProfit, str):
|
2325
2348
|
takeProfit = self.parse_json(takeProfit)
|
2326
|
-
takeProfitPrice = self.
|
2349
|
+
takeProfitPrice = self.omit_zero(self.safe_string(takeProfit, 'stopPrice'))
|
2350
|
+
rawType = self.safe_string_lower_2(order, 'type', 'o')
|
2351
|
+
stopPrice = self.omit_zero(self.safe_string_2(order, 'StopPrice', 'stopPrice'))
|
2352
|
+
triggerPrice = stopPrice
|
2353
|
+
if stopPrice is not None:
|
2354
|
+
if (rawType.find('stop') > -1) and (stopLossPrice is None):
|
2355
|
+
stopLossPrice = stopPrice
|
2356
|
+
triggerPrice = None
|
2357
|
+
if (rawType.find('take') > -1) and (takeProfitPrice is None):
|
2358
|
+
takeProfitPrice = stopPrice
|
2359
|
+
triggerPrice = None
|
2327
2360
|
return self.safe_order({
|
2328
2361
|
'info': info,
|
2329
2362
|
'id': self.safe_string_2(order, 'orderId', 'i'),
|
@@ -2333,13 +2366,13 @@ class bingx(Exchange, ImplicitAPI):
|
|
2333
2366
|
'datetime': self.iso8601(timestamp),
|
2334
2367
|
'lastTradeTimestamp': lastTradeTimestamp,
|
2335
2368
|
'lastUpdateTimestamp': self.safe_integer(order, 'updateTime'),
|
2336
|
-
'type': self.parse_order_type(
|
2369
|
+
'type': self.parse_order_type(rawType),
|
2337
2370
|
'timeInForce': self.safe_string(order, 'timeInForce'),
|
2338
2371
|
'postOnly': None,
|
2339
2372
|
'side': self.parse_order_side(side),
|
2340
2373
|
'price': self.safe_string_2(order, 'price', 'p'),
|
2341
|
-
'stopPrice':
|
2342
|
-
'triggerPrice':
|
2374
|
+
'stopPrice': triggerPrice,
|
2375
|
+
'triggerPrice': triggerPrice,
|
2343
2376
|
'stopLossPrice': stopLossPrice,
|
2344
2377
|
'takeProfitPrice': takeProfitPrice,
|
2345
2378
|
'average': self.safe_string_2(order, 'avgPrice', 'ap'),
|
ccxt/async_support/bitget.py
CHANGED
ccxt/async_support/bitmart.py
CHANGED
@@ -54,7 +54,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
54
54
|
'borrowIsolatedMargin': True,
|
55
55
|
'cancelAllOrders': True,
|
56
56
|
'cancelOrder': True,
|
57
|
-
'cancelOrders':
|
57
|
+
'cancelOrders': True,
|
58
58
|
'createMarketBuyOrderWithCost': True,
|
59
59
|
'createMarketOrderWithCost': False,
|
60
60
|
'createMarketSellOrderWithCost': False,
|
@@ -198,7 +198,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
198
198
|
'spot/v2/orders': 5,
|
199
199
|
'spot/v1/trades': 5,
|
200
200
|
# newer order endpoint
|
201
|
-
'spot/v2/trades':
|
201
|
+
'spot/v2/trades': 4,
|
202
202
|
'spot/v3/orders': 5,
|
203
203
|
'spot/v2/order_detail': 1,
|
204
204
|
# margin
|
@@ -242,6 +242,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
242
242
|
'spot/v4/query/history-orders': 5, # 12 times/2 sec = 6/s => 30/6 = 5
|
243
243
|
'spot/v4/query/trades': 5, # 12 times/2 sec = 6/s => 30/6 = 5
|
244
244
|
'spot/v4/query/order-trades': 5, # 12 times/2 sec = 6/s => 30/6 = 5
|
245
|
+
'spot/v4/cancel_orders': 3,
|
245
246
|
# newer endpoint
|
246
247
|
'spot/v3/cancel_order': 1,
|
247
248
|
'spot/v2/batch_orders': 1,
|
@@ -2523,6 +2524,60 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2523
2524
|
order = self.parse_order(id, market)
|
2524
2525
|
return self.extend(order, {'id': id})
|
2525
2526
|
|
2527
|
+
async def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
|
2528
|
+
"""
|
2529
|
+
cancel multiple orders
|
2530
|
+
:see: https://developer-pro.bitmart.com/en/spot/#cancel-batch-order-v4-signed
|
2531
|
+
:param str[] ids: order ids
|
2532
|
+
:param str symbol: unified symbol of the market the order was made in
|
2533
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2534
|
+
:param str[] [params.clientOrderIds]: client order ids
|
2535
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2536
|
+
"""
|
2537
|
+
if symbol is None:
|
2538
|
+
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
2539
|
+
await self.load_markets()
|
2540
|
+
market = self.market(symbol)
|
2541
|
+
if not market['spot']:
|
2542
|
+
raise NotSupported(self.id + ' cancelOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted')
|
2543
|
+
clientOrderIds = self.safe_list(params, 'clientOrderIds')
|
2544
|
+
params = self.omit(params, ['clientOrderIds'])
|
2545
|
+
request = {
|
2546
|
+
'symbol': market['id'],
|
2547
|
+
}
|
2548
|
+
if clientOrderIds is not None:
|
2549
|
+
request['clientOrderIds'] = clientOrderIds
|
2550
|
+
else:
|
2551
|
+
request['orderIds'] = ids
|
2552
|
+
response = await self.privatePostSpotV4CancelOrders(self.extend(request, params))
|
2553
|
+
#
|
2554
|
+
# {
|
2555
|
+
# "message": "OK",
|
2556
|
+
# "code": 1000,
|
2557
|
+
# "trace": "c4edbce860164203954f7c3c81d60fc6.309.17022669632770001",
|
2558
|
+
# "data": {
|
2559
|
+
# "successIds": [
|
2560
|
+
# "213055379155243012"
|
2561
|
+
# ],
|
2562
|
+
# "failIds": [],
|
2563
|
+
# "totalCount": 1,
|
2564
|
+
# "successCount": 1,
|
2565
|
+
# "failedCount": 0
|
2566
|
+
# }
|
2567
|
+
# }
|
2568
|
+
#
|
2569
|
+
data = self.safe_dict(response, 'data', {})
|
2570
|
+
allOrders = []
|
2571
|
+
successIds = self.safe_list(data, 'successIds', [])
|
2572
|
+
for i in range(0, len(successIds)):
|
2573
|
+
id = successIds[i]
|
2574
|
+
allOrders.append(self.safe_order({'id': id, 'status': 'canceled'}, market))
|
2575
|
+
failIds = self.safe_list(data, 'failIds', [])
|
2576
|
+
for i in range(0, len(failIds)):
|
2577
|
+
id = failIds[i]
|
2578
|
+
allOrders.append(self.safe_order({'id': id, 'status': 'failed'}, market))
|
2579
|
+
return allOrders
|
2580
|
+
|
2526
2581
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
2527
2582
|
"""
|
2528
2583
|
cancel all open orders in a market
|
ccxt/async_support/bybit.py
CHANGED
@@ -2401,12 +2401,12 @@ class bybit(Exchange, ImplicitAPI):
|
|
2401
2401
|
if symbol is None:
|
2402
2402
|
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
2403
2403
|
await self.load_markets()
|
2404
|
-
if limit is None:
|
2405
|
-
limit = 200
|
2406
2404
|
paginate = False
|
2407
2405
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
2408
2406
|
if paginate:
|
2409
2407
|
return await self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200)
|
2408
|
+
if limit is None:
|
2409
|
+
limit = 200
|
2410
2410
|
request = {
|
2411
2411
|
# 'category': '', # Product type. linear,inverse
|
2412
2412
|
# 'symbol': '', # Symbol name
|
ccxt/async_support/coinbase.py
CHANGED
@@ -2845,7 +2845,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
2845
2845
|
marketId = self.safe_string(order, 'product_id')
|
2846
2846
|
symbol = self.safe_symbol(marketId, market, '-')
|
2847
2847
|
if symbol is not None:
|
2848
|
-
market = self.
|
2848
|
+
market = self.safe_market(symbol, market)
|
2849
2849
|
orderConfiguration = self.safe_dict(order, 'order_configuration', {})
|
2850
2850
|
limitGTC = self.safe_dict(orderConfiguration, 'limit_limit_gtc')
|
2851
2851
|
limitGTD = self.safe_dict(orderConfiguration, 'limit_limit_gtd')
|
ccxt/async_support/coinex.py
CHANGED
@@ -458,11 +458,16 @@ class coinex(Exchange, ImplicitAPI):
|
|
458
458
|
'fetchDepositAddress': {
|
459
459
|
'fillResponseFromRequest': True,
|
460
460
|
},
|
461
|
-
'
|
461
|
+
'accountsByType': {
|
462
462
|
'spot': 'SPOT',
|
463
463
|
'margin': 'MARGIN',
|
464
464
|
'swap': 'FUTURES',
|
465
465
|
},
|
466
|
+
'accountsById': {
|
467
|
+
'SPOT': 'spot',
|
468
|
+
'MARGIN': 'margin',
|
469
|
+
'FUTURES': 'swap',
|
470
|
+
},
|
466
471
|
'networks': {
|
467
472
|
'BEP20': 'BSC',
|
468
473
|
'TRX': 'TRC20',
|
@@ -4616,9 +4621,9 @@ class coinex(Exchange, ImplicitAPI):
|
|
4616
4621
|
await self.load_markets()
|
4617
4622
|
currency = self.currency(code)
|
4618
4623
|
amountToPrecision = self.currency_to_precision(code, amount)
|
4619
|
-
|
4620
|
-
fromId = self.safe_string(
|
4621
|
-
toId = self.safe_string(
|
4624
|
+
accountsByType = self.safe_dict(self.options, 'accountsById', {})
|
4625
|
+
fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
|
4626
|
+
toId = self.safe_string(accountsByType, toAccount, toAccount)
|
4622
4627
|
request = {
|
4623
4628
|
'ccy': currency['id'],
|
4624
4629
|
'amount': amountToPrecision,
|
@@ -4652,6 +4657,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
4652
4657
|
'0': 'ok',
|
4653
4658
|
'SUCCESS': 'ok',
|
4654
4659
|
'OK': 'ok',
|
4660
|
+
'finished': 'ok',
|
4661
|
+
'FINISHED': 'ok',
|
4655
4662
|
}
|
4656
4663
|
return self.safe_string(statuses, status, status)
|
4657
4664
|
|
@@ -4675,91 +4682,55 @@ class coinex(Exchange, ImplicitAPI):
|
|
4675
4682
|
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
|
4676
4683
|
"""
|
4677
4684
|
fetch a history of internal transfers made on an account
|
4678
|
-
:see: https://
|
4679
|
-
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history
|
4685
|
+
:see: https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
|
4680
4686
|
:param str code: unified currency code of the currency transferred
|
4681
4687
|
:param int [since]: the earliest time in ms to fetch transfers for
|
4682
|
-
:param int [limit]: the maximum number of
|
4688
|
+
:param int [limit]: the maximum number of transfer structures to retrieve
|
4683
4689
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4690
|
+
:param str [params.marginMode]: 'cross' or 'isolated' for fetching transfers to and from your margin account
|
4684
4691
|
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
|
4685
4692
|
"""
|
4686
4693
|
await self.load_markets()
|
4687
|
-
|
4694
|
+
if code is None:
|
4695
|
+
raise ArgumentsRequired(self.id + ' fetchTransfers() requires a code argument')
|
4696
|
+
currency = self.currency(code)
|
4688
4697
|
request = {
|
4689
|
-
'
|
4690
|
-
# 'limit': limit,
|
4691
|
-
# 'asset': 'USDT',
|
4692
|
-
# 'start_time': since,
|
4693
|
-
# 'end_time': 1515806440,
|
4694
|
-
# 'transfer_type': 'transfer_in', # transfer_in: from Spot to Swap Account, transfer_out: from Swap to Spot Account
|
4698
|
+
'ccy': currency['id'],
|
4695
4699
|
}
|
4696
|
-
page = self.safe_integer(params, 'page')
|
4697
|
-
if page is not None:
|
4698
|
-
request['page'] = page
|
4699
|
-
if code is not None:
|
4700
|
-
currency = self.currency(code)
|
4701
|
-
request['asset'] = currency['id']
|
4702
|
-
if since is not None:
|
4703
|
-
request['start_time'] = since
|
4704
|
-
if limit is not None:
|
4705
|
-
request['limit'] = limit
|
4706
|
-
else:
|
4707
|
-
request['limit'] = 100
|
4708
|
-
params = self.omit(params, 'page')
|
4709
4700
|
marginMode = None
|
4710
4701
|
marginMode, params = self.handle_margin_mode_and_params('fetchTransfers', params)
|
4711
|
-
response = None
|
4712
4702
|
if marginMode is not None:
|
4713
|
-
|
4703
|
+
request['transfer_type'] = 'MARGIN'
|
4714
4704
|
else:
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4705
|
+
request['transfer_type'] = 'FUTURES'
|
4706
|
+
if since is not None:
|
4707
|
+
request['start_time'] = since
|
4708
|
+
if limit is not None:
|
4709
|
+
request['limit'] = limit
|
4710
|
+
request, params = self.handle_until_option('end_time', request, params)
|
4711
|
+
response = await self.v2PrivateGetAssetsTransferHistory(self.extend(request, params))
|
4718
4712
|
#
|
4719
4713
|
# {
|
4720
|
-
# "
|
4721
|
-
#
|
4722
|
-
#
|
4723
|
-
#
|
4724
|
-
#
|
4725
|
-
#
|
4726
|
-
#
|
4727
|
-
#
|
4728
|
-
#
|
4729
|
-
#
|
4730
|
-
#
|
4714
|
+
# "data": [
|
4715
|
+
# {
|
4716
|
+
# "created_at": 1715848480646,
|
4717
|
+
# "from_account_type": "SPOT",
|
4718
|
+
# "to_account_type": "FUTURES",
|
4719
|
+
# "ccy": "USDT",
|
4720
|
+
# "amount": "10",
|
4721
|
+
# "status": "finished"
|
4722
|
+
# },
|
4723
|
+
# ],
|
4724
|
+
# "pagination": {
|
4725
|
+
# "total": 8,
|
4726
|
+
# "has_next": False
|
4731
4727
|
# },
|
4732
|
-
# "message": "Success"
|
4733
|
-
# }
|
4734
|
-
#
|
4735
|
-
# Margin
|
4736
|
-
#
|
4737
|
-
# {
|
4738
4728
|
# "code": 0,
|
4739
|
-
# "
|
4740
|
-
# "records": [
|
4741
|
-
# {
|
4742
|
-
# "id": 7580062,
|
4743
|
-
# "updated_at": 1653684379,
|
4744
|
-
# "user_id": 3620173,
|
4745
|
-
# "from_account_id": 0,
|
4746
|
-
# "to_account_id": 1,
|
4747
|
-
# "asset": "BTC",
|
4748
|
-
# "amount": "0.00160829",
|
4749
|
-
# "balance": "0.00160829",
|
4750
|
-
# "transfer_type": "IN",
|
4751
|
-
# "status": "SUCCESS",
|
4752
|
-
# "created_at": 1653684379
|
4753
|
-
# }
|
4754
|
-
# ],
|
4755
|
-
# "total": 1
|
4756
|
-
# },
|
4757
|
-
# "message": "Success"
|
4729
|
+
# "message": "OK"
|
4758
4730
|
# }
|
4759
4731
|
#
|
4760
|
-
data = self.
|
4761
|
-
|
4762
|
-
return self.parse_transfers(transfers, currency, since, limit)
|
4732
|
+
data = self.safe_list(response, 'data', [])
|
4733
|
+
return self.parse_transfers(data, currency, since, limit)
|
4763
4734
|
|
4764
4735
|
async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
4765
4736
|
"""
|
ccxt/async_support/kraken.py
CHANGED
@@ -58,6 +58,9 @@ class kraken(Exchange, ImplicitAPI):
|
|
58
58
|
'cancelOrder': True,
|
59
59
|
'cancelOrders': True,
|
60
60
|
'createDepositAddress': True,
|
61
|
+
'createMarketBuyOrderWithCost': True,
|
62
|
+
'createMarketOrderWithCost': False,
|
63
|
+
'createMarketSellOrderWithCost': False,
|
61
64
|
'createOrder': True,
|
62
65
|
'createStopLimitOrder': True,
|
63
66
|
'createStopMarketOrder': True,
|
@@ -1308,6 +1311,33 @@ class kraken(Exchange, ImplicitAPI):
|
|
1308
1311
|
#
|
1309
1312
|
return self.parse_balance(response)
|
1310
1313
|
|
1314
|
+
async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
1315
|
+
"""
|
1316
|
+
create a market order by providing the symbol, side and cost
|
1317
|
+
:see: https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
|
1318
|
+
:param str symbol: unified symbol of the market to create an order in(only USD markets are supported)
|
1319
|
+
:param str side: 'buy' or 'sell'
|
1320
|
+
:param float cost: how much you want to trade in units of the quote currency
|
1321
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1322
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1323
|
+
"""
|
1324
|
+
await self.load_markets()
|
1325
|
+
# only buy orders are supported by the endpoint
|
1326
|
+
params['cost'] = cost
|
1327
|
+
return await self.create_order(symbol, 'market', side, cost, None, params)
|
1328
|
+
|
1329
|
+
async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
1330
|
+
"""
|
1331
|
+
create a market buy order by providing the symbol, side and cost
|
1332
|
+
:see: https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
|
1333
|
+
:param str symbol: unified symbol of the market to create an order in
|
1334
|
+
:param float cost: how much you want to trade in units of the quote currency
|
1335
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1336
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1337
|
+
"""
|
1338
|
+
await self.load_markets()
|
1339
|
+
return await self.create_market_order_with_cost(symbol, 'buy', cost, params)
|
1340
|
+
|
1311
1341
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1312
1342
|
"""
|
1313
1343
|
:see: https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
|
@@ -1336,7 +1366,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
1336
1366
|
'ordertype': type,
|
1337
1367
|
'volume': self.amount_to_precision(symbol, amount),
|
1338
1368
|
}
|
1339
|
-
orderRequest = self.order_request('createOrder', symbol, type, request, price, params)
|
1369
|
+
orderRequest = self.order_request('createOrder', symbol, type, request, amount, price, params)
|
1340
1370
|
response = await self.privatePostAddOrder(self.extend(orderRequest[0], orderRequest[1]))
|
1341
1371
|
#
|
1342
1372
|
# {
|
@@ -1616,7 +1646,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
1616
1646
|
'trades': trades,
|
1617
1647
|
}, market)
|
1618
1648
|
|
1619
|
-
def order_request(self, method, symbol, type, request, price=None, params={}):
|
1649
|
+
def order_request(self, method: str, symbol: str, type: str, request: dict, amount: Num, price: Num = None, params={}):
|
1620
1650
|
clientOrderId = self.safe_string_2(params, 'userref', 'clientOrderId')
|
1621
1651
|
params = self.omit(params, ['userref', 'clientOrderId'])
|
1622
1652
|
if clientOrderId is not None:
|
@@ -1630,9 +1660,21 @@ class kraken(Exchange, ImplicitAPI):
|
|
1630
1660
|
trailingLimitAmount = self.safe_string(params, 'trailingLimitAmount')
|
1631
1661
|
isTrailingAmountOrder = trailingAmount is not None
|
1632
1662
|
isLimitOrder = type.endswith('limit') # supporting limit, stop-loss-limit, take-profit-limit, etc
|
1633
|
-
|
1663
|
+
isMarketOrder = type == 'market'
|
1664
|
+
cost = self.safe_string(params, 'cost')
|
1665
|
+
flags = self.safe_string(params, 'oflags')
|
1666
|
+
params = self.omit(params, ['cost', 'oflags'])
|
1667
|
+
isViqcOrder = (flags is not None) and (flags.find('viqc') > -1) # volume in quote currency
|
1668
|
+
if isMarketOrder and (cost is not None or isViqcOrder):
|
1669
|
+
if cost is None and (amount is not None):
|
1670
|
+
request['volume'] = self.cost_to_precision(symbol, self.number_to_string(amount))
|
1671
|
+
else:
|
1672
|
+
request['volume'] = self.cost_to_precision(symbol, cost)
|
1673
|
+
extendedOflags = flags + ',viqc' if (flags is not None) else 'viqc'
|
1674
|
+
request['oflags'] = extendedOflags
|
1675
|
+
elif isLimitOrder and not isTrailingAmountOrder:
|
1634
1676
|
request['price'] = self.price_to_precision(symbol, price)
|
1635
|
-
reduceOnly = self.
|
1677
|
+
reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only')
|
1636
1678
|
if isStopLossOrTakeProfitTrigger:
|
1637
1679
|
if isStopLossTriggerOrder:
|
1638
1680
|
request['price'] = self.price_to_precision(symbol, stopLossTriggerPrice)
|
@@ -1666,7 +1708,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
1666
1708
|
request['reduce_only'] = True # ws request can't have stringified bool
|
1667
1709
|
else:
|
1668
1710
|
request['reduce_only'] = 'true' # not using hasattr(self, boolean) case, because the urlencodedNested transforms it into 'True' string
|
1669
|
-
close = self.
|
1711
|
+
close = self.safe_dict(params, 'close')
|
1670
1712
|
if close is not None:
|
1671
1713
|
close = self.extend({}, close)
|
1672
1714
|
closePrice = self.safe_value(close, 'price')
|
@@ -1683,7 +1725,8 @@ class kraken(Exchange, ImplicitAPI):
|
|
1683
1725
|
postOnly = None
|
1684
1726
|
postOnly, params = self.handle_post_only(isMarket, False, params)
|
1685
1727
|
if postOnly:
|
1686
|
-
|
1728
|
+
extendedPostFlags = flags + ',post' if (flags is not None) else 'post'
|
1729
|
+
request['oflags'] = extendedPostFlags
|
1687
1730
|
params = self.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset'])
|
1688
1731
|
return [request, params]
|
1689
1732
|
|
@@ -1716,7 +1759,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
1716
1759
|
}
|
1717
1760
|
if amount is not None:
|
1718
1761
|
request['volume'] = self.amount_to_precision(symbol, amount)
|
1719
|
-
orderRequest = self.order_request('editOrder', symbol, type, request, price, params)
|
1762
|
+
orderRequest = self.order_request('editOrder', symbol, type, request, amount, price, params)
|
1720
1763
|
response = await self.privatePostEditOrder(self.extend(orderRequest[0], orderRequest[1]))
|
1721
1764
|
#
|
1722
1765
|
# {
|
@@ -2808,6 +2851,8 @@ class kraken(Exchange, ImplicitAPI):
|
|
2808
2851
|
raise CancelPending(self.id + ' ' + body)
|
2809
2852
|
if body.find('Invalid arguments:volume') >= 0:
|
2810
2853
|
raise InvalidOrder(self.id + ' ' + body)
|
2854
|
+
if body.find('Invalid arguments:viqc') >= 0:
|
2855
|
+
raise InvalidOrder(self.id + ' ' + body)
|
2811
2856
|
if body.find('Rate limit exceeded') >= 0:
|
2812
2857
|
raise RateLimitExceeded(self.id + ' ' + body)
|
2813
2858
|
if response is None:
|
@@ -2099,7 +2099,7 @@ class krakenfutures(Exchange, ImplicitAPI):
|
|
2099
2099
|
|
2100
2100
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
2101
2101
|
"""
|
2102
|
-
:see: https://docs.futures.kraken.com/#
|
2102
|
+
:see: https://docs.futures.kraken.com/#http-api-trading-v3-api-account-information-get-open-positions
|
2103
2103
|
Fetches current contract trading positions
|
2104
2104
|
:param str[] symbols: List of unified symbols
|
2105
2105
|
:param dict [params]: Not used by krakenfutures
|
ccxt/async_support/phemex.py
CHANGED
@@ -2168,7 +2168,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2168
2168
|
if feeCost is not None:
|
2169
2169
|
fee = {
|
2170
2170
|
'cost': feeCost,
|
2171
|
-
'currency':
|
2171
|
+
'currency': self.safe_currency_code(self.safe_string(order, 'feeCurrency')),
|
2172
2172
|
}
|
2173
2173
|
timeInForce = self.parse_time_in_force(self.safe_string(order, 'timeInForce'))
|
2174
2174
|
stopPrice = self.parse_number(self.omit_zero(self.from_ep(self.safe_string(order, 'stopPxEp'))))
|
@@ -2313,6 +2313,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2313
2313
|
clientOrderId = None
|
2314
2314
|
marketId = self.safe_string(order, 'symbol')
|
2315
2315
|
symbol = self.safe_symbol(marketId, market)
|
2316
|
+
market = self.safe_market(marketId, market)
|
2316
2317
|
status = self.parse_order_status(self.safe_string(order, 'ordStatus'))
|
2317
2318
|
side = self.parse_order_side(self.safe_string_lower(order, 'side'))
|
2318
2319
|
type = self.parse_order_type(self.safe_string(order, 'orderType'))
|
@@ -2338,6 +2339,19 @@ class phemex(Exchange, ImplicitAPI):
|
|
2338
2339
|
reduceOnly = True
|
2339
2340
|
takeProfit = self.safe_string(order, 'takeProfitRp')
|
2340
2341
|
stopLoss = self.safe_string(order, 'stopLossRp')
|
2342
|
+
feeValue = self.omit_zero(self.safe_string(order, 'execFeeRv'))
|
2343
|
+
ptFeeRv = self.omit_zero(self.safe_string(order, 'ptFeeRv'))
|
2344
|
+
fee = None
|
2345
|
+
if feeValue is not None:
|
2346
|
+
fee = {
|
2347
|
+
'cost': feeValue,
|
2348
|
+
'currency': market['quote'],
|
2349
|
+
}
|
2350
|
+
elif ptFeeRv is not None:
|
2351
|
+
fee = {
|
2352
|
+
'cost': ptFeeRv,
|
2353
|
+
'currency': 'PT',
|
2354
|
+
}
|
2341
2355
|
return self.safe_order({
|
2342
2356
|
'info': order,
|
2343
2357
|
'id': id,
|
@@ -2362,7 +2376,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2362
2376
|
'cost': cost,
|
2363
2377
|
'average': None,
|
2364
2378
|
'status': status,
|
2365
|
-
'fee':
|
2379
|
+
'fee': fee,
|
2366
2380
|
'trades': None,
|
2367
2381
|
})
|
2368
2382
|
|