removed ftx get_mark_price_history, added variable mark_ohlcv_price, used fetch_ohlcv instead of fetch_mark_ohlcv inside get_mark_price_history
This commit is contained in:
parent
a4892654da
commit
0ea8957ccc
@ -80,6 +80,8 @@ class Exchange:
|
||||
# TradingMode.SPOT always supported and not required in this list
|
||||
]
|
||||
|
||||
mark_ohlcv_price = 'mark'
|
||||
|
||||
def __init__(self, config: Dict[str, Any], validate: bool = True) -> None:
|
||||
"""
|
||||
Initializes this module with the given config,
|
||||
@ -1744,15 +1746,32 @@ class Exchange:
|
||||
Get's the mark price history for a pair
|
||||
"""
|
||||
|
||||
candles = self._api.fetch_mark_ohlcv(
|
||||
try:
|
||||
candles = self._api.fetch_ohlcv(
|
||||
pair,
|
||||
timeframe="1h",
|
||||
since=start
|
||||
since=start,
|
||||
params={
|
||||
'price': self.mark_ohlcv_price
|
||||
}
|
||||
)
|
||||
history = {}
|
||||
for candle in candles:
|
||||
history[candle[0]] = candle[1]
|
||||
return history
|
||||
except ccxt.NotSupported as e:
|
||||
raise OperationalException(
|
||||
f'Exchange {self._api.name} does not support fetching historical '
|
||||
f'mark price candle (OHLCV) data. Message: {e}') from e
|
||||
except ccxt.DDoSProtection as e:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
||||
raise TemporaryError(f'Could not fetch historical mark price candle (OHLCV) data '
|
||||
f'for pair {pair} due to {e.__class__.__name__}. '
|
||||
f'Message: {e}') from e
|
||||
except ccxt.BaseError as e:
|
||||
raise OperationalException(f'Could not fetch historical mark price candle (OHLCV) data '
|
||||
f'for pair {pair}. Message: {e}') from e
|
||||
|
||||
def calculate_funding_fees(
|
||||
self,
|
||||
@ -1779,8 +1798,7 @@ class Exchange:
|
||||
)
|
||||
mark_price_history = self._get_mark_price_history(
|
||||
pair,
|
||||
int(open_date.timestamp()),
|
||||
close_date_timestamp
|
||||
int(open_date.timestamp())
|
||||
)
|
||||
for date in self._get_funding_fee_dates(open_date, close_date):
|
||||
funding_rate = funding_rate_history[date.timestamp]
|
||||
|
@ -1,6 +1,6 @@
|
||||
""" FTX exchange subclass """
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
import ccxt
|
||||
|
||||
@ -28,6 +28,7 @@ class Ftx(Exchange):
|
||||
# (TradingMode.MARGIN, Collateral.CROSS), # TODO-lev: Uncomment once supported
|
||||
# (TradingMode.FUTURES, Collateral.CROSS) # TODO-lev: Uncomment once supported
|
||||
]
|
||||
mark_ohlcv_price = 'index'
|
||||
|
||||
def market_is_tradable(self, market: Dict[str, Any]) -> bool:
|
||||
"""
|
||||
@ -168,30 +169,3 @@ class Ftx(Exchange):
|
||||
if order['type'] == 'stop':
|
||||
return safe_value_fallback2(order, order, 'id_stop', 'id')
|
||||
return order['id']
|
||||
|
||||
def _get_mark_price_history(
|
||||
self,
|
||||
pair: str,
|
||||
start: int,
|
||||
end: Optional[int]
|
||||
) -> Dict:
|
||||
"""
|
||||
Get's the mark price history for a pair
|
||||
"""
|
||||
if end:
|
||||
params = {
|
||||
'endTime': end
|
||||
}
|
||||
else:
|
||||
params = {}
|
||||
|
||||
candles = self._api.fetch_index_ohlcv(
|
||||
pair,
|
||||
timeframe="1h",
|
||||
since=start,
|
||||
params=params
|
||||
)
|
||||
history = {}
|
||||
for candle in candles:
|
||||
history[candle[0]] = candle[1]
|
||||
return history
|
||||
|
Loading…
Reference in New Issue
Block a user