ccxt 4.1.83__py2.py3-none-any.whl → 4.1.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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

ccxt/bingx.py CHANGED
@@ -1912,6 +1912,8 @@ class bingx(Exchange, ImplicitAPI):
1912
1912
  positionSide = self.safe_string_2(order, 'positionSide', 'ps')
1913
1913
  marketType = 'spot' if (positionSide is None) else 'swap'
1914
1914
  marketId = self.safe_string_2(order, 'symbol', 's')
1915
+ if market is None:
1916
+ market = self.safe_market(marketId, None, None, marketType)
1915
1917
  symbol = self.safe_symbol(marketId, market, '-', marketType)
1916
1918
  orderId = self.safe_string_2(order, 'orderId', 'i')
1917
1919
  side = self.safe_string_lower_2(order, 'side', 'S')
@@ -2250,15 +2252,14 @@ class bingx(Exchange, ImplicitAPI):
2250
2252
  :param dict [params]: extra parameters specific to the exchange API endpoint
2251
2253
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2252
2254
  """
2253
- if symbol is None:
2254
- raise ArgumentsRequired(self.id + ' fetchOrders() requires a symbol argument')
2255
2255
  self.load_markets()
2256
- market = self.market(symbol)
2257
- request = {
2258
- 'symbol': market['id'],
2259
- }
2256
+ market = None
2257
+ request = {}
2258
+ if symbol is not None:
2259
+ market = self.market(symbol)
2260
+ request['symbol'] = market['id']
2260
2261
  response = None
2261
- marketType, query = self.handle_market_type_and_params('fetchOrder', market, params)
2262
+ marketType, query = self.handle_market_type_and_params('fetchOpenOrders', market, params)
2262
2263
  if marketType == 'spot':
2263
2264
  response = self.spotV1PrivateGetTradeOpenOrders(self.extend(request, query))
2264
2265
  else:
ccxt/bitmart.py CHANGED
@@ -1308,48 +1308,58 @@ class bitmart(Exchange, ImplicitAPI):
1308
1308
  #
1309
1309
  # public fetchTrades spot( amount = count * price )
1310
1310
  #
1311
- # {
1312
- # "amount": "818.94",
1313
- # "order_time": "1637601839035", # ETH/USDT
1314
- # "price": "4221.99",
1315
- # "count": "0.19397",
1316
- # "type": "buy"
1317
- # }
1311
+ # {
1312
+ # "amount": "818.94",
1313
+ # "order_time": "1637601839035", # ETH/USDT
1314
+ # "price": "4221.99",
1315
+ # "count": "0.19397",
1316
+ # "type": "buy"
1317
+ # }
1318
1318
  #
1319
1319
  # spot: fetchMyTrades
1320
1320
  #
1321
- # {
1322
- # "tradeId":"182342999769370687",
1323
- # "orderId":"183270218784142990",
1324
- # "clientOrderId":"183270218784142990",
1325
- # "symbol":"ADA_USDT",
1326
- # "side":"buy",
1327
- # "orderMode":"spot",
1328
- # "type":"market",
1329
- # "price":"0.245948",
1330
- # "size":"20.71",
1331
- # "notional":"5.09358308",
1332
- # "fee":"0.00509358",
1333
- # "feeCoinName":"USDT",
1334
- # "tradeRole":"taker",
1335
- # "createTime":1695658457836,
1336
- # }
1321
+ # {
1322
+ # "tradeId":"182342999769370687",
1323
+ # "orderId":"183270218784142990",
1324
+ # "clientOrderId":"183270218784142990",
1325
+ # "symbol":"ADA_USDT",
1326
+ # "side":"buy",
1327
+ # "orderMode":"spot",
1328
+ # "type":"market",
1329
+ # "price":"0.245948",
1330
+ # "size":"20.71",
1331
+ # "notional":"5.09358308",
1332
+ # "fee":"0.00509358",
1333
+ # "feeCoinName":"USDT",
1334
+ # "tradeRole":"taker",
1335
+ # "createTime":1695658457836,
1336
+ # }
1337
1337
  #
1338
1338
  # swap: fetchMyTrades
1339
1339
  #
1340
- # {
1341
- # "order_id": "230930336848609",
1342
- # "trade_id": "6212604014",
1343
- # "symbol": "BTCUSDT",
1344
- # "side": 3,
1345
- # "price": "26910.4",
1346
- # "vol": "1",
1347
- # "exec_type": "Taker",
1348
- # "profit": False,
1349
- # "create_time": 1695961596692,
1350
- # "realised_profit": "-0.0003",
1351
- # "paid_fees": "0.01614624"
1352
- # }
1340
+ # {
1341
+ # "order_id": "230930336848609",
1342
+ # "trade_id": "6212604014",
1343
+ # "symbol": "BTCUSDT",
1344
+ # "side": 3,
1345
+ # "price": "26910.4",
1346
+ # "vol": "1",
1347
+ # "exec_type": "Taker",
1348
+ # "profit": False,
1349
+ # "create_time": 1695961596692,
1350
+ # "realised_profit": "-0.0003",
1351
+ # "paid_fees": "0.01614624"
1352
+ # }
1353
+ #
1354
+ # ws swap
1355
+ #
1356
+ # {
1357
+ # 'fee': '-0.000044502',
1358
+ # 'feeCcy': 'USDT',
1359
+ # 'fillPrice': '74.17',
1360
+ # 'fillQty': '1',
1361
+ # 'lastTradeID': 6802340762
1362
+ # }
1353
1363
  #
1354
1364
  timestamp = self.safe_integer_n(trade, ['order_time', 'createTime', 'create_time'])
1355
1365
  isPublicTrade = ('order_time' in trade)
@@ -1362,7 +1372,7 @@ class bitmart(Exchange, ImplicitAPI):
1362
1372
  cost = self.safe_string(trade, 'amount')
1363
1373
  side = self.safe_string(trade, 'type')
1364
1374
  else:
1365
- amount = self.safe_string_2(trade, 'size', 'vol')
1375
+ amount = self.safe_string_n(trade, ['size', 'vol', 'fillQty'])
1366
1376
  cost = self.safe_string(trade, 'notional')
1367
1377
  type = self.safe_string(trade, 'type')
1368
1378
  side = self.parse_order_side(self.safe_string(trade, 'side'))
@@ -1381,14 +1391,14 @@ class bitmart(Exchange, ImplicitAPI):
1381
1391
  }
1382
1392
  return self.safe_trade({
1383
1393
  'info': trade,
1384
- 'id': self.safe_string_2(trade, 'tradeId', 'trade_id'),
1394
+ 'id': self.safe_string_n(trade, ['tradeId', 'trade_id', 'lastTradeID']),
1385
1395
  'order': self.safe_string_2(trade, 'orderId', 'order_id'),
1386
1396
  'timestamp': timestamp,
1387
1397
  'datetime': self.iso8601(timestamp),
1388
1398
  'symbol': market['symbol'],
1389
1399
  'type': type,
1390
1400
  'side': side,
1391
- 'price': self.safe_string(trade, 'price'),
1401
+ 'price': self.safe_string_2(trade, 'price', 'fillPrice'),
1392
1402
  'amount': amount,
1393
1403
  'cost': cost,
1394
1404
  'takerOrMaker': self.safe_string_lower_2(trade, 'tradeRole', 'exec_type'),
@@ -1439,38 +1449,45 @@ class bitmart(Exchange, ImplicitAPI):
1439
1449
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1440
1450
  #
1441
1451
  # spot
1442
- #
1443
- # [
1444
- # "1699512060", # timestamp
1445
- # "36746.49", # open
1446
- # "36758.71", # high
1447
- # "36736.13", # low
1448
- # "36755.99", # close
1449
- # "2.83965", # base volume
1450
- # "104353.57" # quote volume
1451
- # ]
1452
+ # [
1453
+ # "1699512060", # timestamp
1454
+ # "36746.49", # open
1455
+ # "36758.71", # high
1456
+ # "36736.13", # low
1457
+ # "36755.99", # close
1458
+ # "2.83965", # base volume
1459
+ # "104353.57" # quote volume
1460
+ # ]
1452
1461
  #
1453
1462
  # swap
1454
- #
1455
- # {
1456
- # "low_price": "20090.3",
1457
- # "high_price": "20095.5",
1458
- # "open_price": "20092.6",
1459
- # "close_price": "20091.4",
1460
- # "volume": "8748",
1461
- # "timestamp": 1665002281
1462
- # }
1463
+ # {
1464
+ # "low_price": "20090.3",
1465
+ # "high_price": "20095.5",
1466
+ # "open_price": "20092.6",
1467
+ # "close_price": "20091.4",
1468
+ # "volume": "8748",
1469
+ # "timestamp": 1665002281
1470
+ # }
1463
1471
  #
1464
1472
  # ws
1465
- #
1466
- # [
1467
- # 1631056350, # timestamp
1468
- # "46532.83", # open
1469
- # "46555.71", # high
1470
- # "46511.41", # low
1471
- # "46555.71", # close
1472
- # "0.25", # volume
1473
- # ]
1473
+ # [
1474
+ # 1631056350, # timestamp
1475
+ # "46532.83", # open
1476
+ # "46555.71", # high
1477
+ # "46511.41", # low
1478
+ # "46555.71", # close
1479
+ # "0.25", # volume
1480
+ # ]
1481
+ #
1482
+ # ws swap
1483
+ # {
1484
+ # "symbol":"BTCUSDT",
1485
+ # "o":"146.24",
1486
+ # "h":"146.24",
1487
+ # "l":"146.24",
1488
+ # "c":"146.24",
1489
+ # "v":"146"
1490
+ # }
1474
1491
  #
1475
1492
  if isinstance(ohlcv, list):
1476
1493
  return [
@@ -1483,12 +1500,12 @@ class bitmart(Exchange, ImplicitAPI):
1483
1500
  ]
1484
1501
  else:
1485
1502
  return [
1486
- self.safe_timestamp(ohlcv, 'timestamp'),
1487
- self.safe_number(ohlcv, 'open_price'),
1488
- self.safe_number(ohlcv, 'high_price'),
1489
- self.safe_number(ohlcv, 'low_price'),
1490
- self.safe_number(ohlcv, 'close_price'),
1491
- self.safe_number(ohlcv, 'volume'),
1503
+ self.safe_timestamp_2(ohlcv, 'timestamp', 'ts'),
1504
+ self.safe_number_2(ohlcv, 'open_price', 'o'),
1505
+ self.safe_number_2(ohlcv, 'high_price', 'h'),
1506
+ self.safe_number_2(ohlcv, 'low_price', 'l'),
1507
+ self.safe_number_2(ohlcv, 'close_price', 'c'),
1508
+ self.safe_number_2(ohlcv, 'volume', 'v'),
1492
1509
  ]
1493
1510
 
1494
1511
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
ccxt/bybit.py CHANGED
@@ -5366,8 +5366,10 @@ class bybit(Exchange, ImplicitAPI):
5366
5366
  raise ArgumentsRequired(self.id + ' fetchPositions() does not accept an array with more than one symbol')
5367
5367
  elif symbolsLength == 1:
5368
5368
  symbol = symbols[0]
5369
+ symbols = self.market_symbols(symbols)
5369
5370
  elif symbols is not None:
5370
5371
  symbol = symbols
5372
+ symbols = [self.symbol(symbol)]
5371
5373
  self.load_markets()
5372
5374
  enableUnifiedMargin, enableUnifiedAccount = self.is_unified_enabled()
5373
5375
  isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
@@ -5376,12 +5378,11 @@ class bybit(Exchange, ImplicitAPI):
5376
5378
  isUsdcSettled = False
5377
5379
  if symbol is not None:
5378
5380
  market = self.market(symbol)
5381
+ symbol = market['symbol']
5379
5382
  request['symbol'] = market['id']
5380
5383
  isUsdcSettled = market['settle'] == 'USDC'
5381
5384
  type = None
5382
5385
  type, params = self.get_bybit_type('fetchPositions', market, params)
5383
- if type == 'spot':
5384
- raise NotSupported(self.id + ' fetchPositions() not support spot market')
5385
5386
  if type == 'linear' or type == 'inverse':
5386
5387
  baseCoin = self.safe_string(params, 'baseCoin')
5387
5388
  if type == 'linear':
ccxt/coinex.py CHANGED
@@ -42,6 +42,7 @@ class coinex(Exchange, ImplicitAPI):
42
42
  # 20 per 2 seconds => 10 per second => weight = 40
43
43
  'rateLimit': 2.5,
44
44
  'pro': True,
45
+ 'certified': True,
45
46
  'has': {
46
47
  'CORS': None,
47
48
  'spot': True,
ccxt/coinsph.py CHANGED
@@ -54,6 +54,9 @@ class coinsph(Exchange, ImplicitAPI):
54
54
  'closeAllPositions': False,
55
55
  'closePosition': False,
56
56
  'createDepositAddress': False,
57
+ 'createMarketBuyOrderWithCost': True,
58
+ 'createMarketOrderWithCost': False,
59
+ 'createMarketSellOrderWithCost': False,
57
60
  'createOrder': True,
58
61
  'createPostOnlyOrder': False,
59
62
  'createReduceOnlyOrder': False,
@@ -1028,12 +1031,14 @@ class coinsph(Exchange, ImplicitAPI):
1028
1031
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
1029
1032
  """
1030
1033
  create a trade order
1034
+ :see: https://coins-docs.github.io/rest-api/#new-order--trade
1031
1035
  :param str symbol: unified symbol of the market to create an order in
1032
1036
  :param str type: 'market', 'limit', 'stop_loss', 'take_profit', 'stop_loss_limit', 'take_profit_limit' or 'limit_maker'
1033
1037
  :param str side: 'buy' or 'sell'
1034
1038
  :param float amount: how much of currency you want to trade in units of base currency
1035
1039
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1036
1040
  :param dict [params]: extra parameters specific to the exchange API endpoint
1041
+ :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
1037
1042
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1038
1043
  """
1039
1044
  # todo: add test order low priority
@@ -1065,20 +1070,24 @@ class coinsph(Exchange, ImplicitAPI):
1065
1070
  if orderSide == 'SELL':
1066
1071
  request['quantity'] = self.amount_to_precision(symbol, amount)
1067
1072
  elif orderSide == 'BUY':
1068
- quoteOrderQty = self.safe_number_2(params, 'cost', 'quoteOrderQty')
1069
- createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
1070
- if quoteOrderQty is not None:
1071
- amount = quoteOrderQty
1073
+ quoteAmount = None
1074
+ createMarketBuyOrderRequiresPrice = True
1075
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
1076
+ cost = self.safe_number_2(params, 'cost', 'quoteOrderQty')
1077
+ params = self.omit(params, 'cost')
1078
+ if cost is not None:
1079
+ quoteAmount = self.cost_to_precision(symbol, cost)
1072
1080
  elif createMarketBuyOrderRequiresPrice:
1073
1081
  if price is None:
1074
- raise InvalidOrder(self.id + " createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = False to supply the cost in the amount argument(the exchange-specific behaviour)")
1082
+ raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
1075
1083
  else:
1076
1084
  amountString = self.number_to_string(amount)
1077
1085
  priceString = self.number_to_string(price)
1078
- quoteAmount = Precise.string_mul(amountString, priceString)
1079
- amount = self.parse_number(quoteAmount)
1080
- request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
1081
- params = self.omit(params, 'cost', 'quoteOrderQty')
1086
+ costRequest = Precise.string_mul(amountString, priceString)
1087
+ quoteAmount = self.cost_to_precision(symbol, costRequest)
1088
+ else:
1089
+ quoteAmount = self.cost_to_precision(symbol, amount)
1090
+ request['quoteOrderQty'] = quoteAmount
1082
1091
  if orderType == 'STOP_LOSS' or orderType == 'STOP_LOSS_LIMIT' or orderType == 'TAKE_PROFIT' or orderType == 'TAKE_PROFIT_LIMIT':
1083
1092
  stopPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1084
1093
  if stopPrice is None:
ccxt/htx.py CHANGED
@@ -56,6 +56,9 @@ class htx(Exchange, ImplicitAPI):
56
56
  'cancelOrder': True,
57
57
  'cancelOrders': True,
58
58
  'createDepositAddress': None,
59
+ 'createMarketBuyOrderWithCost': True,
60
+ 'createMarketOrderWithCost': False,
61
+ 'createMarketSellOrderWithCost': False,
59
62
  'createOrder': True,
60
63
  'createOrders': True,
61
64
  'createReduceOnlyOrder': False,
@@ -4535,6 +4538,22 @@ class htx(Exchange, ImplicitAPI):
4535
4538
  'trades': trades,
4536
4539
  }, market)
4537
4540
 
4541
+ def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
4542
+ """
4543
+ create a market buy order by providing the symbol and cost
4544
+ :see: https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
4545
+ :param str symbol: unified symbol of the market to create an order in
4546
+ :param float cost: how much you want to trade in units of the quote currency
4547
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4548
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4549
+ """
4550
+ self.load_markets()
4551
+ market = self.market(symbol)
4552
+ if not market['spot']:
4553
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
4554
+ params['createMarketBuyOrderRequiresPrice'] = False
4555
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
4556
+
4538
4557
  def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
4539
4558
  """
4540
4559
  * @ignore
@@ -4546,6 +4565,7 @@ class htx(Exchange, ImplicitAPI):
4546
4565
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
4547
4566
  :param dict [params]: extra parameters specific to the exchange API endpoint
4548
4567
  :param str [params.timeInForce]: supports 'IOC' and 'FOK'
4568
+ :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
4549
4569
  :returns dict: request to be sent to the exchange
4550
4570
  """
4551
4571
  self.load_markets()
@@ -4607,9 +4627,16 @@ class htx(Exchange, ImplicitAPI):
4607
4627
  elif marginMode == 'c2c':
4608
4628
  request['source'] = 'c2c-margin-api'
4609
4629
  if (orderType == 'market') and (side == 'buy'):
4610
- if self.options['createMarketBuyOrderRequiresPrice']:
4630
+ quoteAmount = None
4631
+ createMarketBuyOrderRequiresPrice = True
4632
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
4633
+ cost = self.safe_number(params, 'cost')
4634
+ params = self.omit(params, 'cost')
4635
+ if cost is not None:
4636
+ quoteAmount = self.amount_to_precision(symbol, cost)
4637
+ elif createMarketBuyOrderRequiresPrice:
4611
4638
  if price is None:
4612
- raise InvalidOrder(self.id + " market buy order requires price argument to calculate cost(total amount of quote currency to spend for buying, amount * price). To switch off self warning exception and specify cost in the amount argument, set .options['createMarketBuyOrderRequiresPrice'] = False. Make sure you know what you're doing.")
4639
+ raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
4613
4640
  else:
4614
4641
  # despite that cost = amount * price is in quote currency and should have quote precision
4615
4642
  # the exchange API requires the cost supplied in 'amount' to be of base precision
@@ -4619,9 +4646,10 @@ class htx(Exchange, ImplicitAPI):
4619
4646
  # we use amountToPrecision here because the exchange requires cost in base precision
4620
4647
  amountString = self.number_to_string(amount)
4621
4648
  priceString = self.number_to_string(price)
4622
- request['amount'] = self.cost_to_precision(symbol, Precise.string_mul(amountString, priceString))
4649
+ quoteAmount = self.amount_to_precision(symbol, Precise.string_mul(amountString, priceString))
4623
4650
  else:
4624
- request['amount'] = self.cost_to_precision(symbol, amount)
4651
+ quoteAmount = self.amount_to_precision(symbol, amount)
4652
+ request['amount'] = quoteAmount
4625
4653
  else:
4626
4654
  request['amount'] = self.amount_to_precision(symbol, amount)
4627
4655
  limitOrderTypes = self.safe_value(options, 'limitOrderTypes', {})
@@ -4731,6 +4759,7 @@ class htx(Exchange, ImplicitAPI):
4731
4759
  :param bool [params.postOnly]: *contract only* True or False
4732
4760
  :param int [params.leverRate]: *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
4733
4761
  :param str [params.timeInForce]: supports 'IOC' and 'FOK'
4762
+ :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
4734
4763
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4735
4764
  """
4736
4765
  self.load_markets()
ccxt/huobijp.py CHANGED
@@ -16,6 +16,7 @@ from ccxt.base.errors import BadSymbol
16
16
  from ccxt.base.errors import InsufficientFunds
17
17
  from ccxt.base.errors import InvalidOrder
18
18
  from ccxt.base.errors import OrderNotFound
19
+ from ccxt.base.errors import NotSupported
19
20
  from ccxt.base.errors import NetworkError
20
21
  from ccxt.base.errors import ExchangeNotAvailable
21
22
  from ccxt.base.errors import OnMaintenance
@@ -49,6 +50,9 @@ class huobijp(Exchange, ImplicitAPI):
49
50
  'cancelAllOrders': True,
50
51
  'cancelOrder': True,
51
52
  'cancelOrders': True,
53
+ 'createMarketBuyOrderWithCost': True,
54
+ 'createMarketOrderWithCost': False,
55
+ 'createMarketSellOrderWithCost': False,
52
56
  'createOrder': True,
53
57
  'createStopLimitOrder': False,
54
58
  'createStopMarketOrder': False,
@@ -1301,6 +1305,21 @@ class huobijp(Exchange, ImplicitAPI):
1301
1305
  'trades': None,
1302
1306
  }, market)
1303
1307
 
1308
+ def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1309
+ """
1310
+ create a market buy order by providing the symbol and cost
1311
+ :param str symbol: unified symbol of the market to create an order in
1312
+ :param float cost: how much you want to trade in units of the quote currency
1313
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1314
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1315
+ """
1316
+ self.load_markets()
1317
+ market = self.market(symbol)
1318
+ if not market['spot']:
1319
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
1320
+ params['createMarketBuyOrderRequiresPrice'] = False
1321
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
1322
+
1304
1323
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
1305
1324
  """
1306
1325
  create a trade order
@@ -1329,9 +1348,16 @@ class huobijp(Exchange, ImplicitAPI):
1329
1348
  request['client-order-id'] = clientOrderId
1330
1349
  params = self.omit(params, ['clientOrderId', 'client-order-id'])
1331
1350
  if (type == 'market') and (side == 'buy'):
1332
- if self.options['createMarketBuyOrderRequiresPrice']:
1351
+ quoteAmount = None
1352
+ createMarketBuyOrderRequiresPrice = True
1353
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
1354
+ cost = self.safe_number(params, 'cost')
1355
+ params = self.omit(params, 'cost')
1356
+ if cost is not None:
1357
+ quoteAmount = self.amount_to_precision(symbol, cost)
1358
+ elif createMarketBuyOrderRequiresPrice:
1333
1359
  if price is None:
1334
- raise InvalidOrder(self.id + " market buy order requires price argument to calculate cost(total amount of quote currency to spend for buying, amount * price). To switch off self warning exception and specify cost in the amount argument, set .options['createMarketBuyOrderRequiresPrice'] = False. Make sure you know what you're doing.")
1360
+ raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
1335
1361
  else:
1336
1362
  # despite that cost = amount * price is in quote currency and should have quote precision
1337
1363
  # the exchange API requires the cost supplied in 'amount' to be of base precision
@@ -1341,10 +1367,10 @@ class huobijp(Exchange, ImplicitAPI):
1341
1367
  # we use amountToPrecision here because the exchange requires cost in base precision
1342
1368
  amountString = self.number_to_string(amount)
1343
1369
  priceString = self.number_to_string(price)
1344
- baseAmount = Precise.string_mul(amountString, priceString)
1345
- request['amount'] = self.cost_to_precision(symbol, baseAmount)
1370
+ quoteAmount = self.amount_to_precision(symbol, Precise.string_mul(amountString, priceString))
1346
1371
  else:
1347
- request['amount'] = self.cost_to_precision(symbol, amount)
1372
+ quoteAmount = self.amount_to_precision(symbol, amount)
1373
+ request['amount'] = quoteAmount
1348
1374
  else:
1349
1375
  request['amount'] = self.amount_to_precision(symbol, amount)
1350
1376
  if type == 'limit' or type == 'ioc' or type == 'limit-maker' or type == 'stop-limit' or type == 'stop-limit-fok':
ccxt/kucoinfutures.py CHANGED
@@ -692,9 +692,6 @@ class kucoinfutures(kucoin, ImplicitAPI):
692
692
  orderbook['nonce'] = self.safe_integer(data, 'sequence')
693
693
  return orderbook
694
694
 
695
- def fetch_l3_order_book(self, symbol: str, limit: Int = None, params={}):
696
- raise BadRequest(self.id + ' fetchL3OrderBook() is not supported yet')
697
-
698
695
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
699
696
  """
700
697
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.1.83'
7
+ __version__ = '4.1.85'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10