ccxt 4.4.62__py2.py3-none-any.whl → 4.4.64__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.
@@ -24,7 +24,6 @@ from ccxt.base.errors import OrderImmediatelyFillable
24
24
  from ccxt.base.errors import NotSupported
25
25
  from ccxt.base.errors import RateLimitExceeded
26
26
  from ccxt.base.errors import ExchangeNotAvailable
27
- from ccxt.base.errors import BadResponse
28
27
  from ccxt.base.decimal_to_precision import TICK_SIZE
29
28
  from ccxt.base.precise import Precise
30
29
 
@@ -1798,100 +1797,80 @@ class gate(Exchange, ImplicitAPI):
1798
1797
  await self.load_unified_status()
1799
1798
  response = await self.publicSpotGetCurrencies(params)
1800
1799
  #
1801
- # {
1802
- # "currency": "BCN",
1803
- # "delisted": False,
1804
- # "withdraw_disabled": True,
1805
- # "withdraw_delayed": False,
1806
- # "deposit_disabled": True,
1807
- # "trade_disabled": False
1808
- # }
1809
- #
1810
- # {
1811
- # "currency":"USDT_ETH",
1812
- # "delisted":false,
1813
- # "withdraw_disabled":false,
1814
- # "withdraw_delayed":false,
1815
- # "deposit_disabled":false,
1816
- # "trade_disabled":false,
1817
- # "chain":"ETH"
1818
- # }
1819
- #
1800
+ # [
1801
+ # {
1802
+ # "currency": "USDT_ETH",
1803
+ # "name": "Tether",
1804
+ # "delisted": False,
1805
+ # "withdraw_disabled": False,
1806
+ # "withdraw_delayed": False,
1807
+ # "deposit_disabled": False,
1808
+ # "trade_disabled": True,
1809
+ # "chain": "ETH"
1810
+ # },
1811
+ # ]
1812
+ #
1813
+ indexedCurrencies = self.index_by(response, 'currency')
1820
1814
  result: dict = {}
1821
1815
  for i in range(0, len(response)):
1822
1816
  entry = response[i]
1823
1817
  currencyId = self.safe_string(entry, 'currency')
1824
- currencyIdLower = self.safe_string_lower(entry, 'currency')
1825
1818
  parts = currencyId.split('_')
1826
- currency = parts[0]
1827
- code = self.safe_currency_code(currency)
1828
- networkId = self.safe_string(entry, 'chain')
1829
- networkCode = None
1830
- if networkId is not None:
1831
- networkCode = self.network_id_to_code(networkId, code)
1832
- delisted = self.safe_value(entry, 'delisted')
1833
- withdrawDisabled = self.safe_bool(entry, 'withdraw_disabled', False)
1834
- depositDisabled = self.safe_bool(entry, 'deposit_disabled', False)
1835
- tradeDisabled = self.safe_bool(entry, 'trade_disabled', False)
1836
- withdrawEnabled = not withdrawDisabled
1837
- depositEnabled = not depositDisabled
1838
- tradeEnabled = not tradeDisabled
1839
- listed = not delisted
1840
- active = listed and tradeEnabled and withdrawEnabled and depositEnabled
1841
- if self.safe_value(result, code) is None:
1819
+ partFirst = self.safe_string(parts, 0)
1820
+ # if there's an underscore then the second part is always the chain name(except the _OLD suffix)
1821
+ currencyName = currencyId if currencyId.endswith('_OLD') else partFirst
1822
+ withdrawEnabled = not self.safe_bool(entry, 'withdraw_disabled')
1823
+ depositEnabled = not self.safe_bool(entry, 'deposit_disabled')
1824
+ tradeDisabled = not self.safe_bool(entry, 'trade_disabled')
1825
+ precision = self.parse_number('0.0001') # temporary safe default, because no value provided from API
1826
+ code = self.safe_currency_code(currencyName)
1827
+ # check leveraged tokens(e.g. BTC3S, ETH5L)
1828
+ isLeveragedToken = False
1829
+ if currencyId.endswith('3S') or currencyId.endswith('3L') or currencyId.endswith('5S') or currencyId.endswith('5L'):
1830
+ realCurrencyId = currencyId[0:-2]
1831
+ if realCurrencyId in indexedCurrencies:
1832
+ isLeveragedToken = True
1833
+ type = 'leveraged' if isLeveragedToken else 'crypto'
1834
+ # some networks are null, they are mostly obsolete & unsupported dead tokens, so we can default their networkId to their tokenname
1835
+ networkId = self.safe_string(entry, 'chain', currencyId)
1836
+ networkCode = self.network_id_to_code(networkId, code)
1837
+ networkEntry = {
1838
+ 'info': entry,
1839
+ 'id': networkId,
1840
+ 'network': networkCode,
1841
+ 'limits': {
1842
+ 'deposit': {
1843
+ 'min': None,
1844
+ 'max': None,
1845
+ },
1846
+ 'withdraw': {
1847
+ 'min': None,
1848
+ 'max': None,
1849
+ },
1850
+ },
1851
+ 'active': not tradeDisabled,
1852
+ 'deposit': depositEnabled,
1853
+ 'withdraw': withdrawEnabled,
1854
+ 'fee': None,
1855
+ 'precision': precision,
1856
+ }
1857
+ # check if first entry for the specific currency
1858
+ if not (code in result):
1842
1859
  result[code] = {
1843
- 'id': currency,
1860
+ 'id': currencyName,
1861
+ 'lowerCaseId': currencyName.lower(),
1844
1862
  'code': code,
1845
- 'info': None,
1846
- 'name': None,
1847
- 'active': active,
1848
- 'deposit': depositEnabled,
1849
- 'withdraw': withdrawEnabled,
1850
- 'fee': None,
1851
- 'fees': [],
1852
- 'precision': self.parse_number('1e-4'),
1863
+ 'type': type,
1864
+ 'precision': precision,
1853
1865
  'limits': self.limits,
1854
1866
  'networks': {},
1867
+ 'info': [], # will be filled below
1855
1868
  }
1856
- depositAvailable = self.safe_value(result[code], 'deposit')
1857
- depositAvailable = depositEnabled if (depositEnabled) else depositAvailable
1858
- withdrawAvailable = self.safe_value(result[code], 'withdraw')
1859
- withdrawAvailable = withdrawEnabled if (withdrawEnabled) else withdrawAvailable
1860
- networks = self.safe_value(result[code], 'networks', {})
1861
- if networkCode is not None:
1862
- networks[networkCode] = {
1863
- 'info': entry,
1864
- 'id': networkId,
1865
- 'network': networkCode,
1866
- 'currencyId': currencyId,
1867
- 'lowerCaseCurrencyId': currencyIdLower,
1868
- 'deposit': depositEnabled,
1869
- 'withdraw': withdrawEnabled,
1870
- 'active': active,
1871
- 'fee': None,
1872
- 'precision': self.parse_number('1e-4'),
1873
- 'limits': {
1874
- 'amount': {
1875
- 'min': None,
1876
- 'max': None,
1877
- },
1878
- 'withdraw': {
1879
- 'min': None,
1880
- 'max': None,
1881
- },
1882
- 'deposit': {
1883
- 'min': None,
1884
- 'max': None,
1885
- },
1886
- },
1887
- }
1888
- result[code]['networks'] = networks
1889
- info = self.safe_value(result[code], 'info', [])
1869
+ result[code]['networks'][networkCode] = networkEntry
1870
+ info = self.safe_list(result[code], 'info', [])
1890
1871
  info.append(entry)
1891
1872
  result[code]['info'] = info
1892
- result[code]['active'] = depositAvailable and withdrawAvailable
1893
- result[code]['deposit'] = depositAvailable
1894
- result[code]['withdraw'] = withdrawAvailable
1873
+ result[code] = self.safe_currency_structure(result[code]) # self is needed after adding network entry
1895
1874
  return result
1896
1875
 
1897
1876
  async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
@@ -2136,6 +2115,27 @@ class gate(Exchange, ImplicitAPI):
2136
2115
  }
2137
2116
  return result
2138
2117
 
2118
+ async def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
2119
+ """
2120
+ fetch a dictionary of addresses for a currency, indexed by network
2121
+ :param str code: unified currency code of the currency for the deposit address
2122
+ :param dict [params]: extra parameters specific to the api endpoint
2123
+ :returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
2124
+ """
2125
+ await self.load_markets()
2126
+ currency = self.currency(code)
2127
+ request = {
2128
+ 'currency': currency['id'],
2129
+ }
2130
+ response = await self.privateWalletGetDepositAddress(self.extend(request, params))
2131
+ chains = self.safe_value(response, 'multichain_addresses', [])
2132
+ currencyId = self.safe_string(response, 'currency')
2133
+ currency = self.safe_currency(currencyId, currency)
2134
+ parsed = self.parse_deposit_addresses(chains, [currency['code']], False, {
2135
+ 'currency': currency['id'],
2136
+ })
2137
+ return self.index_by(parsed, 'network')
2138
+
2139
2139
  async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
2140
2140
  """
2141
2141
  fetch the deposit address for a currency associated with self account
@@ -2148,65 +2148,30 @@ class gate(Exchange, ImplicitAPI):
2148
2148
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
2149
2149
  """
2150
2150
  await self.load_markets()
2151
- currency = self.currency(code)
2152
- rawNetwork = self.safe_string_upper(params, 'network')
2153
- params = self.omit(params, 'network')
2154
- request: dict = {
2155
- 'currency': currency['id'], # todo: currencies have network-junctions
2156
- }
2157
- response = await self.privateWalletGetDepositAddress(self.extend(request, params))
2151
+ networkCode = None
2152
+ networkCode, params = self.handle_network_code_and_params(params)
2153
+ chainsIndexedById = await self.fetch_deposit_addresses_by_network(code, params)
2154
+ selectedNetworkId = self.select_network_code_from_unified_networks(code, networkCode, chainsIndexedById)
2155
+ return chainsIndexedById[selectedNetworkId]
2156
+
2157
+ def parse_deposit_address(self, depositAddress, currency=None):
2158
2158
  #
2159
- # {
2160
- # "currency": "XRP",
2161
- # "address": "rHcFoo6a9qT5NHiVn1THQRhsEGcxtYCV4d 391331007",
2162
- # "multichain_addresses": [
2163
- # {
2164
- # "chain": "XRP",
2165
- # "address": "rHcFoo6a9qT5NHiVn1THQRhsEGcxtYCV4d",
2166
- # "payment_id": "391331007",
2167
- # "payment_name": "Tag",
2168
- # "obtain_failed": 0
2169
- # }
2170
- # ]
2171
- # }
2159
+ # {
2160
+ # chain: "BTC",
2161
+ # address: "1Nxu.......Ys",
2162
+ # payment_id: "",
2163
+ # payment_name: "",
2164
+ # obtain_failed: "0",
2165
+ # }
2172
2166
  #
2173
- currencyId = self.safe_string(response, 'currency')
2174
- code = self.safe_currency_code(currencyId)
2175
- networkId = self.network_code_to_id(rawNetwork, code)
2176
- network = None
2177
- tag = None
2178
- address = None
2179
- if networkId is not None:
2180
- addresses = self.safe_value(response, 'multichain_addresses')
2181
- for i in range(0, len(addresses)):
2182
- entry = addresses[i]
2183
- entryNetwork = self.safe_string(entry, 'chain')
2184
- if networkId == entryNetwork:
2185
- obtainFailed = self.safe_integer(entry, 'obtain_failed')
2186
- if obtainFailed:
2187
- break
2188
- address = self.safe_string(entry, 'address')
2189
- tag = self.safe_string(entry, 'payment_id')
2190
- network = self.network_id_to_code(networkId, code)
2191
- break
2192
- else:
2193
- addressField = self.safe_string(response, 'address')
2194
- if addressField is not None:
2195
- if addressField.find('New address is being generated for you, please wait') >= 0:
2196
- raise BadResponse(self.id + ' ' + 'New address is being generated for you, please wait a few seconds and try again to get the address.')
2197
- if addressField.find(' ') >= 0:
2198
- splitted = addressField.split(' ')
2199
- address = splitted[0]
2200
- tag = splitted[1]
2201
- else:
2202
- address = addressField
2167
+ address = self.safe_string(depositAddress, 'address')
2203
2168
  self.check_address(address)
2204
2169
  return {
2205
- 'info': response,
2206
- 'currency': code,
2207
- 'network': network,
2170
+ 'info': depositAddress,
2171
+ 'currency': self.safe_string(currency, 'code'),
2208
2172
  'address': address,
2209
- 'tag': tag,
2173
+ 'tag': self.safe_string(depositAddress, 'payment_id'),
2174
+ 'network': self.network_id_to_code(self.safe_string(depositAddress, 'chain')),
2210
2175
  }
2211
2176
 
2212
2177
  async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
@@ -3819,14 +3784,10 @@ class gate(Exchange, ImplicitAPI):
3819
3784
  }
3820
3785
  if tag is not None:
3821
3786
  request['memo'] = tag
3822
- networks = self.safe_value(self.options, 'networks', {})
3823
- network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
3824
- network = self.safe_string_lower(networks, network, network) # handle ETH>ERC20 alias
3825
- if network is not None:
3826
- request['chain'] = network
3827
- params = self.omit(params, 'network')
3828
- else:
3829
- request['chain'] = currency['id'] # todo: currencies have network-junctions
3787
+ networkCode = None
3788
+ networkCode, params = self.handle_network_code_and_params(params)
3789
+ if networkCode is not None:
3790
+ request['chain'] = self.network_code_to_id(networkCode)
3830
3791
  response = await self.privateWithdrawalsPostWithdrawals(self.extend(request, params))
3831
3792
  #
3832
3793
  # {
@@ -5,6 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.phemex import ImplicitAPI
8
+ import asyncio
8
9
  import hashlib
9
10
  import numbers
10
11
  from ccxt.base.types import Any, Balances, Conversion, Currencies, Currency, DepositAddress, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, Transaction, TransferEntry
@@ -685,7 +686,8 @@ class phemex(Exchange, ImplicitAPI):
685
686
  # }
686
687
  #
687
688
  id = self.safe_string(market, 'symbol')
688
- baseId = self.safe_string_2(market, 'baseCurrency', 'contractUnderlyingAssets')
689
+ contractUnderlyingAssets = self.safe_string(market, 'contractUnderlyingAssets')
690
+ baseId = self.safe_string(market, 'baseCurrency', contractUnderlyingAssets)
689
691
  quoteId = self.safe_string(market, 'quoteCurrency')
690
692
  settleId = self.safe_string(market, 'settleCurrency')
691
693
  base = self.safe_currency_code(baseId)
@@ -695,6 +697,9 @@ class phemex(Exchange, ImplicitAPI):
695
697
  inverse = False
696
698
  if settleId != quoteId:
697
699
  inverse = True
700
+ # some unhandled cases
701
+ if not ('baseCurrency' in market) and base == quote:
702
+ base = settle
698
703
  priceScale = self.safe_integer(market, 'priceScale')
699
704
  ratioScale = self.safe_integer(market, 'ratioScale')
700
705
  valueScale = self.safe_integer(market, 'valueScale')
@@ -880,7 +885,7 @@ class phemex(Exchange, ImplicitAPI):
880
885
  :param dict [params]: extra parameters specific to the exchange API endpoint
881
886
  :returns dict[]: an array of objects representing market data
882
887
  """
883
- v2Products = await self.v2GetPublicProducts(params)
888
+ v2ProductsPromise = self.v2GetPublicProducts(params)
884
889
  #
885
890
  # {
886
891
  # "code":0,
@@ -1030,7 +1035,8 @@ class phemex(Exchange, ImplicitAPI):
1030
1035
  # }
1031
1036
  # }
1032
1037
  #
1033
- v1Products = await self.v1GetExchangePublicProducts(params)
1038
+ v1ProductsPromise = self.v1GetExchangePublicProducts(params)
1039
+ v2Products, v1Products = await asyncio.gather(*[v2ProductsPromise, v1ProductsPromise])
1034
1040
  v1ProductsData = self.safe_value(v1Products, 'data', [])
1035
1041
  #
1036
1042
  # {
@@ -1067,14 +1073,14 @@ class phemex(Exchange, ImplicitAPI):
1067
1073
  # ]
1068
1074
  # }
1069
1075
  #
1070
- v2ProductsData = self.safe_value(v2Products, 'data', {})
1071
- products = self.safe_value(v2ProductsData, 'products', [])
1072
- perpetualProductsV2 = self.safe_value(v2ProductsData, 'perpProductsV2', [])
1076
+ v2ProductsData = self.safe_dict(v2Products, 'data', {})
1077
+ products = self.safe_list(v2ProductsData, 'products', [])
1078
+ perpetualProductsV2 = self.safe_list(v2ProductsData, 'perpProductsV2', [])
1073
1079
  products = self.array_concat(products, perpetualProductsV2)
1074
- riskLimits = self.safe_value(v2ProductsData, 'riskLimits', [])
1075
- riskLimitsV2 = self.safe_value(v2ProductsData, 'riskLimitsV2', [])
1080
+ riskLimits = self.safe_list(v2ProductsData, 'riskLimits', [])
1081
+ riskLimitsV2 = self.safe_list(v2ProductsData, 'riskLimitsV2', [])
1076
1082
  riskLimits = self.array_concat(riskLimits, riskLimitsV2)
1077
- currencies = self.safe_value(v2ProductsData, 'currencies', [])
1083
+ currencies = self.safe_list(v2ProductsData, 'currencies', [])
1078
1084
  riskLimitsById = self.index_by(riskLimits, 'symbol')
1079
1085
  v1ProductsById = self.index_by(v1ProductsData, 'symbol')
1080
1086
  currenciesByCode = self.index_by(currencies, 'currency')
@@ -1084,14 +1090,14 @@ class phemex(Exchange, ImplicitAPI):
1084
1090
  type = self.safe_string_lower(market, 'type')
1085
1091
  if (type == 'perpetual') or (type == 'perpetualv2') or (type == 'perpetualpilot'):
1086
1092
  id = self.safe_string(market, 'symbol')
1087
- riskLimitValues = self.safe_value(riskLimitsById, id, {})
1093
+ riskLimitValues = self.safe_dict(riskLimitsById, id, {})
1088
1094
  market = self.extend(market, riskLimitValues)
1089
- v1ProductsValues = self.safe_value(v1ProductsById, id, {})
1095
+ v1ProductsValues = self.safe_dict(v1ProductsById, id, {})
1090
1096
  market = self.extend(market, v1ProductsValues)
1091
1097
  market = self.parse_swap_market(market)
1092
1098
  else:
1093
1099
  baseCurrency = self.safe_string(market, 'baseCurrency')
1094
- currencyValues = self.safe_value(currenciesByCode, baseCurrency, {})
1100
+ currencyValues = self.safe_dict(currenciesByCode, baseCurrency, {})
1095
1101
  valueScale = self.safe_string(currencyValues, 'valueScale', '8')
1096
1102
  market = self.extend(market, {'valueScale': valueScale})
1097
1103
  market = self.parse_spot_market(market)
@@ -511,11 +511,11 @@ class tradeogre(Exchange, ImplicitAPI):
511
511
  if type == 'market':
512
512
  raise BadRequest(self.id + ' createOrder does not support market orders')
513
513
  if price is None:
514
- raise ArgumentsRequired(self.id + ' createOrder requires a limit parameter')
514
+ raise ArgumentsRequired(self.id + ' createOrder requires a price parameter')
515
515
  request: dict = {
516
516
  'market': market['id'],
517
- 'quantity': self.parse_to_numeric(self.amount_to_precision(symbol, amount)),
518
- 'price': self.parse_to_numeric(self.price_to_precision(symbol, price)),
517
+ 'quantity': self.amount_to_precision(symbol, amount),
518
+ 'price': self.price_to_precision(symbol, price),
519
519
  }
520
520
  response = None
521
521
  if side == 'buy':
@@ -2603,12 +2603,10 @@ class whitebit(Exchange, ImplicitAPI):
2603
2603
  url += '?' + self.urlencode(query)
2604
2604
  if accessibility == 'private':
2605
2605
  self.check_required_credentials()
2606
- nonce = self.nonce()
2607
- timestamp = self.parse_to_int(nonce / 1000)
2608
- timestampString = str(timestamp)
2606
+ nonce = str(self.nonce())
2609
2607
  secret = self.encode(self.secret)
2610
2608
  request = '/' + 'api' + '/' + version + pathWithParams
2611
- body = self.json(self.extend({'request': request, 'nonce': timestampString}, params))
2609
+ body = self.json(self.extend({'request': request, 'nonce': nonce}, params))
2612
2610
  payload = self.string_to_base64(body)
2613
2611
  signature = self.hmac(self.encode(payload), secret, hashlib.sha512)
2614
2612
  headers = {
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.62'
7
+ __version__ = '4.4.64'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -1450,11 +1450,11 @@ class Exchange(object):
1450
1450
 
1451
1451
  @staticmethod
1452
1452
  def encode(string):
1453
- return string.encode('latin-1')
1453
+ return string.encode('utf-8')
1454
1454
 
1455
1455
  @staticmethod
1456
1456
  def decode(string):
1457
- return string.decode('latin-1')
1457
+ return string.decode('utf-8')
1458
1458
 
1459
1459
  @staticmethod
1460
1460
  def to_array(value):
@@ -2903,6 +2903,9 @@ class Exchange(object):
2903
2903
 
2904
2904
  def safe_currency_structure(self, currency: object):
2905
2905
  # derive data from networks: deposit, withdraw, active, fee, limits, precision
2906
+ currencyDeposit = self.safe_bool(currency, 'deposit')
2907
+ currencyWithdraw = self.safe_bool(currency, 'withdraw')
2908
+ currencyActive = self.safe_bool(currency, 'active')
2906
2909
  networks = self.safe_dict(currency, 'networks', {})
2907
2910
  keys = list(networks.keys())
2908
2911
  length = len(keys)
@@ -2910,13 +2913,13 @@ class Exchange(object):
2910
2913
  for i in range(0, length):
2911
2914
  network = networks[keys[i]]
2912
2915
  deposit = self.safe_bool(network, 'deposit')
2913
- if currency['deposit'] is None or deposit:
2916
+ if currencyDeposit is None or deposit:
2914
2917
  currency['deposit'] = deposit
2915
2918
  withdraw = self.safe_bool(network, 'withdraw')
2916
- if currency['withdraw'] is None or withdraw:
2919
+ if currencyWithdraw is None or withdraw:
2917
2920
  currency['withdraw'] = withdraw
2918
2921
  active = self.safe_bool(network, 'active')
2919
- if currency['active'] is None or active:
2922
+ if currencyActive is None or active:
2920
2923
  currency['active'] = active
2921
2924
  # find lowest fee(which is more desired)
2922
2925
  fee = self.safe_string(network, 'fee')
@@ -4065,7 +4068,9 @@ class Exchange(object):
4065
4068
  # if networkCode was not provided by user, then we try to use the default network(if it was defined in "defaultNetworks"), otherwise, we just return the first network entry
4066
4069
  defaultNetworkCode = self.default_network_code(currencyCode)
4067
4070
  defaultNetworkId = defaultNetworkCode if isIndexedByUnifiedNetworkCode else self.network_code_to_id(defaultNetworkCode, currencyCode)
4068
- chosenNetworkId = defaultNetworkId if (defaultNetworkId in indexedNetworkEntries) else availableNetworkIds[0]
4071
+ if defaultNetworkId in indexedNetworkEntries:
4072
+ return defaultNetworkId
4073
+ raise NotSupported(self.id + ' - can not determine the default network, please pass param["network"] one from : ' + ', '.join(availableNetworkIds))
4069
4074
  return chosenNetworkId
4070
4075
 
4071
4076
  def safe_number_2(self, dictionary: object, key1: IndexType, key2: IndexType, d=None):
ccxt/binance.py CHANGED
@@ -503,6 +503,7 @@ class binance(Exchange, ImplicitAPI):
503
503
  'portfolio/margin-asset-leverage': 5, # Weight(IP): 50 => cost = 0.1 * 50 = 5
504
504
  'portfolio/balance': 2,
505
505
  'portfolio/negative-balance-exchange-record': 2,
506
+ 'portfolio/pmloan-history': 5,
506
507
  # staking
507
508
  'staking/productList': 0.1,
508
509
  'staking/position': 0.1,
@@ -6163,11 +6164,10 @@ class binance(Exchange, ImplicitAPI):
6163
6164
  """
6164
6165
  self.load_markets()
6165
6166
  market = self.market(symbol)
6167
+ # don't handle/omit params here, omitting happens inside createOrderRequest
6166
6168
  marketType = self.safe_string(params, 'type', market['type'])
6167
- marginMode = None
6168
- marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
6169
- isPortfolioMargin = None
6170
- isPortfolioMargin, params = self.handle_option_and_params_2(params, 'createOrder', 'papi', 'portfolioMargin', False)
6169
+ marginMode = self.safe_string(params, 'marginMode')
6170
+ isPortfolioMargin = self.safe_bool_2(params, 'papi', 'portfolioMargin', False)
6171
6171
  triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
6172
6172
  stopLossPrice = self.safe_string(params, 'stopLossPrice')
6173
6173
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
ccxt/bingx.py CHANGED
@@ -4471,7 +4471,7 @@ class bingx(Exchange, ImplicitAPI):
4471
4471
  response = self.contractV1PrivateGetAllOrders(self.extend(request, params))
4472
4472
  elif type == 'spot':
4473
4473
  if limit is not None:
4474
- request['limit'] = limit
4474
+ request['pageSize'] = limit
4475
4475
  response = self.spotV1PrivateGetTradeHistoryOrders(self.extend(request, params))
4476
4476
  #
4477
4477
  # {