ccxt 4.4.38__py2.py3-none-any.whl → 4.4.40__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 (140) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/digifinex.py +1 -0
  3. ccxt/abstract/mexc.py +1 -0
  4. ccxt/abstract/woo.py +2 -2
  5. ccxt/alpaca.py +74 -3
  6. ccxt/ascendex.py +9 -9
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/alpaca.py +74 -3
  9. ccxt/async_support/ascendex.py +9 -9
  10. ccxt/async_support/base/exchange.py +1 -1
  11. ccxt/async_support/base/ws/aiohttp_client.py +2 -2
  12. ccxt/async_support/binance.py +13 -17
  13. ccxt/async_support/bingx.py +1 -2
  14. ccxt/async_support/bit2c.py +0 -1
  15. ccxt/async_support/bitbank.py +0 -1
  16. ccxt/async_support/bitbns.py +0 -1
  17. ccxt/async_support/bitfinex.py +15 -16
  18. ccxt/async_support/bitfinex1.py +0 -1
  19. ccxt/async_support/bitflyer.py +0 -1
  20. ccxt/async_support/bitget.py +1 -2
  21. ccxt/async_support/bithumb.py +0 -1
  22. ccxt/async_support/bitmart.py +3 -4
  23. ccxt/async_support/bitmex.py +5 -6
  24. ccxt/async_support/bitopro.py +4 -5
  25. ccxt/async_support/bitrue.py +5 -7
  26. ccxt/async_support/bitso.py +1 -2
  27. ccxt/async_support/bitstamp.py +1 -2
  28. ccxt/async_support/bitteam.py +1 -3
  29. ccxt/async_support/bitvavo.py +2 -4
  30. ccxt/async_support/blockchaincom.py +5 -5
  31. ccxt/async_support/blofin.py +10 -10
  32. ccxt/async_support/btcalpha.py +0 -1
  33. ccxt/async_support/btcbox.py +0 -1
  34. ccxt/async_support/btcmarkets.py +1 -3
  35. ccxt/async_support/bybit.py +2 -3
  36. ccxt/async_support/cex.py +1 -1
  37. ccxt/async_support/coinbase.py +77 -1
  38. ccxt/async_support/coinbaseexchange.py +1 -1
  39. ccxt/async_support/coinbaseinternational.py +62 -0
  40. ccxt/async_support/coincatch.py +1 -1
  41. ccxt/async_support/coinex.py +9 -9
  42. ccxt/async_support/coinlist.py +1 -1
  43. ccxt/async_support/coinmetro.py +1 -1
  44. ccxt/async_support/cryptocom.py +91 -2
  45. ccxt/async_support/currencycom.py +1 -1
  46. ccxt/async_support/defx.py +1 -2
  47. ccxt/async_support/delta.py +1 -1
  48. ccxt/async_support/digifinex.py +58 -19
  49. ccxt/async_support/exmo.py +2 -2
  50. ccxt/async_support/gate.py +1 -1
  51. ccxt/async_support/hashkey.py +3 -5
  52. ccxt/async_support/htx.py +155 -33
  53. ccxt/async_support/hyperliquid.py +1 -1
  54. ccxt/async_support/kraken.py +1 -1
  55. ccxt/async_support/kucoin.py +25 -24
  56. ccxt/async_support/luno.py +1 -1
  57. ccxt/async_support/mexc.py +173 -26
  58. ccxt/async_support/ndax.py +1 -1
  59. ccxt/async_support/okcoin.py +18 -18
  60. ccxt/async_support/okx.py +22 -21
  61. ccxt/async_support/phemex.py +12 -8
  62. ccxt/async_support/poloniex.py +1 -1
  63. ccxt/async_support/poloniexfutures.py +6 -6
  64. ccxt/async_support/vertex.py +11 -11
  65. ccxt/async_support/woo.py +39 -39
  66. ccxt/async_support/woofipro.py +24 -24
  67. ccxt/async_support/xt.py +26 -26
  68. ccxt/async_support/zonda.py +1 -1
  69. ccxt/base/exchange.py +32 -25
  70. ccxt/binance.py +13 -17
  71. ccxt/bingx.py +1 -2
  72. ccxt/bit2c.py +0 -1
  73. ccxt/bitbank.py +0 -1
  74. ccxt/bitbns.py +0 -1
  75. ccxt/bitfinex.py +15 -16
  76. ccxt/bitfinex1.py +0 -1
  77. ccxt/bitflyer.py +0 -1
  78. ccxt/bitget.py +1 -2
  79. ccxt/bithumb.py +0 -1
  80. ccxt/bitmart.py +3 -4
  81. ccxt/bitmex.py +5 -6
  82. ccxt/bitopro.py +4 -5
  83. ccxt/bitrue.py +5 -7
  84. ccxt/bitso.py +1 -2
  85. ccxt/bitstamp.py +1 -2
  86. ccxt/bitteam.py +1 -3
  87. ccxt/bitvavo.py +2 -4
  88. ccxt/blockchaincom.py +5 -5
  89. ccxt/blofin.py +10 -10
  90. ccxt/btcalpha.py +0 -1
  91. ccxt/btcbox.py +0 -1
  92. ccxt/btcmarkets.py +1 -3
  93. ccxt/bybit.py +2 -3
  94. ccxt/cex.py +1 -1
  95. ccxt/coinbase.py +77 -1
  96. ccxt/coinbaseexchange.py +1 -1
  97. ccxt/coinbaseinternational.py +62 -0
  98. ccxt/coincatch.py +1 -1
  99. ccxt/coinex.py +9 -9
  100. ccxt/coinlist.py +1 -1
  101. ccxt/coinmetro.py +1 -1
  102. ccxt/cryptocom.py +91 -2
  103. ccxt/currencycom.py +1 -1
  104. ccxt/defx.py +1 -2
  105. ccxt/delta.py +1 -1
  106. ccxt/digifinex.py +58 -19
  107. ccxt/exmo.py +2 -2
  108. ccxt/gate.py +1 -1
  109. ccxt/hashkey.py +3 -5
  110. ccxt/htx.py +155 -33
  111. ccxt/hyperliquid.py +1 -1
  112. ccxt/kraken.py +1 -1
  113. ccxt/kucoin.py +25 -24
  114. ccxt/luno.py +1 -1
  115. ccxt/mexc.py +173 -26
  116. ccxt/ndax.py +1 -1
  117. ccxt/okcoin.py +18 -18
  118. ccxt/okx.py +22 -21
  119. ccxt/phemex.py +12 -8
  120. ccxt/poloniex.py +1 -1
  121. ccxt/poloniexfutures.py +6 -6
  122. ccxt/pro/__init__.py +1 -1
  123. ccxt/pro/bitget.py +1 -1
  124. ccxt/pro/bybit.py +12 -1
  125. ccxt/pro/coinex.py +2 -2
  126. ccxt/pro/gate.py +6 -6
  127. ccxt/pro/kucoin.py +3 -3
  128. ccxt/pro/okx.py +11 -11
  129. ccxt/pro/upbit.py +2 -2
  130. ccxt/pro/woo.py +1 -1
  131. ccxt/vertex.py +11 -11
  132. ccxt/woo.py +39 -39
  133. ccxt/woofipro.py +24 -24
  134. ccxt/xt.py +26 -26
  135. ccxt/zonda.py +1 -1
  136. {ccxt-4.4.38.dist-info → ccxt-4.4.40.dist-info}/METADATA +4 -4
  137. {ccxt-4.4.38.dist-info → ccxt-4.4.40.dist-info}/RECORD +140 -140
  138. {ccxt-4.4.38.dist-info → ccxt-4.4.40.dist-info}/LICENSE.txt +0 -0
  139. {ccxt-4.4.38.dist-info → ccxt-4.4.40.dist-info}/WHEEL +0 -0
  140. {ccxt-4.4.38.dist-info → ccxt-4.4.40.dist-info}/top_level.txt +0 -0
ccxt/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.38'
25
+ __version__ = '4.4.40'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
@@ -71,6 +71,7 @@ class ImplicitAPI:
71
71
  private_swap_get_trade_history_trades = privateSwapGetTradeHistoryTrades = Entry('trade/history_trades', ['private', 'swap'], 'GET', {})
72
72
  private_swap_get_trade_open_orders = privateSwapGetTradeOpenOrders = Entry('trade/open_orders', ['private', 'swap'], 'GET', {})
73
73
  private_swap_get_trade_order_info = privateSwapGetTradeOrderInfo = Entry('trade/order_info', ['private', 'swap'], 'GET', {})
74
+ private_swap_post_account_transfer = privateSwapPostAccountTransfer = Entry('account/transfer', ['private', 'swap'], 'POST', {})
74
75
  private_swap_post_account_leverage = privateSwapPostAccountLeverage = Entry('account/leverage', ['private', 'swap'], 'POST', {})
75
76
  private_swap_post_account_position_mode = privateSwapPostAccountPositionMode = Entry('account/position_mode', ['private', 'swap'], 'POST', {})
76
77
  private_swap_post_account_position_margin = privateSwapPostAccountPositionMargin = Entry('account/position_margin', ['private', 'swap'], 'POST', {})
ccxt/abstract/mexc.py CHANGED
@@ -20,6 +20,7 @@ class ImplicitAPI:
20
20
  spot_private_get_allorders = spotPrivateGetAllOrders = Entry('allOrders', ['spot', 'private'], 'GET', {'cost': 10})
21
21
  spot_private_get_account = spotPrivateGetAccount = Entry('account', ['spot', 'private'], 'GET', {'cost': 10})
22
22
  spot_private_get_mytrades = spotPrivateGetMyTrades = Entry('myTrades', ['spot', 'private'], 'GET', {'cost': 10})
23
+ spot_private_get_tradefee = spotPrivateGetTradeFee = Entry('tradeFee', ['spot', 'private'], 'GET', {'cost': 10})
23
24
  spot_private_get_sub_account_list = spotPrivateGetSubAccountList = Entry('sub-account/list', ['spot', 'private'], 'GET', {'cost': 1})
24
25
  spot_private_get_sub_account_apikey = spotPrivateGetSubAccountApiKey = Entry('sub-account/apiKey', ['spot', 'private'], 'GET', {'cost': 1})
25
26
  spot_private_get_capital_config_getall = spotPrivateGetCapitalConfigGetall = Entry('capital/config/getall', ['spot', 'private'], 'GET', {'cost': 10})
ccxt/abstract/woo.py CHANGED
@@ -3,7 +3,7 @@ from ccxt.base.types import Entry
3
3
 
4
4
  class ImplicitAPI:
5
5
  v1_pub_get_hist_kline = v1PubGetHistKline = Entry('hist/kline', ['v1', 'pub'], 'GET', {'cost': 10})
6
- v1_pub_get_hist_trades = v1PubGetHistTrades = Entry('hist/trades', ['v1', 'pub'], 'GET', {'cost': 1})
6
+ v1_pub_get_hist_trades = v1PubGetHistTrades = Entry('hist/trades', ['v1', 'pub'], 'GET', {'cost': 10})
7
7
  v1_public_get_info = v1PublicGetInfo = Entry('info', ['v1', 'public'], 'GET', {'cost': 1})
8
8
  v1_public_get_info_symbol = v1PublicGetInfoSymbol = Entry('info/{symbol}', ['v1', 'public'], 'GET', {'cost': 1})
9
9
  v1_public_get_system_info = v1PublicGetSystemInfo = Entry('system_info', ['v1', 'public'], 'GET', {'cost': 1})
@@ -43,7 +43,7 @@ class ImplicitAPI:
43
43
  v1_private_get_position_symbol = v1PrivateGetPositionSymbol = Entry('position/{symbol}', ['v1', 'private'], 'GET', {'cost': 3.33})
44
44
  v1_private_get_client_transaction_history = v1PrivateGetClientTransactionHistory = Entry('client/transaction_history', ['v1', 'private'], 'GET', {'cost': 60})
45
45
  v1_private_get_client_futures_leverage = v1PrivateGetClientFuturesLeverage = Entry('client/futures_leverage', ['v1', 'private'], 'GET', {'cost': 60})
46
- v1_private_post_order = v1PrivatePostOrder = Entry('order', ['v1', 'private'], 'POST', {'cost': 5})
46
+ v1_private_post_order = v1PrivatePostOrder = Entry('order', ['v1', 'private'], 'POST', {'cost': 1})
47
47
  v1_private_post_order_cancel_all_after = v1PrivatePostOrderCancelAllAfter = Entry('order/cancel_all_after', ['v1', 'private'], 'POST', {'cost': 1})
48
48
  v1_private_post_asset_main_sub_transfer = v1PrivatePostAssetMainSubTransfer = Entry('asset/main_sub_transfer', ['v1', 'private'], 'POST', {'cost': 30})
49
49
  v1_private_post_asset_ltv = v1PrivatePostAssetLtv = Entry('asset/ltv', ['v1', 'private'], 'POST', {'cost': 30})
ccxt/alpaca.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.alpaca import ImplicitAPI
8
- from ccxt.base.types import Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Balances, Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
@@ -44,7 +44,7 @@ class alpaca(Exchange, ImplicitAPI):
44
44
  'test': {
45
45
  'broker': 'https://broker-api.sandbox.{hostname}',
46
46
  'trader': 'https://paper-api.{hostname}',
47
- 'market': 'https://data.sandbox.{hostname}',
47
+ 'market': 'https://data.{hostname}',
48
48
  },
49
49
  'doc': 'https://alpaca.markets/docs/',
50
50
  'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
@@ -64,7 +64,7 @@ class alpaca(Exchange, ImplicitAPI):
64
64
  'createStopOrder': True,
65
65
  'createTriggerOrder': True,
66
66
  'editOrder': True,
67
- 'fetchBalance': False,
67
+ 'fetchBalance': True,
68
68
  'fetchBidsAsks': False,
69
69
  'fetchClosedOrders': True,
70
70
  'fetchCurrencies': False,
@@ -1553,6 +1553,77 @@ class alpaca(Exchange, ImplicitAPI):
1553
1553
  }
1554
1554
  return self.safe_string(types, type, type)
1555
1555
 
1556
+ def fetch_balance(self, params={}) -> Balances:
1557
+ """
1558
+ query for balance and get the amount of funds available for trading or funds locked in orders
1559
+
1560
+ https://docs.alpaca.markets/reference/getaccount-1
1561
+
1562
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1563
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1564
+ """
1565
+ self.load_markets()
1566
+ response = self.traderPrivateGetV2Account(params)
1567
+ #
1568
+ # {
1569
+ # "id": "43a01bde-4eb1-64fssc26adb5",
1570
+ # "admin_configurations": {
1571
+ # "allow_instant_ach": True,
1572
+ # "max_margin_multiplier": "4"
1573
+ # },
1574
+ # "user_configurations": {
1575
+ # "fractional_trading": True,
1576
+ # "max_margin_multiplier": "4"
1577
+ # },
1578
+ # "account_number": "744873727",
1579
+ # "status": "ACTIVE",
1580
+ # "crypto_status": "ACTIVE",
1581
+ # "currency": "USD",
1582
+ # "buying_power": "5.92",
1583
+ # "regt_buying_power": "5.92",
1584
+ # "daytrading_buying_power": "0",
1585
+ # "effective_buying_power": "5.92",
1586
+ # "non_marginable_buying_power": "5.92",
1587
+ # "bod_dtbp": "0",
1588
+ # "cash": "5.92",
1589
+ # "accrued_fees": "0",
1590
+ # "portfolio_value": "48.6",
1591
+ # "pattern_day_trader": False,
1592
+ # "trading_blocked": False,
1593
+ # "transfers_blocked": False,
1594
+ # "account_blocked": False,
1595
+ # "created_at": "2022-06-13T14:59:18.318096Z",
1596
+ # "trade_suspended_by_user": False,
1597
+ # "multiplier": "1",
1598
+ # "shorting_enabled": False,
1599
+ # "equity": "48.6",
1600
+ # "last_equity": "48.8014266",
1601
+ # "long_market_value": "42.68",
1602
+ # "short_market_value": "0",
1603
+ # "position_market_value": "42.68",
1604
+ # "initial_margin": "0",
1605
+ # "maintenance_margin": "0",
1606
+ # "last_maintenance_margin": "0",
1607
+ # "sma": "5.92",
1608
+ # "daytrade_count": 0,
1609
+ # "balance_asof": "2024-12-10",
1610
+ # "crypto_tier": 1,
1611
+ # "intraday_adjustments": "0",
1612
+ # "pending_reg_taf_fees": "0"
1613
+ # }
1614
+ #
1615
+ return self.parse_balance(response)
1616
+
1617
+ def parse_balance(self, response) -> Balances:
1618
+ result: dict = {'info': response}
1619
+ account = self.account()
1620
+ currencyId = self.safe_string(response, 'currency')
1621
+ code = self.safe_currency_code(currencyId)
1622
+ account['free'] = self.safe_string(response, 'cash')
1623
+ account['total'] = self.safe_string(response, 'equity')
1624
+ result[code] = account
1625
+ return self.safe_balance(result)
1626
+
1556
1627
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1557
1628
  endpoint = '/' + self.implode_params(path, params)
1558
1629
  url = self.implode_hostname(self.urls['api'][api[0]])
ccxt/ascendex.py CHANGED
@@ -1359,7 +1359,7 @@ class ascendex(Exchange, ImplicitAPI):
1359
1359
  'cost': feeCost,
1360
1360
  'currency': feeCurrencyCode,
1361
1361
  }
1362
- stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1362
+ triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1363
1363
  reduceOnly = None
1364
1364
  execInst = self.safe_string(order, 'execInst')
1365
1365
  if execInst == 'reduceOnly':
@@ -1381,8 +1381,8 @@ class ascendex(Exchange, ImplicitAPI):
1381
1381
  'reduceOnly': reduceOnly,
1382
1382
  'side': side,
1383
1383
  'price': price,
1384
- 'stopPrice': stopPrice,
1385
- 'triggerPrice': stopPrice,
1384
+ 'stopPrice': triggerPrice,
1385
+ 'triggerPrice': triggerPrice,
1386
1386
  'amount': amount,
1387
1387
  'cost': None,
1388
1388
  'average': average,
@@ -1453,7 +1453,7 @@ class ascendex(Exchange, ImplicitAPI):
1453
1453
  :param dict [params]: extra parameters specific to the exchange API endpoint
1454
1454
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1455
1455
  :param bool [params.postOnly]: True or False
1456
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1456
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1457
1457
  :returns dict: request to be sent to the exchange
1458
1458
  """
1459
1459
  market = self.market(symbol)
@@ -1484,7 +1484,7 @@ class ascendex(Exchange, ImplicitAPI):
1484
1484
  timeInForce = self.safe_string(params, 'timeInForce')
1485
1485
  postOnly = self.is_post_only(isMarketOrder, False, params)
1486
1486
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1487
- stopPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1487
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1488
1488
  if isLimitOrder:
1489
1489
  request['orderPrice'] = self.price_to_precision(symbol, price)
1490
1490
  if timeInForce == 'IOC':
@@ -1493,8 +1493,8 @@ class ascendex(Exchange, ImplicitAPI):
1493
1493
  request['timeInForce'] = 'FOK'
1494
1494
  if postOnly:
1495
1495
  request['postOnly'] = True
1496
- if stopPrice is not None:
1497
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1496
+ if triggerPrice is not None:
1497
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1498
1498
  if isLimitOrder:
1499
1499
  request['orderType'] = 'stop_limit'
1500
1500
  elif isMarketOrder:
@@ -1528,7 +1528,7 @@ class ascendex(Exchange, ImplicitAPI):
1528
1528
  :param dict [params]: extra parameters specific to the exchange API endpoint
1529
1529
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1530
1530
  :param bool [params.postOnly]: True or False
1531
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1531
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1532
1532
  :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered(perpetual swap markets only)
1533
1533
  :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
1534
1534
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered(perpetual swap markets only)
@@ -1622,7 +1622,7 @@ class ascendex(Exchange, ImplicitAPI):
1622
1622
  :param dict [params]: extra parameters specific to the exchange API endpoint
1623
1623
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1624
1624
  :param bool [params.postOnly]: True or False
1625
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1625
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1626
1626
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1627
1627
  """
1628
1628
  self.load_markets()
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.38'
7
+ __version__ = '4.4.40'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.alpaca import ImplicitAPI
8
- from ccxt.base.types import Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
8
+ from ccxt.base.types import Balances, Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import PermissionDenied
@@ -44,7 +44,7 @@ class alpaca(Exchange, ImplicitAPI):
44
44
  'test': {
45
45
  'broker': 'https://broker-api.sandbox.{hostname}',
46
46
  'trader': 'https://paper-api.{hostname}',
47
- 'market': 'https://data.sandbox.{hostname}',
47
+ 'market': 'https://data.{hostname}',
48
48
  },
49
49
  'doc': 'https://alpaca.markets/docs/',
50
50
  'fees': 'https://docs.alpaca.markets/docs/crypto-fees',
@@ -64,7 +64,7 @@ class alpaca(Exchange, ImplicitAPI):
64
64
  'createStopOrder': True,
65
65
  'createTriggerOrder': True,
66
66
  'editOrder': True,
67
- 'fetchBalance': False,
67
+ 'fetchBalance': True,
68
68
  'fetchBidsAsks': False,
69
69
  'fetchClosedOrders': True,
70
70
  'fetchCurrencies': False,
@@ -1553,6 +1553,77 @@ class alpaca(Exchange, ImplicitAPI):
1553
1553
  }
1554
1554
  return self.safe_string(types, type, type)
1555
1555
 
1556
+ async def fetch_balance(self, params={}) -> Balances:
1557
+ """
1558
+ query for balance and get the amount of funds available for trading or funds locked in orders
1559
+
1560
+ https://docs.alpaca.markets/reference/getaccount-1
1561
+
1562
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1563
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1564
+ """
1565
+ await self.load_markets()
1566
+ response = await self.traderPrivateGetV2Account(params)
1567
+ #
1568
+ # {
1569
+ # "id": "43a01bde-4eb1-64fssc26adb5",
1570
+ # "admin_configurations": {
1571
+ # "allow_instant_ach": True,
1572
+ # "max_margin_multiplier": "4"
1573
+ # },
1574
+ # "user_configurations": {
1575
+ # "fractional_trading": True,
1576
+ # "max_margin_multiplier": "4"
1577
+ # },
1578
+ # "account_number": "744873727",
1579
+ # "status": "ACTIVE",
1580
+ # "crypto_status": "ACTIVE",
1581
+ # "currency": "USD",
1582
+ # "buying_power": "5.92",
1583
+ # "regt_buying_power": "5.92",
1584
+ # "daytrading_buying_power": "0",
1585
+ # "effective_buying_power": "5.92",
1586
+ # "non_marginable_buying_power": "5.92",
1587
+ # "bod_dtbp": "0",
1588
+ # "cash": "5.92",
1589
+ # "accrued_fees": "0",
1590
+ # "portfolio_value": "48.6",
1591
+ # "pattern_day_trader": False,
1592
+ # "trading_blocked": False,
1593
+ # "transfers_blocked": False,
1594
+ # "account_blocked": False,
1595
+ # "created_at": "2022-06-13T14:59:18.318096Z",
1596
+ # "trade_suspended_by_user": False,
1597
+ # "multiplier": "1",
1598
+ # "shorting_enabled": False,
1599
+ # "equity": "48.6",
1600
+ # "last_equity": "48.8014266",
1601
+ # "long_market_value": "42.68",
1602
+ # "short_market_value": "0",
1603
+ # "position_market_value": "42.68",
1604
+ # "initial_margin": "0",
1605
+ # "maintenance_margin": "0",
1606
+ # "last_maintenance_margin": "0",
1607
+ # "sma": "5.92",
1608
+ # "daytrade_count": 0,
1609
+ # "balance_asof": "2024-12-10",
1610
+ # "crypto_tier": 1,
1611
+ # "intraday_adjustments": "0",
1612
+ # "pending_reg_taf_fees": "0"
1613
+ # }
1614
+ #
1615
+ return self.parse_balance(response)
1616
+
1617
+ def parse_balance(self, response) -> Balances:
1618
+ result: dict = {'info': response}
1619
+ account = self.account()
1620
+ currencyId = self.safe_string(response, 'currency')
1621
+ code = self.safe_currency_code(currencyId)
1622
+ account['free'] = self.safe_string(response, 'cash')
1623
+ account['total'] = self.safe_string(response, 'equity')
1624
+ result[code] = account
1625
+ return self.safe_balance(result)
1626
+
1556
1627
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1557
1628
  endpoint = '/' + self.implode_params(path, params)
1558
1629
  url = self.implode_hostname(self.urls['api'][api[0]])
@@ -1360,7 +1360,7 @@ class ascendex(Exchange, ImplicitAPI):
1360
1360
  'cost': feeCost,
1361
1361
  'currency': feeCurrencyCode,
1362
1362
  }
1363
- stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1363
+ triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1364
1364
  reduceOnly = None
1365
1365
  execInst = self.safe_string(order, 'execInst')
1366
1366
  if execInst == 'reduceOnly':
@@ -1382,8 +1382,8 @@ class ascendex(Exchange, ImplicitAPI):
1382
1382
  'reduceOnly': reduceOnly,
1383
1383
  'side': side,
1384
1384
  'price': price,
1385
- 'stopPrice': stopPrice,
1386
- 'triggerPrice': stopPrice,
1385
+ 'stopPrice': triggerPrice,
1386
+ 'triggerPrice': triggerPrice,
1387
1387
  'amount': amount,
1388
1388
  'cost': None,
1389
1389
  'average': average,
@@ -1454,7 +1454,7 @@ class ascendex(Exchange, ImplicitAPI):
1454
1454
  :param dict [params]: extra parameters specific to the exchange API endpoint
1455
1455
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1456
1456
  :param bool [params.postOnly]: True or False
1457
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1457
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1458
1458
  :returns dict: request to be sent to the exchange
1459
1459
  """
1460
1460
  market = self.market(symbol)
@@ -1485,7 +1485,7 @@ class ascendex(Exchange, ImplicitAPI):
1485
1485
  timeInForce = self.safe_string(params, 'timeInForce')
1486
1486
  postOnly = self.is_post_only(isMarketOrder, False, params)
1487
1487
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1488
- stopPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1488
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1489
1489
  if isLimitOrder:
1490
1490
  request['orderPrice'] = self.price_to_precision(symbol, price)
1491
1491
  if timeInForce == 'IOC':
@@ -1494,8 +1494,8 @@ class ascendex(Exchange, ImplicitAPI):
1494
1494
  request['timeInForce'] = 'FOK'
1495
1495
  if postOnly:
1496
1496
  request['postOnly'] = True
1497
- if stopPrice is not None:
1498
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1497
+ if triggerPrice is not None:
1498
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1499
1499
  if isLimitOrder:
1500
1500
  request['orderType'] = 'stop_limit'
1501
1501
  elif isMarketOrder:
@@ -1529,7 +1529,7 @@ class ascendex(Exchange, ImplicitAPI):
1529
1529
  :param dict [params]: extra parameters specific to the exchange API endpoint
1530
1530
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1531
1531
  :param bool [params.postOnly]: True or False
1532
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1532
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1533
1533
  :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered(perpetual swap markets only)
1534
1534
  :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
1535
1535
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered(perpetual swap markets only)
@@ -1623,7 +1623,7 @@ class ascendex(Exchange, ImplicitAPI):
1623
1623
  :param dict [params]: extra parameters specific to the exchange API endpoint
1624
1624
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1625
1625
  :param bool [params.postOnly]: True or False
1626
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1626
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1627
1627
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1628
1628
  """
1629
1629
  await self.load_markets()
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.38'
5
+ __version__ = '4.4.40'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -88,8 +88,8 @@ class AiohttpClient(Client):
88
88
  # call aenter here to simulate async with otherwise we get the error "await not called with future"
89
89
  # if connecting to a non-existent endpoint
90
90
  if (self.proxy):
91
- return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers'), proxy=self.proxy).__aenter__()
92
- return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers')).__aenter__()
91
+ return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers'), proxy=self.proxy, max_msg_size=10485760).__aenter__()
92
+ return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers'), max_msg_size=10485760).__aenter__()
93
93
 
94
94
  async def send(self, message):
95
95
  if self.verbose:
@@ -6010,14 +6010,10 @@ class binance(Exchange, ImplicitAPI):
6010
6010
  marginMode = None
6011
6011
  marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
6012
6012
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
6013
- if (marketType == 'margin') or (marginMode is not None) or market['option']:
6014
- # for swap and future reduceOnly is a string that cant be sent with close position set to True or in hedge mode
6015
- params = self.omit(params, 'reduceOnly')
6016
- if market['option']:
6017
- request['reduceOnly'] = reduceOnly
6018
- else:
6019
- if reduceOnly:
6020
- request['sideEffectType'] = 'AUTO_REPAY'
6013
+ if reduceOnly:
6014
+ if marketType == 'margin' or (not market['contract'] and (marginMode is not None)):
6015
+ params = self.omit(params, 'reduceOnly')
6016
+ request['sideEffectType'] = 'AUTO_REPAY'
6021
6017
  triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
6022
6018
  stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice) # fallback to stopLoss
6023
6019
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
@@ -6374,7 +6370,7 @@ class binance(Exchange, ImplicitAPI):
6374
6370
  :param int [params.until]: the latest time in ms to fetch orders for
6375
6371
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6376
6372
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
6377
- :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
6373
+ :param boolean [params.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
6378
6374
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6379
6375
  """
6380
6376
  if symbol is None:
@@ -6631,7 +6627,7 @@ class binance(Exchange, ImplicitAPI):
6631
6627
  :param dict [params]: extra parameters specific to the exchange API endpoint
6632
6628
  :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
6633
6629
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch open orders in the portfolio margin account
6634
- :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account conditional orders
6630
+ :param boolean [params.trigger]: set to True if you would like to fetch portfolio margin account conditional orders
6635
6631
  :param str [params.subType]: "linear" or "inverse"
6636
6632
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6637
6633
  """
@@ -6917,7 +6913,7 @@ class binance(Exchange, ImplicitAPI):
6917
6913
  :param dict [params]: extra parameters specific to the exchange API endpoint
6918
6914
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6919
6915
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
6920
- :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
6916
+ :param boolean [params.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
6921
6917
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6922
6918
  """
6923
6919
  if symbol is None:
@@ -6946,7 +6942,7 @@ class binance(Exchange, ImplicitAPI):
6946
6942
  :param dict [params]: extra parameters specific to the exchange API endpoint
6947
6943
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6948
6944
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
6949
- :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
6945
+ :param boolean [params.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
6950
6946
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6951
6947
  """
6952
6948
  if symbol is None:
@@ -6975,7 +6971,7 @@ class binance(Exchange, ImplicitAPI):
6975
6971
  :param dict [params]: extra parameters specific to the exchange API endpoint
6976
6972
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6977
6973
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch orders in a portfolio margin account
6978
- :param boolean [params.stop]: set to True if you would like to fetch portfolio margin account stop or conditional orders
6974
+ :param boolean [params.trigger]: set to True if you would like to fetch portfolio margin account trigger or conditional orders
6979
6975
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
6980
6976
  """
6981
6977
  if symbol is None:
@@ -7006,7 +7002,7 @@ class binance(Exchange, ImplicitAPI):
7006
7002
  :param str symbol: unified symbol of the market the order was made in
7007
7003
  :param dict [params]: extra parameters specific to the exchange API endpoint
7008
7004
  :param boolean [params.portfolioMargin]: set to True if you would like to cancel an order in a portfolio margin account
7009
- :param boolean [params.stop]: set to True if you would like to cancel a portfolio margin account conditional order
7005
+ :param boolean [params.trigger]: set to True if you would like to cancel a portfolio margin account conditional order
7010
7006
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
7011
7007
  """
7012
7008
  if symbol is None:
@@ -7086,7 +7082,7 @@ class binance(Exchange, ImplicitAPI):
7086
7082
  :param dict [params]: extra parameters specific to the exchange API endpoint
7087
7083
  :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
7088
7084
  :param boolean [params.portfolioMargin]: set to True if you would like to cancel orders in a portfolio margin account
7089
- :param boolean [params.stop]: set to True if you would like to cancel portfolio margin account conditional orders
7085
+ :param boolean [params.trigger]: set to True if you would like to cancel portfolio margin account conditional orders
7090
7086
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
7091
7087
  """
7092
7088
  if symbol is None:
@@ -10840,7 +10836,7 @@ class binance(Exchange, ImplicitAPI):
10840
10836
  :param str id: the identification number of the ledger entry
10841
10837
  :param str code: unified currency code
10842
10838
  :param dict [params]: extra parameters specific to the exchange API endpoint
10843
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
10839
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
10844
10840
  """
10845
10841
  await self.load_markets()
10846
10842
  type = None
@@ -10886,7 +10882,7 @@ class binance(Exchange, ImplicitAPI):
10886
10882
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
10887
10883
  :param boolean [params.portfolioMargin]: set to True if you would like to fetch the ledger for a portfolio margin account
10888
10884
  :param str [params.subType]: "linear" or "inverse"
10889
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
10885
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
10890
10886
  """
10891
10887
  await self.load_markets()
10892
10888
  paginate = False
@@ -3440,7 +3440,6 @@ class bingx(Exchange, ImplicitAPI):
3440
3440
  'postOnly': None,
3441
3441
  'side': self.parse_order_side(side),
3442
3442
  'price': self.safe_string_2(order, 'price', 'p'),
3443
- 'stopPrice': triggerPrice,
3444
3443
  'triggerPrice': triggerPrice,
3445
3444
  'stopLossPrice': stopLossPrice,
3446
3445
  'takeProfitPrice': takeProfitPrice,
@@ -5873,7 +5872,7 @@ class bingx(Exchange, ImplicitAPI):
5873
5872
  :param float amount: how much of the currency you want to trade in units of the base currency
5874
5873
  :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5875
5874
  :param dict [params]: extra parameters specific to the exchange API endpoint
5876
- :param str [params.stopPrice]: Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
5875
+ :param str [params.triggerPrice]: Trigger price used for TAKE_STOP_LIMIT, TAKE_STOP_MARKET, TRIGGER_LIMIT, TRIGGER_MARKET order types.
5877
5876
  :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
5878
5877
  :param float [params.takeProfit.triggerPrice]: take profit trigger price
5879
5878
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
@@ -620,7 +620,6 @@ class bit2c(Exchange, ImplicitAPI):
620
620
  'postOnly': None,
621
621
  'side': side,
622
622
  'price': price,
623
- 'stopPrice': None,
624
623
  'triggerPrice': None,
625
624
  'amount': amount,
626
625
  'filled': None,
@@ -636,7 +636,6 @@ class bitbank(Exchange, ImplicitAPI):
636
636
  'postOnly': None,
637
637
  'side': side,
638
638
  'price': price,
639
- 'stopPrice': None,
640
639
  'triggerPrice': None,
641
640
  'cost': None,
642
641
  'average': average,
@@ -552,7 +552,6 @@ class bitbns(Exchange, ImplicitAPI):
552
552
  'postOnly': None,
553
553
  'side': side,
554
554
  'price': self.safe_string(order, 'rate'),
555
- 'stopPrice': triggerPrice,
556
555
  'triggerPrice': triggerPrice,
557
556
  'amount': self.safe_string(order, 'btc'),
558
557
  'cost': None,