ccxt 4.0.71__py2.py3-none-any.whl → 4.0.73__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ccxt/async_support/okx.py CHANGED
@@ -101,6 +101,7 @@ class okx(Exchange, ImplicitAPI):
101
101
  'fetchMarketLeverageTiers': True,
102
102
  'fetchMarkets': True,
103
103
  'fetchMarkOHLCV': True,
104
+ 'fetchMySettlementHistory': False,
104
105
  'fetchMyTrades': True,
105
106
  'fetchOHLCV': True,
106
107
  'fetchOpenInterest': True,
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.0.71'
7
+ __version__ = '4.0.73'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -1923,7 +1923,7 @@ class Exchange(object):
1923
1923
  raise NotSupported(self.id + ' parseWsOrderTrade() is not supported yet')
1924
1924
 
1925
1925
  def parse_ws_ohlcv(self, ohlcv, market=None):
1926
- raise NotSupported(self.id + ' parseWsOHLCV() is not supported yet')
1926
+ return self.parse_ohlcv(ohlcv, market)
1927
1927
 
1928
1928
  def fetch_funding_rates(self, symbols: Optional[List[str]] = None, params={}):
1929
1929
  raise NotSupported(self.id + ' fetchFundingRates() is not supported yet')
@@ -4147,6 +4147,12 @@ class Exchange(object):
4147
4147
  market = self.market(firstMarket)
4148
4148
  return market
4149
4149
 
4150
+ def parse_ws_ohlcvs(self, ohlcvs: List[object], market: Optional[Any] = None, timeframe: str = '1m', since: Optional[int] = None, limit: Optional[int] = None):
4151
+ results = []
4152
+ for i in range(0, len(ohlcvs)):
4153
+ results.append(self.parse_ws_ohlcv(ohlcvs[i], market))
4154
+ return results
4155
+
4150
4156
  def fetch_transactions(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4151
4157
  """
4152
4158
  * @deprecated
ccxt/binance.py CHANGED
@@ -102,6 +102,7 @@ class binance(Exchange, ImplicitAPI):
102
102
  'fetchMarketLeverageTiers': 'emulated',
103
103
  'fetchMarkets': True,
104
104
  'fetchMarkOHLCV': True,
105
+ 'fetchMySettlementHistory': True,
105
106
  'fetchMyTrades': True,
106
107
  'fetchOHLCV': True,
107
108
  'fetchOpenInterest': True,
@@ -908,6 +909,21 @@ class binance(Exchange, ImplicitAPI):
908
909
  'cm/openOrder': 1, # 1
909
910
  'cm/openOrders': 1, # 1
910
911
  'cm/allOrders': 20, # 20
912
+ 'um/conditional/openOrder': 1,
913
+ 'um/conditional/openOrders': 40,
914
+ 'um/conditional/orderHistory': 1,
915
+ 'um/conditional/allOrders': 40,
916
+ 'cm/conditional/openOrder': 1,
917
+ 'cm/conditional/openOrders': 40,
918
+ 'cm/conditional/orderHistory': 1,
919
+ 'cm/conditional/allOrders': 40,
920
+ 'margin/order': 5,
921
+ 'margin/openOrders': 5,
922
+ 'margin/allOrders': 100,
923
+ 'margin/orderList': 5,
924
+ 'margin/allOrderList': 100,
925
+ 'margin/openOrderList': 5,
926
+ 'margin/myTrades': 5,
911
927
  'balance': 20, # 20
912
928
  'account': 20, # 20
913
929
  'margin/maxBorrowable': 5, # 5
@@ -926,6 +942,10 @@ class binance(Exchange, ImplicitAPI):
926
942
  'um/apiTradingStatus': 1, # 1
927
943
  'um/commissionRate': 20, # 20
928
944
  'cm/commissionRate': 20, # 20
945
+ 'margin/marginLoan': 10,
946
+ 'margin/repayLoan': 10,
947
+ 'margin/marginInterestHistory': 1,
948
+ 'portfolio/interest-history': 50, # 50
929
949
  'um/income': 30,
930
950
  'cm/income ': 30,
931
951
  'um/account': 5,
@@ -933,10 +953,6 @@ class binance(Exchange, ImplicitAPI):
933
953
  'portfolio/repay-futures-switch': 3, # Weight(IP): 30 => cost = 0.1 * 30 = 3
934
954
  'um/adlQuantile': 5,
935
955
  'cm/adlQuantile': 5,
936
- 'margin/marginLoan': 0.0667, # Weight(UID): 10 => cost = 0.006667 * 10 = 0.06667
937
- 'margin/repayLoan': 0.0667, # Weight(UID): 10 => cost = 0.006667 * 10 = 0.06667
938
- 'margin/marginInterestHistory': 0.1, # Weight(IP): 1 => cost = 0.1 * 1 = 0.1
939
- 'portfolio/interest-history': 50, # 50
940
956
  },
941
957
  'post': {
942
958
  'um/order': 1, # 0
@@ -7160,7 +7176,57 @@ class binance(Exchange, ImplicitAPI):
7160
7176
  sorted = self.sort_by(settlements, 'timestamp')
7161
7177
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
7162
7178
 
7179
+ def fetch_my_settlement_history(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
7180
+ """
7181
+ fetches historical settlement records of the user
7182
+ see https://binance-docs.github.io/apidocs/voptions/en/#user-exercise-record-user_data
7183
+ :param str symbol: unified market symbol of the settlement history
7184
+ :param int [since]: timestamp in ms
7185
+ :param int [limit]: number of records
7186
+ :param dict [params]: exchange specific params
7187
+ :returns dict[]: a list of [settlement history objects]
7188
+ """
7189
+ self.load_markets()
7190
+ market = None if (symbol is None) else self.market(symbol)
7191
+ type = None
7192
+ type, params = self.handle_market_type_and_params('fetchMySettlementHistory', market, params)
7193
+ if type != 'option':
7194
+ raise NotSupported(self.id + ' fetchMySettlementHistory() supports option markets only')
7195
+ request = {}
7196
+ if symbol is not None:
7197
+ request['symbol'] = market['id']
7198
+ if since is not None:
7199
+ request['startTime'] = since
7200
+ if limit is not None:
7201
+ request['limit'] = limit
7202
+ response = self.eapiPrivateGetExerciseRecord(self.extend(request, params))
7203
+ #
7204
+ # [
7205
+ # {
7206
+ # "id": "1125899906842897036",
7207
+ # "currency": "USDT",
7208
+ # "symbol": "BTC-230728-30000-C",
7209
+ # "exercisePrice": "30000.00000000",
7210
+ # "markPrice": "29160.71284993",
7211
+ # "quantity": "1.00000000",
7212
+ # "amount": "0.00000000",
7213
+ # "fee": "0.00000000",
7214
+ # "createDate": 1690531200000,
7215
+ # "priceScale": 0,
7216
+ # "quantityScale": 2,
7217
+ # "optionSide": "CALL",
7218
+ # "positionSide": "LONG",
7219
+ # "quoteAsset": "USDT"
7220
+ # }
7221
+ # ]
7222
+ #
7223
+ settlements = self.parse_settlements(response, market)
7224
+ sorted = self.sort_by(settlements, 'timestamp')
7225
+ return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
7226
+
7163
7227
  def parse_settlement(self, settlement, market):
7228
+ #
7229
+ # fetchSettlementHistory
7164
7230
  #
7165
7231
  # {
7166
7232
  # "symbol": "ETH-230223-1900-P",
@@ -7170,17 +7236,38 @@ class binance(Exchange, ImplicitAPI):
7170
7236
  # "strikeResult": "REALISTIC_VALUE_STRICKEN"
7171
7237
  # }
7172
7238
  #
7173
- timestamp = self.safe_integer(settlement, 'expiryDate')
7239
+ # fetchMySettlementHistory
7240
+ #
7241
+ # {
7242
+ # "id": "1125899906842897036",
7243
+ # "currency": "USDT",
7244
+ # "symbol": "BTC-230728-30000-C",
7245
+ # "exercisePrice": "30000.00000000",
7246
+ # "markPrice": "29160.71284993",
7247
+ # "quantity": "1.00000000",
7248
+ # "amount": "0.00000000",
7249
+ # "fee": "0.00000000",
7250
+ # "createDate": 1690531200000,
7251
+ # "priceScale": 0,
7252
+ # "quantityScale": 2,
7253
+ # "optionSide": "CALL",
7254
+ # "positionSide": "LONG",
7255
+ # "quoteAsset": "USDT"
7256
+ # }
7257
+ #
7258
+ timestamp = self.safe_integer_2(settlement, 'expiryDate', 'createDate')
7174
7259
  marketId = self.safe_string(settlement, 'symbol')
7175
7260
  return {
7176
7261
  'info': settlement,
7177
7262
  'symbol': self.safe_symbol(marketId, market),
7178
- 'price': self.safe_number(settlement, 'realStrikePrice'),
7263
+ 'price': self.safe_number_2(settlement, 'realStrikePrice', 'exercisePrice'),
7179
7264
  'timestamp': timestamp,
7180
7265
  'datetime': self.iso8601(timestamp),
7181
7266
  }
7182
7267
 
7183
7268
  def parse_settlements(self, settlements, market):
7269
+ #
7270
+ # fetchSettlementHistory
7184
7271
  #
7185
7272
  # [
7186
7273
  # {
@@ -7192,6 +7279,27 @@ class binance(Exchange, ImplicitAPI):
7192
7279
  # }
7193
7280
  # ]
7194
7281
  #
7282
+ # fetchMySettlementHistory
7283
+ #
7284
+ # [
7285
+ # {
7286
+ # "id": "1125899906842897036",
7287
+ # "currency": "USDT",
7288
+ # "symbol": "BTC-230728-30000-C",
7289
+ # "exercisePrice": "30000.00000000",
7290
+ # "markPrice": "29160.71284993",
7291
+ # "quantity": "1.00000000",
7292
+ # "amount": "0.00000000",
7293
+ # "fee": "0.00000000",
7294
+ # "createDate": 1690531200000,
7295
+ # "priceScale": 0,
7296
+ # "quantityScale": 2,
7297
+ # "optionSide": "CALL",
7298
+ # "positionSide": "LONG",
7299
+ # "quoteAsset": "USDT"
7300
+ # }
7301
+ # ]
7302
+ #
7195
7303
  result = []
7196
7304
  for i in range(0, len(settlements)):
7197
7305
  result.append(self.parse_settlement(settlements[i], market))
ccxt/bybit.py CHANGED
@@ -80,6 +80,7 @@ class bybit(Exchange, ImplicitAPI):
80
80
  'fetchMarketLeverageTiers': True,
81
81
  'fetchMarkets': True,
82
82
  'fetchMarkOHLCV': True,
83
+ 'fetchMySettlementHistory': True,
83
84
  'fetchMyTrades': True,
84
85
  'fetchOHLCV': True,
85
86
  'fetchOpenInterest': True,
@@ -8308,7 +8309,68 @@ class bybit(Exchange, ImplicitAPI):
8308
8309
  sorted = self.sort_by(settlements, 'timestamp')
8309
8310
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
8310
8311
 
8312
+ def fetch_my_settlement_history(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
8313
+ """
8314
+ fetches historical settlement records of the user
8315
+ see https://bybit-exchange.github.io/docs/v5/asset/delivery
8316
+ :param str symbol: unified market symbol of the settlement history
8317
+ :param int [since]: timestamp in ms
8318
+ :param int [limit]: number of records
8319
+ :param dict [params]: exchange specific params
8320
+ :returns dict[]: a list of [settlement history objects]
8321
+ """
8322
+ self.load_markets()
8323
+ request = {}
8324
+ market = None
8325
+ if symbol is not None:
8326
+ market = self.market(symbol)
8327
+ request['symbol'] = market['id']
8328
+ type = None
8329
+ type, params = self.handle_market_type_and_params('fetchMySettlementHistory', market, params)
8330
+ if type == 'option':
8331
+ request['category'] = 'option'
8332
+ else:
8333
+ subType = None
8334
+ subType, params = self.handle_sub_type_and_params('fetchMySettlementHistory', market, params, 'linear')
8335
+ if subType == 'inverse':
8336
+ raise NotSupported(self.id + ' fetchMySettlementHistory() doesn\'t support inverse markets')
8337
+ request['category'] = 'linear'
8338
+ if limit is not None:
8339
+ request['limit'] = limit
8340
+ response = self.privateGetV5AssetDeliveryRecord(self.extend(request, params))
8341
+ #
8342
+ # {
8343
+ # "retCode": 0,
8344
+ # "retMsg": "success",
8345
+ # "result": {
8346
+ # "category": "option",
8347
+ # "nextPageCursor": "0%2C3",
8348
+ # "list": [
8349
+ # {
8350
+ # "symbol": "SOL-27JUN23-20-C",
8351
+ # "deliveryPrice": "16.62258889",
8352
+ # "deliveryTime": "1687852800000",
8353
+ # "side": "Buy",
8354
+ # "strike": "20",
8355
+ # "fee": "0.00000000",
8356
+ # "position": "0.01",
8357
+ # "deliveryRpl": "3.5"
8358
+ # },
8359
+ # ]
8360
+ # },
8361
+ # "retExtInfo": {},
8362
+ # "time": 1689043527231
8363
+ # }
8364
+ #
8365
+ result = self.safe_value(response, 'result', {})
8366
+ data = self.safe_value(result, 'list', [])
8367
+ settlements = self.parse_settlements(data, market)
8368
+ sorted = self.sort_by(settlements, 'timestamp')
8369
+ return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
8370
+
8311
8371
  def parse_settlement(self, settlement, market):
8372
+ #
8373
+ # fetchSettlementHistory
8312
8374
  #
8313
8375
  # {
8314
8376
  # "symbol": "SOL-27JUN23-20-C",
@@ -8316,6 +8378,19 @@ class bybit(Exchange, ImplicitAPI):
8316
8378
  # "deliveryTime": "1687852800000"
8317
8379
  # }
8318
8380
  #
8381
+ # fetchMySettlementHistory
8382
+ #
8383
+ # {
8384
+ # "symbol": "SOL-27JUN23-20-C",
8385
+ # "deliveryPrice": "16.62258889",
8386
+ # "deliveryTime": "1687852800000",
8387
+ # "side": "Buy",
8388
+ # "strike": "20",
8389
+ # "fee": "0.00000000",
8390
+ # "position": "0.01",
8391
+ # "deliveryRpl": "3.5"
8392
+ # }
8393
+ #
8319
8394
  timestamp = self.safe_integer(settlement, 'deliveryTime')
8320
8395
  marketId = self.safe_string(settlement, 'symbol')
8321
8396
  return {
@@ -8327,6 +8402,8 @@ class bybit(Exchange, ImplicitAPI):
8327
8402
  }
8328
8403
 
8329
8404
  def parse_settlements(self, settlements, market):
8405
+ #
8406
+ # fetchSettlementHistory
8330
8407
  #
8331
8408
  # [
8332
8409
  # {
@@ -8336,6 +8413,21 @@ class bybit(Exchange, ImplicitAPI):
8336
8413
  # }
8337
8414
  # ]
8338
8415
  #
8416
+ # fetchMySettlementHistory
8417
+ #
8418
+ # [
8419
+ # {
8420
+ # "symbol": "SOL-27JUN23-20-C",
8421
+ # "deliveryPrice": "16.62258889",
8422
+ # "deliveryTime": "1687852800000",
8423
+ # "side": "Buy",
8424
+ # "strike": "20",
8425
+ # "fee": "0.00000000",
8426
+ # "position": "0.01",
8427
+ # "deliveryRpl": "3.5"
8428
+ # }
8429
+ # ]
8430
+ #
8339
8431
  result = []
8340
8432
  for i in range(0, len(settlements)):
8341
8433
  result.append(self.parse_settlement(settlements[i], market))
ccxt/cryptocom.py CHANGED
@@ -78,6 +78,7 @@ class cryptocom(Exchange, ImplicitAPI):
78
78
  'fetchMarketLeverageTiers': False,
79
79
  'fetchMarkets': True,
80
80
  'fetchMarkOHLCV': False,
81
+ 'fetchMySettlementHistory': False,
81
82
  'fetchMyTrades': True,
82
83
  'fetchOHLCV': True,
83
84
  'fetchOpenOrders': True,
ccxt/delta.py CHANGED
@@ -63,6 +63,7 @@ class delta(Exchange, ImplicitAPI):
63
63
  'fetchMarketLeverageTiers': False,
64
64
  'fetchMarkets': True,
65
65
  'fetchMarkOHLCV': True,
66
+ 'fetchMySettlementHistory': False,
66
67
  'fetchMyTrades': True,
67
68
  'fetchOHLCV': True,
68
69
  'fetchOpenInterest': True,
ccxt/deribit.py CHANGED
@@ -76,6 +76,7 @@ class deribit(Exchange, ImplicitAPI):
76
76
  'fetchMarginMode': False,
77
77
  'fetchMarkets': True,
78
78
  'fetchMarkOHLCV': False,
79
+ 'fetchMySettlementHistory': False,
79
80
  'fetchMyTrades': True,
80
81
  'fetchOHLCV': True,
81
82
  'fetchOpenOrders': True,
ccxt/gate.py CHANGED
@@ -129,6 +129,7 @@ class gate(Exchange, ImplicitAPI):
129
129
  'fetchMarketLeverageTiers': 'emulated',
130
130
  'fetchMarkets': True,
131
131
  'fetchMarkOHLCV': True,
132
+ 'fetchMySettlementHistory': True,
132
133
  'fetchMyTrades': True,
133
134
  'fetchNetworkDepositAddress': True,
134
135
  'fetchOHLCV': True,
@@ -833,6 +834,97 @@ class gate(Exchange, ImplicitAPI):
833
834
  super(gate, self).set_sandbox_mode(enable)
834
835
  self.options['sandboxMode'] = enable
835
836
 
837
+ def convert_expire_date(self, date):
838
+ # parse YYMMDD to timestamp
839
+ year = date[0:2]
840
+ month = date[2:4]
841
+ day = date[4:6]
842
+ reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z'
843
+ return reconstructedDate
844
+
845
+ def create_expired_option_market(self, symbol):
846
+ # support expired option contracts
847
+ quote = 'USDT'
848
+ settle = quote
849
+ optionParts = symbol.split('-')
850
+ symbolBase = symbol.split('/')
851
+ marketIdBase = symbol.split('_')
852
+ base = None
853
+ expiry = self.safe_string(optionParts, 1)
854
+ if symbol.find('/') > -1:
855
+ base = self.safe_string(symbolBase, 0)
856
+ else:
857
+ base = self.safe_string(marketIdBase, 0)
858
+ expiry = expiry[2:8] # convert 20230728 to 230728
859
+ strike = self.safe_string(optionParts, 2)
860
+ optionType = self.safe_string(optionParts, 3)
861
+ datetime = self.convert_expire_date(expiry)
862
+ timestamp = self.parse8601(datetime)
863
+ return {
864
+ 'id': base + '_' + quote + '-' + '20' + expiry + '-' + strike + '-' + optionType,
865
+ 'symbol': base + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
866
+ 'base': base,
867
+ 'quote': quote,
868
+ 'settle': settle,
869
+ 'baseId': base,
870
+ 'quoteId': quote,
871
+ 'settleId': settle,
872
+ 'active': False,
873
+ 'type': 'option',
874
+ 'linear': None,
875
+ 'inverse': None,
876
+ 'spot': False,
877
+ 'swap': False,
878
+ 'future': False,
879
+ 'option': True,
880
+ 'margin': False,
881
+ 'contract': True,
882
+ 'contractSize': self.parse_number('1'),
883
+ 'expiry': timestamp,
884
+ 'expiryDatetime': datetime,
885
+ 'optionType': 'call' if (optionType == 'C') else 'put',
886
+ 'strike': self.parse_number(strike),
887
+ 'precision': {
888
+ 'amount': self.parse_number('1'),
889
+ 'price': None,
890
+ },
891
+ 'limits': {
892
+ 'amount': {
893
+ 'min': None,
894
+ 'max': None,
895
+ },
896
+ 'price': {
897
+ 'min': None,
898
+ 'max': None,
899
+ },
900
+ 'cost': {
901
+ 'min': None,
902
+ 'max': None,
903
+ },
904
+ },
905
+ 'info': None,
906
+ }
907
+
908
+ def market(self, symbol):
909
+ if self.markets is None:
910
+ raise ExchangeError(self.id + ' markets not loaded')
911
+ if isinstance(symbol, str):
912
+ if symbol in self.markets:
913
+ return self.markets[symbol]
914
+ elif symbol in self.markets_by_id:
915
+ markets = self.markets_by_id[symbol]
916
+ return markets[0]
917
+ elif (symbol.find('-C') > -1) or (symbol.find('-P') > -1):
918
+ return self.create_expired_option_market(symbol)
919
+ raise BadSymbol(self.id + ' does not have market symbol ' + symbol)
920
+
921
+ def safe_market(self, marketId=None, market=None, delimiter=None, marketType=None):
922
+ isOption = (marketId is not None) and ((marketId.find('-C') > -1) or (marketId.find('-P') > -1))
923
+ if isOption and not (marketId in self.markets_by_id):
924
+ # handle expired option contracts
925
+ return self.create_expired_option_market(marketId)
926
+ return super(gate, self).safe_market(marketId, market, delimiter, marketType)
927
+
836
928
  def fetch_markets(self, params={}):
837
929
  """
838
930
  retrieves data on all markets for gate
@@ -5400,7 +5492,58 @@ class gate(Exchange, ImplicitAPI):
5400
5492
  sorted = self.sort_by(settlements, 'timestamp')
5401
5493
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
5402
5494
 
5495
+ def fetch_my_settlement_history(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
5496
+ """
5497
+ fetches historical settlement records of the user
5498
+ see https://www.gate.io/docs/developers/apiv4/en/#list-my-options-settlements
5499
+ :param str symbol: unified market symbol of the settlement history
5500
+ :param int [since]: timestamp in ms
5501
+ :param int [limit]: number of records
5502
+ :param dict [params]: exchange specific params
5503
+ :returns dict[]: a list of [settlement history objects]
5504
+ """
5505
+ self.check_required_symbol('fetchMySettlementHistory', symbol)
5506
+ self.load_markets()
5507
+ market = self.market(symbol)
5508
+ type = None
5509
+ type, params = self.handle_market_type_and_params('fetchMySettlementHistory', market, params)
5510
+ if type != 'option':
5511
+ raise NotSupported(self.id + ' fetchMySettlementHistory() supports option markets only')
5512
+ marketId = market['id']
5513
+ optionParts = marketId.split('-')
5514
+ request = {
5515
+ 'underlying': self.safe_string(optionParts, 0),
5516
+ 'contract': marketId,
5517
+ }
5518
+ if since is not None:
5519
+ request['from'] = since
5520
+ if limit is not None:
5521
+ request['limit'] = limit
5522
+ response = self.privateOptionsGetMySettlements(self.extend(request, params))
5523
+ #
5524
+ # [
5525
+ # {
5526
+ # "size": -1,
5527
+ # "settle_profit": "0",
5528
+ # "contract": "BTC_USDT-20220624-26000-C",
5529
+ # "strike_price": "26000",
5530
+ # "time": 1656057600,
5531
+ # "settle_price": "20917.461281337048",
5532
+ # "underlying": "BTC_USDT",
5533
+ # "realised_pnl": "-0.00116042",
5534
+ # "fee": "0"
5535
+ # }
5536
+ # ]
5537
+ #
5538
+ result = self.safe_value(response, 'result', {})
5539
+ data = self.safe_value(result, 'list', [])
5540
+ settlements = self.parse_settlements(data, market)
5541
+ sorted = self.sort_by(settlements, 'timestamp')
5542
+ return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
5543
+
5403
5544
  def parse_settlement(self, settlement, market):
5545
+ #
5546
+ # fetchSettlementHistory
5404
5547
  #
5405
5548
  # {
5406
5549
  # "time": 1685952000,
@@ -5411,6 +5554,20 @@ class gate(Exchange, ImplicitAPI):
5411
5554
  # "strike_price": "25000"
5412
5555
  # }
5413
5556
  #
5557
+ # fetchMySettlementHistory
5558
+ #
5559
+ # {
5560
+ # "size": -1,
5561
+ # "settle_profit": "0",
5562
+ # "contract": "BTC_USDT-20220624-26000-C",
5563
+ # "strike_price": "26000",
5564
+ # "time": 1656057600,
5565
+ # "settle_price": "20917.461281337048",
5566
+ # "underlying": "BTC_USDT",
5567
+ # "realised_pnl": "-0.00116042",
5568
+ # "fee": "0"
5569
+ # }
5570
+ #
5414
5571
  timestamp = self.safe_timestamp(settlement, 'time')
5415
5572
  marketId = self.safe_string(settlement, 'contract')
5416
5573
  return {
@@ -5422,6 +5579,8 @@ class gate(Exchange, ImplicitAPI):
5422
5579
  }
5423
5580
 
5424
5581
  def parse_settlements(self, settlements, market):
5582
+ #
5583
+ # fetchSettlementHistory
5425
5584
  #
5426
5585
  # [
5427
5586
  # {
@@ -5434,6 +5593,22 @@ class gate(Exchange, ImplicitAPI):
5434
5593
  # }
5435
5594
  # ]
5436
5595
  #
5596
+ # fetchMySettlementHistory
5597
+ #
5598
+ # [
5599
+ # {
5600
+ # "size": -1,
5601
+ # "settle_profit": "0",
5602
+ # "contract": "BTC_USDT-20220624-26000-C",
5603
+ # "strike_price": "26000",
5604
+ # "time": 1656057600,
5605
+ # "settle_price": "20917.461281337048",
5606
+ # "underlying": "BTC_USDT",
5607
+ # "realised_pnl": "-0.00116042",
5608
+ # "fee": "0"
5609
+ # }
5610
+ # ]
5611
+ #
5437
5612
  result = []
5438
5613
  for i in range(0, len(settlements)):
5439
5614
  result.append(self.parse_settlement(settlements[i], market))