ccxt 4.3.20__py2.py3-none-any.whl → 4.3.22__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

ccxt/coinex.py CHANGED
@@ -307,7 +307,7 @@ class coinex(Exchange, ImplicitAPI):
307
307
  'v2': {
308
308
  'public': {
309
309
  'get': {
310
- 'maintain-info': 1,
310
+ 'maintain/info': 1,
311
311
  'ping': 1,
312
312
  'time': 1,
313
313
  'spot/market': 1,
@@ -3987,160 +3987,127 @@ class coinex(Exchange, ImplicitAPI):
3987
3987
  def modify_margin_helper(self, symbol: str, amount, addOrReduce, params={}):
3988
3988
  self.load_markets()
3989
3989
  market = self.market(symbol)
3990
+ rawAmount = self.amount_to_precision(symbol, amount)
3991
+ requestAmount = rawAmount
3992
+ if addOrReduce == 'reduce':
3993
+ requestAmount = Precise.string_neg(rawAmount)
3990
3994
  request = {
3991
3995
  'market': market['id'],
3992
- 'amount': self.amount_to_precision(symbol, amount),
3993
- 'type': addOrReduce,
3996
+ 'market_type': 'FUTURES',
3997
+ 'amount': requestAmount,
3994
3998
  }
3995
- response = self.v1PerpetualPrivatePostPositionAdjustMargin(self.extend(request, params))
3999
+ response = self.v2PrivatePostFuturesAdjustPositionMargin(self.extend(request, params))
3996
4000
  #
3997
4001
  # {
3998
4002
  # "code": 0,
3999
4003
  # "data": {
4000
- # "adl_sort": 1,
4001
- # "adl_sort_val": "0.00004320",
4002
- # "amount": "0.0005",
4003
- # "amount_max": "0.0005",
4004
- # "amount_max_margin": "6.57352000000000000000",
4005
- # "bkr_price": "16294.08000000000000011090",
4006
- # "bkr_price_imply": "0.00000000000000000000",
4007
- # "close_left": "0.0005",
4008
- # "create_time": 1651202571.320778,
4009
- # "deal_all": "19.72000000000000000000",
4010
- # "deal_asset_fee": "0.00000000000000000000",
4011
- # "fee_asset": "",
4012
- # "finish_type": 1,
4013
- # "first_price": "39441.12",
4014
- # "insurance": "0.00000000000000000000",
4015
- # "latest_price": "39441.12",
4004
+ # "adl_level": 1,
4005
+ # "ath_margin_size": "2.034928",
4006
+ # "ath_position_amount": "0.0001",
4007
+ # "avg_entry_price": "61047.84",
4008
+ # "bkr_price": "30698.5600000000000004142",
4009
+ # "close_avbl": "0.0001",
4010
+ # "cml_position_value": "6.104784",
4011
+ # "created_at": 1715488472908,
4016
4012
  # "leverage": "3",
4017
- # "liq_amount": "0.00000000000000000000",
4018
- # "liq_order_price": "0",
4019
- # "liq_order_time": 0,
4020
- # "liq_price": "16491.28560000000000011090",
4021
- # "liq_price_imply": "0.00000000000000000000",
4022
- # "liq_profit": "0.00000000000000000000",
4023
- # "liq_time": 0,
4024
- # "mainten_margin": "0.005",
4025
- # "mainten_margin_amount": "0.09860280000000000000",
4026
- # "maker_fee": "0.00000000000000000000",
4027
- # "margin_amount": "11.57352000000000000000",
4013
+ # "liq_price": "30852.82412060301507579316",
4014
+ # "maintenance_margin_rate": "0.005",
4015
+ # "maintenance_margin_value": "0.03051465",
4016
+ # "margin_avbl": "3.034928",
4017
+ # "margin_mode": "isolated",
4028
4018
  # "market": "BTCUSDT",
4029
- # "open_margin": "0.58687582908396110455",
4030
- # "open_margin_imply": "0.00000000000000000000",
4031
- # "open_price": "39441.12000000000000000000",
4032
- # "open_val": "19.72056000000000000000",
4033
- # "open_val_max": "19.72056000000000000000",
4034
- # "position_id": 65171206,
4035
- # "profit_clearing": "-0.00986028000000000000",
4036
- # "profit_real": "-0.00986028000000000000",
4037
- # "profit_unreal": "0.00",
4038
- # "side": 2,
4039
- # "stop_loss_price": "0.00000000000000000000",
4040
- # "stop_loss_type": 0,
4041
- # "s ys": 0,
4042
- # "take_profit_price": "0.00000000000000000000",
4043
- # "take_profit_type": 0,
4044
- # "taker_fee": "0.00000000000000000000",
4045
- # "total": 3464,
4046
- # "type": 1,
4047
- # "update_time": 1651202638.911212,
4048
- # "user_id": 3620173
4019
+ # "market_type": "FUTURES",
4020
+ # "max_position_value": "6.104784",
4021
+ # "open_interest": "0.0001",
4022
+ # "position_id": 306458800,
4023
+ # "position_margin_rate": "0.49713929272518077625",
4024
+ # "realized_pnl": "-0.003052392",
4025
+ # "settle_price": "61047.84",
4026
+ # "settle_value": "6.104784",
4027
+ # "side": "long",
4028
+ # "stop_loss_price": "0",
4029
+ # "stop_loss_type": "",
4030
+ # "take_profit_price": "0",
4031
+ # "take_profit_type": "",
4032
+ # "unrealized_pnl": "0",
4033
+ # "updated_at": 1715488805563
4049
4034
  # },
4050
- # "message":"OK"
4035
+ # "message": "OK"
4051
4036
  # }
4052
4037
  #
4053
4038
  data = self.safe_dict(response, 'data')
4054
- status = self.safe_string(response, 'message')
4039
+ status = self.safe_string_lower(response, 'message')
4040
+ type = 'reduce' if (addOrReduce == 'reduce') else 'add'
4055
4041
  return self.extend(self.parse_margin_modification(data, market), {
4042
+ 'type': type,
4056
4043
  'amount': self.parse_number(amount),
4057
4044
  'status': status,
4058
4045
  })
4059
4046
 
4060
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
4047
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
4061
4048
  #
4062
4049
  # addMargin/reduceMargin
4063
4050
  #
4064
- # {
4065
- # "adl_sort": 1,
4066
- # "adl_sort_val": "0.00004320",
4067
- # "amount": "0.0005",
4068
- # "amount_max": "0.0005",
4069
- # "amount_max_margin": "6.57352000000000000000",
4070
- # "bkr_price": "16294.08000000000000011090",
4071
- # "bkr_price_imply": "0.00000000000000000000",
4072
- # "close_left": "0.0005",
4073
- # "create_time": 1651202571.320778,
4074
- # "deal_all": "19.72000000000000000000",
4075
- # "deal_asset_fee": "0.00000000000000000000",
4076
- # "fee_asset": "",
4077
- # "finish_type": 1,
4078
- # "first_price": "39441.12",
4079
- # "insurance": "0.00000000000000000000",
4080
- # "latest_price": "39441.12",
4081
- # "leverage": "3",
4082
- # "liq_amount": "0.00000000000000000000",
4083
- # "liq_order_price": "0",
4084
- # "liq_order_time": 0,
4085
- # "liq_price": "16491.28560000000000011090",
4086
- # "liq_price_imply": "0.00000000000000000000",
4087
- # "liq_profit": "0.00000000000000000000",
4088
- # "liq_time": 0,
4089
- # "mainten_margin": "0.005",
4090
- # "mainten_margin_amount": "0.09860280000000000000",
4091
- # "maker_fee": "0.00000000000000000000",
4092
- # "margin_amount": "11.57352000000000000000",
4093
- # "market": "BTCUSDT",
4094
- # "open_margin": "0.58687582908396110455",
4095
- # "open_margin_imply": "0.00000000000000000000",
4096
- # "open_price": "39441.12000000000000000000",
4097
- # "open_val": "19.72056000000000000000",
4098
- # "open_val_max": "19.72056000000000000000",
4099
- # "position_id": 65171206,
4100
- # "profit_clearing": "-0.00986028000000000000",
4101
- # "profit_real": "-0.00986028000000000000",
4102
- # "profit_unreal": "0.00",
4103
- # "side": 2,
4104
- # "stop_loss_price": "0.00000000000000000000",
4105
- # "stop_loss_type": 0,
4106
- # "sy s": 0,
4107
- # "take_profit_price": "0.00000000000000000000",
4108
- # "take_profit_type": 0,
4109
- # "taker_fee": "0.00000000000000000000",
4110
- # "total": 3464,
4111
- # "type": 1,
4112
- # "update_time": 1651202638.911212,
4113
- # "user_id": 3620173
4114
- # }
4051
+ # {
4052
+ # "adl_level": 1,
4053
+ # "ath_margin_size": "2.034928",
4054
+ # "ath_position_amount": "0.0001",
4055
+ # "avg_entry_price": "61047.84",
4056
+ # "bkr_price": "30698.5600000000000004142",
4057
+ # "close_avbl": "0.0001",
4058
+ # "cml_position_value": "6.104784",
4059
+ # "created_at": 1715488472908,
4060
+ # "leverage": "3",
4061
+ # "liq_price": "30852.82412060301507579316",
4062
+ # "maintenance_margin_rate": "0.005",
4063
+ # "maintenance_margin_value": "0.03051465",
4064
+ # "margin_avbl": "3.034928",
4065
+ # "margin_mode": "isolated",
4066
+ # "market": "BTCUSDT",
4067
+ # "market_type": "FUTURES",
4068
+ # "max_position_value": "6.104784",
4069
+ # "open_interest": "0.0001",
4070
+ # "position_id": 306458800,
4071
+ # "position_margin_rate": "0.49713929272518077625",
4072
+ # "realized_pnl": "-0.003052392",
4073
+ # "settle_price": "61047.84",
4074
+ # "settle_value": "6.104784",
4075
+ # "side": "long",
4076
+ # "stop_loss_price": "0",
4077
+ # "stop_loss_type": "",
4078
+ # "take_profit_price": "0",
4079
+ # "take_profit_type": "",
4080
+ # "unrealized_pnl": "0",
4081
+ # "updated_at": 1715488805563
4082
+ # }
4115
4083
  #
4116
4084
  # fetchMarginAdjustmentHistory
4117
4085
  #
4118
- # {
4119
- # bkr_price: '0',
4120
- # leverage: '3',
4121
- # liq_price: '0',
4122
- # margin_amount: '5.33236666666666666666',
4123
- # margin_change: '3',
4124
- # market: 'XRPUSDT',
4125
- # position_amount: '11',
4126
- # position_id: '297155652',
4127
- # position_type: '2',
4128
- # settle_price: '0.6361',
4129
- # time: '1711050906.382891',
4130
- # type: '1',
4131
- # user_id: '3685860'
4132
- # }
4086
+ # {
4087
+ # "bkr_pirce": "24698.56000000000000005224",
4088
+ # "created_at": 1715489978697,
4089
+ # "leverage": "3",
4090
+ # "liq_price": "24822.67336683417085432386",
4091
+ # "margin_avbl": "3.634928",
4092
+ # "margin_change": "-1.5",
4093
+ # "margin_mode": "isolated",
4094
+ # "market": "BTCUSDT",
4095
+ # "market_type": "FUTURES",
4096
+ # "open_interest": "0.0001",
4097
+ # "position_id": 306458800,
4098
+ # "settle_price": "61047.84"
4099
+ # }
4133
4100
  #
4134
4101
  marketId = self.safe_string(data, 'market')
4135
- type = self.safe_string(data, 'type')
4136
- timestamp = self.safe_integer_product_2(data, 'time', 'update_time', 1000)
4102
+ timestamp = self.safe_integer_2(data, 'updated_at', 'created_at')
4103
+ change = self.safe_string(data, 'margin_change')
4137
4104
  return {
4138
4105
  'info': data,
4139
4106
  'symbol': self.safe_symbol(marketId, market, None, 'swap'),
4140
- 'type': 'add' if (type == '1') else 'reduce',
4107
+ 'type': None,
4141
4108
  'marginMode': 'isolated',
4142
- 'amount': self.safe_number(data, 'margin_change'),
4143
- 'total': self.safe_number(data, 'position_amount'),
4109
+ 'amount': self.parse_number(Precise.string_abs(change)),
4110
+ 'total': self.safe_number(data, 'margin_avbl'),
4144
4111
  'code': market['quote'],
4145
4112
  'status': None,
4146
4113
  'timestamp': timestamp,
@@ -4150,24 +4117,24 @@ class coinex(Exchange, ImplicitAPI):
4150
4117
  def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4151
4118
  """
4152
4119
  add margin
4153
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
4120
+ :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4154
4121
  :param str symbol: unified market symbol
4155
4122
  :param float amount: amount of margin to add
4156
4123
  :param dict [params]: extra parameters specific to the exchange API endpoint
4157
4124
  :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
4158
4125
  """
4159
- return self.modify_margin_helper(symbol, amount, 1, params)
4126
+ return self.modify_margin_helper(symbol, amount, 'add', params)
4160
4127
 
4161
4128
  def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4162
4129
  """
4163
4130
  remove margin from a position
4164
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
4131
+ :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4165
4132
  :param str symbol: unified market symbol
4166
4133
  :param float amount: the amount of margin to remove
4167
4134
  :param dict [params]: extra parameters specific to the exchange API endpoint
4168
4135
  :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
4169
4136
  """
4170
- return self.modify_margin_helper(symbol, amount, 2, params)
4137
+ return self.modify_margin_helper(symbol, amount, 'reduce', params)
4171
4138
 
4172
4139
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4173
4140
  """
@@ -5582,7 +5549,7 @@ class coinex(Exchange, ImplicitAPI):
5582
5549
  code = self.safe_string(response, 'code')
5583
5550
  data = self.safe_value(response, 'data')
5584
5551
  message = self.safe_string(response, 'message')
5585
- if (code != '0') or ((message != 'Success') and (message != 'Succeeded') and (message != 'Ok') and not data):
5552
+ if (code != '0') or ((message != 'Success') and (message != 'Succeeded') and (message.lower() != 'ok') and not data):
5586
5553
  feedback = self.id + ' ' + message
5587
5554
  self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
5588
5555
  self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
@@ -5592,65 +5559,60 @@ class coinex(Exchange, ImplicitAPI):
5592
5559
  def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}) -> List[MarginModification]:
5593
5560
  """
5594
5561
  fetches the history of margin added or reduced from contract isolated positions
5595
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http046_position_margin_history
5596
- :param str [symbol]: unified market symbol
5562
+ :see: https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5563
+ :param str symbol: unified market symbol
5597
5564
  :param str [type]: not used by coinex fetchMarginAdjustmentHistory
5598
5565
  :param int [since]: timestamp in ms of the earliest change to fetch
5599
- :param int [limit]: the maximum amount of changes to fetch, default=100, max=100
5566
+ :param int [limit]: the maximum amount of changes to fetch, default is 10
5600
5567
  :param dict params: extra parameters specific to the exchange api endpoint
5601
5568
  :param int [params.until]: timestamp in ms of the latest change to fetch
5602
- *
5603
- * EXCHANGE SPECIFIC PARAMETERS
5604
- :param int [params.offset]: offset
5569
+ :param int [params.positionId]: the id of the position that you want to retrieve margin adjustment history for
5605
5570
  :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
5606
5571
  """
5607
5572
  self.load_markets()
5608
- until = self.safe_integer(params, 'until')
5609
- params = self.omit(params, 'until')
5610
- if limit is None:
5611
- limit = 100
5573
+ if symbol is None:
5574
+ raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a symbol argument')
5575
+ positionId = self.safe_integer_2(params, 'positionId', 'position_id')
5576
+ params = self.omit(params, 'positionId')
5577
+ if positionId is None:
5578
+ raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter')
5579
+ market = self.market(symbol)
5612
5580
  request = {
5613
- 'market': '',
5614
- 'position_id': 0,
5615
- 'offset': 0,
5616
- 'limit': limit,
5581
+ 'market': market['id'],
5582
+ 'market_type': 'FUTURES',
5583
+ 'position_id': positionId,
5617
5584
  }
5618
- if symbol is not None:
5619
- market = self.market(symbol)
5620
- request['market'] = market['id']
5585
+ request, params = self.handle_until_option('end_time', request, params)
5621
5586
  if since is not None:
5622
5587
  request['start_time'] = since
5623
- if until is not None:
5624
- request['end_time'] = until
5625
- response = self.v1PerpetualPrivateGetPositionMarginHistory(self.extend(request, params))
5588
+ if limit is not None:
5589
+ request['limit'] = limit
5590
+ response = self.v2PrivateGetFuturesPositionMarginHistory(self.extend(request, params))
5626
5591
  #
5627
- # {
5628
- # code: '0',
5629
- # data: {
5630
- # limit: '100',
5631
- # offset: '0',
5632
- # records: [
5633
- # {
5634
- # bkr_price: '0',
5635
- # leverage: '3',
5636
- # liq_price: '0',
5637
- # margin_amount: '5.33236666666666666666',
5638
- # margin_change: '3',
5639
- # market: 'XRPUSDT',
5640
- # position_amount: '11',
5641
- # position_id: '297155652',
5642
- # position_type: '2',
5643
- # settle_price: '0.6361',
5644
- # time: '1711050906.382891',
5645
- # type: '1',
5646
- # user_id: '3685860'
5647
- # }
5648
- # ]
5649
- # },
5650
- # message: 'OK'
5651
- # }
5592
+ # {
5593
+ # "code": 0,
5594
+ # "data": [
5595
+ # {
5596
+ # "bkr_pirce": "24698.56000000000000005224",
5597
+ # "created_at": 1715489978697,
5598
+ # "leverage": "3",
5599
+ # "liq_price": "24822.67336683417085432386",
5600
+ # "margin_avbl": "3.634928",
5601
+ # "margin_change": "-1.5",
5602
+ # "margin_mode": "isolated",
5603
+ # "market": "BTCUSDT",
5604
+ # "market_type": "FUTURES",
5605
+ # "open_interest": "0.0001",
5606
+ # "position_id": 306458800,
5607
+ # "settle_price": "61047.84"
5608
+ # },
5609
+ # ],
5610
+ # "message": "OK",
5611
+ # "pagination": {
5612
+ # "has_next": True
5613
+ # }
5614
+ # }
5652
5615
  #
5653
- data = self.safe_dict(response, 'data', {})
5654
- records = self.safe_list(data, 'records', [])
5655
- modifications = self.parse_margin_modifications(records, None, 'market', 'swap')
5616
+ data = self.safe_list(response, 'data', [])
5617
+ modifications = self.parse_margin_modifications(data, None, 'market', 'swap')
5656
5618
  return self.filter_by_symbol_since_limit(modifications, symbol, since, limit)
ccxt/delta.py CHANGED
@@ -2539,7 +2539,7 @@ class delta(Exchange, ImplicitAPI):
2539
2539
  result = self.safe_dict(response, 'result', {})
2540
2540
  return self.parse_margin_modification(result, market)
2541
2541
 
2542
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
2542
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
2543
2543
  #
2544
2544
  # {
2545
2545
  # "auto_topup": False,
ccxt/digifinex.py CHANGED
@@ -3791,7 +3791,7 @@ class digifinex(Exchange, ImplicitAPI):
3791
3791
  'status': status,
3792
3792
  })
3793
3793
 
3794
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3794
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
3795
3795
  #
3796
3796
  # {
3797
3797
  # "instrument_id": "BTCUSDTPERP",
ccxt/exmo.py CHANGED
@@ -270,7 +270,7 @@ class exmo(Exchange, ImplicitAPI):
270
270
  margin['amount'] = amount
271
271
  return margin
272
272
 
273
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
273
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
274
274
  #
275
275
  # {}
276
276
  #
ccxt/gate.py CHANGED
@@ -5678,7 +5678,7 @@ class gate(Exchange, ImplicitAPI):
5678
5678
  raise NotSupported(self.id + ' modifyMarginHelper() not support self market type')
5679
5679
  return self.parse_margin_modification(response, market)
5680
5680
 
5681
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
5681
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
5682
5682
  #
5683
5683
  # {
5684
5684
  # "value": "11.9257",
ccxt/hitbtc.py CHANGED
@@ -3057,7 +3057,7 @@ class hitbtc(Exchange, ImplicitAPI):
3057
3057
  'type': type,
3058
3058
  })
3059
3059
 
3060
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3060
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
3061
3061
  #
3062
3062
  # addMargin/reduceMargin
3063
3063
  #
ccxt/hyperliquid.py CHANGED
@@ -1544,14 +1544,17 @@ class hyperliquid(Exchange, ImplicitAPI):
1544
1544
  :param int [limit]: the maximum number of open orders structures to retrieve
1545
1545
  :param dict [params]: extra parameters specific to the exchange API endpoint
1546
1546
  :param str [params.user]: user address, will default to self.walletAddress if not provided
1547
+ :param str [params.method]: 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders'
1547
1548
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1548
1549
  """
1549
1550
  userAddress = None
1550
1551
  userAddress, params = self.handle_public_address('fetchOpenOrders', params)
1552
+ method = None
1553
+ method, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'method', 'frontendOpenOrders')
1551
1554
  self.load_markets()
1552
1555
  market = self.safe_market(symbol)
1553
1556
  request = {
1554
- 'type': 'openOrders',
1557
+ 'type': method,
1555
1558
  'user': userAddress,
1556
1559
  }
1557
1560
  response = self.publicPostInfo(self.extend(request, params))
@@ -1725,6 +1728,25 @@ class hyperliquid(Exchange, ImplicitAPI):
1725
1728
  # "oid":6195281425
1726
1729
  # }
1727
1730
  # }
1731
+ # frontendOrder
1732
+ # {
1733
+ # "children": [],
1734
+ # "cloid": null,
1735
+ # "coin": "BLUR",
1736
+ # "isPositionTpsl": False,
1737
+ # "isTrigger": True,
1738
+ # "limitPx": "0.5",
1739
+ # "oid": 8670487141,
1740
+ # "orderType": "Stop Limit",
1741
+ # "origSz": "20.0",
1742
+ # "reduceOnly": False,
1743
+ # "side": "B",
1744
+ # "sz": "20.0",
1745
+ # "tif": null,
1746
+ # "timestamp": 1715523663687,
1747
+ # "triggerCondition": "Price above 0.6",
1748
+ # "triggerPx": "0.6"
1749
+ # }
1728
1750
  #
1729
1751
  entry = self.safe_dict_n(order, ['order', 'resting', 'filled'])
1730
1752
  if entry is None:
@@ -1755,7 +1777,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1755
1777
  'lastTradeTimestamp': None,
1756
1778
  'lastUpdateTimestamp': None,
1757
1779
  'symbol': symbol,
1758
- 'type': self.safe_string_lower(entry, 'orderType'),
1780
+ 'type': self.parse_order_type(self.safe_string_lower(entry, 'orderType')),
1759
1781
  'timeInForce': self.safe_string_upper(entry, 'tif'),
1760
1782
  'postOnly': None,
1761
1783
  'reduceOnly': self.safe_bool(entry, 'reduceOnly'),
@@ -2190,7 +2212,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2190
2212
  'code': self.safe_string(response, 'status'),
2191
2213
  })
2192
2214
 
2193
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
2215
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
2194
2216
  #
2195
2217
  # {
2196
2218
  # 'type': 'default'
ccxt/okx.py CHANGED
@@ -269,6 +269,9 @@ class okx(Exchange, ImplicitAPI):
269
269
  'sprd/books': 1 / 2,
270
270
  'sprd/ticker': 1,
271
271
  'sprd/public-trades': 1 / 5,
272
+ 'market/sprd-ticker': 2,
273
+ 'market/sprd-candles': 2,
274
+ 'market/sprd-history-candles': 2,
272
275
  'tradingBot/grid/ai-param': 1,
273
276
  'tradingBot/grid/min-investment': 1,
274
277
  'tradingBot/public/rsi-back-testing': 1,
@@ -6235,7 +6238,7 @@ class okx(Exchange, ImplicitAPI):
6235
6238
  'status': 'ok' if (errorCode == '0') else 'failed',
6236
6239
  })
6237
6240
 
6238
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
6241
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
6239
6242
  #
6240
6243
  # addMargin/reduceMargin
6241
6244
  #
ccxt/phemex.py CHANGED
@@ -1658,6 +1658,26 @@ class phemex(Exchange, ImplicitAPI):
1658
1658
  # "execId": "8718cae",
1659
1659
  # "execStatus": 6
1660
1660
  # }
1661
+ # spot with fees paid using PT token
1662
+ # "createdAt": "1714990724076",
1663
+ # "symbol": "BTCUSDT",
1664
+ # "currency": "USDT",
1665
+ # "action": "1",
1666
+ # "tradeType": "1",
1667
+ # "execQtyRq": "0.003",
1668
+ # "execPriceRp": "64935",
1669
+ # "side": "2",
1670
+ # "orderQtyRq": "0.003",
1671
+ # "priceRp": "51600",
1672
+ # "execValueRv": "194.805",
1673
+ # "feeRateRr": "0.000495",
1674
+ # "execFeeRv": "0",
1675
+ # "ordType": "3",
1676
+ # "execId": "XXXXXX",
1677
+ # "execStatus": "7",
1678
+ # "posSide": "1",
1679
+ # "ptFeeRv": "0.110012249248",
1680
+ # "ptPriceRp": "0.876524893"
1661
1681
  #
1662
1682
  priceString: Str
1663
1683
  amountString: Str
@@ -1706,10 +1726,16 @@ class phemex(Exchange, ImplicitAPI):
1706
1726
  priceString = self.safe_string(trade, 'execPriceRp')
1707
1727
  amountString = self.safe_string(trade, 'execQtyRq')
1708
1728
  costString = self.safe_string(trade, 'execValueRv')
1709
- feeCostString = self.safe_string(trade, 'execFeeRv')
1729
+ feeCostString = self.omit_zero(self.safe_string(trade, 'execFeeRv'))
1710
1730
  feeRateString = self.safe_string(trade, 'feeRateRr')
1711
- currencyId = self.safe_string(trade, 'currency')
1712
- feeCurrencyCode = self.safe_currency_code(currencyId)
1731
+ if feeCostString is not None:
1732
+ currencyId = self.safe_string(trade, 'currency')
1733
+ feeCurrencyCode = self.safe_currency_code(currencyId)
1734
+ else:
1735
+ ptFeeRv = self.omit_zero(self.safe_string(trade, 'ptFeeRv'))
1736
+ if ptFeeRv is not None:
1737
+ feeCostString = ptFeeRv
1738
+ feeCurrencyCode = 'PT'
1713
1739
  else:
1714
1740
  side = self.safe_string_lower(trade, 'side')
1715
1741
  type = self.parse_order_type(self.safe_string(trade, 'ordType'))
@@ -1720,7 +1746,7 @@ class phemex(Exchange, ImplicitAPI):
1720
1746
  amountString = self.from_ev(self.safe_string(trade, 'execBaseQtyEv'), market)
1721
1747
  amountString = self.safe_string(trade, 'execQty', amountString)
1722
1748
  costString = self.from_er(self.safe_string_2(trade, 'execQuoteQtyEv', 'execValueEv'), market)
1723
- feeCostString = self.from_er(self.safe_string(trade, 'execFeeEv'), market)
1749
+ feeCostString = self.from_er(self.omit_zero(self.safe_string(trade, 'execFeeEv')), market)
1724
1750
  if feeCostString is not None:
1725
1751
  feeRateString = self.from_er(self.safe_string(trade, 'feeRateEr'), market)
1726
1752
  if market['spot']:
@@ -1730,6 +1756,10 @@ class phemex(Exchange, ImplicitAPI):
1730
1756
  if info is not None:
1731
1757
  settlementCurrencyId = self.safe_string(info, 'settlementCurrency')
1732
1758
  feeCurrencyCode = self.safe_currency_code(settlementCurrencyId)
1759
+ else:
1760
+ feeCostString = self.safe_string(trade, 'ptFeeRv')
1761
+ if feeCostString is not None:
1762
+ feeCurrencyCode = 'PT'
1733
1763
  fee = {
1734
1764
  'cost': feeCostString,
1735
1765
  'rate': feeRateString,
@@ -3790,7 +3820,7 @@ class phemex(Exchange, ImplicitAPI):
3790
3820
  }
3791
3821
  return self.safe_string(statuses, status, status)
3792
3822
 
3793
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3823
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
3794
3824
  #
3795
3825
  # {
3796
3826
  # "code": 0,
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.20'
7
+ __version__ = '4.3.22'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10