ccxt 4.1.81__py2.py3-none-any.whl → 4.1.83__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 CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.1.81'
25
+ __version__ = '4.1.83'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.1.81'
7
+ __version__ = '4.1.83'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.1.81'
5
+ __version__ = '4.1.83'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -1010,7 +1010,7 @@ class Exchange(BaseExchange):
1010
1010
  async def fetch_funding_history(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
1011
1011
  raise NotSupported(self.id + ' fetchFundingHistory() is not supported yet')
1012
1012
 
1013
- async def close_position(self, symbol: str, side: OrderSide = None, marginMode: str = None, params={}):
1013
+ async def close_position(self, symbol: str, side: OrderSide = None, params={}):
1014
1014
  raise NotSupported(self.id + ' closePositions() is not supported yet')
1015
1015
 
1016
1016
  async def close_all_positions(self, params={}):
@@ -3172,7 +3172,7 @@ class bingx(Exchange, ImplicitAPI):
3172
3172
  :see: https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
3173
3173
  :param dict [params]: extra parameters specific to the okx api endpoint
3174
3174
  :param str [params.recvWindow]: request valid time window value
3175
- :returns [dict]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
3175
+ :returns dict[]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
3176
3176
  """
3177
3177
  await self.load_markets()
3178
3178
  defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
@@ -6555,7 +6555,7 @@ class bitget(Exchange, ImplicitAPI):
6555
6555
  :param dict [params]: extra parameters specific to the okx api endpoint
6556
6556
  :param str [params.subType]: 'linear' or 'inverse'
6557
6557
  :param str [params.settle]: *required and only valid when params.subType == "linear"* 'USDT' or 'USDC'
6558
- :returns [dict]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
6558
+ :returns dict[]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
6559
6559
  """
6560
6560
  await self.load_markets()
6561
6561
  subType = None
@@ -2897,7 +2897,7 @@ class bybit(Exchange, ImplicitAPI):
2897
2897
  :see: https://bybit-exchange.github.io/docs/v5/account/wallet-balance
2898
2898
  :param dict [params]: extra parameters specific to the exchange API endpoint
2899
2899
  :param str [params.type]: wallet type, ['spot', 'swap', 'fund']
2900
- :returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
2900
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
2901
2901
  """
2902
2902
  await self.load_markets()
2903
2903
  request = {}
ccxt/async_support/cex.py CHANGED
@@ -45,6 +45,9 @@ class cex(Exchange, ImplicitAPI):
45
45
  'cancelOrder': True,
46
46
  'cancelOrders': False,
47
47
  'createDepositAddress': False,
48
+ 'createMarketBuyOrderWithCost': True,
49
+ 'createMarketOrderWithCost': False,
50
+ 'createMarketSellOrderWithCost': False,
48
51
  'createOrder': True,
49
52
  'createStopLimitOrder': False,
50
53
  'createStopMarketOrder': False,
@@ -728,27 +731,39 @@ class cex(Exchange, ImplicitAPI):
728
731
  :param float amount: how much of currency you want to trade in units of base currency
729
732
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
730
733
  :param dict [params]: extra parameters specific to the exchange API endpoint
734
+ :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
731
735
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
732
736
  """
733
- # for market buy it requires the amount of quote currency to spend
734
- if (type == 'market') and (side == 'buy'):
735
- if self.options['createMarketBuyOrderRequiresPrice']:
736
- if price is None:
737
- 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)")
738
- else:
739
- amountString = self.number_to_string(amount)
740
- priceString = self.number_to_string(price)
741
- baseAmount = Precise.string_mul(amountString, priceString)
742
- amount = self.parse_number(baseAmount)
743
737
  await self.load_markets()
744
738
  market = self.market(symbol)
745
739
  request = {
746
740
  'pair': market['id'],
747
741
  'type': side,
748
- 'amount': amount,
749
742
  }
743
+ # for market buy it requires the amount of quote currency to spend
744
+ if (type == 'market') and (side == 'buy'):
745
+ quoteAmount = None
746
+ createMarketBuyOrderRequiresPrice = True
747
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
748
+ cost = self.safe_string(params, 'cost')
749
+ params = self.omit(params, 'cost')
750
+ if cost is not None:
751
+ quoteAmount = self.cost_to_precision(symbol, cost)
752
+ elif createMarketBuyOrderRequiresPrice:
753
+ if price is None:
754
+ 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')
755
+ else:
756
+ amountString = self.number_to_string(amount)
757
+ priceString = self.number_to_string(price)
758
+ costRequest = Precise.string_mul(amountString, priceString)
759
+ quoteAmount = self.cost_to_precision(symbol, costRequest)
760
+ else:
761
+ quoteAmount = self.cost_to_precision(symbol, amount)
762
+ request['amount'] = quoteAmount
763
+ else:
764
+ request['amount'] = self.amount_to_precision(symbol, amount)
750
765
  if type == 'limit':
751
- request['price'] = price
766
+ request['price'] = self.number_to_string(price)
752
767
  else:
753
768
  request['order_type'] = type
754
769
  response = await self.privatePostPlaceOrderPair(self.extend(request, params))