ccxt 4.1.75__py2.py3-none-any.whl → 4.1.77__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.
Files changed (114) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +2 -0
  3. ccxt/abstract/binancecoinm.py +2 -0
  4. ccxt/abstract/binanceus.py +2 -0
  5. ccxt/abstract/binanceusdm.py +2 -0
  6. ccxt/abstract/okx.py +23 -9
  7. ccxt/ace.py +2 -0
  8. ccxt/alpaca.py +2 -0
  9. ccxt/async_support/__init__.py +1 -1
  10. ccxt/async_support/ace.py +2 -0
  11. ccxt/async_support/alpaca.py +2 -0
  12. ccxt/async_support/base/exchange.py +7 -1
  13. ccxt/async_support/binance.py +4 -0
  14. ccxt/async_support/binanceus.py +2 -0
  15. ccxt/async_support/bingx.py +76 -25
  16. ccxt/async_support/bit2c.py +2 -0
  17. ccxt/async_support/bitbank.py +2 -0
  18. ccxt/async_support/bithumb.py +2 -0
  19. ccxt/async_support/bitmex.py +5 -1
  20. ccxt/async_support/bitopro.py +2 -0
  21. ccxt/async_support/bitpanda.py +2 -0
  22. ccxt/async_support/bitrue.py +24 -1
  23. ccxt/async_support/bitso.py +2 -0
  24. ccxt/async_support/bitstamp.py +5 -2
  25. ccxt/async_support/bittrex.py +2 -0
  26. ccxt/async_support/bitvavo.py +2 -0
  27. ccxt/async_support/bl3p.py +2 -0
  28. ccxt/async_support/btcalpha.py +2 -0
  29. ccxt/async_support/btcbox.py +2 -0
  30. ccxt/async_support/btcmarkets.py +2 -0
  31. ccxt/async_support/btcturk.py +2 -0
  32. ccxt/async_support/bybit.py +2 -0
  33. ccxt/async_support/coinbase.py +33 -6
  34. ccxt/async_support/coincheck.py +2 -0
  35. ccxt/async_support/coinlist.py +2 -0
  36. ccxt/async_support/coinmate.py +2 -0
  37. ccxt/async_support/coinone.py +2 -0
  38. ccxt/async_support/coinsph.py +2 -0
  39. ccxt/async_support/coinspot.py +2 -0
  40. ccxt/async_support/cryptocom.py +2 -167
  41. ccxt/async_support/gate.py +1 -0
  42. ccxt/async_support/gemini.py +2 -0
  43. ccxt/async_support/idex.py +2 -0
  44. ccxt/async_support/independentreserve.py +2 -0
  45. ccxt/async_support/indodax.py +2 -0
  46. ccxt/async_support/kucoin.py +2 -0
  47. ccxt/async_support/kuna.py +2 -0
  48. ccxt/async_support/latoken.py +2 -0
  49. ccxt/async_support/luno.py +2 -0
  50. ccxt/async_support/mercado.py +2 -0
  51. ccxt/async_support/mexc.py +2 -0
  52. ccxt/async_support/ndax.py +2 -0
  53. ccxt/async_support/novadax.py +2 -0
  54. ccxt/async_support/okx.py +25 -10
  55. ccxt/async_support/p2b.py +2 -0
  56. ccxt/async_support/wavesexchange.py +2 -0
  57. ccxt/async_support/wazirx.py +2 -0
  58. ccxt/async_support/woo.py +2 -0
  59. ccxt/async_support/yobit.py +2 -0
  60. ccxt/async_support/zonda.py +2 -0
  61. ccxt/base/exchange.py +7 -1
  62. ccxt/binance.py +4 -0
  63. ccxt/binanceus.py +2 -0
  64. ccxt/bingx.py +76 -25
  65. ccxt/bit2c.py +2 -0
  66. ccxt/bitbank.py +2 -0
  67. ccxt/bithumb.py +2 -0
  68. ccxt/bitmex.py +5 -1
  69. ccxt/bitopro.py +2 -0
  70. ccxt/bitpanda.py +2 -0
  71. ccxt/bitrue.py +24 -1
  72. ccxt/bitso.py +2 -0
  73. ccxt/bitstamp.py +5 -2
  74. ccxt/bittrex.py +2 -0
  75. ccxt/bitvavo.py +2 -0
  76. ccxt/bl3p.py +2 -0
  77. ccxt/btcalpha.py +2 -0
  78. ccxt/btcbox.py +2 -0
  79. ccxt/btcmarkets.py +2 -0
  80. ccxt/btcturk.py +2 -0
  81. ccxt/bybit.py +2 -0
  82. ccxt/coinbase.py +33 -6
  83. ccxt/coincheck.py +2 -0
  84. ccxt/coinlist.py +2 -0
  85. ccxt/coinmate.py +2 -0
  86. ccxt/coinone.py +2 -0
  87. ccxt/coinsph.py +2 -0
  88. ccxt/coinspot.py +2 -0
  89. ccxt/cryptocom.py +2 -167
  90. ccxt/gate.py +1 -0
  91. ccxt/gemini.py +2 -0
  92. ccxt/idex.py +2 -0
  93. ccxt/independentreserve.py +2 -0
  94. ccxt/indodax.py +2 -0
  95. ccxt/kucoin.py +2 -0
  96. ccxt/kuna.py +2 -0
  97. ccxt/latoken.py +2 -0
  98. ccxt/luno.py +2 -0
  99. ccxt/mercado.py +2 -0
  100. ccxt/mexc.py +2 -0
  101. ccxt/ndax.py +2 -0
  102. ccxt/novadax.py +2 -0
  103. ccxt/okx.py +25 -10
  104. ccxt/p2b.py +2 -0
  105. ccxt/pro/__init__.py +1 -1
  106. ccxt/wavesexchange.py +2 -0
  107. ccxt/wazirx.py +2 -0
  108. ccxt/woo.py +2 -0
  109. ccxt/yobit.py +2 -0
  110. ccxt/zonda.py +2 -0
  111. {ccxt-4.1.75.dist-info → ccxt-4.1.77.dist-info}/METADATA +4 -4
  112. {ccxt-4.1.75.dist-info → ccxt-4.1.77.dist-info}/RECORD +114 -114
  113. {ccxt-4.1.75.dist-info → ccxt-4.1.77.dist-info}/WHEEL +0 -0
  114. {ccxt-4.1.75.dist-info → ccxt-4.1.77.dist-info}/top_level.txt +0 -0
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.1.75'
7
+ __version__ = '4.1.77'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -3847,6 +3847,12 @@ class Exchange(object):
3847
3847
  def fetch_funding_history(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
3848
3848
  raise NotSupported(self.id + ' fetchFundingHistory() is not supported yet')
3849
3849
 
3850
+ def close_position(self, symbol: str, side: OrderSide = None, marginMode: str = None, params={}):
3851
+ raise NotSupported(self.id + ' closePositions() is not supported yet')
3852
+
3853
+ def close_all_positions(self, params={}):
3854
+ raise NotSupported(self.id + ' closeAllPositions() is not supported yet')
3855
+
3850
3856
  def parse_last_price(self, price, market: Market = None):
3851
3857
  raise NotSupported(self.id + ' parseLastPrice() is not supported yet')
3852
3858
 
ccxt/binance.py CHANGED
@@ -59,6 +59,8 @@ class binance(Exchange, ImplicitAPI):
59
59
  'cancelAllOrders': True,
60
60
  'cancelOrder': True,
61
61
  'cancelOrders': True, # contract only
62
+ 'closeAllPositions': False,
63
+ 'closePosition': False,
62
64
  'createDepositAddress': False,
63
65
  'createOrder': True,
64
66
  'createOrders': True,
@@ -895,6 +897,7 @@ class binance(Exchange, ImplicitAPI):
895
897
  'uiKlines': 0.4,
896
898
  'ticker/24hr': {'cost': 0.4, 'noSymbol': 16},
897
899
  'ticker': {'cost': 0.4, 'noSymbol': 16},
900
+ 'ticker/tradingDay': 0.8,
898
901
  'ticker/price': {'cost': 0.4, 'noSymbol': 0.8},
899
902
  'ticker/bookTicker': {'cost': 0.4, 'noSymbol': 0.8},
900
903
  'exchangeInfo': 4, # Weight(IP): 20 => cost = 0.2 * 20 = 4
@@ -923,6 +926,7 @@ class binance(Exchange, ImplicitAPI):
923
926
  'rateLimit/order': 8, # Weight(IP): 40 => cost = 0.2 * 40 = 8
924
927
  'myPreventedMatches': 4, # Weight(IP): 20 => cost = 0.2 * 20 = 4
925
928
  'myAllocations': 4,
929
+ 'account/commission': 4,
926
930
  },
927
931
  'post': {
928
932
  'order/oco': 0.2,
ccxt/binanceus.py CHANGED
@@ -52,6 +52,8 @@ class binanceus(binance, ImplicitAPI):
52
52
  'option': False,
53
53
  'addMargin': False,
54
54
  'borrowMargin': False,
55
+ 'closeAllPositions': False,
56
+ 'closePosition': False,
55
57
  'createReduceOnlyOrder': False,
56
58
  'fetchBorrowInterest': False,
57
59
  'fetchBorrowRate': False,
ccxt/bingx.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bingx import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -44,6 +44,8 @@ class bingx(Exchange, ImplicitAPI):
44
44
  'cancelAllOrders': True,
45
45
  'cancelOrder': True,
46
46
  'cancelOrders': True,
47
+ 'closeAllPosition': True,
48
+ 'closePosition': False,
47
49
  'createMarketBuyOrderWithCost': True,
48
50
  'createMarketOrderWithCost': True,
49
51
  'createMarketSellOrderWithCost': True,
@@ -95,10 +97,18 @@ class bingx(Exchange, ImplicitAPI):
95
97
  'www': 'https://bingx.com/',
96
98
  'doc': 'https://bingx-api.github.io/docs/',
97
99
  'referral': 'https://bingx.com/invite/OHETOM',
98
- 'fees': {
99
- 'trading': {
100
- 'tierBased': True,
101
- },
100
+ },
101
+ 'fees': {
102
+ 'tierBased': True,
103
+ 'spot': {
104
+ 'feeSide': 'get',
105
+ 'maker': self.parse_number('0.001'),
106
+ 'taker': self.parse_number('0.001'),
107
+ },
108
+ 'swap': {
109
+ 'feeSide': 'quote',
110
+ 'maker': self.parse_number('0.0002'),
111
+ 'taker': self.parse_number('0.0005'),
102
112
  },
103
113
  },
104
114
  'requiredCredentials': {
@@ -317,10 +327,6 @@ class bingx(Exchange, ImplicitAPI):
317
327
  '1w': '1w',
318
328
  '1M': '1M',
319
329
  },
320
- 'fees': {
321
- 'trading': {
322
- },
323
- },
324
330
  'precisionMode': DECIMAL_PLACES,
325
331
  'exceptions': {
326
332
  'exact': {
@@ -562,11 +568,12 @@ class bingx(Exchange, ImplicitAPI):
562
568
  symbol = base + '/' + quote
563
569
  if settle is not None:
564
570
  symbol += ':' + settle
571
+ fees = self.safe_value(self.fees, type, {})
565
572
  contractSize = self.safe_number(market, 'size')
566
573
  isActive = self.safe_string(market, 'status') == '1'
567
574
  isInverse = None if (spot) else False
568
575
  isLinear = None if (spot) else swap
569
- return {
576
+ return self.safe_market_structure({
570
577
  'id': id,
571
578
  'symbol': symbol,
572
579
  'base': base,
@@ -585,8 +592,9 @@ class bingx(Exchange, ImplicitAPI):
585
592
  'contract': swap,
586
593
  'linear': isLinear,
587
594
  'inverse': isInverse,
588
- 'taker': None,
589
- 'maker': None,
595
+ 'taker': self.safe_number(fees, 'taker'),
596
+ 'maker': self.safe_number(fees, 'maker'),
597
+ 'feeSide': self.safe_string(fees, 'feeSide'),
590
598
  'contractSize': contractSize,
591
599
  'expiry': None,
592
600
  'expiryDatetime': None,
@@ -616,7 +624,7 @@ class bingx(Exchange, ImplicitAPI):
616
624
  },
617
625
  'created': None,
618
626
  'info': market,
619
- }
627
+ })
620
628
 
621
629
  def fetch_markets(self, params={}):
622
630
  """
@@ -1524,23 +1532,27 @@ class bingx(Exchange, ImplicitAPI):
1524
1532
  # "avgPrice": "2.2",
1525
1533
  # "leverage": 10,
1526
1534
  # }
1535
+ #
1527
1536
  # standard position
1537
+ #
1528
1538
  # {
1529
- # "currentPrice":"82.91",
1530
- # "symbol":"LTC/USDT",
1531
- # "initialMargin":"5.00000000000000000000",
1532
- # "unrealizedProfit":"-0.26464500",
1533
- # "leverage":"20.000000000",
1534
- # "isolated":true,
1535
- # "entryPrice":"83.13",
1536
- # "positionSide":"LONG",
1537
- # "positionAmt":"1.20365912",
1539
+ # "currentPrice": "82.91",
1540
+ # "symbol": "LTC/USDT",
1541
+ # "initialMargin": "5.00000000000000000000",
1542
+ # "unrealizedProfit": "-0.26464500",
1543
+ # "leverage": "20.000000000",
1544
+ # "isolated": True,
1545
+ # "entryPrice": "83.13",
1546
+ # "positionSide": "LONG",
1547
+ # "positionAmt": "1.20365912",
1538
1548
  # }
1539
1549
  #
1540
- marketId = self.safe_string(position, 'symbol')
1550
+ marketId = self.safe_string(position, 'symbol', '')
1541
1551
  marketId = marketId.replace('/', '-') # standard return different format
1542
1552
  isolated = self.safe_value(position, 'isolated')
1543
- marginMode = 'isolated' if isolated else 'cross'
1553
+ marginMode = None
1554
+ if isolated is not None:
1555
+ marginMode = 'isolated' if isolated else 'cross'
1544
1556
  return self.safe_position({
1545
1557
  'info': position,
1546
1558
  'id': self.safe_string(position, 'positionId'),
@@ -1701,7 +1713,6 @@ class bingx(Exchange, ImplicitAPI):
1701
1713
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
1702
1714
  """
1703
1715
  create a trade order
1704
- :see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
1705
1716
  :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
1706
1717
  :param str symbol: unified symbol of the market to create an order in
1707
1718
  :param str type: 'market' or 'limit'
@@ -3216,6 +3227,46 @@ class bingx(Exchange, ImplicitAPI):
3216
3227
  'datetime': self.iso8601(timestamp),
3217
3228
  })
3218
3229
 
3230
+ def close_all_positions(self, params={}) -> List[Position]:
3231
+ """
3232
+ closes open positions for a market
3233
+ :see: https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
3234
+ :param dict [params]: extra parameters specific to the okx api endpoint
3235
+ :param str [params.recvWindow]: request valid time window value
3236
+ :returns [dict]: `A list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
3237
+ """
3238
+ self.load_markets()
3239
+ defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
3240
+ recvWindow = self.safe_integer(self.parse_params, 'recvWindow', defaultRecvWindow)
3241
+ marketType = None
3242
+ marketType, params = self.handle_market_type_and_params('closeAllPositions', None, params)
3243
+ if marketType == 'margin':
3244
+ raise BadRequest(self.id + ' closePositions() cannot be used for ' + marketType + ' markets')
3245
+ request = {
3246
+ 'recvWindow': recvWindow,
3247
+ }
3248
+ response = self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
3249
+ #
3250
+ # {
3251
+ # "code": 0,
3252
+ # "msg": "",
3253
+ # "data": {
3254
+ # "success": [
3255
+ # 1727686766700486656,
3256
+ # 1727686767048613888
3257
+ # ],
3258
+ # "failed": null
3259
+ # }
3260
+ # }
3261
+ #
3262
+ data = self.safe_value(response, 'data', {})
3263
+ success = self.safe_value(data, 'success', [])
3264
+ positions = []
3265
+ for i in range(0, len(success)):
3266
+ position = self.parse_position({'positionId': success[i]})
3267
+ positions.append(position)
3268
+ return positions
3269
+
3219
3270
  def sign(self, path, section='public', method='GET', params={}, headers=None, body=None):
3220
3271
  type = section[0]
3221
3272
  version = section[1]
ccxt/bit2c.py CHANGED
@@ -37,6 +37,8 @@ class bit2c(Exchange, ImplicitAPI):
37
37
  'option': False,
38
38
  'addMargin': False,
39
39
  'cancelOrder': True,
40
+ 'closeAllPositions': False,
41
+ 'closePosition': False,
40
42
  'createOrder': True,
41
43
  'createReduceOnlyOrder': False,
42
44
  'fetchBalance': True,
ccxt/bitbank.py CHANGED
@@ -35,6 +35,8 @@ class bitbank(Exchange, ImplicitAPI):
35
35
  'option': False,
36
36
  'addMargin': False,
37
37
  'cancelOrder': True,
38
+ 'closeAllPositions': False,
39
+ 'closePosition': False,
38
40
  'createOrder': True,
39
41
  'createReduceOnlyOrder': False,
40
42
  'fetchBalance': True,
ccxt/bithumb.py CHANGED
@@ -39,6 +39,8 @@ class bithumb(Exchange, ImplicitAPI):
39
39
  'option': False,
40
40
  'addMargin': False,
41
41
  'cancelOrder': True,
42
+ 'closeAllPositions': False,
43
+ 'closePosition': False,
42
44
  'createMarketOrder': True,
43
45
  'createOrder': True,
44
46
  'createReduceOnlyOrder': False,
ccxt/bitmex.py CHANGED
@@ -393,7 +393,11 @@ class bitmex(Exchange, ImplicitAPI):
393
393
  finalAmount = Precise.string_div(amountString, precision)
394
394
  return self.parse_number(finalAmount)
395
395
 
396
- def convert_to_real_amount(self, code: str, amount: str):
396
+ def convert_to_real_amount(self, code: Str, amount: Str):
397
+ if code is None:
398
+ return amount
399
+ elif amount is None:
400
+ return None
397
401
  currency = self.currency(code)
398
402
  precision = self.safe_string(currency, 'precision')
399
403
  return Precise.string_mul(amount, precision)
ccxt/bitopro.py CHANGED
@@ -39,6 +39,8 @@ class bitopro(Exchange, ImplicitAPI):
39
39
  'cancelAllOrders': True,
40
40
  'cancelOrder': True,
41
41
  'cancelOrders': True,
42
+ 'closeAllPositions': False,
43
+ 'closePosition': False,
42
44
  'createOrder': True,
43
45
  'editOrder': False,
44
46
  'fetchBalance': True,
ccxt/bitpanda.py CHANGED
@@ -44,6 +44,8 @@ class bitpanda(Exchange, ImplicitAPI):
44
44
  'cancelAllOrders': True,
45
45
  'cancelOrder': True,
46
46
  'cancelOrders': True,
47
+ 'closeAllPositions': False,
48
+ 'closePosition': False,
47
49
  'createDepositAddress': True,
48
50
  'createOrder': True,
49
51
  'createReduceOnlyOrder': False,
ccxt/bitrue.py CHANGED
@@ -52,6 +52,9 @@ class bitrue(Exchange, ImplicitAPI):
52
52
  'option': False,
53
53
  'cancelAllOrders': True,
54
54
  'cancelOrder': True,
55
+ 'createMarketBuyOrderWithCost': True,
56
+ 'createMarketOrderWithCost': False,
57
+ 'createMarketSellOrderWithCost': False,
55
58
  'createOrder': True,
56
59
  'createStopLimitOrder': True,
57
60
  'createStopMarketOrder': True,
@@ -1803,6 +1806,23 @@ class bitrue(Exchange, ImplicitAPI):
1803
1806
  'trades': fills,
1804
1807
  }, market)
1805
1808
 
1809
+ def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1810
+ """
1811
+ create a market buy order by providing the symbol and cost
1812
+ :see: https://www.bitrue.com/api-docs#new-order-trade-hmac-sha256
1813
+ :see: https://www.bitrue.com/api_docs_includes_file/delivery.html#new-order-trade-hmac-sha256
1814
+ :param str symbol: unified symbol of the market to create an order in
1815
+ :param float cost: how much you want to trade in units of the quote currency
1816
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1817
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1818
+ """
1819
+ self.load_markets()
1820
+ market = self.market(symbol)
1821
+ if not market['swap']:
1822
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports swap orders only')
1823
+ params['createMarketBuyOrderRequiresPrice'] = False
1824
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
1825
+
1806
1826
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
1807
1827
  """
1808
1828
  create a trade order
@@ -1824,6 +1844,7 @@ class bitrue(Exchange, ImplicitAPI):
1824
1844
  * EXCHANGE SPECIFIC PARAMETERS
1825
1845
  :param decimal [params.icebergQty]:
1826
1846
  :param long [params.recvWindow]:
1847
+ :param float [params.cost]: *swap market buy only* the quote quantity that can be used alternative for the amount
1827
1848
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1828
1849
  """
1829
1850
  self.load_markets()
@@ -1855,7 +1876,9 @@ class bitrue(Exchange, ImplicitAPI):
1855
1876
  elif timeInForce == 'ioc':
1856
1877
  request['type'] = 'IOC'
1857
1878
  request['contractName'] = market['id']
1858
- if isMarket and (side == 'buy') and (self.options['createMarketBuyOrderRequiresPrice']):
1879
+ createMarketBuyOrderRequiresPrice = True
1880
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
1881
+ if isMarket and (side == 'buy') and createMarketBuyOrderRequiresPrice:
1859
1882
  cost = self.safe_string(params, 'cost')
1860
1883
  params = self.omit(params, 'cost')
1861
1884
  if price is None and cost is None:
ccxt/bitso.py CHANGED
@@ -39,6 +39,8 @@ class bitso(Exchange, ImplicitAPI):
39
39
  'cancelAllOrders': True,
40
40
  'cancelOrder': True,
41
41
  'cancelOrders': True,
42
+ 'closeAllPositions': False,
43
+ 'closePosition': False,
42
44
  'createDepositAddress': False,
43
45
  'createOrder': True,
44
46
  'createReduceOnlyOrder': False,
ccxt/bitstamp.py CHANGED
@@ -46,6 +46,8 @@ class bitstamp(Exchange, ImplicitAPI):
46
46
  'addMargin': False,
47
47
  'cancelAllOrders': True,
48
48
  'cancelOrder': True,
49
+ 'closeAllPositions': False,
50
+ 'closePosition': False,
49
51
  'createOrder': True,
50
52
  'createReduceOnlyOrder': False,
51
53
  'createStopLimitOrder': False,
@@ -1005,6 +1007,7 @@ class bitstamp(Exchange, ImplicitAPI):
1005
1007
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1006
1008
  """
1007
1009
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1010
+ :see: https://www.bitstamp.net/api/#tag/Market-info/operation/GetOHLCData
1008
1011
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1009
1012
  :param str timeframe: the length of time each candle represents
1010
1013
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1026,13 +1029,13 @@ class bitstamp(Exchange, ImplicitAPI):
1026
1029
  limit = 1000
1027
1030
  start = self.parse_to_int(since / 1000)
1028
1031
  request['start'] = start
1029
- request['end'] = self.sum(start, limit * duration)
1032
+ request['end'] = self.sum(start, duration * (limit - 1))
1030
1033
  request['limit'] = limit
1031
1034
  else:
1032
1035
  if since is not None:
1033
1036
  start = self.parse_to_int(since / 1000)
1034
1037
  request['start'] = start
1035
- request['end'] = self.sum(start, limit * duration)
1038
+ request['end'] = self.sum(start, duration * (limit - 1))
1036
1039
  request['limit'] = min(limit, 1000) # min 1, max 1000
1037
1040
  response = self.publicGetOhlcPair(self.extend(request, params))
1038
1041
  #
ccxt/bittrex.py CHANGED
@@ -48,6 +48,8 @@ class bittrex(Exchange, ImplicitAPI):
48
48
  'addMargin': False,
49
49
  'cancelAllOrders': True,
50
50
  'cancelOrder': True,
51
+ 'closeAllPositions': False,
52
+ 'closePosition': False,
51
53
  'createDepositAddress': True,
52
54
  'createMarketOrder': True,
53
55
  'createOrder': True,
ccxt/bitvavo.py CHANGED
@@ -50,6 +50,8 @@ class bitvavo(Exchange, ImplicitAPI):
50
50
  'addMargin': False,
51
51
  'cancelAllOrders': True,
52
52
  'cancelOrder': True,
53
+ 'closeAllPositions': False,
54
+ 'closePosition': False,
53
55
  'createOrder': True,
54
56
  'createReduceOnlyOrder': False,
55
57
  'createStopLimitOrder': True,
ccxt/bl3p.py CHANGED
@@ -32,6 +32,8 @@ class bl3p(Exchange, ImplicitAPI):
32
32
  'option': False,
33
33
  'addMargin': False,
34
34
  'cancelOrder': True,
35
+ 'closeAllPositions': False,
36
+ 'closePosition': False,
35
37
  'createOrder': True,
36
38
  'createReduceOnlyOrder': False,
37
39
  'createStopLimitOrder': False,
ccxt/btcalpha.py CHANGED
@@ -34,6 +34,8 @@ class btcalpha(Exchange, ImplicitAPI):
34
34
  'option': False,
35
35
  'addMargin': False,
36
36
  'cancelOrder': True,
37
+ 'closeAllPositions': False,
38
+ 'closePosition': False,
37
39
  'createOrder': True,
38
40
  'createReduceOnlyOrder': False,
39
41
  'createStopLimitOrder': False,
ccxt/btcbox.py CHANGED
@@ -40,6 +40,8 @@ class btcbox(Exchange, ImplicitAPI):
40
40
  'option': False,
41
41
  'addMargin': False,
42
42
  'cancelOrder': True,
43
+ 'closeAllPositions': False,
44
+ 'closePosition': False,
43
45
  'createOrder': True,
44
46
  'createReduceOnlyOrder': False,
45
47
  'fetchBalance': True,
ccxt/btcmarkets.py CHANGED
@@ -38,6 +38,8 @@ class btcmarkets(Exchange, ImplicitAPI):
38
38
  'addMargin': False,
39
39
  'cancelOrder': True,
40
40
  'cancelOrders': True,
41
+ 'closeAllPositions': False,
42
+ 'closePosition': False,
41
43
  'createOrder': True,
42
44
  'createReduceOnlyOrder': False,
43
45
  'fetchBalance': True,
ccxt/btcturk.py CHANGED
@@ -35,6 +35,8 @@ class btcturk(Exchange, ImplicitAPI):
35
35
  'option': False,
36
36
  'addMargin': False,
37
37
  'cancelOrder': True,
38
+ 'closeAllPositions': False,
39
+ 'closePosition': False,
38
40
  'createOrder': True,
39
41
  'createReduceOnlyOrder': False,
40
42
  'fetchBalance': True,
ccxt/bybit.py CHANGED
@@ -50,6 +50,8 @@ class bybit(Exchange, ImplicitAPI):
50
50
  'borrowCrossMargin': True,
51
51
  'cancelAllOrders': True,
52
52
  'cancelOrder': True,
53
+ 'closeAllPositions': False,
54
+ 'closePosition': False,
53
55
  'createMarketBuyOrderWithCost': True,
54
56
  'createMarketSellOrderWithCost': False,
55
57
  'createOrder': True,
ccxt/coinbase.py CHANGED
@@ -45,11 +45,16 @@ class coinbase(Exchange, ImplicitAPI):
45
45
  'addMargin': False,
46
46
  'cancelOrder': True,
47
47
  'cancelOrders': True,
48
+ 'closeAllPositions': False,
49
+ 'closePosition': False,
48
50
  'createDepositAddress': True,
49
51
  'createLimitBuyOrder': True,
50
52
  'createLimitSellOrder': True,
51
53
  'createMarketBuyOrder': True,
54
+ 'createMarketBuyOrderWithCost': True,
55
+ 'createMarketOrderWithCost': False,
52
56
  'createMarketSellOrder': True,
57
+ 'createMarketSellOrderWithCost': False,
53
58
  'createOrder': True,
54
59
  'createPostOnlyOrder': True,
55
60
  'createReduceOnlyOrder': False,
@@ -2008,6 +2013,22 @@ class coinbase(Exchange, ImplicitAPI):
2008
2013
  request['limit'] = limit
2009
2014
  return request
2010
2015
 
2016
+ def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
2017
+ """
2018
+ create a market buy order by providing the symbol and cost
2019
+ :see: https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_postorder
2020
+ :param str symbol: unified symbol of the market to create an order in
2021
+ :param float cost: how much you want to trade in units of the quote currency
2022
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2023
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2024
+ """
2025
+ self.load_markets()
2026
+ market = self.market(symbol)
2027
+ if not market['spot']:
2028
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2029
+ params['createMarketBuyOrderRequiresPrice'] = False
2030
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
2031
+
2011
2032
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
2012
2033
  """
2013
2034
  create a trade order
@@ -2026,6 +2047,7 @@ class coinbase(Exchange, ImplicitAPI):
2026
2047
  :param str [params.timeInForce]: 'GTC', 'IOC', 'GTD' or 'PO'
2027
2048
  :param str [params.stop_direction]: 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2028
2049
  :param str [params.end_time]: '2023-05-25T17:01:05.092Z' for 'GTD' orders
2050
+ :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
2029
2051
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2030
2052
  """
2031
2053
  self.load_markets()
@@ -2112,18 +2134,23 @@ class coinbase(Exchange, ImplicitAPI):
2112
2134
  if isStop or isStopLoss or isTakeProfit:
2113
2135
  raise NotSupported(self.id + ' createOrder() only stop limit orders are supported')
2114
2136
  if side == 'buy':
2115
- createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
2116
2137
  total = None
2117
- if createMarketBuyOrderRequiresPrice:
2138
+ createMarketBuyOrderRequiresPrice = True
2139
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
2140
+ cost = self.safe_number(params, 'cost')
2141
+ params = self.omit(params, 'cost')
2142
+ if cost is not None:
2143
+ total = self.cost_to_precision(symbol, cost)
2144
+ elif createMarketBuyOrderRequiresPrice:
2118
2145
  if price is None:
2119
- raise InvalidOrder(self.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option to False and pass in the cost to spend into the amount parameter')
2146
+ raise InvalidOrder(self.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
2120
2147
  else:
2121
2148
  amountString = self.number_to_string(amount)
2122
2149
  priceString = self.number_to_string(price)
2123
- cost = self.parse_number(Precise.string_mul(amountString, priceString))
2124
- total = self.price_to_precision(symbol, cost)
2150
+ costRequest = Precise.string_mul(amountString, priceString)
2151
+ total = self.cost_to_precision(symbol, costRequest)
2125
2152
  else:
2126
- total = self.price_to_precision(symbol, amount)
2153
+ total = self.cost_to_precision(symbol, amount)
2127
2154
  request['order_configuration'] = {
2128
2155
  'market_market_ioc': {
2129
2156
  'quote_size': total,
ccxt/coincheck.py CHANGED
@@ -31,6 +31,8 @@ class coincheck(Exchange, ImplicitAPI):
31
31
  'option': False,
32
32
  'addMargin': False,
33
33
  'cancelOrder': True,
34
+ 'closeAllPositions': False,
35
+ 'closePosition': False,
34
36
  'createOrder': True,
35
37
  'createReduceOnlyOrder': False,
36
38
  'fetchBalance': True,
ccxt/coinlist.py CHANGED
@@ -48,6 +48,8 @@ class coinlist(Exchange, ImplicitAPI):
48
48
  'cancelAllOrders': True,
49
49
  'cancelOrder': True,
50
50
  'cancelOrders': True,
51
+ 'closeAllPositions': False,
52
+ 'closePosition': False,
51
53
  'createDepositAddress': False,
52
54
  'createOrder': True,
53
55
  'createPostOnlyOrder': True,
ccxt/coinmate.py CHANGED
@@ -36,6 +36,8 @@ class coinmate(Exchange, ImplicitAPI):
36
36
  'option': False,
37
37
  'addMargin': False,
38
38
  'cancelOrder': True,
39
+ 'closeAllPositions': False,
40
+ 'closePosition': False,
39
41
  'createOrder': True,
40
42
  'createReduceOnlyOrder': False,
41
43
  'fetchBalance': True,
ccxt/coinone.py CHANGED
@@ -38,6 +38,8 @@ class coinone(Exchange, ImplicitAPI):
38
38
  'option': False,
39
39
  'addMargin': False,
40
40
  'cancelOrder': True,
41
+ 'closeAllPositions': False,
42
+ 'closePosition': False,
41
43
  'createMarketOrder': False,
42
44
  'createOrder': True,
43
45
  'createReduceOnlyOrder': False,
ccxt/coinsph.py CHANGED
@@ -51,6 +51,8 @@ class coinsph(Exchange, ImplicitAPI):
51
51
  'cancelAllOrders': True,
52
52
  'cancelOrder': True,
53
53
  'cancelOrders': False,
54
+ 'closeAllPositions': False,
55
+ 'closePosition': False,
54
56
  'createDepositAddress': False,
55
57
  'createOrder': True,
56
58
  'createPostOnlyOrder': False,
ccxt/coinspot.py CHANGED
@@ -32,6 +32,8 @@ class coinspot(Exchange, ImplicitAPI):
32
32
  'option': False,
33
33
  'addMargin': False,
34
34
  'cancelOrder': True,
35
+ 'closeAllPositions': False,
36
+ 'closePosition': False,
35
37
  'createMarketOrder': False,
36
38
  'createOrder': True,
37
39
  'createReduceOnlyOrder': False,