ccxt 4.2.35__py2.py3-none-any.whl → 4.2.37__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.
@@ -292,6 +292,7 @@ class bitmex(Exchange, ImplicitAPI):
292
292
  async def fetch_currencies(self, params={}):
293
293
  """
294
294
  fetches all available currencies on an exchange
295
+ :see: https://www.bitmex.com/api/explorer/#not /Wallet/Wallet_getAssetsConfig
295
296
  :param dict [params]: extra parameters specific to the exchange API endpoint
296
297
  :returns dict: an associative dictionary of currencies
297
298
  """
@@ -752,6 +753,7 @@ class bitmex(Exchange, ImplicitAPI):
752
753
  async def fetch_balance(self, params={}) -> Balances:
753
754
  """
754
755
  query for balance and get the amount of funds available for trading or funds locked in orders
756
+ :see: https://www.bitmex.com/api/explorer/#not /User/User_getMargin
755
757
  :param dict [params]: extra parameters specific to the exchange API endpoint
756
758
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
757
759
  """
@@ -812,6 +814,7 @@ class bitmex(Exchange, ImplicitAPI):
812
814
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
813
815
  """
814
816
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
817
+ :see: https://www.bitmex.com/api/explorer/#not /OrderBook/OrderBook_getL2
815
818
  :param str symbol: unified symbol of the market to fetch the order book for
816
819
  :param int [limit]: the maximum amount of order book entries to return
817
820
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -850,6 +853,7 @@ class bitmex(Exchange, ImplicitAPI):
850
853
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
851
854
  """
852
855
  fetches information on an order made by the user
856
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_getOrders
853
857
  :param str symbol: unified symbol of the market the order was made in
854
858
  :param dict [params]: extra parameters specific to the exchange API endpoint
855
859
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -907,6 +911,7 @@ class bitmex(Exchange, ImplicitAPI):
907
911
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
908
912
  """
909
913
  fetch all unfilled currently open orders
914
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_getOrders
910
915
  :param str symbol: unified market symbol
911
916
  :param int [since]: the earliest time in ms to fetch open orders for
912
917
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -923,6 +928,7 @@ class bitmex(Exchange, ImplicitAPI):
923
928
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
924
929
  """
925
930
  fetches information on multiple closed orders made by the user
931
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_getOrders
926
932
  :param str symbol: unified market symbol of the market orders were made in
927
933
  :param int [since]: the earliest time in ms to fetch orders for
928
934
  :param int [limit]: the maximum number of order structures to retrieve
@@ -935,8 +941,8 @@ class bitmex(Exchange, ImplicitAPI):
935
941
 
936
942
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
937
943
  """
938
- :see: https://www.bitmex.com/api/explorer/#not /Execution/Execution_getTradeHistory
939
944
  fetch all trades made by the user
945
+ :see: https://www.bitmex.com/api/explorer/#not /Execution/Execution_getTradeHistory
940
946
  :param str symbol: unified market symbol
941
947
  :param int [since]: the earliest time in ms to fetch trades for
942
948
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -1132,6 +1138,7 @@ class bitmex(Exchange, ImplicitAPI):
1132
1138
  async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1133
1139
  """
1134
1140
  fetch the history of changes, actions done by the user or operations that altered balance of the user
1141
+ :see: https://www.bitmex.com/api/explorer/#not /User/User_getWalletHistory
1135
1142
  :param str code: unified currency code, default is None
1136
1143
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1137
1144
  :param int [limit]: max number of ledger entrys to return, default is None
@@ -1179,6 +1186,7 @@ class bitmex(Exchange, ImplicitAPI):
1179
1186
  async def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1180
1187
  """
1181
1188
  fetch history of deposits and withdrawals
1189
+ :see: https://www.bitmex.com/api/explorer/#not /User/User_getWalletHistory
1182
1190
  :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
1183
1191
  :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
1184
1192
  :param int [limit]: max number of deposit/withdrawals to return, default is None
@@ -1290,6 +1298,7 @@ class bitmex(Exchange, ImplicitAPI):
1290
1298
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1291
1299
  """
1292
1300
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1301
+ :see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_get
1293
1302
  :param str symbol: unified symbol of the market to fetch the ticker for
1294
1303
  :param dict [params]: extra parameters specific to the exchange API endpoint
1295
1304
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1308,6 +1317,7 @@ class bitmex(Exchange, ImplicitAPI):
1308
1317
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1309
1318
  """
1310
1319
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1320
+ :see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_getActiveAndIndices
1311
1321
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1312
1322
  :param dict [params]: extra parameters specific to the exchange API endpoint
1313
1323
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1386,8 +1396,8 @@ class bitmex(Exchange, ImplicitAPI):
1386
1396
 
1387
1397
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1388
1398
  """
1389
- :see: https://www.bitmex.com/api/explorer/#not /Trade/Trade_getBucketed
1390
1399
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1400
+ :see: https://www.bitmex.com/api/explorer/#not /Trade/Trade_getBucketed
1391
1401
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1392
1402
  :param str timeframe: the length of time each candle represents
1393
1403
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1683,8 +1693,8 @@ class bitmex(Exchange, ImplicitAPI):
1683
1693
 
1684
1694
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1685
1695
  """
1686
- :see: https://www.bitmex.com/api/explorer/#not /Trade/Trade_get
1687
1696
  get the list of most recent trades for a particular symbol
1697
+ :see: https://www.bitmex.com/api/explorer/#not /Trade/Trade_get
1688
1698
  :param str symbol: unified symbol of the market to fetch trades for
1689
1699
  :param int [since]: timestamp in ms of the earliest trade to fetch
1690
1700
  :param int [limit]: the maximum amount of trades to fetch
@@ -1866,6 +1876,7 @@ class bitmex(Exchange, ImplicitAPI):
1866
1876
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
1867
1877
  """
1868
1878
  cancels an open order
1879
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_cancel
1869
1880
  :param str id: order id
1870
1881
  :param str symbol: not used by bitmex cancelOrder()
1871
1882
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1891,6 +1902,7 @@ class bitmex(Exchange, ImplicitAPI):
1891
1902
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
1892
1903
  """
1893
1904
  cancel multiple orders
1905
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_cancel
1894
1906
  :param str[] ids: order ids
1895
1907
  :param str symbol: not used by bitmex cancelOrders()
1896
1908
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1912,6 +1924,7 @@ class bitmex(Exchange, ImplicitAPI):
1912
1924
  async def cancel_all_orders(self, symbol: Str = None, params={}):
1913
1925
  """
1914
1926
  cancel all open orders
1927
+ :see: https://www.bitmex.com/api/explorer/#not /Order/Order_cancelAll
1915
1928
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
1916
1929
  :param dict [params]: extra parameters specific to the exchange API endpoint
1917
1930
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1967,6 +1980,7 @@ class bitmex(Exchange, ImplicitAPI):
1967
1980
  async def fetch_positions(self, symbols: Strings = None, params={}):
1968
1981
  """
1969
1982
  fetch all open positions
1983
+ :see: https://www.bitmex.com/api/explorer/#not /Position/Position_get
1970
1984
  :param str[]|None symbols: list of unified market symbols
1971
1985
  :param dict [params]: extra parameters specific to the exchange API endpoint
1972
1986
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -2220,6 +2234,7 @@ class bitmex(Exchange, ImplicitAPI):
2220
2234
  async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2221
2235
  """
2222
2236
  make a withdrawal
2237
+ :see: https://www.bitmex.com/api/explorer/#not /User/User_requestWithdrawal
2223
2238
  :param str code: unified currency code
2224
2239
  :param float amount: the amount to withdraw
2225
2240
  :param str address: the address to withdraw to
@@ -2265,6 +2280,7 @@ class bitmex(Exchange, ImplicitAPI):
2265
2280
  async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2266
2281
  """
2267
2282
  fetch the funding rate for multiple markets
2283
+ :see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_getActiveAndIndices
2268
2284
  :param str[]|None symbols: list of unified market symbols
2269
2285
  :param dict [params]: extra parameters specific to the exchange API endpoint
2270
2286
  :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
@@ -2312,6 +2328,7 @@ class bitmex(Exchange, ImplicitAPI):
2312
2328
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2313
2329
  """
2314
2330
  Fetches the history of funding rates
2331
+ :see: https://www.bitmex.com/api/explorer/#not /Funding/Funding_get
2315
2332
  :param str symbol: unified symbol of the market to fetch the funding rate history for
2316
2333
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
2317
2334
  :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
@@ -2386,6 +2403,7 @@ class bitmex(Exchange, ImplicitAPI):
2386
2403
  async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
2387
2404
  """
2388
2405
  set the level of leverage for a market
2406
+ :see: https://www.bitmex.com/api/explorer/#not /Position/Position_updateLeverage
2389
2407
  :param float leverage: the rate of leverage
2390
2408
  :param str symbol: unified market symbol
2391
2409
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2408,6 +2426,7 @@ class bitmex(Exchange, ImplicitAPI):
2408
2426
  async def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
2409
2427
  """
2410
2428
  set margin mode to 'cross' or 'isolated'
2429
+ :see: https://www.bitmex.com/api/explorer/#not /Position/Position_isolateMargin
2411
2430
  :param str marginMode: 'cross' or 'isolated'
2412
2431
  :param str symbol: unified market symbol
2413
2432
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3526,9 +3526,19 @@ class bybit(Exchange, ImplicitAPI):
3526
3526
  if isStopLoss:
3527
3527
  slTriggerPrice = self.safe_value_2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss)
3528
3528
  request['stopLoss'] = self.price_to_precision(symbol, slTriggerPrice)
3529
+ slLimitPrice = self.safe_value(stopLoss, 'price')
3530
+ if slLimitPrice is not None:
3531
+ request['tpslMode'] = 'Partial'
3532
+ request['slOrderType'] = 'Limit'
3533
+ request['slLimitPrice'] = self.price_to_precision(symbol, slLimitPrice)
3529
3534
  if isTakeProfit:
3530
3535
  tpTriggerPrice = self.safe_value_2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit)
3531
3536
  request['takeProfit'] = self.price_to_precision(symbol, tpTriggerPrice)
3537
+ tpLimitPrice = self.safe_value(takeProfit, 'price')
3538
+ if tpLimitPrice is not None:
3539
+ request['tpslMode'] = 'Partial'
3540
+ request['tpOrderType'] = 'Limit'
3541
+ request['tpLimitPrice'] = self.price_to_precision(symbol, tpLimitPrice)
3532
3542
  if market['spot']:
3533
3543
  # only works for spot market
3534
3544
  if triggerPrice is not None:
@@ -5622,9 +5632,6 @@ class bybit(Exchange, ImplicitAPI):
5622
5632
  timestamp = self.parse8601(self.safe_string(position, 'updated_at'))
5623
5633
  if timestamp is None:
5624
5634
  timestamp = self.safe_integer_n(position, ['updatedTime', 'updatedAt'])
5625
- # default to cross of USDC margined positions
5626
- tradeMode = self.safe_integer(position, 'tradeMode', 0)
5627
- marginMode = 'isolated' if tradeMode else 'cross'
5628
5635
  collateralString = self.safe_string(position, 'positionBalance')
5629
5636
  entryPrice = self.omit_zero(self.safe_string_2(position, 'entryPrice', 'avgPrice'))
5630
5637
  liquidationPrice = self.omit_zero(self.safe_string(position, 'liqPrice'))
@@ -5681,7 +5688,7 @@ class bybit(Exchange, ImplicitAPI):
5681
5688
  'markPrice': self.safe_number(position, 'markPrice'),
5682
5689
  'lastPrice': None,
5683
5690
  'collateral': self.parse_number(collateralString),
5684
- 'marginMode': marginMode,
5691
+ 'marginMode': None,
5685
5692
  'side': side,
5686
5693
  'percentage': None,
5687
5694
  'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
ccxt/async_support/woo.py CHANGED
@@ -1440,11 +1440,12 @@ class woo(Exchange, ImplicitAPI):
1440
1440
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1441
1441
  """
1442
1442
  :see: https://docs.woo.org/#kline-public
1443
+ :see: https://docs.woo.org/#kline-historical-data-public
1443
1444
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1444
1445
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1445
1446
  :param str timeframe: the length of time each candle represents
1446
1447
  :param int [since]: timestamp in ms of the earliest candle to fetch
1447
- :param int [limit]: the maximum amount of candles to fetch
1448
+ :param int [limit]: max=1000, max=100 when since is defined and is less than(now - (999 * (timeframe in ms)))
1448
1449
  :param dict [params]: extra parameters specific to the exchange API endpoint
1449
1450
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1450
1451
  """
@@ -1454,41 +1455,65 @@ class woo(Exchange, ImplicitAPI):
1454
1455
  'symbol': market['id'],
1455
1456
  'type': self.safe_string(self.timeframes, timeframe, timeframe),
1456
1457
  }
1457
- if limit is not None:
1458
+ useHistEndpoint = since is not None
1459
+ if (limit is not None) and (since is not None):
1460
+ oneThousandCandles = self.parse_timeframe(timeframe) * 1000 * 999 # 999 because there will be delay between self and the request, causing the latest candle to be excluded sometimes
1461
+ startWithLimit = self.milliseconds() - oneThousandCandles
1462
+ useHistEndpoint = since < startWithLimit
1463
+ if useHistEndpoint:
1464
+ request['start_time'] = since
1465
+ elif limit is not None: # the hist endpoint does not accept limit
1458
1466
  request['limit'] = min(limit, 1000)
1459
- response = await self.v1PublicGetKline(self.extend(request, params))
1460
- # {
1461
- # "success": True,
1462
- # "rows": [
1463
- # {
1464
- # "open": "0.94238",
1465
- # "close": "0.94271",
1466
- # "low": "0.94238",
1467
- # "high": "0.94296",
1468
- # "volume": "73.55",
1469
- # "amount": "69.32040520",
1470
- # "symbol": "SPOT_WOO_USDT",
1471
- # "type": "1m",
1472
- # "start_timestamp": "1641584700000",
1473
- # "end_timestamp": "1641584760000"
1474
- # },
1475
- # {
1476
- # "open": "0.94186",
1477
- # "close": "0.94186",
1478
- # "low": "0.94186",
1479
- # "high": "0.94186",
1480
- # "volume": "64.00",
1481
- # "amount": "60.27904000",
1482
- # "symbol": "SPOT_WOO_USDT",
1483
- # "type": "1m",
1484
- # "start_timestamp": "1641584640000",
1485
- # "end_timestamp": "1641584700000"
1486
- # },
1487
- # ...
1488
- # ]
1489
- # }
1490
- data = self.safe_value(response, 'rows', [])
1491
- return self.parse_ohlcvs(data, market, timeframe, since, limit)
1467
+ response = None
1468
+ if not useHistEndpoint:
1469
+ response = await self.v1PublicGetKline(self.extend(request, params))
1470
+ #
1471
+ # {
1472
+ # "success": True,
1473
+ # "rows": [
1474
+ # {
1475
+ # "open": "0.94238",
1476
+ # "close": "0.94271",
1477
+ # "low": "0.94238",
1478
+ # "high": "0.94296",
1479
+ # "volume": "73.55",
1480
+ # "amount": "69.32040520",
1481
+ # "symbol": "SPOT_WOO_USDT",
1482
+ # "type": "1m",
1483
+ # "start_timestamp": "1641584700000",
1484
+ # "end_timestamp": "1641584760000"
1485
+ # },
1486
+ # ...
1487
+ # ]
1488
+ # }
1489
+ #
1490
+ else:
1491
+ response = await self.v1PubGetHistKline(self.extend(request, params))
1492
+ response = self.safe_dict(response, 'data')
1493
+ #
1494
+ # {
1495
+ # "success": True,
1496
+ # "data": {
1497
+ # "rows": [
1498
+ # {
1499
+ # "symbol": "SPOT_BTC_USDT",
1500
+ # "open": 44181.40000000,
1501
+ # "close": 44174.29000000,
1502
+ # "high": 44193.44000000,
1503
+ # "low": 44148.34000000,
1504
+ # "volume": 110.11930100,
1505
+ # "amount": 4863796.24318878,
1506
+ # "type": "1m",
1507
+ # "start_timestamp": 1704153600000,
1508
+ # "end_timestamp": 1704153660000
1509
+ # },
1510
+ # ...
1511
+ # ]
1512
+ # }
1513
+ # }
1514
+ #
1515
+ rows = self.safe_value(response, 'rows', [])
1516
+ return self.parse_ohlcvs(rows, market, timeframe, since, limit)
1492
1517
 
1493
1518
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1494
1519
  # example response in fetchOHLCV
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.35'
7
+ __version__ = '4.2.37'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10