ccxt 4.4.39__py2.py3-none-any.whl → 4.4.41__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 (137) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bitmart.py +2 -0
  3. ccxt/abstract/okx.py +5 -0
  4. ccxt/ascendex.py +9 -9
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/ascendex.py +9 -9
  7. ccxt/async_support/base/exchange.py +10 -3
  8. ccxt/async_support/base/ws/aiohttp_client.py +2 -2
  9. ccxt/async_support/binance.py +37 -41
  10. ccxt/async_support/bingx.py +4 -3
  11. ccxt/async_support/bit2c.py +0 -1
  12. ccxt/async_support/bitbank.py +0 -1
  13. ccxt/async_support/bitbns.py +0 -1
  14. ccxt/async_support/bitfinex.py +16 -17
  15. ccxt/async_support/bitfinex1.py +0 -1
  16. ccxt/async_support/bitflyer.py +0 -1
  17. ccxt/async_support/bitget.py +2 -2
  18. ccxt/async_support/bithumb.py +0 -1
  19. ccxt/async_support/bitmart.py +246 -6
  20. ccxt/async_support/bitmex.py +5 -6
  21. ccxt/async_support/bitopro.py +4 -5
  22. ccxt/async_support/bitrue.py +5 -7
  23. ccxt/async_support/bitso.py +1 -2
  24. ccxt/async_support/bitstamp.py +1 -2
  25. ccxt/async_support/bitteam.py +1 -3
  26. ccxt/async_support/bitvavo.py +2 -4
  27. ccxt/async_support/blockchaincom.py +5 -5
  28. ccxt/async_support/blofin.py +10 -10
  29. ccxt/async_support/btcalpha.py +0 -1
  30. ccxt/async_support/btcbox.py +0 -1
  31. ccxt/async_support/btcmarkets.py +1 -3
  32. ccxt/async_support/bybit.py +10 -11
  33. ccxt/async_support/cex.py +1 -1
  34. ccxt/async_support/coinbase.py +77 -1
  35. ccxt/async_support/coinbaseexchange.py +1 -1
  36. ccxt/async_support/coinbaseinternational.py +62 -0
  37. ccxt/async_support/coincatch.py +1 -1
  38. ccxt/async_support/coinex.py +9 -9
  39. ccxt/async_support/coinlist.py +1 -1
  40. ccxt/async_support/coinmetro.py +1 -1
  41. ccxt/async_support/cryptocom.py +91 -2
  42. ccxt/async_support/currencycom.py +1 -1
  43. ccxt/async_support/defx.py +1 -2
  44. ccxt/async_support/delta.py +1 -1
  45. ccxt/async_support/digifinex.py +1 -1
  46. ccxt/async_support/exmo.py +62 -6
  47. ccxt/async_support/gate.py +2 -2
  48. ccxt/async_support/hashkey.py +3 -5
  49. ccxt/async_support/htx.py +2 -2
  50. ccxt/async_support/hyperliquid.py +61 -2
  51. ccxt/async_support/kraken.py +124 -26
  52. ccxt/async_support/kucoin.py +29 -25
  53. ccxt/async_support/luno.py +1 -1
  54. ccxt/async_support/mexc.py +137 -1
  55. ccxt/async_support/ndax.py +1 -1
  56. ccxt/async_support/okcoin.py +18 -18
  57. ccxt/async_support/okx.py +27 -22
  58. ccxt/async_support/phemex.py +12 -8
  59. ccxt/async_support/poloniex.py +1 -1
  60. ccxt/async_support/poloniexfutures.py +6 -6
  61. ccxt/async_support/vertex.py +11 -11
  62. ccxt/async_support/woo.py +33 -33
  63. ccxt/async_support/woofipro.py +24 -24
  64. ccxt/async_support/xt.py +29 -27
  65. ccxt/async_support/zonda.py +1 -1
  66. ccxt/base/exchange.py +31 -19
  67. ccxt/base/types.py +10 -0
  68. ccxt/binance.py +37 -41
  69. ccxt/bingx.py +4 -3
  70. ccxt/bit2c.py +0 -1
  71. ccxt/bitbank.py +0 -1
  72. ccxt/bitbns.py +0 -1
  73. ccxt/bitfinex.py +16 -17
  74. ccxt/bitfinex1.py +0 -1
  75. ccxt/bitflyer.py +0 -1
  76. ccxt/bitget.py +2 -2
  77. ccxt/bithumb.py +0 -1
  78. ccxt/bitmart.py +246 -6
  79. ccxt/bitmex.py +5 -6
  80. ccxt/bitopro.py +4 -5
  81. ccxt/bitrue.py +5 -7
  82. ccxt/bitso.py +1 -2
  83. ccxt/bitstamp.py +1 -2
  84. ccxt/bitteam.py +1 -3
  85. ccxt/bitvavo.py +2 -4
  86. ccxt/blockchaincom.py +5 -5
  87. ccxt/blofin.py +10 -10
  88. ccxt/btcalpha.py +0 -1
  89. ccxt/btcbox.py +0 -1
  90. ccxt/btcmarkets.py +1 -3
  91. ccxt/bybit.py +10 -11
  92. ccxt/cex.py +1 -1
  93. ccxt/coinbase.py +77 -1
  94. ccxt/coinbaseexchange.py +1 -1
  95. ccxt/coinbaseinternational.py +62 -0
  96. ccxt/coincatch.py +1 -1
  97. ccxt/coinex.py +9 -9
  98. ccxt/coinlist.py +1 -1
  99. ccxt/coinmetro.py +1 -1
  100. ccxt/cryptocom.py +91 -2
  101. ccxt/currencycom.py +1 -1
  102. ccxt/defx.py +1 -2
  103. ccxt/delta.py +1 -1
  104. ccxt/digifinex.py +1 -1
  105. ccxt/exmo.py +62 -6
  106. ccxt/gate.py +2 -2
  107. ccxt/hashkey.py +3 -5
  108. ccxt/htx.py +2 -2
  109. ccxt/hyperliquid.py +61 -2
  110. ccxt/kraken.py +124 -26
  111. ccxt/kucoin.py +29 -25
  112. ccxt/luno.py +1 -1
  113. ccxt/mexc.py +137 -1
  114. ccxt/ndax.py +1 -1
  115. ccxt/okcoin.py +18 -18
  116. ccxt/okx.py +27 -22
  117. ccxt/phemex.py +12 -8
  118. ccxt/poloniex.py +1 -1
  119. ccxt/poloniexfutures.py +6 -6
  120. ccxt/pro/__init__.py +1 -1
  121. ccxt/pro/bitget.py +1 -1
  122. ccxt/pro/bybit.py +12 -1
  123. ccxt/pro/coinex.py +2 -2
  124. ccxt/pro/gate.py +6 -6
  125. ccxt/pro/kucoin.py +3 -3
  126. ccxt/pro/okx.py +11 -11
  127. ccxt/pro/upbit.py +2 -2
  128. ccxt/vertex.py +11 -11
  129. ccxt/woo.py +33 -33
  130. ccxt/woofipro.py +24 -24
  131. ccxt/xt.py +29 -27
  132. ccxt/zonda.py +1 -1
  133. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/METADATA +4 -4
  134. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/RECORD +137 -137
  135. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/LICENSE.txt +0 -0
  136. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/WHEEL +0 -0
  137. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/top_level.txt +0 -0
@@ -1484,10 +1484,10 @@ class bitfinex(Exchange, ImplicitAPI):
1484
1484
  if flags[i] == 'postOnly':
1485
1485
  postOnly = True
1486
1486
  price = self.safe_string(orderList, 16)
1487
- stopPrice = None
1487
+ triggerPrice = None
1488
1488
  if (orderType == 'EXCHANGE STOP') or (orderType == 'EXCHANGE STOP LIMIT'):
1489
1489
  price = None
1490
- stopPrice = self.safe_string(orderList, 16)
1490
+ triggerPrice = self.safe_string(orderList, 16)
1491
1491
  if orderType == 'EXCHANGE STOP LIMIT':
1492
1492
  price = self.safe_string(orderList, 19)
1493
1493
  status = None
@@ -1510,8 +1510,7 @@ class bitfinex(Exchange, ImplicitAPI):
1510
1510
  'postOnly': postOnly,
1511
1511
  'side': side,
1512
1512
  'price': price,
1513
- 'stopPrice': stopPrice,
1514
- 'triggerPrice': stopPrice,
1513
+ 'triggerPrice': triggerPrice,
1515
1514
  'amount': amount,
1516
1515
  'cost': None,
1517
1516
  'average': average,
@@ -1532,7 +1531,7 @@ class bitfinex(Exchange, ImplicitAPI):
1532
1531
  :param float amount: how much you want to trade in units of the base currency
1533
1532
  :param float [price]: the price of the order, in units of the quote currency, ignored in market orders
1534
1533
  :param dict [params]: extra parameters specific to the exchange API endpoint
1535
- :param float [params.stopPrice]: The price at which a trigger order is triggered at
1534
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
1536
1535
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1537
1536
  :param bool [params.postOnly]:
1538
1537
  :param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
@@ -1550,7 +1549,7 @@ class bitfinex(Exchange, ImplicitAPI):
1550
1549
  'symbol': market['id'],
1551
1550
  'amount': amountString,
1552
1551
  }
1553
- stopPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
1552
+ triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
1554
1553
  trailingAmount = self.safe_string(params, 'trailingAmount')
1555
1554
  timeInForce = self.safe_string(params, 'timeInForce')
1556
1555
  postOnlyParam = self.safe_bool(params, 'postOnly', False)
@@ -1560,9 +1559,9 @@ class bitfinex(Exchange, ImplicitAPI):
1560
1559
  if trailingAmount is not None:
1561
1560
  orderType = 'TRAILING STOP'
1562
1561
  request['price_trailing'] = trailingAmount
1563
- elif stopPrice is not None:
1562
+ elif triggerPrice is not None:
1564
1563
  # request['price'] is taken for stop orders
1565
- request['price'] = self.price_to_precision(symbol, stopPrice)
1564
+ request['price'] = self.price_to_precision(symbol, triggerPrice)
1566
1565
  if type == 'limit':
1567
1566
  orderType = 'STOP LIMIT'
1568
1567
  request['price_aux_limit'] = self.price_to_precision(symbol, price)
@@ -1575,7 +1574,7 @@ class bitfinex(Exchange, ImplicitAPI):
1575
1574
  raise InvalidOrder(self.id + ' createOrder() requires a price argument with IOC and FOK orders')
1576
1575
  if (ioc or fok) and (type == 'market'):
1577
1576
  raise InvalidOrder(self.id + ' createOrder() does not allow market IOC and FOK orders')
1578
- if (type != 'market') and (stopPrice is None):
1577
+ if (type != 'market') and (triggerPrice is None):
1579
1578
  request['price'] = self.price_to_precision(symbol, price)
1580
1579
  if ioc:
1581
1580
  orderType = 'IOC'
@@ -1612,7 +1611,7 @@ class bitfinex(Exchange, ImplicitAPI):
1612
1611
  :param float amount: the amount of currency to trade
1613
1612
  :param float [price]: price of the order
1614
1613
  :param dict [params]: extra parameters specific to the exchange API endpoint
1615
- :param float [params.stopPrice]: the price that triggers a trigger order
1614
+ :param float [params.triggerPrice]: the price that triggers a trigger order
1616
1615
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1617
1616
  :param boolean [params.postOnly]: set to True if you want to make a post only order
1618
1617
  :param boolean [params.reduceOnly]: indicates that the order is to reduce the size of a position
@@ -2850,7 +2849,7 @@ class bitfinex(Exchange, ImplicitAPI):
2850
2849
  :param dict [params]: extra parameters specific to the exchange API endpoint
2851
2850
  :param int [params.until]: timestamp in ms of the latest ledger entry
2852
2851
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2853
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2852
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2854
2853
  """
2855
2854
  await self.load_markets()
2856
2855
  paginate = False
@@ -3226,7 +3225,7 @@ class bitfinex(Exchange, ImplicitAPI):
3226
3225
  # ],
3227
3226
  # ]
3228
3227
  #
3229
- return self.parse_open_interests(response, market, since, limit)
3228
+ return self.parse_open_interests_history(response, market, since, limit)
3230
3229
 
3231
3230
  def parse_open_interest(self, interest, market: Market = None):
3232
3231
  #
@@ -3521,7 +3520,7 @@ class bitfinex(Exchange, ImplicitAPI):
3521
3520
  :param float amount: how much you want to trade in units of the base currency
3522
3521
  :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
3523
3522
  :param dict [params]: extra parameters specific to the exchange API endpoint
3524
- :param float [params.stopPrice]: the price that triggers a trigger order
3523
+ :param float [params.triggerPrice]: the price that triggers a trigger order
3525
3524
  :param boolean [params.postOnly]: set to True if you want to make a post only order
3526
3525
  :param boolean [params.reduceOnly]: indicates that the order is to reduce the size of a position
3527
3526
  :param int [params.flags]: additional order parameters: 4096(Post Only), 1024(Reduce Only), 16384(OCO), 64(Hidden), 512(Close), 524288(No Var Rates)
@@ -3539,7 +3538,7 @@ class bitfinex(Exchange, ImplicitAPI):
3539
3538
  amountString = self.amount_to_precision(symbol, amount)
3540
3539
  amountString = amountString if (side == 'buy') else Precise.string_neg(amountString)
3541
3540
  request['amount'] = amountString
3542
- stopPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
3541
+ triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
3543
3542
  trailingAmount = self.safe_string(params, 'trailingAmount')
3544
3543
  timeInForce = self.safe_string(params, 'timeInForce')
3545
3544
  postOnlyParam = self.safe_bool(params, 'postOnly', False)
@@ -3547,13 +3546,13 @@ class bitfinex(Exchange, ImplicitAPI):
3547
3546
  clientOrderId = self.safe_integer_2(params, 'cid', 'clientOrderId')
3548
3547
  if trailingAmount is not None:
3549
3548
  request['price_trailing'] = trailingAmount
3550
- elif stopPrice is not None:
3549
+ elif triggerPrice is not None:
3551
3550
  # request['price'] is taken for stop orders
3552
- request['price'] = self.price_to_precision(symbol, stopPrice)
3551
+ request['price'] = self.price_to_precision(symbol, triggerPrice)
3553
3552
  if type == 'limit':
3554
3553
  request['price_aux_limit'] = self.price_to_precision(symbol, price)
3555
3554
  postOnly = (postOnlyParam or (timeInForce == 'PO'))
3556
- if (type != 'market') and (stopPrice is None):
3555
+ if (type != 'market') and (triggerPrice is None):
3557
3556
  request['price'] = self.price_to_precision(symbol, price)
3558
3557
  # flag values may be summed to combine flags
3559
3558
  flags = 0
@@ -1248,7 +1248,6 @@ class bitfinex1(Exchange, ImplicitAPI):
1248
1248
  'postOnly': None,
1249
1249
  'side': side,
1250
1250
  'price': self.safe_string(order, 'price'),
1251
- 'stopPrice': None,
1252
1251
  'triggerPrice': None,
1253
1252
  'average': self.safe_string(order, 'avg_execution_price'),
1254
1253
  'amount': self.safe_string(order, 'original_amount'),
@@ -638,7 +638,6 @@ class bitflyer(Exchange, ImplicitAPI):
638
638
  'postOnly': None,
639
639
  'side': side,
640
640
  'price': price,
641
- 'stopPrice': None,
642
641
  'triggerPrice': None,
643
642
  'cost': None,
644
643
  'amount': amount,
@@ -1265,6 +1265,7 @@ class bitget(Exchange, ImplicitAPI):
1265
1265
  '41103': InvalidOrder, # {"code":"41103","msg":"param price scale error error","requestTime":1725635883561,"data":null}
1266
1266
  '41114': OnMaintenance, # {"code":"41114","msg":"The current trading pair is under maintenance, please refer to the official announcement for the opening time","requestTime":1679196062544,"data":null}
1267
1267
  '43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
1268
+ '43001': OrderNotFound,
1268
1269
  '43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
1269
1270
  '43025': InvalidOrder, # Plan order does not exist
1270
1271
  '43115': OnMaintenance, # {"code":"43115","msg":"The current trading pair is opening soon, please refer to the official announcement for the opening time","requestTime":1688907202434,"data":null}
@@ -4103,7 +4104,6 @@ class bitget(Exchange, ImplicitAPI):
4103
4104
  'timeInForce': timeInForce,
4104
4105
  'postOnly': postOnly,
4105
4106
  'reduceOnly': reduceOnly,
4106
- 'stopPrice': self.safe_number(order, 'triggerPrice'),
4107
4107
  'triggerPrice': self.safe_number(order, 'triggerPrice'),
4108
4108
  'takeProfitPrice': self.safe_number_2(order, 'presetStopSurplusPrice', 'stopSurplusTriggerPrice'),
4109
4109
  'stopLossPrice': self.safe_number_2(order, 'presetStopLossPrice', 'stopLossTriggerPrice'),
@@ -5713,7 +5713,7 @@ class bitget(Exchange, ImplicitAPI):
5713
5713
  :param str [params.symbol]: *contract only* unified market symbol
5714
5714
  :param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
5715
5715
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
5716
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
5716
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
5717
5717
  """
5718
5718
  await self.load_markets()
5719
5719
  symbol = self.safe_string(params, 'symbol')
@@ -906,7 +906,6 @@ class bithumb(Exchange, ImplicitAPI):
906
906
  'postOnly': None,
907
907
  'side': side,
908
908
  'price': price,
909
- 'stopPrice': None,
910
909
  'triggerPrice': None,
911
910
  'amount': amount,
912
911
  'cost': None,
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmart import ImplicitAPI
8
8
  import hashlib
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
9
+ from ccxt.base.types import Balances, BorrowInterest, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, 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
@@ -81,12 +81,13 @@ class bitmart(Exchange, ImplicitAPI):
81
81
  'fetchDeposits': True,
82
82
  'fetchDepositWithdrawFee': True,
83
83
  'fetchDepositWithdrawFees': False,
84
- 'fetchFundingHistory': None,
84
+ 'fetchFundingHistory': True,
85
85
  'fetchFundingRate': True,
86
86
  'fetchFundingRateHistory': False,
87
87
  'fetchFundingRates': False,
88
88
  'fetchIsolatedBorrowRate': True,
89
89
  'fetchIsolatedBorrowRates': True,
90
+ 'fetchLedger': True,
90
91
  'fetchLiquidations': False,
91
92
  'fetchMarginMode': False,
92
93
  'fetchMarkets': True,
@@ -173,6 +174,7 @@ class bitmart(Exchange, ImplicitAPI):
173
174
  'contract/public/depth': 5,
174
175
  'contract/public/open-interest': 30,
175
176
  'contract/public/funding-rate': 30,
177
+ 'contract/public/funding-rate-history': 30,
176
178
  'contract/public/kline': 6, # should be 5 but errors
177
179
  'account/v1/currencies': 30,
178
180
  },
@@ -223,6 +225,7 @@ class bitmart(Exchange, ImplicitAPI):
223
225
  'contract/private/position-risk': 10,
224
226
  'contract/private/affilate/rebate-list': 10,
225
227
  'contract/private/affilate/trade-list': 10,
228
+ 'contract/private/transaction-history': 10,
226
229
  },
227
230
  'post': {
228
231
  # sub-account endpoints
@@ -2482,7 +2485,6 @@ class bitmart(Exchange, ImplicitAPI):
2482
2485
  'postOnly': postOnly,
2483
2486
  'side': self.parse_order_side(self.safe_string(order, 'side')),
2484
2487
  'price': self.omit_zero(priceString),
2485
- 'stopPrice': trailingActivationPrice,
2486
2488
  'triggerPrice': trailingActivationPrice,
2487
2489
  'amount': self.omit_zero(self.safe_string(order, 'size')),
2488
2490
  'cost': self.safe_string_2(order, 'filled_notional', 'filledNotional'),
@@ -2890,7 +2892,7 @@ class bitmart(Exchange, ImplicitAPI):
2890
2892
  :param str symbol: unified symbol of the market the order was made in
2891
2893
  :param dict [params]: extra parameters specific to the exchange API endpoint
2892
2894
  :param str [params.clientOrderId]: *spot only* the client order id of the order to cancel
2893
- :param boolean [params.stop]: *swap only* whether the order is a stop order
2895
+ :param boolean [params.trigger]: *swap only* whether the order is a trigger order
2894
2896
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2895
2897
  """
2896
2898
  if symbol is None:
@@ -2910,9 +2912,9 @@ class bitmart(Exchange, ImplicitAPI):
2910
2912
  if market['spot']:
2911
2913
  response = await self.privatePostSpotV3CancelOrder(self.extend(request, params))
2912
2914
  else:
2913
- stop = self.safe_bool_2(params, 'stop', 'trigger')
2915
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
2914
2916
  params = self.omit(params, ['stop', 'trigger'])
2915
- if not stop:
2917
+ if not trigger:
2916
2918
  response = await self.privatePostContractPrivateCancelOrder(self.extend(request, params))
2917
2919
  else:
2918
2920
  response = await self.privatePostContractPrivateCancelPlanOrder(self.extend(request, params))
@@ -4376,6 +4378,62 @@ class bitmart(Exchange, ImplicitAPI):
4376
4378
  data = self.safe_dict(response, 'data', {})
4377
4379
  return self.parse_funding_rate(data, market)
4378
4380
 
4381
+ async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4382
+ """
4383
+ fetches historical funding rate prices
4384
+
4385
+ https://developer-pro.bitmart.com/en/futuresv2/#get-funding-rate-history
4386
+
4387
+ :param str symbol: unified symbol of the market to fetch the funding rate history for
4388
+ :param int [since]: timestamp in ms of the earliest funding rate to fetch
4389
+ :param int [limit]: the maximum amount of funding rate structures to fetch
4390
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4391
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
4392
+ """
4393
+ if symbol is None:
4394
+ raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
4395
+ await self.load_markets()
4396
+ market = self.market(symbol)
4397
+ request: dict = {
4398
+ 'symbol': market['id'],
4399
+ }
4400
+ if limit is not None:
4401
+ request['limit'] = limit
4402
+ response = await self.publicGetContractPublicFundingRateHistory(self.extend(request, params))
4403
+ #
4404
+ # {
4405
+ # "code": 1000,
4406
+ # "message": "Ok",
4407
+ # "data": {
4408
+ # "list": [
4409
+ # {
4410
+ # "symbol": "BTCUSDT",
4411
+ # "funding_rate": "0.000091412174",
4412
+ # "funding_time": "1734336000000"
4413
+ # },
4414
+ # ]
4415
+ # },
4416
+ # "trace": "fg73d949fgfdf6a40c8fc7f5ae6738.54.345345345345"
4417
+ # }
4418
+ #
4419
+ data = self.safe_dict(response, 'data', {})
4420
+ result = self.safe_list(data, 'list', [])
4421
+ rates = []
4422
+ for i in range(0, len(result)):
4423
+ entry = result[i]
4424
+ marketId = self.safe_string(entry, 'symbol')
4425
+ symbolInner = self.safe_symbol(marketId, market, '-', 'swap')
4426
+ timestamp = self.safe_integer(entry, 'funding_time')
4427
+ rates.append({
4428
+ 'info': entry,
4429
+ 'symbol': symbolInner,
4430
+ 'fundingRate': self.safe_number(entry, 'funding_rate'),
4431
+ 'timestamp': timestamp,
4432
+ 'datetime': self.iso8601(timestamp),
4433
+ })
4434
+ sorted = self.sort_by(rates, 'timestamp')
4435
+ return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
4436
+
4379
4437
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4380
4438
  #
4381
4439
  # {
@@ -4789,6 +4847,188 @@ class bitmart(Exchange, ImplicitAPI):
4789
4847
  data = self.safe_dict(response, 'data', {})
4790
4848
  return self.parse_order(data, market)
4791
4849
 
4850
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
4851
+ """
4852
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
4853
+
4854
+ https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
4855
+
4856
+ :param str [code]: unified currency code
4857
+ :param int [since]: timestamp in ms of the earliest ledger entry
4858
+ :param int [limit]: max number of ledger entries to return
4859
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4860
+ :param int [params.until]: timestamp in ms of the latest ledger entry
4861
+ :returns dict[]: a list of `ledger structures <https://docs.ccxt.com/#/?id=ledger>`
4862
+ """
4863
+ await self.load_markets()
4864
+ currency = None
4865
+ if code is not None:
4866
+ currency = self.currency(code)
4867
+ request: dict = {}
4868
+ request, params = self.handle_until_option('end_time', request, params)
4869
+ transactionsRequest = self.fetch_transactions_request(0, None, since, limit, params)
4870
+ response = await self.privateGetContractPrivateTransactionHistory(transactionsRequest)
4871
+ #
4872
+ # {
4873
+ # "code": 1000,
4874
+ # "message": "Ok",
4875
+ # "data": [
4876
+ # {
4877
+ # "time": "1734422402121",
4878
+ # "type": "Funding Fee",
4879
+ # "amount": "-0.00008253",
4880
+ # "asset": "USDT",
4881
+ # "symbol": "LTCUSDT",
4882
+ # "tran_id": "1734422402121",
4883
+ # "flow_type": 3
4884
+ # },
4885
+ # ],
4886
+ # "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
4887
+ # }
4888
+ #
4889
+ data = self.safe_list(response, 'data', [])
4890
+ return self.parse_ledger(data, currency, since, limit)
4891
+
4892
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
4893
+ #
4894
+ # {
4895
+ # "time": "1734422402121",
4896
+ # "type": "Funding Fee",
4897
+ # "amount": "-0.00008253",
4898
+ # "asset": "USDT",
4899
+ # "symbol": "LTCUSDT",
4900
+ # "tran_id": "1734422402121",
4901
+ # "flow_type": 3
4902
+ # }
4903
+ #
4904
+ amount = self.safe_string(item, 'amount')
4905
+ direction = None
4906
+ if Precise.string_le(amount, '0'):
4907
+ direction = 'out'
4908
+ amount = Precise.string_mul('-1', amount)
4909
+ else:
4910
+ direction = 'in'
4911
+ currencyId = self.safe_string(item, 'asset')
4912
+ timestamp = self.safe_integer(item, 'time')
4913
+ type = self.safe_string(item, 'type')
4914
+ return self.safe_ledger_entry({
4915
+ 'info': item,
4916
+ 'id': self.safe_string(item, 'tran_id'),
4917
+ 'direction': direction,
4918
+ 'account': None,
4919
+ 'referenceAccount': None,
4920
+ 'referenceId': self.safe_string(item, 'tradeId'),
4921
+ 'type': self.parse_ledger_entry_type(type),
4922
+ 'currency': self.safe_currency_code(currencyId, currency),
4923
+ 'amount': self.parse_number(amount),
4924
+ 'timestamp': timestamp,
4925
+ 'datetime': self.iso8601(timestamp),
4926
+ 'before': None,
4927
+ 'after': None,
4928
+ 'status': None,
4929
+ 'fee': None,
4930
+ }, currency)
4931
+
4932
+ def parse_ledger_entry_type(self, type):
4933
+ ledgerType: dict = {
4934
+ 'Commission Fee': 'fee',
4935
+ 'Funding Fee': 'fee',
4936
+ 'Realized PNL': 'trade',
4937
+ 'Transfer': 'transfer',
4938
+ 'Liquidation Clearance': 'settlement',
4939
+ }
4940
+ return self.safe_string(ledgerType, type, type)
4941
+
4942
+ def fetch_transactions_request(self, flowType: Int = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4943
+ request: dict = {}
4944
+ if flowType is not None:
4945
+ request['flow_type'] = flowType
4946
+ market = None
4947
+ if symbol is not None:
4948
+ market = self.market(symbol)
4949
+ request['symbol'] = market['id']
4950
+ if since is not None:
4951
+ request['start_time'] = since
4952
+ if limit is not None:
4953
+ request['page_size'] = limit
4954
+ request, params = self.handle_until_option('end_time', request, params)
4955
+ return self.extend(request, params)
4956
+
4957
+ async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
4958
+ """
4959
+ fetch the history of funding payments paid and received on self account
4960
+
4961
+ https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
4962
+
4963
+ :param str [symbol]: unified market symbol
4964
+ :param int [since]: the starting timestamp in milliseconds
4965
+ :param int [limit]: the number of entries to return
4966
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4967
+ :param int [params.until]: the latest time in ms to fetch funding history for
4968
+ :returns dict[]: a list of `funding history structures <https://docs.ccxt.com/#/?id=funding-history-structure>`
4969
+ """
4970
+ await self.load_markets()
4971
+ market = None
4972
+ if symbol is not None:
4973
+ market = self.market(symbol)
4974
+ request: dict = {}
4975
+ request, params = self.handle_until_option('end_time', request, params)
4976
+ transactionsRequest = self.fetch_transactions_request(3, symbol, since, limit, params)
4977
+ response = await self.privateGetContractPrivateTransactionHistory(transactionsRequest)
4978
+ #
4979
+ # {
4980
+ # "code": 1000,
4981
+ # "message": "Ok",
4982
+ # "data": [
4983
+ # {
4984
+ # "time": "1734422402121",
4985
+ # "type": "Funding Fee",
4986
+ # "amount": "-0.00008253",
4987
+ # "asset": "USDT",
4988
+ # "symbol": "LTCUSDT",
4989
+ # "tran_id": "1734422402121",
4990
+ # "flow_type": 3
4991
+ # },
4992
+ # ],
4993
+ # "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
4994
+ # }
4995
+ #
4996
+ data = self.safe_list(response, 'data', [])
4997
+ return self.parse_funding_histories(data, market, since, limit)
4998
+
4999
+ def parse_funding_history(self, contract, market: Market = None):
5000
+ #
5001
+ # {
5002
+ # "time": "1734422402121",
5003
+ # "type": "Funding Fee",
5004
+ # "amount": "-0.00008253",
5005
+ # "asset": "USDT",
5006
+ # "symbol": "LTCUSDT",
5007
+ # "tran_id": "1734422402121",
5008
+ # "flow_type": 3
5009
+ # }
5010
+ #
5011
+ marketId = self.safe_string(contract, 'symbol')
5012
+ currencyId = self.safe_string(contract, 'asset')
5013
+ timestamp = self.safe_integer(contract, 'time')
5014
+ return {
5015
+ 'info': contract,
5016
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
5017
+ 'code': self.safe_currency_code(currencyId),
5018
+ 'timestamp': timestamp,
5019
+ 'datetime': self.iso8601(timestamp),
5020
+ 'id': self.safe_string(contract, 'tran_id'),
5021
+ 'amount': self.safe_number(contract, 'amount'),
5022
+ }
5023
+
5024
+ def parse_funding_histories(self, contracts, market=None, since: Int = None, limit: Int = None) -> List[FundingHistory]:
5025
+ result = []
5026
+ for i in range(0, len(contracts)):
5027
+ contract = contracts[i]
5028
+ result.append(self.parse_funding_history(contract, market))
5029
+ sorted = self.sort_by(result, 'timestamp')
5030
+ return self.filter_by_since_limit(sorted, since, limit)
5031
+
4792
5032
  def nonce(self):
4793
5033
  return self.milliseconds()
4794
5034
 
@@ -1277,7 +1277,7 @@ class bitmex(Exchange, ImplicitAPI):
1277
1277
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1278
1278
  :param int [limit]: max number of ledger entries to return, default is None
1279
1279
  :param dict [params]: extra parameters specific to the exchange API endpoint
1280
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1280
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
1281
1281
  """
1282
1282
  await self.load_markets()
1283
1283
  request: dict = {
@@ -1807,7 +1807,7 @@ class bitmex(Exchange, ImplicitAPI):
1807
1807
  if execInst is not None:
1808
1808
  postOnly = (execInst == 'ParticipateDoNotInitiate')
1809
1809
  timestamp = self.parse8601(self.safe_string(order, 'timestamp'))
1810
- stopPrice = self.safe_number(order, 'stopPx')
1810
+ triggerPrice = self.safe_number(order, 'stopPx')
1811
1811
  remaining = self.safe_string(order, 'leavesQty')
1812
1812
  return self.safe_order({
1813
1813
  'info': order,
@@ -1822,8 +1822,7 @@ class bitmex(Exchange, ImplicitAPI):
1822
1822
  'postOnly': postOnly,
1823
1823
  'side': self.safe_string_lower(order, 'side'),
1824
1824
  'price': self.safe_string(order, 'price'),
1825
- 'stopPrice': stopPrice,
1826
- 'triggerPrice': stopPrice,
1825
+ 'triggerPrice': triggerPrice,
1827
1826
  'amount': amount,
1828
1827
  'cost': cost,
1829
1828
  'average': average,
@@ -1961,7 +1960,7 @@ class bitmex(Exchange, ImplicitAPI):
1961
1960
  else:
1962
1961
  if triggerPrice is None:
1963
1962
  # if exchange specific trigger types were provided
1964
- raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice(stopPx|stopPrice) parameter for the ' + orderType + ' order type')
1963
+ raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice parameter for the ' + orderType + ' order type')
1965
1964
  request['stopPx'] = self.parse_to_numeric(self.price_to_precision(symbol, triggerPrice))
1966
1965
  request['ordType'] = orderType
1967
1966
  params = self.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection', 'trailingAmount'])
@@ -2523,7 +2522,7 @@ class bitmex(Exchange, ImplicitAPI):
2523
2522
  'timestamp': self.parse8601(datetime),
2524
2523
  'datetime': datetime,
2525
2524
  'fundingRate': self.safe_number(contract, 'fundingRate'),
2526
- 'fundingTimestamp': self.parse_to_numeric(self.iso8601(fundingDatetime)),
2525
+ 'fundingTimestamp': self.parse8601(fundingDatetime),
2527
2526
  'fundingDatetime': fundingDatetime,
2528
2527
  'nextFundingRate': self.safe_number(contract, 'indicativeFundingRate'),
2529
2528
  'nextFundingTimestamp': None,
@@ -964,7 +964,6 @@ class bitopro(Exchange, ImplicitAPI):
964
964
  'postOnly': postOnly,
965
965
  'side': side,
966
966
  'price': price,
967
- 'stopPrice': None,
968
967
  'triggerPrice': None,
969
968
  'amount': amount,
970
969
  'cost': None,
@@ -1006,12 +1005,12 @@ class bitopro(Exchange, ImplicitAPI):
1006
1005
  request['price'] = self.price_to_precision(symbol, price)
1007
1006
  if orderType == 'STOP_LIMIT':
1008
1007
  request['price'] = self.price_to_precision(symbol, price)
1009
- stopPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1008
+ triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1010
1009
  params = self.omit(params, ['triggerPrice', 'stopPrice'])
1011
- if stopPrice is None:
1012
- raise InvalidOrder(self.id + ' createOrder() requires a stopPrice parameter for ' + orderType + ' orders')
1010
+ if triggerPrice is None:
1011
+ raise InvalidOrder(self.id + ' createOrder() requires a triggerPrice parameter for ' + orderType + ' orders')
1013
1012
  else:
1014
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1013
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1015
1014
  condition = self.safe_string(params, 'condition')
1016
1015
  if condition is None:
1017
1016
  raise InvalidOrder(self.id + ' createOrder() requires a condition parameter for ' + orderType + ' orders')
@@ -1778,8 +1778,7 @@ class bitrue(Exchange, ImplicitAPI):
1778
1778
  postOnly = (type == 'limit_maker') or (timeInForce == 'GTX') or (type == 'post_only')
1779
1779
  if type == 'limit_maker':
1780
1780
  type = 'limit'
1781
- stopPriceString = self.safe_string(order, 'stopPrice')
1782
- stopPrice = self.parse_number(self.omit_zero(stopPriceString))
1781
+ triggerPrice = self.parse_number(self.omit_zero(self.safe_string(order, 'stopPrice')))
1783
1782
  return self.safe_order({
1784
1783
  'info': order,
1785
1784
  'id': id,
@@ -1793,8 +1792,7 @@ class bitrue(Exchange, ImplicitAPI):
1793
1792
  'postOnly': postOnly,
1794
1793
  'side': side,
1795
1794
  'price': price,
1796
- 'stopPrice': stopPrice,
1797
- 'triggerPrice': stopPrice,
1795
+ 'triggerPrice': triggerPrice,
1798
1796
  'amount': amount,
1799
1797
  'cost': cost,
1800
1798
  'average': average,
@@ -1917,10 +1915,10 @@ class bitrue(Exchange, ImplicitAPI):
1917
1915
  if clientOrderId is not None:
1918
1916
  params = self.omit(params, ['newClientOrderId', 'clientOrderId'])
1919
1917
  request['newClientOrderId'] = clientOrderId
1920
- stopPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1921
- if stopPrice is not None:
1918
+ triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1919
+ if triggerPrice is not None:
1922
1920
  params = self.omit(params, ['triggerPrice', 'stopPrice'])
1923
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1921
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1924
1922
  response = await self.spotV1PrivatePostOrder(self.extend(request, params))
1925
1923
  data = response
1926
1924
  else:
@@ -209,7 +209,7 @@ class bitso(Exchange, ImplicitAPI):
209
209
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
210
210
  :param int [limit]: max number of ledger entries to return, default is None
211
211
  :param dict [params]: extra parameters specific to the exchange API endpoint
212
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
212
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
213
213
  """
214
214
  request: dict = {}
215
215
  if limit is not None:
@@ -1108,7 +1108,6 @@ class bitso(Exchange, ImplicitAPI):
1108
1108
  'postOnly': None,
1109
1109
  'side': side,
1110
1110
  'price': price,
1111
- 'stopPrice': None,
1112
1111
  'triggerPrice': None,
1113
1112
  'amount': amount,
1114
1113
  'cost': None,
@@ -1850,7 +1850,6 @@ class bitstamp(Exchange, ImplicitAPI):
1850
1850
  'postOnly': None,
1851
1851
  'side': side,
1852
1852
  'price': price,
1853
- 'stopPrice': None,
1854
1853
  'triggerPrice': None,
1855
1854
  'cost': None,
1856
1855
  'amount': amount,
@@ -1968,7 +1967,7 @@ class bitstamp(Exchange, ImplicitAPI):
1968
1967
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1969
1968
  :param int [limit]: max number of ledger entries to return, default is None
1970
1969
  :param dict [params]: extra parameters specific to the exchange API endpoint
1971
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1970
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
1972
1971
  """
1973
1972
  await self.load_markets()
1974
1973
  request: dict = {}