Add support for fudging unavailable funding rates, allowing backtesting of timeranges where futures candles are available, but rates are not

This commit is contained in:
froggleston
2022-05-17 22:05:33 +01:00
parent 7b9439f2e4
commit bb758da940
4 changed files with 34 additions and 3 deletions

View File

@@ -68,7 +68,8 @@ def load_data(datadir: Path,
startup_candles: int = 0,
fail_without_data: bool = False,
data_format: str = 'json',
candle_type: CandleType = CandleType.SPOT
candle_type: CandleType = CandleType.SPOT,
user_futures_funding_rate = None,
) -> Dict[str, DataFrame]:
"""
Load ohlcv history data for a list of pairs.
@@ -100,6 +101,10 @@ def load_data(datadir: Path,
)
if not hist.empty:
result[pair] = hist
else:
if candle_type is CandleType.FUNDING_RATE and user_futures_funding_rate is not None:
logger.warn(f"{pair} using user specified [{user_futures_funding_rate}]")
result[pair] = DataFrame(columns=["open","close","high","low","volume"])
if fail_without_data and not result:
raise OperationalException("No data found. Terminating.")