mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Merge pull request #10546 from stash86/fix-recursive
add startup count from strategy to the analysis
This commit is contained in:
commit
624dfdf6ac
|
@ -14,6 +14,7 @@ from freqtrade.loggers.set_log_levels import (
|
||||||
)
|
)
|
||||||
from freqtrade.optimize.backtesting import Backtesting
|
from freqtrade.optimize.backtesting import Backtesting
|
||||||
from freqtrade.optimize.base_analysis import BaseAnalysis, VarHolder
|
from freqtrade.optimize.base_analysis import BaseAnalysis, VarHolder
|
||||||
|
from freqtrade.resolvers import StrategyResolver
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -21,10 +22,19 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class RecursiveAnalysis(BaseAnalysis):
|
class RecursiveAnalysis(BaseAnalysis):
|
||||||
def __init__(self, config: Dict[str, Any], strategy_obj: Dict):
|
def __init__(self, config: Dict[str, Any], strategy_obj: Dict):
|
||||||
self._startup_candle = config.get("startup_candle", [199, 399, 499, 999, 1999])
|
self._startup_candle = list(
|
||||||
|
map(int, config.get("startup_candle", [199, 399, 499, 999, 1999]))
|
||||||
|
)
|
||||||
|
|
||||||
super().__init__(config, strategy_obj)
|
super().__init__(config, strategy_obj)
|
||||||
|
|
||||||
|
strat = StrategyResolver.load_strategy(config)
|
||||||
|
self._strat_scc = strat.startup_candle_count
|
||||||
|
|
||||||
|
if self._strat_scc not in self._startup_candle:
|
||||||
|
self._startup_candle.append(self._strat_scc)
|
||||||
|
self._startup_candle.sort()
|
||||||
|
|
||||||
self.partial_varHolder_array: List[VarHolder] = []
|
self.partial_varHolder_array: List[VarHolder] = []
|
||||||
self.partial_varHolder_lookahead_array: List[VarHolder] = []
|
self.partial_varHolder_lookahead_array: List[VarHolder] = []
|
||||||
|
|
||||||
|
@ -58,9 +68,13 @@ class RecursiveAnalysis(BaseAnalysis):
|
||||||
values_diff = compare_df.loc[indicator]
|
values_diff = compare_df.loc[indicator]
|
||||||
values_diff_self = values_diff.loc["self"]
|
values_diff_self = values_diff.loc["self"]
|
||||||
values_diff_other = values_diff.loc["other"]
|
values_diff_other = values_diff.loc["other"]
|
||||||
diff = (values_diff_other - values_diff_self) / values_diff_self * 100
|
|
||||||
|
|
||||||
self.dict_recursive[indicator][part.startup_candle] = f"{diff:.3f}%"
|
if values_diff_self and values_diff_other:
|
||||||
|
diff = (values_diff_other - values_diff_self) / values_diff_self * 100
|
||||||
|
str_diff = f"{diff:.3f}%"
|
||||||
|
else:
|
||||||
|
str_diff = "NaN"
|
||||||
|
self.dict_recursive[indicator][part.startup_candle] = str_diff
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.info("No variance on indicator(s) found due to recursive formula.")
|
logger.info("No variance on indicator(s) found due to recursive formula.")
|
||||||
|
@ -174,7 +188,7 @@ class RecursiveAnalysis(BaseAnalysis):
|
||||||
start_date_partial = end_date_full - timedelta(minutes=int(timeframe_minutes))
|
start_date_partial = end_date_full - timedelta(minutes=int(timeframe_minutes))
|
||||||
|
|
||||||
for startup_candle in self._startup_candle:
|
for startup_candle in self._startup_candle:
|
||||||
self.fill_partial_varholder(start_date_partial, int(startup_candle))
|
self.fill_partial_varholder(start_date_partial, startup_candle)
|
||||||
|
|
||||||
# Restore verbosity, so it's not too quiet for the next strategy
|
# Restore verbosity, so it's not too quiet for the next strategy
|
||||||
restore_verbosity_for_bias_tester()
|
restore_verbosity_for_bias_tester()
|
||||||
|
|
|
@ -17,9 +17,13 @@ class RecursiveAnalysisSubFunctions:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def text_table_recursive_analysis_instances(recursive_instances: List[RecursiveAnalysis]):
|
def text_table_recursive_analysis_instances(recursive_instances: List[RecursiveAnalysis]):
|
||||||
startups = recursive_instances[0]._startup_candle
|
startups = recursive_instances[0]._startup_candle
|
||||||
|
strat_scc = recursive_instances[0]._strat_scc
|
||||||
headers = ["Indicators"]
|
headers = ["Indicators"]
|
||||||
for candle in startups:
|
for candle in startups:
|
||||||
headers.append(str(candle))
|
if candle == strat_scc:
|
||||||
|
headers.append(f"{candle} (from strategy)")
|
||||||
|
else:
|
||||||
|
headers.append(str(candle))
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for inst in recursive_instances:
|
for inst in recursive_instances:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user