ccxt 4.2.59__py2.py3-none-any.whl → 4.2.60__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

ccxt/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.2.59'
25
+ __version__ = '4.2.60'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/blofin.py CHANGED
@@ -19,6 +19,7 @@ class ImplicitAPI:
19
19
  private_get_account_balance = privateGetAccountBalance = Entry('account/balance', 'private', 'GET', {'cost': 1})
20
20
  private_get_account_positions = privateGetAccountPositions = Entry('account/positions', 'private', 'GET', {'cost': 1})
21
21
  private_get_account_leverage_info = privateGetAccountLeverageInfo = Entry('account/leverage-info', 'private', 'GET', {'cost': 1})
22
+ private_get_account_batch_leverage_info = privateGetAccountBatchLeverageInfo = Entry('account/batch-leverage-info', 'private', 'GET', {'cost': 1})
22
23
  private_get_trade_orders_tpsl_pending = privateGetTradeOrdersTpslPending = Entry('trade/orders-tpsl-pending', 'private', 'GET', {'cost': 1})
23
24
  private_get_trade_orders_history = privateGetTradeOrdersHistory = Entry('trade/orders-history', 'private', 'GET', {'cost': 1})
24
25
  private_get_trade_orders_tpsl_history = privateGetTradeOrdersTpslHistory = Entry('trade/orders-tpsl-history', 'private', 'GET', {'cost': 1})
ccxt/abstract/kraken.py CHANGED
@@ -15,43 +15,43 @@ class ImplicitAPI:
15
15
  public_get_trades = publicGetTrades = Entry('Trades', 'public', 'GET', {'cost': 1})
16
16
  private_post_addorder = privatePostAddOrder = Entry('AddOrder', 'private', 'POST', {'cost': 0})
17
17
  private_post_addorderbatch = privatePostAddOrderBatch = Entry('AddOrderBatch', 'private', 'POST', {'cost': 0})
18
- private_post_addexport = privatePostAddExport = Entry('AddExport', 'private', 'POST', {'cost': 1})
19
- private_post_balance = privatePostBalance = Entry('Balance', 'private', 'POST', {'cost': 1})
20
- private_post_cancelall = privatePostCancelAll = Entry('CancelAll', 'private', 'POST', {'cost': 1})
21
- private_post_cancelallordersafter = privatePostCancelAllOrdersAfter = Entry('CancelAllOrdersAfter', 'private', 'POST', {'cost': 1})
18
+ private_post_addexport = privatePostAddExport = Entry('AddExport', 'private', 'POST', {'cost': 3})
19
+ private_post_balance = privatePostBalance = Entry('Balance', 'private', 'POST', {'cost': 3})
20
+ private_post_cancelall = privatePostCancelAll = Entry('CancelAll', 'private', 'POST', {'cost': 3})
21
+ private_post_cancelallordersafter = privatePostCancelAllOrdersAfter = Entry('CancelAllOrdersAfter', 'private', 'POST', {'cost': 3})
22
22
  private_post_cancelorder = privatePostCancelOrder = Entry('CancelOrder', 'private', 'POST', {'cost': 0})
23
23
  private_post_cancelorderbatch = privatePostCancelOrderBatch = Entry('CancelOrderBatch', 'private', 'POST', {'cost': 0})
24
- private_post_closedorders = privatePostClosedOrders = Entry('ClosedOrders', 'private', 'POST', {'cost': 1})
25
- private_post_depositaddresses = privatePostDepositAddresses = Entry('DepositAddresses', 'private', 'POST', {'cost': 1})
26
- private_post_depositmethods = privatePostDepositMethods = Entry('DepositMethods', 'private', 'POST', {'cost': 1})
27
- private_post_depositstatus = privatePostDepositStatus = Entry('DepositStatus', 'private', 'POST', {'cost': 1})
24
+ private_post_closedorders = privatePostClosedOrders = Entry('ClosedOrders', 'private', 'POST', {'cost': 3})
25
+ private_post_depositaddresses = privatePostDepositAddresses = Entry('DepositAddresses', 'private', 'POST', {'cost': 3})
26
+ private_post_depositmethods = privatePostDepositMethods = Entry('DepositMethods', 'private', 'POST', {'cost': 3})
27
+ private_post_depositstatus = privatePostDepositStatus = Entry('DepositStatus', 'private', 'POST', {'cost': 3})
28
28
  private_post_editorder = privatePostEditOrder = Entry('EditOrder', 'private', 'POST', {'cost': 0})
29
- private_post_exportstatus = privatePostExportStatus = Entry('ExportStatus', 'private', 'POST', {'cost': 1})
30
- private_post_getwebsocketstoken = privatePostGetWebSocketsToken = Entry('GetWebSocketsToken', 'private', 'POST', {'cost': 1})
31
- private_post_ledgers = privatePostLedgers = Entry('Ledgers', 'private', 'POST', {'cost': 2})
32
- private_post_openorders = privatePostOpenOrders = Entry('OpenOrders', 'private', 'POST', {'cost': 1})
33
- private_post_openpositions = privatePostOpenPositions = Entry('OpenPositions', 'private', 'POST', {'cost': 1})
34
- private_post_queryledgers = privatePostQueryLedgers = Entry('QueryLedgers', 'private', 'POST', {'cost': 1})
35
- private_post_queryorders = privatePostQueryOrders = Entry('QueryOrders', 'private', 'POST', {'cost': 1})
36
- private_post_querytrades = privatePostQueryTrades = Entry('QueryTrades', 'private', 'POST', {'cost': 1})
37
- private_post_retrieveexport = privatePostRetrieveExport = Entry('RetrieveExport', 'private', 'POST', {'cost': 1})
38
- private_post_removeexport = privatePostRemoveExport = Entry('RemoveExport', 'private', 'POST', {'cost': 1})
39
- private_post_balanceex = privatePostBalanceEx = Entry('BalanceEx', 'private', 'POST', {'cost': 1})
40
- private_post_tradebalance = privatePostTradeBalance = Entry('TradeBalance', 'private', 'POST', {'cost': 1})
41
- private_post_tradeshistory = privatePostTradesHistory = Entry('TradesHistory', 'private', 'POST', {'cost': 2})
42
- private_post_tradevolume = privatePostTradeVolume = Entry('TradeVolume', 'private', 'POST', {'cost': 1})
43
- private_post_withdraw = privatePostWithdraw = Entry('Withdraw', 'private', 'POST', {'cost': 1})
44
- private_post_withdrawcancel = privatePostWithdrawCancel = Entry('WithdrawCancel', 'private', 'POST', {'cost': 1})
45
- private_post_withdrawinfo = privatePostWithdrawInfo = Entry('WithdrawInfo', 'private', 'POST', {'cost': 1})
46
- private_post_withdrawmethods = privatePostWithdrawMethods = Entry('WithdrawMethods', 'private', 'POST', {'cost': 1})
47
- private_post_withdrawaddresses = privatePostWithdrawAddresses = Entry('WithdrawAddresses', 'private', 'POST', {'cost': 1})
48
- private_post_withdrawstatus = privatePostWithdrawStatus = Entry('WithdrawStatus', 'private', 'POST', {'cost': 1})
49
- private_post_wallettransfer = privatePostWalletTransfer = Entry('WalletTransfer', 'private', 'POST', {'cost': 1})
50
- private_post_createsubaccount = privatePostCreateSubaccount = Entry('CreateSubaccount', 'private', 'POST', {'cost': 1})
51
- private_post_accounttransfer = privatePostAccountTransfer = Entry('AccountTransfer', 'private', 'POST', {'cost': 1})
52
- private_post_earn_allocate = privatePostEarnAllocate = Entry('Earn/Allocate', 'private', 'POST', {'cost': 1})
53
- private_post_earn_deallocate = privatePostEarnDeallocate = Entry('Earn/Deallocate', 'private', 'POST', {'cost': 1})
54
- private_post_earn_allocatestatus = privatePostEarnAllocateStatus = Entry('Earn/AllocateStatus', 'private', 'POST', {'cost': 1})
55
- private_post_earn_deallocatestatus = privatePostEarnDeallocateStatus = Entry('Earn/DeallocateStatus', 'private', 'POST', {'cost': 1})
56
- private_post_earn_strategies = privatePostEarnStrategies = Entry('Earn/Strategies', 'private', 'POST', {'cost': 1})
57
- private_post_earn_allocations = privatePostEarnAllocations = Entry('Earn/Allocations', 'private', 'POST', {'cost': 1})
29
+ private_post_exportstatus = privatePostExportStatus = Entry('ExportStatus', 'private', 'POST', {'cost': 3})
30
+ private_post_getwebsocketstoken = privatePostGetWebSocketsToken = Entry('GetWebSocketsToken', 'private', 'POST', {'cost': 3})
31
+ private_post_ledgers = privatePostLedgers = Entry('Ledgers', 'private', 'POST', {'cost': 6})
32
+ private_post_openorders = privatePostOpenOrders = Entry('OpenOrders', 'private', 'POST', {'cost': 3})
33
+ private_post_openpositions = privatePostOpenPositions = Entry('OpenPositions', 'private', 'POST', {'cost': 3})
34
+ private_post_queryledgers = privatePostQueryLedgers = Entry('QueryLedgers', 'private', 'POST', {'cost': 3})
35
+ private_post_queryorders = privatePostQueryOrders = Entry('QueryOrders', 'private', 'POST', {'cost': 3})
36
+ private_post_querytrades = privatePostQueryTrades = Entry('QueryTrades', 'private', 'POST', {'cost': 3})
37
+ private_post_retrieveexport = privatePostRetrieveExport = Entry('RetrieveExport', 'private', 'POST', {'cost': 3})
38
+ private_post_removeexport = privatePostRemoveExport = Entry('RemoveExport', 'private', 'POST', {'cost': 3})
39
+ private_post_balanceex = privatePostBalanceEx = Entry('BalanceEx', 'private', 'POST', {'cost': 3})
40
+ private_post_tradebalance = privatePostTradeBalance = Entry('TradeBalance', 'private', 'POST', {'cost': 3})
41
+ private_post_tradeshistory = privatePostTradesHistory = Entry('TradesHistory', 'private', 'POST', {'cost': 6})
42
+ private_post_tradevolume = privatePostTradeVolume = Entry('TradeVolume', 'private', 'POST', {'cost': 3})
43
+ private_post_withdraw = privatePostWithdraw = Entry('Withdraw', 'private', 'POST', {'cost': 3})
44
+ private_post_withdrawcancel = privatePostWithdrawCancel = Entry('WithdrawCancel', 'private', 'POST', {'cost': 3})
45
+ private_post_withdrawinfo = privatePostWithdrawInfo = Entry('WithdrawInfo', 'private', 'POST', {'cost': 3})
46
+ private_post_withdrawmethods = privatePostWithdrawMethods = Entry('WithdrawMethods', 'private', 'POST', {'cost': 3})
47
+ private_post_withdrawaddresses = privatePostWithdrawAddresses = Entry('WithdrawAddresses', 'private', 'POST', {'cost': 3})
48
+ private_post_withdrawstatus = privatePostWithdrawStatus = Entry('WithdrawStatus', 'private', 'POST', {'cost': 3})
49
+ private_post_wallettransfer = privatePostWalletTransfer = Entry('WalletTransfer', 'private', 'POST', {'cost': 3})
50
+ private_post_createsubaccount = privatePostCreateSubaccount = Entry('CreateSubaccount', 'private', 'POST', {'cost': 3})
51
+ private_post_accounttransfer = privatePostAccountTransfer = Entry('AccountTransfer', 'private', 'POST', {'cost': 3})
52
+ private_post_earn_allocate = privatePostEarnAllocate = Entry('Earn/Allocate', 'private', 'POST', {'cost': 3})
53
+ private_post_earn_deallocate = privatePostEarnDeallocate = Entry('Earn/Deallocate', 'private', 'POST', {'cost': 3})
54
+ private_post_earn_allocatestatus = privatePostEarnAllocateStatus = Entry('Earn/AllocateStatus', 'private', 'POST', {'cost': 3})
55
+ private_post_earn_deallocatestatus = privatePostEarnDeallocateStatus = Entry('Earn/DeallocateStatus', 'private', 'POST', {'cost': 3})
56
+ private_post_earn_strategies = privatePostEarnStrategies = Entry('Earn/Strategies', 'private', 'POST', {'cost': 3})
57
+ private_post_earn_allocations = privatePostEarnAllocations = Entry('Earn/Allocations', 'private', 'POST', {'cost': 3})
ccxt/abstract/wazirx.py CHANGED
@@ -3,7 +3,7 @@ from ccxt.base.types import Entry
3
3
 
4
4
  class ImplicitAPI:
5
5
  public_get_exchangeinfo = publicGetExchangeInfo = Entry('exchangeInfo', 'public', 'GET', {'cost': 1})
6
- public_get_depth = publicGetDepth = Entry('depth', 'public', 'GET', {'cost': 1})
6
+ public_get_depth = publicGetDepth = Entry('depth', 'public', 'GET', {'cost': 0.5})
7
7
  public_get_ping = publicGetPing = Entry('ping', 'public', 'GET', {'cost': 1})
8
8
  public_get_systemstatus = publicGetSystemStatus = Entry('systemStatus', 'public', 'GET', {'cost': 1})
9
9
  public_get_tickers_24hr = publicGetTickers24hr = Entry('tickers/24hr', 'public', 'GET', {'cost': 1})
@@ -18,6 +18,11 @@ class ImplicitAPI:
18
18
  private_get_openorders = privateGetOpenOrders = Entry('openOrders', 'private', 'GET', {'cost': 1})
19
19
  private_get_order = privateGetOrder = Entry('order', 'private', 'GET', {'cost': 0.5})
20
20
  private_get_mytrades = privateGetMyTrades = Entry('myTrades', 'private', 'GET', {'cost': 0.5})
21
+ private_get_coins = privateGetCoins = Entry('coins', 'private', 'GET', {'cost': 12})
22
+ private_get_crypto_withdraws = privateGetCryptoWithdraws = Entry('crypto/withdraws', 'private', 'GET', {'cost': 12})
23
+ private_get_crypto_deposits_address = privateGetCryptoDepositsAddress = Entry('crypto/deposits/address', 'private', 'GET', {'cost': 60})
24
+ private_get_sub_account_fund_transfer_history = privateGetSubAccountFundTransferHistory = Entry('sub_account/fund_transfer/history', 'private', 'GET', {'cost': 1})
25
+ private_get_sub_account_accounts = privateGetSubAccountAccounts = Entry('sub_account/accounts', 'private', 'GET', {'cost': 1})
21
26
  private_post_order = privatePostOrder = Entry('order', 'private', 'POST', {'cost': 0.1})
22
27
  private_post_order_test = privatePostOrderTest = Entry('order/test', 'private', 'POST', {'cost': 0.5})
23
28
  private_post_create_auth_token = privatePostCreateAuthToken = Entry('create_auth_token', 'private', 'POST', {'cost': 1})
ccxt/ascendex.py CHANGED
@@ -751,11 +751,10 @@ class ascendex(Exchange, ImplicitAPI):
751
751
  ]
752
752
 
753
753
  def parse_balance(self, response) -> Balances:
754
- timestamp = self.milliseconds()
755
754
  result = {
756
755
  'info': response,
757
- 'timestamp': timestamp,
758
- 'datetime': self.iso8601(timestamp),
756
+ 'timestamp': None,
757
+ 'datetime': None,
759
758
  }
760
759
  balances = self.safe_value(response, 'data', [])
761
760
  for i in range(0, len(balances)):
@@ -768,11 +767,10 @@ class ascendex(Exchange, ImplicitAPI):
768
767
  return self.safe_balance(result)
769
768
 
770
769
  def parse_margin_balance(self, response):
771
- timestamp = self.milliseconds()
772
770
  result = {
773
771
  'info': response,
774
- 'timestamp': timestamp,
775
- 'datetime': self.iso8601(timestamp),
772
+ 'timestamp': None,
773
+ 'datetime': None,
776
774
  }
777
775
  balances = self.safe_value(response, 'data', [])
778
776
  for i in range(0, len(balances)):
@@ -788,11 +786,10 @@ class ascendex(Exchange, ImplicitAPI):
788
786
  return self.safe_balance(result)
789
787
 
790
788
  def parse_swap_balance(self, response):
791
- timestamp = self.milliseconds()
792
789
  result = {
793
790
  'info': response,
794
- 'timestamp': timestamp,
795
- 'datetime': self.iso8601(timestamp),
791
+ 'timestamp': None,
792
+ 'datetime': None,
796
793
  }
797
794
  data = self.safe_value(response, 'data', {})
798
795
  collaterals = self.safe_value(data, 'collaterals', [])
@@ -811,6 +808,8 @@ class ascendex(Exchange, ImplicitAPI):
811
808
  :see: https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
812
809
  :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
813
810
  :param dict [params]: extra parameters specific to the exchange API endpoint
811
+ :param str [params.type]: wallet type, 'spot', 'margin', or 'swap'
812
+ :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid
814
813
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
815
814
  """
816
815
  self.load_markets()
@@ -3011,12 +3010,11 @@ class ascendex(Exchange, ImplicitAPI):
3011
3010
  #
3012
3011
  status = self.safe_integer(transfer, 'code')
3013
3012
  currencyCode = self.safe_currency_code(None, currency)
3014
- timestamp = self.milliseconds()
3015
3013
  return {
3016
3014
  'info': transfer,
3017
3015
  'id': None,
3018
- 'timestamp': timestamp,
3019
- 'datetime': self.iso8601(timestamp),
3016
+ 'timestamp': None,
3017
+ 'datetime': None,
3020
3018
  'currency': currencyCode,
3021
3019
  'amount': None,
3022
3020
  'fromAccount': None,
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.59'
7
+ __version__ = '4.2.60'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -751,11 +751,10 @@ class ascendex(Exchange, ImplicitAPI):
751
751
  ]
752
752
 
753
753
  def parse_balance(self, response) -> Balances:
754
- timestamp = self.milliseconds()
755
754
  result = {
756
755
  'info': response,
757
- 'timestamp': timestamp,
758
- 'datetime': self.iso8601(timestamp),
756
+ 'timestamp': None,
757
+ 'datetime': None,
759
758
  }
760
759
  balances = self.safe_value(response, 'data', [])
761
760
  for i in range(0, len(balances)):
@@ -768,11 +767,10 @@ class ascendex(Exchange, ImplicitAPI):
768
767
  return self.safe_balance(result)
769
768
 
770
769
  def parse_margin_balance(self, response):
771
- timestamp = self.milliseconds()
772
770
  result = {
773
771
  'info': response,
774
- 'timestamp': timestamp,
775
- 'datetime': self.iso8601(timestamp),
772
+ 'timestamp': None,
773
+ 'datetime': None,
776
774
  }
777
775
  balances = self.safe_value(response, 'data', [])
778
776
  for i in range(0, len(balances)):
@@ -788,11 +786,10 @@ class ascendex(Exchange, ImplicitAPI):
788
786
  return self.safe_balance(result)
789
787
 
790
788
  def parse_swap_balance(self, response):
791
- timestamp = self.milliseconds()
792
789
  result = {
793
790
  'info': response,
794
- 'timestamp': timestamp,
795
- 'datetime': self.iso8601(timestamp),
791
+ 'timestamp': None,
792
+ 'datetime': None,
796
793
  }
797
794
  data = self.safe_value(response, 'data', {})
798
795
  collaterals = self.safe_value(data, 'collaterals', [])
@@ -811,6 +808,8 @@ class ascendex(Exchange, ImplicitAPI):
811
808
  :see: https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
812
809
  :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
813
810
  :param dict [params]: extra parameters specific to the exchange API endpoint
811
+ :param str [params.type]: wallet type, 'spot', 'margin', or 'swap'
812
+ :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid
814
813
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
815
814
  """
816
815
  await self.load_markets()
@@ -3011,12 +3010,11 @@ class ascendex(Exchange, ImplicitAPI):
3011
3010
  #
3012
3011
  status = self.safe_integer(transfer, 'code')
3013
3012
  currencyCode = self.safe_currency_code(None, currency)
3014
- timestamp = self.milliseconds()
3015
3013
  return {
3016
3014
  'info': transfer,
3017
3015
  'id': None,
3018
- 'timestamp': timestamp,
3019
- 'datetime': self.iso8601(timestamp),
3016
+ 'timestamp': None,
3017
+ 'datetime': None,
3020
3018
  'currency': currencyCode,
3021
3019
  'amount': None,
3022
3020
  'fromAccount': None,
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.2.59'
5
+ __version__ = '4.2.60'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -8,7 +8,7 @@ from ccxt.abstract.bingx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import numbers
11
- from ccxt.base.types import Balances, Currency, Int, Leverage, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
11
+ from ccxt.base.types import Balances, Currency, Int, Leverage, MarginMode, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import PermissionDenied
@@ -73,6 +73,7 @@ class bingx(Exchange, ImplicitAPI):
73
73
  'fetchFundingRates': True,
74
74
  'fetchLeverage': True,
75
75
  'fetchLiquidations': False,
76
+ 'fetchMarginMode': True,
76
77
  'fetchMarkets': True,
77
78
  'fetchMarkOHLCV': True,
78
79
  'fetchMyLiquidations': True,
@@ -3899,6 +3900,41 @@ class bingx(Exchange, ImplicitAPI):
3899
3900
  data = self.safe_dict(response, 'data')
3900
3901
  return self.parse_order(data, market)
3901
3902
 
3903
+ async def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
3904
+ """
3905
+ fetches the margin mode of the trading pair
3906
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
3907
+ :param str symbol: unified symbol of the market to fetch the margin mode for
3908
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3909
+ :returns dict: Struct of MarginMode
3910
+ """
3911
+ await self.load_markets()
3912
+ market = self.market(symbol)
3913
+ request: dict = {
3914
+ 'symbol': market['id'],
3915
+ }
3916
+ response = await self.swapV2PrivateGetTradeMarginType(self.extend(request, params))
3917
+ #
3918
+ # {
3919
+ # "code": 0,
3920
+ # "msg": "",
3921
+ # "data": {
3922
+ # "marginType": "CROSSED"
3923
+ # }
3924
+ # }
3925
+ #
3926
+ data = self.safe_dict(response, 'data', {})
3927
+ return self.parse_margin_mode(data, market)
3928
+
3929
+ def parse_margin_mode(self, marginMode, market=None) -> MarginMode:
3930
+ marginType = self.safe_string_lower(marginMode, 'marginType')
3931
+ marginType = 'cross' if (marginType == 'crossed') else marginType
3932
+ return {
3933
+ 'info': marginMode,
3934
+ 'symbol': market['symbol'],
3935
+ 'marginMode': marginType,
3936
+ }
3937
+
3902
3938
  def sign(self, path, section='public', method='GET', params={}, headers=None, body=None):
3903
3939
  type = section[0]
3904
3940
  version = section[1]
@@ -46,8 +46,8 @@ class bitfinex2(Exchange, ImplicitAPI):
46
46
  'spot': True,
47
47
  'margin': True,
48
48
  'swap': True,
49
- 'future': None,
50
- 'option': None,
49
+ 'future': False,
50
+ 'option': False,
51
51
  'addMargin': False,
52
52
  'borrowCrossMargin': False,
53
53
  'borrowIsolatedMargin': False,
@@ -58,6 +58,7 @@ class bitfinex2(Exchange, ImplicitAPI):
58
58
  'createLimitOrder': True,
59
59
  'createMarketOrder': True,
60
60
  'createOrder': True,
61
+ 'createPostOnlyOrder': True,
61
62
  'createReduceOnlyOrder': True,
62
63
  'createStopLimitOrder': True,
63
64
  'createStopMarketOrder': True,
@@ -68,8 +69,11 @@ class bitfinex2(Exchange, ImplicitAPI):
68
69
  'editOrder': True,
69
70
  'fetchBalance': True,
70
71
  'fetchBorrowInterest': False,
72
+ 'fetchBorrowRate': False,
71
73
  'fetchBorrowRateHistories': False,
72
74
  'fetchBorrowRateHistory': False,
75
+ 'fetchBorrowRates': False,
76
+ 'fetchBorrowRatesPerSymbol': False,
73
77
  'fetchClosedOrder': True,
74
78
  'fetchClosedOrders': True,
75
79
  'fetchCrossBorrowRate': False,
@@ -98,6 +102,8 @@ class bitfinex2(Exchange, ImplicitAPI):
98
102
  'fetchOpenOrder': True,
99
103
  'fetchOpenOrders': True,
100
104
  'fetchOrder': True,
105
+ 'fetchOrderBook': True,
106
+ 'fetchOrderBooks': False,
101
107
  'fetchOrderTrades': True,
102
108
  'fetchPosition': False,
103
109
  'fetchPositionMode': False,
@@ -117,6 +123,8 @@ class bitfinex2(Exchange, ImplicitAPI):
117
123
  'setMargin': True,
118
124
  'setMarginMode': False,
119
125
  'setPositionMode': False,
126
+ 'signIn': False,
127
+ 'transfer': True,
120
128
  'withdraw': True,
121
129
  },
122
130
  'timeframes': {
@@ -1484,7 +1492,16 @@ class bitfinex2(Exchange, ImplicitAPI):
1484
1492
  :param float amount: how much you want to trade in units of the base currency
1485
1493
  :param float [price]: the price of the order, in units of the quote currency, ignored in market orders
1486
1494
  :param dict [params]: extra parameters specific to the exchange API endpoint
1487
- :returns dict: request to be sent to the exchange
1495
+ :param float [params.stopPrice]: The price at which a trigger order is triggered at
1496
+ :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1497
+ :param bool [params.postOnly]:
1498
+ :param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
1499
+ :param int [params.flags]: additional order parameters: 4096(Post Only), 1024(Reduce Only), 16384(OCO), 64(Hidden), 512(Close), 524288(No Var Rates)
1500
+ :param int [params.lev]: leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
1501
+ :param str [params.price_traling]: The trailing price for a trailing stop order
1502
+ :param str [params.price_aux_limit]: Order price for stop limit orders
1503
+ :param str [params.price_oco_stop]: OCO stop price
1504
+ :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
1488
1505
  """
1489
1506
  market = self.market(symbol)
1490
1507
  amountString = self.amount_to_precision(symbol, amount)
@@ -2847,8 +2847,13 @@ class bitget(Exchange, ImplicitAPI):
2847
2847
  currencyCode = self.safe_currency_code(self.safe_string(feeStructure, 'feeCoin'))
2848
2848
  fee = {
2849
2849
  'currency': currencyCode,
2850
- 'cost': Precise.string_abs(self.safe_string(feeStructure, 'totalFee')),
2851
2850
  }
2851
+ feeCostString = self.safe_string(feeStructure, 'totalFee')
2852
+ deduction = self.safe_string(feeStructure, 'deduction') is True if 'yes' else False
2853
+ if deduction:
2854
+ fee['cost'] = feeCostString
2855
+ else:
2856
+ fee['cost'] = Precise.string_neg(feeCostString)
2852
2857
  return self.safe_trade({
2853
2858
  'info': trade,
2854
2859
  'id': self.safe_string(trade, 'tradeId'),
@@ -3866,7 +3871,7 @@ class bitget(Exchange, ImplicitAPI):
3866
3871
  :see: https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
3867
3872
  :param str symbol: unified symbol of the market to create an order in
3868
3873
  :param str type: 'market' or 'limit'
3869
- :param str side: 'buy' or 'sell' or 'open_long' or 'open_short' or 'close_long' or 'close_short'
3874
+ :param str side: 'buy' or 'sell'
3870
3875
  :param float amount: how much you want to trade in units of the base currency
3871
3876
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
3872
3877
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -530,6 +530,7 @@ class bitmart(Exchange, ImplicitAPI):
530
530
  },
531
531
  'networks': {
532
532
  'ERC20': 'ERC20',
533
+ 'SOL': 'SOL',
533
534
  'BTC': 'BTC',
534
535
  'TRC20': 'TRC20',
535
536
  # todo: should be TRX after unification
@@ -552,7 +553,6 @@ class bitmart(Exchange, ImplicitAPI):
552
553
  'FIO': 'FIO',
553
554
  'SCRT': 'SCRT',
554
555
  'IOTX': 'IOTX',
555
- 'SOL': 'SOL',
556
556
  'ALGO': 'ALGO',
557
557
  'ATOM': 'ATOM',
558
558
  'DOT': 'DOT',
@@ -2886,6 +2886,7 @@ class bitmart(Exchange, ImplicitAPI):
2886
2886
  async def fetch_deposit_address(self, code: str, params={}):
2887
2887
  """
2888
2888
  fetch the deposit address for a currency associated with self account
2889
+ :see: https://developer-pro.bitmart.com/en/spot/#deposit-address-keyed
2889
2890
  :param str code: unified currency code
2890
2891
  :param dict [params]: extra parameters specific to the exchange API endpoint
2891
2892
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
@@ -2906,39 +2907,55 @@ class bitmart(Exchange, ImplicitAPI):
2906
2907
  params = self.omit(params, 'network')
2907
2908
  response = await self.privateGetAccountV1DepositAddress(self.extend(request, params))
2908
2909
  #
2909
- # {
2910
- # "message":"OK",
2911
- # "code":1000,
2912
- # "trace":"0e6edd79-f77f-4251-abe5-83ba75d06c1a",
2913
- # "data":{
2914
- # "currency":"USDT-TRC20",
2915
- # "chain":"USDT-TRC20",
2916
- # "address":"TGR3ghy2b5VLbyAYrmiE15jasR6aPHTvC5",
2917
- # "address_memo":""
2918
- # }
2919
- # }
2910
+ # {
2911
+ # "message": "OK",
2912
+ # "code": 1000,
2913
+ # "trace": "0e6edd79-f77f-4251-abe5-83ba75d06c1a",
2914
+ # "data": {
2915
+ # currency: 'ETH',
2916
+ # chain: 'Ethereum',
2917
+ # address: '0x99B5EEc2C520f86F0F62F05820d28D05D36EccCf',
2918
+ # address_memo: ''
2919
+ # }
2920
+ # }
2920
2921
  #
2921
2922
  data = self.safe_value(response, 'data', {})
2922
- address = self.safe_string(data, 'address')
2923
- tag = self.safe_string(data, 'address_memo')
2924
- chain = self.safe_string(data, 'chain')
2923
+ return self.parse_deposit_address(data, currency)
2924
+
2925
+ def parse_deposit_address(self, depositAddress, currency=None):
2926
+ #
2927
+ # {
2928
+ # currency: 'ETH',
2929
+ # chain: 'Ethereum',
2930
+ # address: '0x99B5EEc2C520f86F0F62F05820d28D05D36EccCf',
2931
+ # address_memo: ''
2932
+ # }
2933
+ #
2934
+ currencyId = self.safe_string(depositAddress, 'currency')
2935
+ address = self.safe_string(depositAddress, 'address')
2936
+ chain = self.safe_string(depositAddress, 'chain')
2925
2937
  network = None
2938
+ currency = self.safe_currency(currencyId, currency)
2926
2939
  if chain is not None:
2927
2940
  parts = chain.split('-')
2928
- networkId = self.safe_string(parts, 1)
2929
- network = self.safe_network(networkId)
2941
+ partsLength = len(parts)
2942
+ networkId = self.safe_string(parts, partsLength - 1)
2943
+ network = self.safe_network_code(networkId, currency)
2930
2944
  self.check_address(address)
2931
2945
  return {
2932
- 'currency': code,
2946
+ 'info': depositAddress,
2947
+ 'currency': self.safe_string(currency, 'code'),
2933
2948
  'address': address,
2934
- 'tag': tag,
2949
+ 'tag': self.safe_string(depositAddress, 'address_memo'),
2935
2950
  'network': network,
2936
- 'info': response,
2937
2951
  }
2938
2952
 
2939
- def safe_network(self, networkId):
2940
- # TODO: parse
2941
- return networkId
2953
+ def safe_network_code(self, networkId, currency=None):
2954
+ name = self.safe_string(currency, 'name')
2955
+ if networkId == name:
2956
+ code = self.safe_string(currency, 'code')
2957
+ return code
2958
+ return self.network_id_to_code(networkId)
2942
2959
 
2943
2960
  async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2944
2961
  """
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.blofin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Leverage, Market, Order, TransferEntry, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, Market, Order, TransferEntry, 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 ArgumentsRequired
@@ -89,6 +89,7 @@ class blofin(Exchange, ImplicitAPI):
89
89
  'fetchLedger': True,
90
90
  'fetchLedgerEntry': None,
91
91
  'fetchLeverage': True,
92
+ 'fetchLeverages': True,
92
93
  'fetchLeverageTiers': False,
93
94
  'fetchMarketLeverageTiers': False,
94
95
  'fetchMarkets': True,
@@ -193,6 +194,7 @@ class blofin(Exchange, ImplicitAPI):
193
194
  'account/balance': 1,
194
195
  'account/positions': 1,
195
196
  'account/leverage-info': 1,
197
+ 'account/batch-leverage-info': 1,
196
198
  'trade/orders-tpsl-pending': 1,
197
199
  'trade/orders-history': 1,
198
200
  'trade/orders-tpsl-history': 1,
@@ -1757,10 +1759,58 @@ class blofin(Exchange, ImplicitAPI):
1757
1759
  'takeProfitPrice': None,
1758
1760
  })
1759
1761
 
1762
+ async def fetch_leverages(self, symbols: List[str] = None, params={}) -> Leverages:
1763
+ """
1764
+ fetch the set leverage for all contract markets
1765
+ :see: https://docs.blofin.com/index.html#get-multiple-leverage
1766
+ :param str[] symbols: a list of unified market symbols, required on blofin
1767
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1768
+ :param str [params.marginMode]: 'cross' or 'isolated'
1769
+ :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
1770
+ """
1771
+ await self.load_markets()
1772
+ if symbols is None:
1773
+ raise ArgumentsRequired(self.id + ' fetchLeverages() requires a symbols argument')
1774
+ marginMode = None
1775
+ marginMode, params = self.handle_margin_mode_and_params('fetchLeverages', params)
1776
+ if marginMode is None:
1777
+ marginMode = self.safe_string(params, 'marginMode', 'cross') # cross marginMode
1778
+ if (marginMode != 'cross') and (marginMode != 'isolated'):
1779
+ raise BadRequest(self.id + ' fetchLeverages() requires a marginMode parameter that must be either cross or isolated')
1780
+ symbols = self.market_symbols(symbols)
1781
+ instIds = ''
1782
+ for i in range(0, len(symbols)):
1783
+ entry = symbols[i]
1784
+ entryMarket = self.market(entry)
1785
+ if i > 0:
1786
+ instIds = instIds + ',' + entryMarket['id']
1787
+ else:
1788
+ instIds = instIds + entryMarket['id']
1789
+ request = {
1790
+ 'instId': instIds,
1791
+ 'marginMode': marginMode,
1792
+ }
1793
+ response = await self.privateGetAccountBatchLeverageInfo(self.extend(request, params))
1794
+ #
1795
+ # {
1796
+ # "code": "0",
1797
+ # "msg": "success",
1798
+ # "data": [
1799
+ # {
1800
+ # "leverage": "3",
1801
+ # "marginMode": "cross",
1802
+ # "instId": "BTC-USDT"
1803
+ # },
1804
+ # ]
1805
+ # }
1806
+ #
1807
+ leverages = self.safe_list(response, 'data', [])
1808
+ return self.parse_leverages(leverages, symbols, 'instId')
1809
+
1760
1810
  async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
1761
1811
  """
1762
1812
  fetch the set leverage for a market
1763
- :see: https://blofin.com/docs#set-leverage
1813
+ :see: https://docs.blofin.com/index.html#get-leverage
1764
1814
  :param str symbol: unified market symbol
1765
1815
  :param dict [params]: extra parameters specific to the exchange API endpoint
1766
1816
  :param str [params.marginMode]: 'cross' or 'isolated'
@@ -2508,7 +2508,7 @@ class hitbtc(Exchange, ImplicitAPI):
2508
2508
  if (network is not None) and (code == 'USDT'):
2509
2509
  parsedNetwork = self.safe_string(networks, network)
2510
2510
  if parsedNetwork is not None:
2511
- request['currency'] = parsedNetwork
2511
+ request['network_code'] = parsedNetwork
2512
2512
  params = self.omit(params, 'network')
2513
2513
  withdrawOptions = self.safe_value(self.options, 'withdraw', {})
2514
2514
  includeFee = self.safe_bool(withdrawOptions, 'includeFee', False)