ccxt 4.4.4__py2.py3-none-any.whl → 4.4.5__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.
ccxt/bitget.py CHANGED
@@ -1534,6 +1534,7 @@ class bitget(Exchange, ImplicitAPI):
1534
1534
  retrieves data on all markets for bitget
1535
1535
  :see: https://www.bitget.com/api-doc/spot/market/Get-Symbols
1536
1536
  :see: https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
1537
+ :see: https://www.bitget.com/api-doc/margin/common/support-currencies
1537
1538
  :param dict [params]: extra parameters specific to the exchange API endpoint
1538
1539
  :returns dict[]: an array of objects representing market data
1539
1540
  """
@@ -1542,9 +1543,10 @@ class bitget(Exchange, ImplicitAPI):
1542
1543
  if sandboxMode:
1543
1544
  types = ['swap']
1544
1545
  promises = []
1546
+ fetchMargins = False
1545
1547
  for i in range(0, len(types)):
1546
1548
  type = types[i]
1547
- if type == 'swap':
1549
+ if (type == 'swap') or (type == 'future'):
1548
1550
  subTypes = None
1549
1551
  if sandboxMode:
1550
1552
  # the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
@@ -1552,15 +1554,33 @@ class bitget(Exchange, ImplicitAPI):
1552
1554
  else:
1553
1555
  subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
1554
1556
  for j in range(0, len(subTypes)):
1555
- promises.append(self.fetch_markets_by_type(type, self.extend(params, {
1557
+ promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
1556
1558
  'productType': subTypes[j],
1557
1559
  })))
1560
+ elif type == 'spot':
1561
+ promises.append(self.publicSpotGetV2SpotPublicSymbols(params))
1562
+ fetchMargins = True
1563
+ promises.append(self.publicMarginGetV2MarginCurrencies(params))
1564
+ else:
1565
+ raise NotSupported(self.id + ' does not support ' + type + ' market')
1566
+ results = promises
1567
+ markets = []
1568
+ self.options['crossMarginPairsData'] = []
1569
+ self.options['isolatedMarginPairsData'] = []
1570
+ for i in range(0, len(results)):
1571
+ res = self.safe_dict(results, i)
1572
+ data = self.safe_list(res, 'data', [])
1573
+ firstData = self.safe_dict(data, 0, {})
1574
+ isBorrowable = self.safe_string(firstData, 'isBorrowable')
1575
+ if fetchMargins and isBorrowable is not None:
1576
+ keysList = list(self.index_by(data, 'symbol').keys())
1577
+ self.options['crossMarginPairsData'] = keysList
1578
+ self.options['isolatedMarginPairsData'] = keysList
1558
1579
  else:
1559
- promises.append(self.fetch_markets_by_type(types[i], params))
1560
- promises = promises
1561
- result = promises[0]
1562
- for i in range(1, len(promises)):
1563
- result = self.array_concat(result, promises[i])
1580
+ markets = self.array_concat(markets, data)
1581
+ result = []
1582
+ for i in range(0, len(markets)):
1583
+ result.append(self.parse_market(markets[i]))
1564
1584
  return result
1565
1585
 
1566
1586
  def parse_market(self, market: dict) -> Market:
@@ -1648,11 +1668,20 @@ class bitget(Exchange, ImplicitAPI):
1648
1668
  expiry = None
1649
1669
  expiryDatetime = None
1650
1670
  symbolType = self.safe_string(market, 'symbolType')
1671
+ marginModes = None
1672
+ isMarginTradingAllowed = False
1651
1673
  if symbolType is None:
1652
1674
  type = 'spot'
1653
1675
  spot = True
1654
1676
  pricePrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision')))
1655
1677
  amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
1678
+ hasCrossMargin = self.in_array(marketId, self.options['crossMarginPairsData'])
1679
+ hasIsolatedMargin = self.in_array(marketId, self.options['isolatedMarginPairsData'])
1680
+ marginModes = {
1681
+ 'cross': hasCrossMargin,
1682
+ 'isolated': hasIsolatedMargin,
1683
+ }
1684
+ isMarginTradingAllowed = hasCrossMargin or hasCrossMargin
1656
1685
  else:
1657
1686
  if symbolType == 'perpetual':
1658
1687
  type = 'swap'
@@ -1688,6 +1717,10 @@ class bitget(Exchange, ImplicitAPI):
1688
1717
  preciseAmount.reduce()
1689
1718
  amountString = str(preciseAmount)
1690
1719
  amountPrecision = self.parse_number(amountString)
1720
+ marginModes = {
1721
+ 'cross': True,
1722
+ 'isolated': True,
1723
+ }
1691
1724
  status = self.safe_string_2(market, 'status', 'symbolStatus')
1692
1725
  active = None
1693
1726
  if status is not None:
@@ -1707,7 +1740,8 @@ class bitget(Exchange, ImplicitAPI):
1707
1740
  'settleId': settleId,
1708
1741
  'type': type,
1709
1742
  'spot': spot,
1710
- 'margin': None,
1743
+ 'margin': spot and isMarginTradingAllowed,
1744
+ 'marginModes': marginModes,
1711
1745
  'swap': swap,
1712
1746
  'future': future,
1713
1747
  'option': False,
@@ -1748,88 +1782,6 @@ class bitget(Exchange, ImplicitAPI):
1748
1782
  'info': market,
1749
1783
  }
1750
1784
 
1751
- def fetch_markets_by_type(self, type, params={}):
1752
- response = None
1753
- if type == 'spot':
1754
- response = self.publicSpotGetV2SpotPublicSymbols(params)
1755
- elif (type == 'swap') or (type == 'future'):
1756
- response = self.publicMixGetV2MixMarketContracts(params)
1757
- else:
1758
- raise NotSupported(self.id + ' does not support ' + type + ' market')
1759
- #
1760
- # spot
1761
- #
1762
- # {
1763
- # "code": "00000",
1764
- # "msg": "success",
1765
- # "requestTime": 1700102364653,
1766
- # "data": [
1767
- # {
1768
- # "symbol": "TRXUSDT",
1769
- # "baseCoin": "TRX",
1770
- # "quoteCoin": "USDT",
1771
- # "minTradeAmount": "0",
1772
- # "maxTradeAmount": "10000000000",
1773
- # "takerFeeRate": "0.002",
1774
- # "makerFeeRate": "0.002",
1775
- # "pricePrecision": "6",
1776
- # "quantityPrecision": "4",
1777
- # "quotePrecision": "6",
1778
- # "status": "online",
1779
- # "minTradeUSDT": "5",
1780
- # "buyLimitPriceRatio": "0.05",
1781
- # "sellLimitPriceRatio": "0.05"
1782
- # },
1783
- # ]
1784
- # }
1785
- #
1786
- # swap and future
1787
- #
1788
- # {
1789
- # "code": "00000",
1790
- # "msg": "success",
1791
- # "requestTime": 1700102364709,
1792
- # "data": [
1793
- # {
1794
- # "symbol": "BTCUSDT",
1795
- # "baseCoin": "BTC",
1796
- # "quoteCoin": "USDT",
1797
- # "buyLimitPriceRatio": "0.01",
1798
- # "sellLimitPriceRatio": "0.01",
1799
- # "feeRateUpRatio": "0.005",
1800
- # "makerFeeRate": "0.0002",
1801
- # "takerFeeRate": "0.0006",
1802
- # "openCostUpRatio": "0.01",
1803
- # "supportMarginCoins": ["USDT"],
1804
- # "minTradeNum": "0.001",
1805
- # "priceEndStep": "1",
1806
- # "volumePlace": "3",
1807
- # "pricePlace": "1",
1808
- # "sizeMultiplier": "0.001",
1809
- # "symbolType": "perpetual",
1810
- # "minTradeUSDT": "5",
1811
- # "maxSymbolOrderNum": "200",
1812
- # "maxProductOrderNum": "400",
1813
- # "maxPositionNum": "150",
1814
- # "symbolStatus": "normal",
1815
- # "offTime": "-1",
1816
- # "limitOpenTime": "-1",
1817
- # "deliveryTime": "",
1818
- # "deliveryStartTime": "",
1819
- # "deliveryPeriod": "",
1820
- # "launchTime": "",
1821
- # "fundInterval": "8",
1822
- # "minLever": "1",
1823
- # "maxLever": "125",
1824
- # "posLimit": "0.05",
1825
- # "maintainTime": ""
1826
- # },
1827
- # ]
1828
- # }
1829
- #
1830
- data = self.safe_value(response, 'data', [])
1831
- return self.parse_markets(data)
1832
-
1833
1785
  def fetch_currencies(self, params={}) -> Currencies:
1834
1786
  """
1835
1787
  fetches all available currencies on an exchange
ccxt/bybit.py CHANGED
@@ -114,7 +114,7 @@ class bybit(Exchange, ImplicitAPI):
114
114
  'fetchOpenOrders': True,
115
115
  'fetchOption': True,
116
116
  'fetchOptionChain': True,
117
- 'fetchOrder': False,
117
+ 'fetchOrder': True,
118
118
  'fetchOrderBook': True,
119
119
  'fetchOrders': False,
120
120
  'fetchOrderTrades': True,
@@ -4526,13 +4526,84 @@ class bybit(Exchange, ImplicitAPI):
4526
4526
  :param str id: the order id
4527
4527
  :param str symbol: unified symbol of the market the order was made in
4528
4528
  :param dict [params]: extra parameters specific to the exchange API endpoint
4529
+ :param dict [params.acknowledged]: to suppress the warning, set to True
4529
4530
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4530
4531
  """
4531
- res = self.is_unified_enabled()
4532
- enableUnifiedAccount = self.safe_bool(res, 1)
4533
- if enableUnifiedAccount:
4534
- raise NotSupported(self.id + ' fetchOrder() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrder or fetchClosedOrder')
4535
- return self.fetch_order_classic(id, symbol, params)
4532
+ self.load_markets()
4533
+ enableUnifiedMargin, enableUnifiedAccount = self.is_unified_enabled()
4534
+ isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
4535
+ if not isUnifiedAccount:
4536
+ return self.fetch_order_classic(id, symbol, params)
4537
+ acknowledge = False
4538
+ acknowledge, params = self.handle_option_and_params(params, 'fetchOrder', 'acknowledged')
4539
+ if not acknowledge:
4540
+ raise ArgumentsRequired(self.id + ' fetchOrder() can only access an order if it is in last 500 orders(of any status) for your account. Set params["acknowledged"] = True to hide self warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrder')
4541
+ market = self.market(symbol)
4542
+ marketType = None
4543
+ marketType, params = self.get_bybit_type('fetchOrder', market, params)
4544
+ request: dict = {
4545
+ 'symbol': market['id'],
4546
+ 'orderId': id,
4547
+ 'category': marketType,
4548
+ }
4549
+ isTrigger = None
4550
+ isTrigger, params = self.handle_param_bool_2(params, 'trigger', 'stop', False)
4551
+ if isTrigger:
4552
+ request['orderFilter'] = 'StopOrder'
4553
+ response = self.privateGetV5OrderRealtime(self.extend(request, params))
4554
+ #
4555
+ # {
4556
+ # "retCode": 0,
4557
+ # "retMsg": "OK",
4558
+ # "result": {
4559
+ # "nextPageCursor": "1321052653536515584%3A1672217748287%2C1321052653536515584%3A1672217748287",
4560
+ # "category": "spot",
4561
+ # "list": [
4562
+ # {
4563
+ # "symbol": "ETHUSDT",
4564
+ # "orderType": "Limit",
4565
+ # "orderLinkId": "1672217748277652",
4566
+ # "orderId": "1321052653536515584",
4567
+ # "cancelType": "UNKNOWN",
4568
+ # "avgPrice": "",
4569
+ # "stopOrderType": "tpslOrder",
4570
+ # "lastPriceOnCreated": "",
4571
+ # "orderStatus": "Cancelled",
4572
+ # "takeProfit": "",
4573
+ # "cumExecValue": "0",
4574
+ # "triggerDirection": 0,
4575
+ # "isLeverage": "0",
4576
+ # "rejectReason": "",
4577
+ # "price": "1000",
4578
+ # "orderIv": "",
4579
+ # "createdTime": "1672217748287",
4580
+ # "tpTriggerBy": "",
4581
+ # "positionIdx": 0,
4582
+ # "timeInForce": "GTC",
4583
+ # "leavesValue": "500",
4584
+ # "updatedTime": "1672217748287",
4585
+ # "side": "Buy",
4586
+ # "triggerPrice": "1500",
4587
+ # "cumExecFee": "0",
4588
+ # "leavesQty": "0",
4589
+ # "slTriggerBy": "",
4590
+ # "closeOnTrigger": False,
4591
+ # "cumExecQty": "0",
4592
+ # "reduceOnly": False,
4593
+ # "qty": "0.5",
4594
+ # "stopLoss": "",
4595
+ # "triggerBy": "1192.5"
4596
+ # }
4597
+ # ]
4598
+ # },
4599
+ # "retExtInfo": {},
4600
+ # "time": 1672219526294
4601
+ # }
4602
+ #
4603
+ result = self.safe_dict(response, 'result', {})
4604
+ innerList = self.safe_list(result, 'list', [])
4605
+ order = self.safe_dict(innerList, 0, {})
4606
+ return self.parse_order(order, market)
4536
4607
 
4537
4608
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
4538
4609
  res = self.is_unified_enabled()
ccxt/lykke.py CHANGED
@@ -667,9 +667,9 @@ class lykke(Exchange, ImplicitAPI):
667
667
  currencyId = self.safe_string(balance, 'assetId')
668
668
  code = self.safe_currency_code(currencyId)
669
669
  account = self.account()
670
- free = self.safe_string(balance, 'available')
670
+ total = self.safe_string(balance, 'available')
671
671
  used = self.safe_string(balance, 'reserved')
672
- account['free'] = free
672
+ account['total'] = total
673
673
  account['used'] = used
674
674
  result[code] = account
675
675
  return self.safe_balance(result)
ccxt/mexc.py CHANGED
@@ -103,7 +103,7 @@ class mexc(Exchange, ImplicitAPI):
103
103
  'fetchOrderBooks': None,
104
104
  'fetchOrders': True,
105
105
  'fetchOrderTrades': True,
106
- 'fetchPosition': True,
106
+ 'fetchPosition': 'emulated',
107
107
  'fetchPositionHistory': 'emulated',
108
108
  'fetchPositionMode': True,
109
109
  'fetchPositions': True,
@@ -2736,6 +2736,9 @@ class mexc(Exchange, ImplicitAPI):
2736
2736
  def cancel_order(self, id: str, symbol: Str = None, params={}):
2737
2737
  """
2738
2738
  cancels an open order
2739
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
2740
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2741
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
2739
2742
  :param str id: order id
2740
2743
  :param str symbol: unified symbol of the market the order was made in
2741
2744
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2838,6 +2841,7 @@ class mexc(Exchange, ImplicitAPI):
2838
2841
  def cancel_orders(self, ids, symbol: Str = None, params={}):
2839
2842
  """
2840
2843
  cancel multiple orders
2844
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2841
2845
  :param str[] ids: order ids
2842
2846
  :param str symbol: unified market symbol, default is None
2843
2847
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4451,6 +4455,7 @@ class mexc(Exchange, ImplicitAPI):
4451
4455
  def fetch_position(self, symbol: str, params={}):
4452
4456
  """
4453
4457
  fetch data on a single open contract trade position
4458
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4454
4459
  :param str symbol: unified market symbol of the market the position is held in, default is None
4455
4460
  :param dict [params]: extra parameters specific to the exchange API endpoint
4456
4461
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4466,6 +4471,7 @@ class mexc(Exchange, ImplicitAPI):
4466
4471
  def fetch_positions(self, symbols: Strings = None, params={}):
4467
4472
  """
4468
4473
  fetch all open positions
4474
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4469
4475
  :param str[]|None symbols: list of unified market symbols
4470
4476
  :param dict [params]: extra parameters specific to the exchange API endpoint
4471
4477
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
ccxt/paradex.py CHANGED
@@ -640,7 +640,7 @@ class paradex(Exchange, ImplicitAPI):
640
640
  'low': None,
641
641
  'bid': self.safe_string(ticker, 'bid'),
642
642
  'bidVolume': None,
643
- 'ask': self.safe_string(ticker, 'sdk'),
643
+ 'ask': self.safe_string(ticker, 'ask'),
644
644
  'askVolume': None,
645
645
  'vwap': None,
646
646
  'open': None,
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.4'
7
+ __version__ = '4.4.5'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/binance.py CHANGED
@@ -20,7 +20,11 @@ from ccxt.base.precise import Precise
20
20
  class binance(ccxt.async_support.binance):
21
21
 
22
22
  def describe(self):
23
- return self.deep_extend(super(binance, self).describe(), {
23
+ superDescribe = super(binance, self).describe()
24
+ return self.deep_extend(superDescribe, self.describe_data())
25
+
26
+ def describe_data(self):
27
+ return {
24
28
  'has': {
25
29
  'ws': True,
26
30
  'watchBalance': True,
@@ -162,7 +166,7 @@ class binance(ccxt.async_support.binance):
162
166
  'bookTicker': 'bookTicker',
163
167
  },
164
168
  },
165
- })
169
+ }
166
170
 
167
171
  def request_id(self, url):
168
172
  options = self.safe_dict(self.options, 'requestId', self.create_safe_dictionary())
ccxt/pro/binanceus.py CHANGED
@@ -14,7 +14,8 @@ class binanceus(binance):
14
14
  # eslint-disable-next-line new-cap
15
15
  restInstance = binanceusRest()
16
16
  restDescribe = restInstance.describe()
17
- extended = self.deep_extend(restDescribe, super(binanceus, self).describe())
17
+ parentWsDescribe = super(binanceus, self).describe_data()
18
+ extended = self.deep_extend(restDescribe, parentWsDescribe)
18
19
  return self.deep_extend(extended, {
19
20
  'id': 'binanceus',
20
21
  'name': 'Binance US',
ccxt/pro/hyperliquid.py CHANGED
@@ -26,7 +26,7 @@ class hyperliquid(ccxt.async_support.hyperliquid):
26
26
  'watchOHLCV': True,
27
27
  'watchOrderBook': True,
28
28
  'watchOrders': True,
29
- 'watchTicker': False,
29
+ 'watchTicker': True,
30
30
  'watchTickers': True,
31
31
  'watchTrades': True,
32
32
  'watchTradesForSymbols': False,
@@ -233,6 +233,19 @@ class hyperliquid(ccxt.async_support.hyperliquid):
233
233
  messageHash = 'orderbook:' + symbol
234
234
  client.resolve(orderbook, messageHash)
235
235
 
236
+ async def watch_ticker(self, symbol: str, params={}) -> Ticker:
237
+ """
238
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
239
+ watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
240
+ :param str symbol: unified symbol of the market to fetch the ticker for
241
+ :param dict [params]: extra parameters specific to the exchange API endpoint
242
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
243
+ """
244
+ market = self.market(symbol)
245
+ symbol = market['symbol']
246
+ tickers = await self.watch_tickers([symbol], params)
247
+ return tickers[symbol]
248
+
236
249
  async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
237
250
  """
238
251
  watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
ccxt/pro/paradex.py CHANGED
@@ -211,6 +211,7 @@ class paradex(ccxt.async_support.paradex):
211
211
  async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
212
212
  """
213
213
  watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
214
+ :see: https://docs.api.testnet.paradex.trade/#sub-markets_summary-operation
214
215
  :param str[] symbols: unified symbol of the market to fetch the ticker for
215
216
  :param dict [params]: extra parameters specific to the exchange API endpoint
216
217
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.4.4
3
+ Version: 4.4.5
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -272,13 +272,13 @@ console.log(version, Object.keys(exchanges));
272
272
 
273
273
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
274
274
 
275
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.4/dist/ccxt.browser.min.js
276
- * unpkg: https://unpkg.com/ccxt@4.4.4/dist/ccxt.browser.min.js
275
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.5/dist/ccxt.browser.min.js
276
+ * unpkg: https://unpkg.com/ccxt@4.4.5/dist/ccxt.browser.min.js
277
277
 
278
278
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
279
279
 
280
280
  ```HTML
281
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.4/dist/ccxt.browser.min.js"></script>
281
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.4.5/dist/ccxt.browser.min.js"></script>
282
282
  ```
283
283
 
284
284
  Creates a global `ccxt` object: