From 08d5174d026f0cabce5262c216e0ddbf6a7445dd Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Wed, 4 Sep 2024 09:56:12 +0530 Subject: [PATCH] update documentation and add default values --- docs/advanced-backtesting.md | 21 +++++++++++++++++++++ freqtrade/data/entryexitanalysis.py | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/advanced-backtesting.md b/docs/advanced-backtesting.md index e1f7d77d4..de1264ae8 100644 --- a/docs/advanced-backtesting.md +++ b/docs/advanced-backtesting.md @@ -122,6 +122,27 @@ automatically accessible by including them on the indicator-list, and these incl - **profit_ratio :** trade profit ratio - **profit_abs :** absolute profit return of the trade +#### Sample Output for Indicator Values + +```bash +freqtrade backtesting-analysis -c user_data/config.json --analysis-groups 0 --indicator-list chikou_span tenkan_sen +``` +In this example, +we aim to display the `chikou_span` and `tenkan_sen` indicator values at both the entry and exit points of trades. + +A sample output for indicators might look like this: + +| pair | open_date | enter_reason | exit_reason | chikou_span (entry) | tenkan_sen (entry) | chikou_span (exit) | tenkan_sen (exit) | +|-----------|---------------------------|--------------|-------------|---------------------|--------------------|--------------------|-------------------| +| DOGE/USDT | 2024-07-06 00:35:00+00:00 | | exit_signal | 0.105 | 0.106 | 0.105 | 0.107 | +| BTC/USDT | 2024-08-05 14:20:00+00:00 | | roi | 54643.440 | 51696.400 | 54386.000 | 52072.010 | + +As shown in the table, `chikou_span (entry)` represents the indicator value at the time of trade entry, +while `chikou_span (exit)` reflects its value at the time of exit. +This detailed view of indicator values enhances the analysis. + +The `(entry)` and `(exit)` suffixes are added to indicators +to distinguish the values at the entry and exit points of the trade. ### Filtering the trade output by date diff --git a/freqtrade/data/entryexitanalysis.py b/freqtrade/data/entryexitanalysis.py index da5489731..964c4f86f 100644 --- a/freqtrade/data/entryexitanalysis.py +++ b/freqtrade/data/entryexitanalysis.py @@ -51,7 +51,9 @@ 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, date_col: str): +def _process_candles_and_indicators( + pairlist, strategy_name, trades, signal_candles, date_col: str = "open_date" +): analysed_trades_dict: Dict[str, Dict] = {strategy_name: {}} try: @@ -69,7 +71,7 @@ def _process_candles_and_indicators(pairlist, strategy_name, trades, signal_cand def _analyze_candles_and_indicators( - pair: str, trades: pd.DataFrame, signal_candles: pd.DataFrame, date_col: str + pair: str, trades: pd.DataFrame, signal_candles: pd.DataFrame, date_col: str = "open_date" ) -> pd.DataFrame: buyf = signal_candles