mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
fix ruff
This commit is contained in:
parent
feab5f82c1
commit
821a598ff4
|
@ -208,8 +208,9 @@ class Arguments:
|
|||
start_list_strategies, start_list_timeframes,
|
||||
start_lookahead_analysis, start_new_config,
|
||||
start_new_strategy, start_plot_dataframe, start_plot_profit,
|
||||
start_recursive_analysis, start_show_trades, start_strategy_update,
|
||||
start_test_pairlist, start_trading, start_webserver)
|
||||
start_recursive_analysis, start_show_trades,
|
||||
start_strategy_update, start_test_pairlist,
|
||||
start_trading, start_webserver)
|
||||
|
||||
subparsers = self.parser.add_subparsers(dest='command',
|
||||
# Use custom message when no subhandler is added
|
||||
|
|
|
@ -8,7 +8,6 @@ from typing import Any, Dict, List, Optional
|
|||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.configuration import TimeRange
|
||||
from freqtrade.data.history import get_timerange
|
||||
from freqtrade.exchange import timeframe_to_minutes
|
||||
from freqtrade.loggers.set_log_levels import (reduce_verbosity_for_bias_tester,
|
||||
restore_verbosity_for_bias_tester)
|
||||
|
@ -54,21 +53,16 @@ class RecursiveAnalysis:
|
|||
# For recursive bias check
|
||||
# analyzes two data frames with processed indicators and shows differences between them.
|
||||
def analyze_indicators(self):
|
||||
|
||||
|
||||
pair_to_check = self.local_config['pairs'][0]
|
||||
logger.info(f"Start checking for recursive bias")
|
||||
logger.info("Start checking for recursive bias")
|
||||
|
||||
# check and report signals
|
||||
base_last_row = self.full_varHolder.indicators[pair_to_check].iloc[-1]
|
||||
base_timerange = self.full_varHolder.from_dt.strftime('%Y-%m-%dT%H:%M:%S') + "-" + self.full_varHolder.to_dt.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
||||
for part in self.partial_varHolder_array:
|
||||
part_last_row = part.indicators[pair_to_check].iloc[-1]
|
||||
part_timerange = part.from_dt.strftime('%Y-%m-%dT%H:%M:%S') + "-" + part.to_dt.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
||||
logger.info(f"Comparing last row of {base_timerange} backtest")
|
||||
logger.info(f"vs {part_timerange} with {part.startup_candle} startup candle")
|
||||
|
||||
compare_df = base_last_row.compare(part_last_row)
|
||||
if compare_df.shape[0] > 0:
|
||||
# print(compare_df)
|
||||
|
@ -85,13 +79,9 @@ class RecursiveAnalysis:
|
|||
values_diff = compare_df.loc[indicator]
|
||||
values_diff_self = values_diff.loc['self']
|
||||
values_diff_other = values_diff.loc['other']
|
||||
difference = (values_diff_other - values_diff_self) / values_diff_self * 100
|
||||
|
||||
self.dict_recursive[indicator][part.startup_candle] = "{:.3f}%".format(difference)
|
||||
diff = (values_diff_other - values_diff_self) / values_diff_self * 100
|
||||
|
||||
# logger.info(f"=> found difference in indicator "
|
||||
# f"{indicator}, with difference of "
|
||||
# "{:.8f}%".format(difference))
|
||||
self.dict_recursive[indicator][part.startup_candle] = "{:.3f}%".format(diff)
|
||||
|
||||
else:
|
||||
logger.info("No difference found. Stop the process.")
|
||||
|
@ -100,25 +90,22 @@ class RecursiveAnalysis:
|
|||
# For lookahead bias check
|
||||
# analyzes two data frames with processed indicators and shows differences between them.
|
||||
def analyze_indicators_lookahead(self):
|
||||
|
||||
pair_to_check = self.local_config['pairs'][0]
|
||||
logger.info(f"Start checking for lookahead bias")
|
||||
|
||||
# check and report signals
|
||||
# base_last_row = self.full_varHolder.indicators[pair_to_check].iloc[-1]
|
||||
# base_timerange = self.full_varHolder.from_dt.strftime('%Y-%m-%dT%H:%M:%S') + "-" + self.full_varHolder.to_dt.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
||||
pair_to_check = self.local_config['pairs'][0]
|
||||
logger.info("Start checking for lookahead bias on indicators only")
|
||||
|
||||
part = self.partial_varHolder_lookahead_array[0]
|
||||
part_last_row = part.indicators[pair_to_check].iloc[-1]
|
||||
date_to_check = part_last_row['date']
|
||||
base_row_to_check = self.full_varHolder.indicators[pair_to_check].loc[(self.full_varHolder.indicators[pair_to_check]['date'] == date_to_check)].iloc[-1]
|
||||
index_to_get = (self.full_varHolder.indicators[pair_to_check]['date'] == date_to_check)
|
||||
base_row_check = self.full_varHolder.indicators[pair_to_check].loc[index_to_get].iloc[-1]
|
||||
|
||||
check_time = part.to_dt.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
|
||||
logger.info(f"Check indicators at {check_time}")
|
||||
# logger.info(f"vs {part_timerange} with {part.startup_candle} startup candle")
|
||||
|
||||
compare_df = base_row_to_check.compare(part_last_row)
|
||||
|
||||
compare_df = base_row_check.compare(part_last_row)
|
||||
if compare_df.shape[0] > 0:
|
||||
# print(compare_df)
|
||||
for col_name, values in compare_df.items():
|
||||
|
@ -133,7 +120,7 @@ class RecursiveAnalysis:
|
|||
# logger.info("part value {:.5f}".format(values_diff_other))
|
||||
|
||||
else:
|
||||
logger.info("No lookahead bias found. Stop the process.")
|
||||
logger.info("No lookahead bias on indicators found. Stop the process.")
|
||||
|
||||
def prepare_data(self, varholder: VarHolder, pairs_to_load: List[DataFrame]):
|
||||
|
||||
|
@ -233,4 +220,4 @@ class RecursiveAnalysis:
|
|||
restore_verbosity_for_bias_tester()
|
||||
|
||||
self.analyze_indicators()
|
||||
self.analyze_indicators_lookahead()
|
||||
self.analyze_indicators_lookahead()
|
||||
|
|
Loading…
Reference in New Issue
Block a user