Fix flake issues
This commit is contained in:
parent
bb758da940
commit
37e4ede65c
@ -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.
|
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
|
### Developer
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ def load_data(datadir: Path,
|
|||||||
fail_without_data: bool = False,
|
fail_without_data: bool = False,
|
||||||
data_format: str = 'json',
|
data_format: str = 'json',
|
||||||
candle_type: CandleType = CandleType.SPOT,
|
candle_type: CandleType = CandleType.SPOT,
|
||||||
user_futures_funding_rate = None,
|
user_futures_funding_rate: int = None,
|
||||||
) -> Dict[str, DataFrame]:
|
) -> Dict[str, DataFrame]:
|
||||||
"""
|
"""
|
||||||
Load ohlcv history data for a list of pairs.
|
Load ohlcv history data for a list of pairs.
|
||||||
@ -104,7 +104,7 @@ def load_data(datadir: Path,
|
|||||||
else:
|
else:
|
||||||
if candle_type is CandleType.FUNDING_RATE and user_futures_funding_rate is not None:
|
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}]")
|
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:
|
if fail_without_data and not result:
|
||||||
raise OperationalException("No data found. Terminating.")
|
raise OperationalException("No data found. Terminating.")
|
||||||
|
@ -277,25 +277,26 @@ class Backtesting:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if (pair in mark_rates_dict
|
if (pair in mark_rates_dict
|
||||||
and len(funding_rates_dict[pair]) == 0
|
and len(funding_rates_dict[pair]) == 0
|
||||||
and "futures_funding_rate" in self.config):
|
and "futures_funding_rate" in self.config):
|
||||||
mark_rates_dict[pair]["open_fund"] = self.config.get('futures_funding_rate')
|
mark_rates_dict[pair]["open_fund"] = self.config.get('futures_funding_rate')
|
||||||
mark_rates_dict[pair]["close_fund"] = 0.0
|
mark_rates_dict[pair]["close_fund"] = 0.0
|
||||||
mark_rates_dict[pair]["high_fund"] = 0.0
|
mark_rates_dict[pair]["high_fund"] = 0.0
|
||||||
mark_rates_dict[pair]["low_fund"] = 0.0
|
mark_rates_dict[pair]["low_fund"] = 0.0
|
||||||
mark_rates_dict[pair]["volume_fund"] = 0.0
|
mark_rates_dict[pair]["volume_fund"] = 0.0
|
||||||
mark_rates_dict[pair].rename(
|
mark_rates_dict[pair].rename(
|
||||||
columns = {'open':'open_mark',
|
columns={'open': 'open_mark',
|
||||||
'close':'close_mark',
|
'close': 'close_mark',
|
||||||
'high':'high_mark',
|
'high': 'high_mark',
|
||||||
'low':'low_mark',
|
'low': 'low_mark',
|
||||||
'volume':'volume_mark'},
|
'volume': 'volume_mark'},
|
||||||
inplace = True)
|
inplace=True)
|
||||||
|
|
||||||
self.futures_data[pair] = mark_rates_dict[pair]
|
self.futures_data[pair] = mark_rates_dict[pair]
|
||||||
else:
|
else:
|
||||||
self.futures_data[pair] = mark_rates_dict[pair].merge(
|
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:
|
if unavailable_pairs:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
|
Loading…
Reference in New Issue
Block a user