mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
refactor: change analyse_on variable name to date_col
This commit is contained in:
@@ -51,10 +51,8 @@ def _load_exit_signal_candles(backtest_dir: Path) -> Dict[str, Dict[str, pd.Data
|
||||
return _load_backtest_analysis_data(backtest_dir, "exited")
|
||||
|
||||
|
||||
def _process_candles_and_indicators(
|
||||
pairlist, strategy_name, trades, signal_candles, analyse_on="open_date"
|
||||
):
|
||||
analysed_trades_dict = {strategy_name: {}}
|
||||
def _process_candles_and_indicators(pairlist, strategy_name, trades, signal_candles, date_col: str):
|
||||
analysed_trades_dict: Dict[str, Dict] = {strategy_name: {}}
|
||||
|
||||
try:
|
||||
logger.info(f"Processing {strategy_name} : {len(pairlist)} pairs")
|
||||
@@ -62,7 +60,7 @@ def _process_candles_and_indicators(
|
||||
for pair in pairlist:
|
||||
if pair in signal_candles[strategy_name]:
|
||||
analysed_trades_dict[strategy_name][pair] = _analyze_candles_and_indicators(
|
||||
pair, trades, signal_candles[strategy_name][pair], analyse_on
|
||||
pair, trades, signal_candles[strategy_name][pair], date_col
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Cannot process entry/exit reasons for {strategy_name}: ", e)
|
||||
@@ -71,7 +69,7 @@ def _process_candles_and_indicators(
|
||||
|
||||
|
||||
def _analyze_candles_and_indicators(
|
||||
pair: str, trades: pd.DataFrame, signal_candles: pd.DataFrame, analyse_on="open_date"
|
||||
pair: str, trades: pd.DataFrame, signal_candles: pd.DataFrame, date_col: str
|
||||
) -> pd.DataFrame:
|
||||
buyf = signal_candles
|
||||
|
||||
@@ -83,7 +81,7 @@ def _analyze_candles_and_indicators(
|
||||
|
||||
if trades_red.shape[0] > 0 and buyf.shape[0] > 0:
|
||||
for t, v in trades_red.iterrows():
|
||||
allinds = buyf.loc[(buyf["date"] < v[analyse_on])]
|
||||
allinds = buyf.loc[(buyf["date"] < v[date_col])]
|
||||
if allinds.shape[0] > 0:
|
||||
tmp_inds = allinds.iloc[[-1]]
|
||||
|
||||
@@ -343,10 +341,10 @@ def process_entry_exit_reasons(config: Config):
|
||||
trades = load_backtest_data(config["exportfilename"], strategy_name)
|
||||
|
||||
if trades is not None and not trades.empty:
|
||||
analyse_on = "open_date"
|
||||
date_col = "open_date"
|
||||
if do_exited is True:
|
||||
signal_candles = _load_exit_signal_candles(config["exportfilename"])
|
||||
analyse_on = "close_date"
|
||||
date_col = "close_date"
|
||||
else:
|
||||
signal_candles = _load_signal_candles(config["exportfilename"])
|
||||
|
||||
@@ -366,7 +364,7 @@ def process_entry_exit_reasons(config: Config):
|
||||
strategy_name,
|
||||
trades,
|
||||
signal_candles,
|
||||
analyse_on,
|
||||
date_col,
|
||||
)
|
||||
|
||||
res_df = prepare_results(
|
||||
|
||||
@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def generate_trade_signal_candles(
|
||||
preprocessed_df: Dict[str, DataFrame], bt_results: Dict[str, Any], analysis_on: str
|
||||
preprocessed_df: Dict[str, DataFrame], bt_results: Dict[str, Any], date_col: str
|
||||
) -> Dict[str, DataFrame]:
|
||||
signal_candles_only = {}
|
||||
for pair in preprocessed_df.keys():
|
||||
@@ -37,7 +37,7 @@ def generate_trade_signal_candles(
|
||||
|
||||
if pairdf.shape[0] > 0:
|
||||
for t, v in pairresults.iterrows():
|
||||
allinds = pairdf.loc[(pairdf["date"] < v[analysis_on])]
|
||||
allinds = pairdf.loc[(pairdf["date"] < v[date_col])]
|
||||
signal_inds = allinds.iloc[[-1]]
|
||||
signal_candles_only_df = concat(
|
||||
[signal_candles_only_df.infer_objects(), signal_inds.infer_objects()]
|
||||
|
||||
Reference in New Issue
Block a user