ccxt 4.4.5__py2.py3-none-any.whl → 4.4.7__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.
@@ -752,28 +752,26 @@ class coinbase(Exchange, ImplicitAPI):
752
752
 
753
753
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
754
754
  """
755
- fetch all withdrawals made from an account
756
- :see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-withdrawals#list-withdrawals
755
+ Fetch all withdrawals made from an account. Won't return crypto withdrawals. Use fetchLedger for those.
756
+ :see: https://docs.cdp.coinbase.com/coinbase-app/docs/api-withdrawals#list-withdrawals
757
757
  :param str code: unified currency code
758
758
  :param int [since]: the earliest time in ms to fetch withdrawals for
759
759
  :param int [limit]: the maximum number of withdrawals structures to retrieve
760
760
  :param dict [params]: extra parameters specific to the exchange API endpoint
761
761
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
762
762
  """
763
- # fiat only, for crypto transactions use fetchLedger
764
763
  return await self.fetch_transactions_with_method('v2PrivateGetAccountsAccountIdWithdrawals', code, since, limit, params)
765
764
 
766
765
  async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
767
766
  """
768
- fetch all deposits made to an account
769
- :see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-deposits#list-deposits
767
+ Fetch all fiat deposits made to an account. Won't return crypto deposits or staking rewards. Use fetchLedger for those.
768
+ :see: https://docs.cdp.coinbase.com/coinbase-app/docs/api-deposits#list-deposits
770
769
  :param str code: unified currency code
771
770
  :param int [since]: the earliest time in ms to fetch deposits for
772
771
  :param int [limit]: the maximum number of deposits structures to retrieve
773
772
  :param dict [params]: extra parameters specific to the exchange API endpoint
774
773
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
775
774
  """
776
- # fiat only, for crypto transactions use fetchLedger
777
775
  return await self.fetch_transactions_with_method('v2PrivateGetAccountsAccountIdDeposits', code, since, limit, params)
778
776
 
779
777
  def parse_transaction_status(self, status: Str):
@@ -2173,8 +2171,8 @@ class coinbase(Exchange, ImplicitAPI):
2173
2171
 
2174
2172
  async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2175
2173
  """
2176
- fetch the history of changes, actions done by the user or operations that altered the balance of the user
2177
- :see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#list-transactions
2174
+ Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals.
2175
+ :see: https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions#list-transactions
2178
2176
  :param str [code]: unified currency code, default is None
2179
2177
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2180
2178
  :param int [limit]: max number of ledger entries to return, default is None
@@ -658,6 +658,9 @@ class gate(Exchange, ImplicitAPI):
658
658
  'OPTIMISM': 'OPETH',
659
659
  'POLKADOT': 'DOTSM',
660
660
  'TRC20': 'TRX',
661
+ 'LUNA': 'LUNC',
662
+ 'BASE': 'BASEEVM',
663
+ 'BRC20': 'BTCBRC',
661
664
  },
662
665
  'timeInForce': {
663
666
  'GTC': 'gtc',
@@ -249,6 +249,8 @@ class kraken(Exchange, ImplicitAPI):
249
249
  'XDG': 'DOGE',
250
250
  },
251
251
  'options': {
252
+ 'timeDifference': 0, # the difference between system clock and Binance clock
253
+ 'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
252
254
  'marketsByAltname': {},
253
255
  'delistedMarketsById': {},
254
256
  # cannot withdraw/deposit these
@@ -477,6 +479,8 @@ class kraken(Exchange, ImplicitAPI):
477
479
  :param dict [params]: extra parameters specific to the exchange API endpoint
478
480
  :returns dict[]: an array of objects representing market data
479
481
  """
482
+ if self.options['adjustForTimeDifference']:
483
+ await self.load_time_difference()
480
484
  response = await self.publicGetAssetPairs(params)
481
485
  #
482
486
  # {
@@ -2941,7 +2945,7 @@ class kraken(Exchange, ImplicitAPI):
2941
2945
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
2942
2946
 
2943
2947
  def nonce(self):
2944
- return self.milliseconds()
2948
+ return self.milliseconds() - self.options['timeDifference']
2945
2949
 
2946
2950
  def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
2947
2951
  if code == 520:
@@ -778,7 +778,7 @@ class kucoin(Exchange, ImplicitAPI):
778
778
  'hf': 'trade_hf',
779
779
  },
780
780
  'networks': {
781
- 'BTC': 'btc',
781
+ 'BRC20': 'btc',
782
782
  'BTCNATIVESEGWIT': 'bech32',
783
783
  'ERC20': 'eth',
784
784
  'TRC20': 'trx',
@@ -1344,7 +1344,7 @@ class kucoin(Exchange, ImplicitAPI):
1344
1344
  for j in range(0, chainsLength):
1345
1345
  chain = chains[j]
1346
1346
  chainId = self.safe_string(chain, 'chainId')
1347
- networkCode = self.network_id_to_code(chainId)
1347
+ networkCode = self.network_id_to_code(chainId, code)
1348
1348
  chainWithdrawEnabled = self.safe_bool(chain, 'isWithdrawEnabled', False)
1349
1349
  if isWithdrawEnabled is None:
1350
1350
  isWithdrawEnabled = chainWithdrawEnabled
@@ -45,6 +45,9 @@ class mexc(Exchange, ImplicitAPI):
45
45
  'future': False,
46
46
  'option': False,
47
47
  'addMargin': True,
48
+ 'borrowCrossMargin': False,
49
+ 'borrowIsolatedMargin': False,
50
+ 'borrowMargin': False,
48
51
  'cancelAllOrders': True,
49
52
  'cancelOrder': True,
50
53
  'cancelOrders': None,
@@ -52,18 +55,27 @@ class mexc(Exchange, ImplicitAPI):
52
55
  'closePosition': False,
53
56
  'createDepositAddress': True,
54
57
  'createMarketBuyOrderWithCost': True,
55
- 'createMarketOrderWithCost': False,
56
- 'createMarketSellOrderWithCost': False,
58
+ 'createMarketOrderWithCost': True,
59
+ 'createMarketSellOrderWithCost': True,
57
60
  'createOrder': True,
58
61
  'createOrders': True,
59
62
  'createPostOnlyOrder': True,
60
63
  'createReduceOnlyOrder': True,
64
+ 'createStopLimitOrder': True,
65
+ 'createStopMarketOrder': True,
66
+ 'createStopOrder': True,
67
+ 'createTriggerOrder': True,
61
68
  'deposit': None,
62
69
  'editOrder': None,
63
70
  'fetchAccounts': True,
64
71
  'fetchBalance': True,
65
72
  'fetchBidsAsks': True,
66
- 'fetchBorrowRateHistory': None,
73
+ 'fetchBorrowInterest': False,
74
+ 'fetchBorrowRate': False,
75
+ 'fetchBorrowRateHistories': False,
76
+ 'fetchBorrowRateHistory': False,
77
+ 'fetchBorrowRates': False,
78
+ 'fetchBorrowRatesPerSymbol': False,
67
79
  'fetchCanceledOrders': True,
68
80
  'fetchClosedOrder': None,
69
81
  'fetchClosedOrders': True,
@@ -84,6 +96,7 @@ class mexc(Exchange, ImplicitAPI):
84
96
  'fetchIndexOHLCV': True,
85
97
  'fetchIsolatedBorrowRate': False,
86
98
  'fetchIsolatedBorrowRates': False,
99
+ 'fetchIsolatedPositions': False,
87
100
  'fetchL2OrderBook': True,
88
101
  'fetchLedger': None,
89
102
  'fetchLedgerEntry': None,
@@ -92,11 +105,13 @@ class mexc(Exchange, ImplicitAPI):
92
105
  'fetchLeverageTiers': True,
93
106
  'fetchMarginAdjustmentHistory': False,
94
107
  'fetchMarginMode': False,
95
- 'fetchMarketLeverageTiers': None,
108
+ 'fetchMarketLeverageTiers': 'emulated',
96
109
  'fetchMarkets': True,
97
110
  'fetchMarkOHLCV': True,
98
111
  'fetchMyTrades': True,
99
112
  'fetchOHLCV': True,
113
+ 'fetchOpenInterest': False,
114
+ 'fetchOpenInterestHistory': False,
100
115
  'fetchOpenOrder': None,
101
116
  'fetchOpenOrders': True,
102
117
  'fetchOrder': True,
@@ -130,7 +145,7 @@ class mexc(Exchange, ImplicitAPI):
130
145
  'repayCrossMargin': False,
131
146
  'repayIsolatedMargin': False,
132
147
  'setLeverage': True,
133
- 'setMarginMode': None,
148
+ 'setMarginMode': True,
134
149
  'setPositionMode': True,
135
150
  'signIn': None,
136
151
  'transfer': None,
@@ -414,7 +429,8 @@ class mexc(Exchange, ImplicitAPI):
414
429
  },
415
430
  },
416
431
  'options': {
417
- 'createMarketBuyOrderRequiresPrice': True,
432
+ 'adjustForTimeDifference': False,
433
+ 'timeDifference': 0,
418
434
  'unavailableContracts': {
419
435
  'BTC/USDT:USDT': True,
420
436
  'LTC/USDT:USDT': True,
@@ -463,11 +479,14 @@ class mexc(Exchange, ImplicitAPI):
463
479
  'LTC': 'LTC',
464
480
  },
465
481
  'networks': {
482
+ 'ZKSYNC': 'ZKSYNCERA',
466
483
  'TRC20': 'TRX',
467
484
  'TON': 'TONCOIN',
468
485
  'AVAXC': 'AVAX_CCHAIN',
469
486
  'ERC20': 'ETH',
470
487
  'ACA': 'ACALA',
488
+ 'BEP20': 'BSC',
489
+ 'OPTIMISM': 'OP',
471
490
  # 'ADA': 'Cardano(ADA)',
472
491
  # 'AE': 'AE',
473
492
  # 'ALGO': 'Algorand(ALGO)',
@@ -1008,6 +1027,8 @@ class mexc(Exchange, ImplicitAPI):
1008
1027
  :param dict [params]: extra parameters specific to the exchange API endpoint
1009
1028
  :returns dict[]: an array of objects representing market data
1010
1029
  """
1030
+ if self.options['adjustForTimeDifference']:
1031
+ await self.load_time_difference()
1011
1032
  spotMarketPromise = self.fetch_spot_markets(params)
1012
1033
  swapMarketPromise = self.fetch_swap_markets(params)
1013
1034
  spotMarket, swapMarket = await asyncio.gather(*[spotMarketPromise, swapMarketPromise])
@@ -1999,8 +2020,24 @@ class mexc(Exchange, ImplicitAPI):
1999
2020
  market = self.market(symbol)
2000
2021
  if not market['spot']:
2001
2022
  raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2002
- params['createMarketBuyOrderRequiresPrice'] = False
2003
- return await self.create_order(symbol, 'market', 'buy', cost, None, params)
2023
+ params['cost'] = cost
2024
+ return await self.create_order(symbol, 'market', 'buy', 0, None, params)
2025
+
2026
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
2027
+ """
2028
+ create a market sell order by providing the symbol and cost
2029
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2030
+ :param str symbol: unified symbol of the market to create an order in
2031
+ :param float cost: how much you want to trade in units of the quote currency
2032
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2033
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2034
+ """
2035
+ await self.load_markets()
2036
+ market = self.market(symbol)
2037
+ if not market['spot']:
2038
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2039
+ params['cost'] = cost
2040
+ return await self.create_order(symbol, 'market', 'sell', 0, None, params)
2004
2041
 
2005
2042
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2006
2043
  """
@@ -2024,6 +2061,7 @@ class mexc(Exchange, ImplicitAPI):
2024
2061
  :param long [params.positionId]: *contract only* it is recommended to hasattr(self, fill) parameter when closing a position
2025
2062
  :param str [params.externalOid]: *contract only* external order ID
2026
2063
  :param int [params.positionMode]: *contract only* 1:hedge, 2:one-way, default: the user's current config
2064
+ :param boolean [params.test]: *spot only* whether to use the test endpoint or not, default is False
2027
2065
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2028
2066
  """
2029
2067
  await self.load_markets()
@@ -2042,22 +2080,21 @@ class mexc(Exchange, ImplicitAPI):
2042
2080
  'side': orderSide,
2043
2081
  'type': type.upper(),
2044
2082
  }
2045
- if orderSide == 'BUY' and type == 'market':
2046
- createMarketBuyOrderRequiresPrice = True
2047
- createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
2083
+ if type == 'market':
2048
2084
  cost = self.safe_number_2(params, 'cost', 'quoteOrderQty')
2049
2085
  params = self.omit(params, 'cost')
2050
2086
  if cost is not None:
2051
2087
  amount = cost
2052
- elif createMarketBuyOrderRequiresPrice:
2088
+ request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2089
+ else:
2053
2090
  if price is None:
2054
- raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
2091
+ request['quantity'] = self.amount_to_precision(symbol, amount)
2055
2092
  else:
2056
2093
  amountString = self.number_to_string(amount)
2057
2094
  priceString = self.number_to_string(price)
2058
2095
  quoteAmount = Precise.string_mul(amountString, priceString)
2059
2096
  amount = quoteAmount
2060
- request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2097
+ request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2061
2098
  else:
2062
2099
  request['quantity'] = self.amount_to_precision(symbol, amount)
2063
2100
  if price is not None:
@@ -2092,8 +2129,14 @@ class mexc(Exchange, ImplicitAPI):
2092
2129
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2093
2130
  """
2094
2131
  await self.load_markets()
2132
+ test = self.safe_bool(params, 'test', False)
2133
+ params = self.omit(params, 'test')
2095
2134
  request = self.create_spot_order_request(market, type, side, amount, price, marginMode, params)
2096
- response = await self.spotPrivatePostOrder(self.extend(request, params))
2135
+ response = None
2136
+ if test:
2137
+ response = await self.spotPrivatePostOrderTest(request)
2138
+ else:
2139
+ response = await self.spotPrivatePostOrder(request)
2097
2140
  #
2098
2141
  # spot
2099
2142
  #
@@ -2407,6 +2450,9 @@ class mexc(Exchange, ImplicitAPI):
2407
2450
  async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2408
2451
  """
2409
2452
  fetches information on multiple orders made by the user
2453
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2454
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2455
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2410
2456
  :param str symbol: unified market symbol of the market orders were made in
2411
2457
  :param int [since]: the earliest time in ms to fetch orders for
2412
2458
  :param int [limit]: the maximum number of order structures to retrieve
@@ -2620,6 +2666,9 @@ class mexc(Exchange, ImplicitAPI):
2620
2666
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2621
2667
  """
2622
2668
  fetch all unfilled currently open orders
2669
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-open-orders
2670
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2671
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2623
2672
  :param str symbol: unified market symbol
2624
2673
  :param int [since]: the earliest time in ms to fetch open orders for
2625
2674
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -2702,6 +2751,9 @@ class mexc(Exchange, ImplicitAPI):
2702
2751
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2703
2752
  """
2704
2753
  fetches information on multiple closed orders made by the user
2754
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2755
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2756
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2705
2757
  :param str symbol: unified market symbol of the market orders were made in
2706
2758
  :param int [since]: the earliest time in ms to fetch orders for
2707
2759
  :param int [limit]: the maximum number of order structures to retrieve
@@ -2713,6 +2765,9 @@ class mexc(Exchange, ImplicitAPI):
2713
2765
  async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2714
2766
  """
2715
2767
  fetches information on multiple canceled orders made by the user
2768
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2769
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2770
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2716
2771
  :param str symbol: unified market symbol of the market orders were made in
2717
2772
  :param int [since]: timestamp in ms of the earliest order, default is None
2718
2773
  :param int [limit]: max number of orders to return, default is None
@@ -4248,7 +4303,7 @@ class mexc(Exchange, ImplicitAPI):
4248
4303
  # 'coin': currency['id'] + network example: USDT-TRX,
4249
4304
  # 'status': 'status',
4250
4305
  # 'startTime': since, # default 90 days
4251
- # 'endTime': self.milliseconds(),
4306
+ # 'endTime': self.nonce(),
4252
4307
  # 'limit': limit, # default 1000, maximum 1000
4253
4308
  }
4254
4309
  currency = None
@@ -4301,7 +4356,7 @@ class mexc(Exchange, ImplicitAPI):
4301
4356
  # 'coin': currency['id'],
4302
4357
  # 'status': 'status',
4303
4358
  # 'startTime': since, # default 90 days
4304
- # 'endTime': self.milliseconds(),
4359
+ # 'endTime': self.nonce(),
4305
4360
  # 'limit': limit, # default 1000, maximum 1000
4306
4361
  }
4307
4362
  currency = None
@@ -5266,6 +5321,46 @@ class mexc(Exchange, ImplicitAPI):
5266
5321
  positions = self.parse_positions(data, symbols, params)
5267
5322
  return self.filter_by_since_limit(positions, since, limit)
5268
5323
 
5324
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
5325
+ """
5326
+ set margin mode to 'cross' or 'isolated'
5327
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
5328
+ :param str marginMode: 'cross' or 'isolated'
5329
+ :param str [symbol]: required when there is no position, else provide params["positionId"]
5330
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5331
+ :param str [params.positionId]: required when a position is set
5332
+ :param str [params.direction]: "long" or "short" required when there is no position
5333
+ :returns dict: response from the exchange
5334
+ """
5335
+ await self.load_markets()
5336
+ market = self.market(symbol)
5337
+ if market['spot']:
5338
+ raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
5339
+ marginMode = marginMode.lower()
5340
+ if marginMode != 'isolated' and marginMode != 'cross':
5341
+ raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
5342
+ leverage = self.safe_integer(params, 'leverage')
5343
+ if leverage is None:
5344
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
5345
+ direction = self.safe_string_lower_2(params, 'direction', 'positionId')
5346
+ request: dict = {
5347
+ 'leverage': leverage,
5348
+ 'openType': 1 if (marginMode == 'isolated') else 2,
5349
+ }
5350
+ if symbol is not None:
5351
+ request['symbol'] = market['id']
5352
+ if direction is not None:
5353
+ request['positionType'] = 2 if (direction == 'short') else 1
5354
+ params = self.omit(params, 'direction')
5355
+ response = await self.contractPrivatePostPositionChangeLeverage(self.extend(request, params))
5356
+ #
5357
+ # {success: True, code: '0'}
5358
+ #
5359
+ return self.parse_leverage(response, market)
5360
+
5361
+ def nonce(self):
5362
+ return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
5363
+
5269
5364
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
5270
5365
  section = self.safe_string(api, 0)
5271
5366
  access = self.safe_string(api, 1)
@@ -5278,7 +5373,7 @@ class mexc(Exchange, ImplicitAPI):
5278
5373
  url = self.urls['api'][section][access] + '/api/' + self.version + '/' + path
5279
5374
  paramsEncoded = ''
5280
5375
  if access == 'private':
5281
- params['timestamp'] = self.milliseconds()
5376
+ params['timestamp'] = self.nonce()
5282
5377
  params['recvWindow'] = self.safe_integer(self.options, 'recvWindow', 5000)
5283
5378
  if params:
5284
5379
  paramsEncoded = self.urlencode(params)
@@ -5301,7 +5396,7 @@ class mexc(Exchange, ImplicitAPI):
5301
5396
  url += '?' + self.urlencode(params)
5302
5397
  else:
5303
5398
  self.check_required_credentials()
5304
- timestamp = str(self.milliseconds())
5399
+ timestamp = str(self.nonce())
5305
5400
  auth = ''
5306
5401
  headers = {
5307
5402
  'ApiKey': self.apiKey,
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.5'
7
+ __version__ = '4.4.7'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -1734,6 +1734,9 @@ class Exchange(object):
1734
1734
  def create_safe_dictionary(self):
1735
1735
  return {}
1736
1736
 
1737
+ def rand_number(self, size):
1738
+ return int(''.join([str(random.randint(0, 9)) for _ in range(size)]))
1739
+
1737
1740
  # ########################################################################
1738
1741
  # ########################################################################
1739
1742
  # ########################################################################
@@ -2676,6 +2679,7 @@ class Exchange(object):
2676
2679
  'ETH': {'ERC20': 'ETH'},
2677
2680
  'TRX': {'TRC20': 'TRX'},
2678
2681
  'CRO': {'CRC20': 'CRONOS'},
2682
+ 'BRC20': {'BRC20': 'BTC'},
2679
2683
  },
2680
2684
  }
2681
2685
 
@@ -5946,8 +5950,17 @@ class Exchange(object):
5946
5950
  if responseLength == 0:
5947
5951
  break
5948
5952
  result = self.array_concat(result, response)
5949
- last = self.safe_value(response, responseLength - 1)
5950
- cursorValue = self.safe_value(last['info'], cursorReceived)
5953
+ last = self.safe_dict(response, responseLength - 1)
5954
+ # cursorValue = self.safe_value(last['info'], cursorReceived)
5955
+ cursorValue = None # search for the cursor
5956
+ for j in range(0, responseLength):
5957
+ index = responseLength - j - 1
5958
+ entry = self.safe_dict(response, index)
5959
+ info = self.safe_dict(entry, 'info')
5960
+ cursor = self.safe_value(info, cursorReceived)
5961
+ if cursor is not None:
5962
+ cursorValue = cursor
5963
+ break
5951
5964
  if cursorValue is None:
5952
5965
  break
5953
5966
  lastTimestamp = self.safe_integer(last, 'timestamp')
ccxt/bingx.py CHANGED
@@ -503,6 +503,9 @@ class bingx(Exchange, ImplicitAPI):
503
503
  'BTC': 'BTC',
504
504
  'LTC': 'LTC',
505
505
  },
506
+ 'networks': {
507
+ 'ARB': 'ARBITRUM',
508
+ },
506
509
  },
507
510
  })
508
511
 
ccxt/bitflyer.py CHANGED
@@ -995,8 +995,8 @@ class bitflyer(Exchange, ImplicitAPI):
995
995
  feedback = self.id + ' ' + body
996
996
  # i.e. {"status":-2,"error_message":"Under maintenance","data":null}
997
997
  errorMessage = self.safe_string(response, 'error_message')
998
- statusCode = self.safe_number(response, 'status')
998
+ statusCode = self.safe_integer(response, 'status')
999
999
  if errorMessage is not None:
1000
1000
  self.throw_exactly_matched_exception(self.exceptions['exact'], statusCode, feedback)
1001
- self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
1001
+ raise ExchangeError(feedback)
1002
1002
  return None
ccxt/bitget.py CHANGED
@@ -1336,6 +1336,8 @@ class bitget(Exchange, ImplicitAPI):
1336
1336
  'TONCOIN': 'TON',
1337
1337
  },
1338
1338
  'options': {
1339
+ 'timeDifference': 0, # the difference between system clock and Binance clock
1340
+ 'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
1339
1341
  'timeframes': {
1340
1342
  'spot': {
1341
1343
  '1m': '1min',
@@ -1434,11 +1436,13 @@ class bitget(Exchange, ImplicitAPI):
1434
1436
  'networks': {
1435
1437
  'TRX': 'TRC20',
1436
1438
  'ETH': 'ERC20',
1437
- 'BSC': 'BEP20',
1439
+ 'BEP20': 'BSC',
1440
+ 'ZKSYNC': 'zkSyncEra',
1441
+ 'STARKNET': 'Starknet',
1442
+ 'OPTIMISM': 'Optimism',
1443
+ 'ARBITRUM': 'Arbitrum',
1438
1444
  },
1439
1445
  'networksById': {
1440
- 'TRC20': 'TRX',
1441
- 'BSC': 'BEP20',
1442
1446
  },
1443
1447
  'fetchPositions': {
1444
1448
  'method': 'privateMixGetV2MixPositionAllPosition', # or privateMixGetV2MixPositionHistoryPosition
@@ -1538,6 +1542,8 @@ class bitget(Exchange, ImplicitAPI):
1538
1542
  :param dict [params]: extra parameters specific to the exchange API endpoint
1539
1543
  :returns dict[]: an array of objects representing market data
1540
1544
  """
1545
+ if self.options['adjustForTimeDifference']:
1546
+ self.load_time_difference()
1541
1547
  sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
1542
1548
  types = self.safe_value(self.options, 'fetchMarkets', ['spot', 'swap'])
1543
1549
  if sandboxMode:
@@ -1835,7 +1841,9 @@ class bitget(Exchange, ImplicitAPI):
1835
1841
  for j in range(0, len(chains)):
1836
1842
  chain = chains[j]
1837
1843
  networkId = self.safe_string(chain, 'chain')
1838
- network = self.safe_currency_code(networkId)
1844
+ network = self.network_id_to_code(networkId, code)
1845
+ if network is not None:
1846
+ network = network.upper()
1839
1847
  withdrawEnabled = self.safe_string(chain, 'withdrawable')
1840
1848
  canWithdraw = withdrawEnabled == 'true'
1841
1849
  withdraw = canWithdraw if (canWithdraw) else withdraw
@@ -8202,6 +8210,9 @@ class bitget(Exchange, ImplicitAPI):
8202
8210
  raise ExchangeError(feedback) # unknown message
8203
8211
  return None
8204
8212
 
8213
+ def nonce(self):
8214
+ return self.milliseconds() - self.options['timeDifference']
8215
+
8205
8216
  def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
8206
8217
  signed = api[0] == 'private'
8207
8218
  endpoint = api[1]
@@ -8217,7 +8228,7 @@ class bitget(Exchange, ImplicitAPI):
8217
8228
  url = url + '?' + self.urlencode(query)
8218
8229
  if signed:
8219
8230
  self.check_required_credentials()
8220
- timestamp = str(self.milliseconds())
8231
+ timestamp = str(self.nonce())
8221
8232
  auth = timestamp + method + payload
8222
8233
  if method == 'POST':
8223
8234
  body = self.json(params)