ccxt 4.4.25__py2.py3-none-any.whl → 4.4.26__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.
Files changed (55) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/alpaca.py +1 -0
  3. ccxt/abstract/bingx.py +1 -0
  4. ccxt/abstract/okx.py +1 -0
  5. ccxt/abstract/phemex.py +1 -0
  6. ccxt/alpaca.py +245 -12
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/alpaca.py +245 -12
  9. ccxt/async_support/base/exchange.py +6 -6
  10. ccxt/async_support/binance.py +5 -6
  11. ccxt/async_support/bingx.py +6 -1
  12. ccxt/async_support/bitget.py +5 -5
  13. ccxt/async_support/bitmart.py +6 -6
  14. ccxt/async_support/bybit.py +6 -15
  15. ccxt/async_support/cex.py +36 -0
  16. ccxt/async_support/coinex.py +5 -7
  17. ccxt/async_support/digifinex.py +5 -5
  18. ccxt/async_support/exmo.py +1 -0
  19. ccxt/async_support/gate.py +6 -6
  20. ccxt/async_support/htx.py +5 -6
  21. ccxt/async_support/hyperliquid.py +12 -4
  22. ccxt/async_support/kucoin.py +5 -5
  23. ccxt/async_support/okx.py +6 -5
  24. ccxt/async_support/phemex.py +4 -2
  25. ccxt/async_support/whitebit.py +5 -5
  26. ccxt/async_support/woo.py +1 -1
  27. ccxt/async_support/xt.py +32 -24
  28. ccxt/base/exchange.py +11 -6
  29. ccxt/base/types.py +12 -0
  30. ccxt/binance.py +5 -6
  31. ccxt/bingx.py +6 -1
  32. ccxt/bitget.py +5 -5
  33. ccxt/bitmart.py +6 -6
  34. ccxt/bybit.py +6 -15
  35. ccxt/cex.py +36 -0
  36. ccxt/coinex.py +5 -7
  37. ccxt/digifinex.py +5 -5
  38. ccxt/exmo.py +1 -0
  39. ccxt/gate.py +6 -6
  40. ccxt/htx.py +5 -6
  41. ccxt/hyperliquid.py +12 -4
  42. ccxt/kucoin.py +5 -5
  43. ccxt/okx.py +6 -5
  44. ccxt/phemex.py +4 -2
  45. ccxt/pro/__init__.py +1 -1
  46. ccxt/pro/exmo.py +204 -4
  47. ccxt/test/tests_helpers.py +3 -1
  48. ccxt/whitebit.py +5 -5
  49. ccxt/woo.py +1 -1
  50. ccxt/xt.py +32 -24
  51. {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/METADATA +5 -5
  52. {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/RECORD +55 -55
  53. {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/LICENSE.txt +0 -0
  54. {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/WHEEL +0 -0
  55. {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/top_level.txt +0 -0
ccxt/binance.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.binance import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import LongShortRatio, Balances, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, LongShortRatio, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -11304,7 +11304,7 @@ class binance(Exchange, ImplicitAPI):
11304
11304
  #
11305
11305
  return response
11306
11306
 
11307
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
11307
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
11308
11308
  """
11309
11309
  fetch the interest owed by the user for borrowing currency for margin trading
11310
11310
  :see: https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
@@ -11378,21 +11378,20 @@ class binance(Exchange, ImplicitAPI):
11378
11378
  interest = self.parse_borrow_interests(rows, market)
11379
11379
  return self.filter_by_currency_since_limit(interest, code, since, limit)
11380
11380
 
11381
- def parse_borrow_interest(self, info: dict, market: Market = None):
11381
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
11382
11382
  symbol = self.safe_string(info, 'isolatedSymbol')
11383
11383
  timestamp = self.safe_integer(info, 'interestAccuredTime')
11384
11384
  marginMode = 'cross' if (symbol is None) else 'isolated'
11385
11385
  return {
11386
- 'account': 'cross' if (symbol is None) else symbol,
11386
+ 'info': info,
11387
11387
  'symbol': symbol,
11388
- 'marginMode': marginMode,
11389
11388
  'currency': self.safe_currency_code(self.safe_string(info, 'asset')),
11390
11389
  'interest': self.safe_number(info, 'interest'),
11391
11390
  'interestRate': self.safe_number(info, 'interestRate'),
11392
11391
  'amountBorrowed': self.safe_number(info, 'principal'),
11392
+ 'marginMode': marginMode,
11393
11393
  'timestamp': timestamp,
11394
11394
  'datetime': self.iso8601(timestamp),
11395
- 'info': info,
11396
11395
  }
11397
11396
 
11398
11397
  def repay_cross_margin(self, code: str, amount, params={}):
ccxt/bingx.py CHANGED
@@ -219,6 +219,7 @@ class bingx(Exchange, ImplicitAPI):
219
219
  'market/markPriceKlines': 1,
220
220
  'trade/batchCancelReplace': 5,
221
221
  'trade/fullOrder': 2,
222
+ 'positionMargin/history': 2,
222
223
  },
223
224
  'post': {
224
225
  'trade/cancelReplace': 2,
@@ -2676,6 +2677,7 @@ class bingx(Exchange, ImplicitAPI):
2676
2677
  :see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
2677
2678
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2678
2679
  :param dict [params]: extra parameters specific to the exchange API endpoint
2680
+ :param boolean [params.sync]: *spot only* if True, multiple orders are ordered serially and all orders do not require the same symbol/side/type
2679
2681
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2680
2682
  """
2681
2683
  self.load_markets()
@@ -2703,6 +2705,9 @@ class bingx(Exchange, ImplicitAPI):
2703
2705
  request['batchOrders'] = self.json(ordersRequests)
2704
2706
  response = self.swapV2PrivatePostTradeBatchOrders(request)
2705
2707
  else:
2708
+ sync = self.safe_bool(params, 'sync', False)
2709
+ if sync:
2710
+ request['sync'] = True
2706
2711
  request['data'] = self.json(ordersRequests)
2707
2712
  response = self.spotV1PrivatePostTradeBatchOrders(request)
2708
2713
  #
@@ -3139,7 +3144,7 @@ class bingx(Exchange, ImplicitAPI):
3139
3144
  'cost': Precise.string_abs(feeCost),
3140
3145
  },
3141
3146
  'trades': None,
3142
- 'reduceOnly': self.safe_bool(order, 'reduceOnly'),
3147
+ 'reduceOnly': self.safe_bool_2(order, 'reduceOnly', 'ro'),
3143
3148
  }, market)
3144
3149
 
3145
3150
  def parse_order_status(self, status: Str):
ccxt/bitget.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitget import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import LongShortRatio, Balances, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, LongShortRatio, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -7628,7 +7628,7 @@ class bitget(Exchange, ImplicitAPI):
7628
7628
  'info': info,
7629
7629
  }
7630
7630
 
7631
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
7631
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
7632
7632
  """
7633
7633
  fetch the interest owed by the user for borrowing currency for margin trading
7634
7634
  :see: https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
@@ -7725,7 +7725,7 @@ class bitget(Exchange, ImplicitAPI):
7725
7725
  interest = self.parse_borrow_interests(rows, market)
7726
7726
  return self.filter_by_currency_since_limit(interest, code, since, limit)
7727
7727
 
7728
- def parse_borrow_interest(self, info: dict, market: Market = None):
7728
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
7729
7729
  #
7730
7730
  # isolated
7731
7731
  #
@@ -7759,15 +7759,15 @@ class bitget(Exchange, ImplicitAPI):
7759
7759
  marginMode = 'isolated' if (marketId is not None) else 'cross'
7760
7760
  timestamp = self.safe_integer(info, 'cTime')
7761
7761
  return {
7762
+ 'info': info,
7762
7763
  'symbol': self.safe_string(market, 'symbol'),
7763
- 'marginMode': marginMode,
7764
7764
  'currency': self.safe_currency_code(self.safe_string(info, 'interestCoin')),
7765
7765
  'interest': self.safe_number(info, 'interestAmount'),
7766
7766
  'interestRate': self.safe_number(info, 'dailyInterestRate'),
7767
7767
  'amountBorrowed': None,
7768
+ 'marginMode': marginMode,
7768
7769
  'timestamp': timestamp,
7769
7770
  'datetime': self.iso8601(timestamp),
7770
- 'info': info,
7771
7771
  }
7772
7772
 
7773
7773
  def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
ccxt/bitmart.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmart import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -1806,7 +1806,7 @@ class bitmart(Exchange, ImplicitAPI):
1806
1806
  if since is not None:
1807
1807
  request['after'] = self.parse_to_int((since / 1000)) - 1
1808
1808
  else:
1809
- maxLimit = 1200
1809
+ maxLimit = 500
1810
1810
  if limit is None:
1811
1811
  limit = maxLimit
1812
1812
  limit = min(maxLimit, limit)
@@ -3983,7 +3983,7 @@ class bitmart(Exchange, ImplicitAPI):
3983
3983
  records = self.safe_list(data, 'records', [])
3984
3984
  return self.parse_transfers(records, currency, since, limit)
3985
3985
 
3986
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3986
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
3987
3987
  """
3988
3988
  fetch the interest owed by the user for borrowing currency for margin trading
3989
3989
  :see: https://developer-pro.bitmart.com/en/spot/#get-borrow-record-isolated
@@ -4032,7 +4032,7 @@ class bitmart(Exchange, ImplicitAPI):
4032
4032
  interest = self.parse_borrow_interests(rows, market)
4033
4033
  return self.filter_by_currency_since_limit(interest, code, since, limit)
4034
4034
 
4035
- def parse_borrow_interest(self, info: dict, market: Market = None):
4035
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
4036
4036
  #
4037
4037
  # {
4038
4038
  # "borrow_id": "1657664327844Lk5eJJugXmdHHZoe",
@@ -4049,15 +4049,15 @@ class bitmart(Exchange, ImplicitAPI):
4049
4049
  market = self.safe_market(marketId, market)
4050
4050
  timestamp = self.safe_integer(info, 'create_time')
4051
4051
  return {
4052
+ 'info': info,
4052
4053
  'symbol': self.safe_string(market, 'symbol'),
4053
- 'marginMode': 'isolated',
4054
4054
  'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
4055
4055
  'interest': self.safe_number(info, 'interest_amount'),
4056
4056
  'interestRate': self.safe_number(info, 'hourly_interest'),
4057
4057
  'amountBorrowed': self.safe_number(info, 'borrow_amount'),
4058
+ 'marginMode': 'isolated',
4058
4059
  'timestamp': timestamp, # borrow creation time
4059
4060
  'datetime': self.iso8601(timestamp),
4060
- 'info': info,
4061
4061
  }
4062
4062
 
4063
4063
  def fetch_open_interest(self, symbol: str, params={}):
ccxt/bybit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import LongShortRatio, Balances, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, LongShortRatio, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -1018,7 +1018,6 @@ class bybit(Exchange, ImplicitAPI):
1018
1018
  'precisionMode': TICK_SIZE,
1019
1019
  'options': {
1020
1020
  'usePrivateInstrumentsInfo': False,
1021
- 'sandboxMode': False,
1022
1021
  'enableDemoTrading': False,
1023
1022
  'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
1024
1023
  'createOrder': {
@@ -1104,21 +1103,13 @@ class bybit(Exchange, ImplicitAPI):
1104
1103
  },
1105
1104
  })
1106
1105
 
1107
- def set_sandbox_mode(self, enable: bool):
1108
- """
1109
- enables or disables sandbox mode
1110
- :param boolean [enable]: True if demo trading should be enabled, False otherwise
1111
- """
1112
- super(bybit, self).set_sandbox_mode(enable)
1113
- self.options['sandboxMode'] = enable
1114
-
1115
1106
  def enable_demo_trading(self, enable: bool):
1116
1107
  """
1117
1108
  enables or disables demo trading mode
1118
1109
  :see: https://bybit-exchange.github.io/docs/v5/demo
1119
1110
  :param boolean [enable]: True if demo trading should be enabled, False otherwise
1120
1111
  """
1121
- if self.options['sandboxMode']:
1112
+ if self.isSandboxModeEnabled:
1122
1113
  raise NotSupported(self.id + ' demo trading does not support in sandbox environment')
1123
1114
  # enable demo trading in bybit, see: https://bybit-exchange.github.io/docs/v5/demo
1124
1115
  if enable:
@@ -6832,7 +6823,7 @@ class bybit(Exchange, ImplicitAPI):
6832
6823
  'info': info,
6833
6824
  }
6834
6825
 
6835
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
6826
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
6836
6827
  """
6837
6828
  fetch the interest owed by the user for borrowing currency for margin trading
6838
6829
  :see: https://bybit-exchange.github.io/docs/zh-TW/v5/spot-margin-normal/account-info
@@ -6923,7 +6914,7 @@ class bybit(Exchange, ImplicitAPI):
6923
6914
  rows = self.safe_list(data, 'list', [])
6924
6915
  return self.parse_borrow_rate_history(rows, code, since, limit)
6925
6916
 
6926
- def parse_borrow_interest(self, info: dict, market: Market = None):
6917
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
6927
6918
  #
6928
6919
  # {
6929
6920
  # "tokenId": "BTC",
@@ -6935,15 +6926,15 @@ class bybit(Exchange, ImplicitAPI):
6935
6926
  # },
6936
6927
  #
6937
6928
  return {
6929
+ 'info': info,
6938
6930
  'symbol': None,
6939
- 'marginMode': 'cross',
6940
6931
  'currency': self.safe_currency_code(self.safe_string(info, 'tokenId')),
6941
6932
  'interest': self.safe_number(info, 'interest'),
6942
6933
  'interestRate': None,
6943
6934
  'amountBorrowed': self.safe_number(info, 'loan'),
6935
+ 'marginMode': 'cross',
6944
6936
  'timestamp': None,
6945
6937
  'datetime': None,
6946
- 'info': info,
6947
6938
  }
6948
6939
 
6949
6940
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
ccxt/cex.py CHANGED
@@ -39,6 +39,7 @@ class cex(Exchange, ImplicitAPI):
39
39
  'createOrder': True,
40
40
  'fetchAccounts': True,
41
41
  'fetchBalance': True,
42
+ 'fetchClosedOrder': True,
42
43
  'fetchClosedOrders': True,
43
44
  'fetchCurrencies': True,
44
45
  'fetchDepositAddress': True,
@@ -50,6 +51,7 @@ class cex(Exchange, ImplicitAPI):
50
51
  'fetchLedger': True,
51
52
  'fetchMarkets': True,
52
53
  'fetchOHLCV': True,
54
+ 'fetchOpenOrder': True,
53
55
  'fetchOpenOrders': True,
54
56
  'fetchOrderBook': True,
55
57
  'fetchTicker': True,
@@ -898,6 +900,7 @@ class cex(Exchange, ImplicitAPI):
898
900
 
899
901
  def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
900
902
  """
903
+ :see: https://trade.cex.io/docs/#rest-private-api-calls-orders
901
904
  fetches information on multiple canceled orders made by the user
902
905
  :param str symbol: unified market symbol of the market orders were made in
903
906
  :param int [since]: timestamp in ms of the earliest order, default is None
@@ -909,6 +912,7 @@ class cex(Exchange, ImplicitAPI):
909
912
 
910
913
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
911
914
  """
915
+ :see: https://trade.cex.io/docs/#rest-private-api-calls-orders
912
916
  fetches information on multiple canceled orders made by the user
913
917
  :param str symbol: unified market symbol of the market orders were made in
914
918
  :param int [since]: timestamp in ms of the earliest order, default is None
@@ -918,6 +922,38 @@ class cex(Exchange, ImplicitAPI):
918
922
  """
919
923
  return self.fetch_orders_by_status('open', symbol, since, limit, params)
920
924
 
925
+ def fetch_open_order(self, id: str, symbol: Str = None, params={}):
926
+ """
927
+ fetches information on an open order made by the user
928
+ :see: https://trade.cex.io/docs/#rest-private-api-calls-orders
929
+ :param str id: order id
930
+ :param str [symbol]: unified symbol of the market the order was made in
931
+ :param dict [params]: extra parameters specific to the exchange API endpoint
932
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
933
+ """
934
+ self.load_markets()
935
+ request: dict = {
936
+ 'orderId': int(id),
937
+ }
938
+ result = self.fetch_open_orders(symbol, None, None, self.extend(request, params))
939
+ return result[0]
940
+
941
+ def fetch_closed_order(self, id: str, symbol: Str = None, params={}):
942
+ """
943
+ fetches information on an closed order made by the user
944
+ :see: https://trade.cex.io/docs/#rest-private-api-calls-orders
945
+ :param str id: order id
946
+ :param str [symbol]: unified symbol of the market the order was made in
947
+ :param dict [params]: extra parameters specific to the exchange API endpoint
948
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
949
+ """
950
+ self.load_markets()
951
+ request: dict = {
952
+ 'orderId': int(id),
953
+ }
954
+ result = self.fetch_closed_orders(symbol, None, None, self.extend(request, params))
955
+ return result[0]
956
+
921
957
  def parse_order_status(self, status: Str):
922
958
  statuses: dict = {
923
959
  'FILLED': 'closed',
ccxt/coinex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
8
+ from ccxt.base.types import Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -4959,7 +4959,7 @@ class coinex(Exchange, ImplicitAPI):
4959
4959
  data = self.safe_dict(response, 'data', {})
4960
4960
  return self.parse_isolated_borrow_rate(data, market)
4961
4961
 
4962
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4962
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
4963
4963
  """
4964
4964
  fetch the interest owed by the user for borrowing currency for margin trading
4965
4965
  :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
@@ -5007,7 +5007,7 @@ class coinex(Exchange, ImplicitAPI):
5007
5007
  interest = self.parse_borrow_interests(rows, market)
5008
5008
  return self.filter_by_currency_since_limit(interest, code, since, limit)
5009
5009
 
5010
- def parse_borrow_interest(self, info: dict, market: Market = None):
5010
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
5011
5011
  #
5012
5012
  # {
5013
5013
  # "borrow_id": 2642934,
@@ -5026,17 +5026,15 @@ class coinex(Exchange, ImplicitAPI):
5026
5026
  market = self.safe_market(marketId, market, None, 'spot')
5027
5027
  timestamp = self.safe_integer(info, 'expired_at')
5028
5028
  return {
5029
- 'account': None, # deprecated
5029
+ 'info': info,
5030
5030
  'symbol': market['symbol'],
5031
- 'marginMode': 'isolated',
5032
- 'marginType': None, # deprecated
5033
5031
  'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
5034
5032
  'interest': self.safe_number(info, 'to_repaied_amount'),
5035
5033
  'interestRate': self.safe_number(info, 'daily_interest_rate'),
5036
5034
  'amountBorrowed': self.safe_number(info, 'borrow_amount'),
5035
+ 'marginMode': 'isolated',
5037
5036
  'timestamp': timestamp, # expiry time
5038
5037
  'datetime': self.iso8601(timestamp),
5039
- 'info': info,
5040
5038
  }
5041
5039
 
5042
5040
  def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
ccxt/digifinex.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -2816,7 +2816,7 @@ class digifinex(Exchange, ImplicitAPI):
2816
2816
  #
2817
2817
  return self.parse_transaction(response, currency)
2818
2818
 
2819
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2819
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
2820
2820
  self.load_markets()
2821
2821
  request: dict = {}
2822
2822
  market = None
@@ -2849,7 +2849,7 @@ class digifinex(Exchange, ImplicitAPI):
2849
2849
  interest = self.parse_borrow_interests(rows, market)
2850
2850
  return self.filter_by_currency_since_limit(interest, code, since, limit)
2851
2851
 
2852
- def parse_borrow_interest(self, info: dict, market: Market = None):
2852
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
2853
2853
  #
2854
2854
  # {
2855
2855
  # "amount": 0.0006103,
@@ -2871,15 +2871,15 @@ class digifinex(Exchange, ImplicitAPI):
2871
2871
  currency = None if (market is None) else market['base']
2872
2872
  symbol = self.safe_symbol(marketId, market)
2873
2873
  return {
2874
- 'account': symbol,
2874
+ 'info': info,
2875
2875
  'symbol': symbol,
2876
2876
  'currency': currency,
2877
2877
  'interest': None,
2878
2878
  'interestRate': 0.001, # all interest rates on digifinex are 0.1%
2879
2879
  'amountBorrowed': self.parse_number(amountBorrowed),
2880
+ 'marginMode': None,
2880
2881
  'timestamp': None,
2881
2882
  'datetime': None,
2882
- 'info': info,
2883
2883
  }
2884
2884
 
2885
2885
  def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
ccxt/exmo.py CHANGED
@@ -223,6 +223,7 @@ class exmo(Exchange, ImplicitAPI):
223
223
  'precisionMode': TICK_SIZE,
224
224
  'exceptions': {
225
225
  'exact': {
226
+ '140333': InvalidOrder, # {"error":{"code":140333,"msg":"The number of characters after the point in the price exceeds the maximum number '8\u003e6'"}}
226
227
  '140434': BadRequest,
227
228
  '40005': AuthenticationError, # Authorization error, incorrect signature
228
229
  '40009': InvalidNonce, #
ccxt/gate.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Bool, Currencies, Currency, DepositAddress, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, BorrowInterest, Bool, Currencies, Currency, DepositAddress, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -5968,7 +5968,7 @@ class gate(Exchange, ImplicitAPI):
5968
5968
  'info': info,
5969
5969
  }
5970
5970
 
5971
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
5971
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
5972
5972
  """
5973
5973
  fetch the interest owed by the user for borrowing currency for margin trading
5974
5974
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-interest-records
@@ -6013,21 +6013,21 @@ class gate(Exchange, ImplicitAPI):
6013
6013
  interest = self.parse_borrow_interests(response, market)
6014
6014
  return self.filter_by_currency_since_limit(interest, code, since, limit)
6015
6015
 
6016
- def parse_borrow_interest(self, info: dict, market: Market = None):
6016
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
6017
6017
  marketId = self.safe_string(info, 'currency_pair')
6018
6018
  market = self.safe_market(marketId, market)
6019
6019
  marginMode = 'isolated' if (marketId is not None) else 'cross'
6020
6020
  timestamp = self.safe_integer(info, 'create_time')
6021
6021
  return {
6022
6022
  'info': info,
6023
- 'timestamp': timestamp,
6024
- 'datetime': self.iso8601(timestamp),
6025
6023
  'symbol': self.safe_string(market, 'symbol'),
6026
6024
  'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
6027
- 'marginMode': marginMode,
6028
6025
  'interest': self.safe_number(info, 'interest'),
6029
6026
  'interestRate': self.safe_number(info, 'actual_rate'),
6030
6027
  'amountBorrowed': None,
6028
+ 'marginMode': marginMode,
6029
+ 'timestamp': timestamp,
6030
+ 'datetime': self.iso8601(timestamp),
6031
6031
  }
6032
6032
 
6033
6033
  def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
ccxt/htx.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.htx import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -6574,7 +6574,7 @@ class htx(Exchange, ImplicitAPI):
6574
6574
  result = self.parse_funding_rates(data)
6575
6575
  return self.filter_by_array(result, 'symbol', symbols)
6576
6576
 
6577
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
6577
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
6578
6578
  """
6579
6579
  fetch the interest owed by the user for borrowing currency for margin trading
6580
6580
  :see: https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-cross
@@ -6633,7 +6633,7 @@ class htx(Exchange, ImplicitAPI):
6633
6633
  interest = self.parse_borrow_interests(data, market)
6634
6634
  return self.filter_by_currency_since_limit(interest, code, since, limit)
6635
6635
 
6636
- def parse_borrow_interest(self, info: dict, market: Market = None):
6636
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
6637
6637
  # isolated
6638
6638
  # {
6639
6639
  # "interest-rate":"0.000040830000000000",
@@ -6681,16 +6681,15 @@ class htx(Exchange, ImplicitAPI):
6681
6681
  symbol = self.safe_string(market, 'symbol')
6682
6682
  timestamp = self.safe_integer(info, 'accrued-at')
6683
6683
  return {
6684
- 'account': symbol if (marginMode == 'isolated') else 'cross', # deprecated
6684
+ 'info': info,
6685
6685
  'symbol': symbol,
6686
- 'marginMode': marginMode,
6687
6686
  'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
6688
6687
  'interest': self.safe_number(info, 'interest-amount'),
6689
6688
  'interestRate': self.safe_number(info, 'interest-rate'),
6690
6689
  'amountBorrowed': self.safe_number(info, 'loan-amount'),
6690
+ 'marginMode': marginMode,
6691
6691
  'timestamp': timestamp, # Interest accrued time
6692
6692
  'datetime': self.iso8601(timestamp),
6693
- 'info': info,
6694
6693
  }
6695
6694
 
6696
6695
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
ccxt/hyperliquid.py CHANGED
@@ -769,9 +769,16 @@ class hyperliquid(Exchange, ImplicitAPI):
769
769
  self.load_markets()
770
770
  market = self.market(symbol)
771
771
  until = self.safe_integer(params, 'until', self.milliseconds())
772
- useTail = (since is None)
772
+ useTail = since is None
773
+ originalSince = since
773
774
  if since is None:
774
- since = 0
775
+ if limit is not None:
776
+ # optimization if limit is provided
777
+ timeframeInMilliseconds = self.parse_timeframe(timeframe) * 1000
778
+ since = self.sum(until, timeframeInMilliseconds * limit * -1)
779
+ useTail = False
780
+ else:
781
+ since = 0
775
782
  params = self.omit(params, ['until'])
776
783
  request: dict = {
777
784
  'type': 'candleSnapshot',
@@ -799,7 +806,7 @@ class hyperliquid(Exchange, ImplicitAPI):
799
806
  # }
800
807
  # ]
801
808
  #
802
- return self.parse_ohlcvs(response, market, timeframe, since, limit, useTail)
809
+ return self.parse_ohlcvs(response, market, timeframe, originalSince, limit, useTail)
803
810
 
804
811
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
805
812
  #
@@ -1533,7 +1540,8 @@ class hyperliquid(Exchange, ImplicitAPI):
1533
1540
  if since is not None:
1534
1541
  request['startTime'] = since
1535
1542
  else:
1536
- request['startTime'] = self.milliseconds() - 100 * 60 * 60 * 1000
1543
+ maxLimit = 500 if (limit is None) else limit
1544
+ request['startTime'] = self.milliseconds() - maxLimit * 60 * 60 * 1000
1537
1545
  until = self.safe_integer(params, 'until')
1538
1546
  params = self.omit(params, 'until')
1539
1547
  if until is not None:
ccxt/kucoin.py CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.kucoin import ImplicitAPI
8
8
  import hashlib
9
9
  import math
10
10
  import json
11
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
+ from ccxt.base.types import Account, Balances, BorrowInterest, Bool, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -4153,7 +4153,7 @@ class kucoin(Exchange, ImplicitAPI):
4153
4153
  'info': info,
4154
4154
  }
4155
4155
 
4156
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4156
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
4157
4157
  """
4158
4158
  fetch the interest owed by the user for borrowing currency for margin trading
4159
4159
  :see: https://docs.kucoin.com/#get-repay-record
@@ -4248,7 +4248,7 @@ class kucoin(Exchange, ImplicitAPI):
4248
4248
  assets = self.safe_list(data, 'assets', []) if (marginMode == 'isolated') else self.safe_list(data, 'accounts', [])
4249
4249
  return self.parse_borrow_interests(assets, None)
4250
4250
 
4251
- def parse_borrow_interest(self, info: dict, market: Market = None):
4251
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
4252
4252
  #
4253
4253
  # Cross
4254
4254
  #
@@ -4311,15 +4311,15 @@ class kucoin(Exchange, ImplicitAPI):
4311
4311
  interest = self.safe_number(info, 'accruedInterest')
4312
4312
  currencyId = self.safe_string(info, 'currency')
4313
4313
  return {
4314
+ 'info': info,
4314
4315
  'symbol': symbol,
4315
- 'marginMode': marginMode,
4316
4316
  'currency': self.safe_currency_code(currencyId),
4317
4317
  'interest': interest,
4318
4318
  'interestRate': self.safe_number(info, 'dailyIntRate'),
4319
4319
  'amountBorrowed': amountBorrowed,
4320
+ 'marginMode': marginMode,
4320
4321
  'timestamp': timestamp, # create time
4321
4322
  'datetime': self.iso8601(timestamp),
4322
- 'info': info,
4323
4323
  }
4324
4324
 
4325
4325
  def fetch_borrow_rate_histories(self, codes=None, since: Int = None, limit: Int = None, params={}):