Fix flake issues

This commit is contained in:
froggleston 2022-05-17 22:32:17 +01:00
parent bb758da940
commit 37e4ede65c
3 changed files with 15 additions and 13 deletions

View File

@ -105,7 +105,8 @@ Possible values are any floats between 0.0 and 0.99
For futures data, exchanges commonly provide the futures candles, the marks, and the funding rates. However, it is common that whilst candles and marks might be available, the funding rates are not. This can affect backtesting timeranges, i.e. you may only be able to test recent timeranges and not earlier, experiencing the `No data found. Terminating.` error. To get around this, add the `futures_funding_rate` config option as listed in [configuration.md](configuration.md), and it is recommended that you set this to `0`, unless you know a given specific funding rate for your pair, exchange and timerange. Setting this to anything other than `0` can have drastic effects on your profit calculations within strategy, e.g. within the `custom_exit`, `custom_stoploss`, etc functions.
!!! This will not overwrite funding rates that are available from the exchange.
!!! Warning This will mean your backtests are inaccurate.
This will not overwrite funding rates that are available from the exchange, but bear in mind that setting a false funding rate will mean backtesting results will be inaccurate for historical timeranges where funding rates are not available.
### Developer

View File

@ -69,7 +69,7 @@ def load_data(datadir: Path,
fail_without_data: bool = False,
data_format: str = 'json',
candle_type: CandleType = CandleType.SPOT,
user_futures_funding_rate = None,
user_futures_funding_rate: int = None,
) -> Dict[str, DataFrame]:
"""
Load ohlcv history data for a list of pairs.
@ -104,7 +104,7 @@ def load_data(datadir: Path,
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"])
result[pair] = DataFrame(columns=["open", "close", "high", "low", "volume"])
if fail_without_data and not result:
raise OperationalException("No data found. Terminating.")

View File

@ -285,17 +285,18 @@ class Backtesting:
mark_rates_dict[pair]["low_fund"] = 0.0
mark_rates_dict[pair]["volume_fund"] = 0.0
mark_rates_dict[pair].rename(
columns = {'open':'open_mark',
'close':'close_mark',
'high':'high_mark',
'low':'low_mark',
'volume':'volume_mark'},
inplace = True)
columns={'open': 'open_mark',
'close': 'close_mark',
'high': 'high_mark',
'low': 'low_mark',
'volume': 'volume_mark'},
inplace=True)
self.futures_data[pair] = mark_rates_dict[pair]
else:
self.futures_data[pair] = mark_rates_dict[pair].merge(
funding_rates_dict[pair], on='date', how="inner", suffixes=["_fund", "_mark"])
funding_rates_dict[pair], on='date',
how="inner", suffixes=["_fund", "_mark"])
if unavailable_pairs:
raise OperationalException(