Fix group 0 table, add pathlib.Path use
This commit is contained in:
parent
80c6190c05
commit
8c03ebb78f
@ -1,5 +1,4 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
@ -26,14 +25,19 @@ def setup_analyze_configuration(args: Dict[str, Any], method: RunMode) -> Dict[s
|
|||||||
if method in no_unlimited_runmodes.keys():
|
if method in no_unlimited_runmodes.keys():
|
||||||
from freqtrade.data.btanalysis import get_latest_backtest_filename
|
from freqtrade.data.btanalysis import get_latest_backtest_filename
|
||||||
|
|
||||||
btfile = get_latest_backtest_filename(config['user_data_dir'] / 'backtest_results')
|
btfile = Path(get_latest_backtest_filename(config['user_data_dir'] / 'backtest_results'))
|
||||||
signals_file = f"{os.path.basename(os.path.splitext(btfile)[0])}_signals.pkl"
|
signals_file = f"{btfile.stem}_signals.pkl"
|
||||||
|
|
||||||
if (not os.path.exists(config['user_data_dir'] / 'backtest_results' / signals_file)):
|
if (not (config['user_data_dir'] / 'backtest_results' / signals_file).exists()):
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
"Cannot find latest backtest signals file. Run backtesting with --export signals."
|
"Cannot find latest backtest signals file. Run backtesting with --export signals."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ('strategy' not in config):
|
||||||
|
raise OperationalException(
|
||||||
|
"No strategy defined. Use --strategy or supply in config."
|
||||||
|
)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +52,8 @@ def start_analysis_entries_exits(args: Dict[str, Any]) -> None:
|
|||||||
# Initialize configuration
|
# Initialize configuration
|
||||||
config = setup_analyze_configuration(args, RunMode.BACKTEST)
|
config = setup_analyze_configuration(args, RunMode.BACKTEST)
|
||||||
|
|
||||||
|
print(config)
|
||||||
|
|
||||||
logger.info('Starting freqtrade in analysis mode')
|
logger.info('Starting freqtrade in analysis mode')
|
||||||
|
|
||||||
process_entry_exit_reasons(Path(config['user_data_dir'], 'backtest_results'),
|
process_entry_exit_reasons(Path(config['user_data_dir'], 'backtest_results'),
|
||||||
|
@ -644,5 +644,6 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
help=("Comma separated list of indicators to analyse. ",
|
help=("Comma separated list of indicators to analyse. ",
|
||||||
"e.g. 'close,rsi,bb_lowerband,profit_abs'"),
|
"e.g. 'close,rsi,bb_lowerband,profit_abs'"),
|
||||||
nargs='?',
|
nargs='?',
|
||||||
|
default='',
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -97,15 +97,12 @@ def _do_group_table_output(bigdf, glist):
|
|||||||
'count',
|
'count',
|
||||||
lambda x: sum(x > 0),
|
lambda x: sum(x > 0),
|
||||||
lambda x: sum(x <= 0)]})
|
lambda x: sum(x <= 0)]})
|
||||||
|
new = pd.concat([new, wins, loss], axis=1).fillna(0)
|
||||||
new = pd.merge(new, wins, left_index=True, right_index=True)
|
|
||||||
new = pd.merge(new, loss, left_index=True, right_index=True)
|
|
||||||
|
|
||||||
new['profit_tot'] = new['profit_abs_wins'] - abs(new['profit_abs_loss'])
|
new['profit_tot'] = new['profit_abs_wins'] - abs(new['profit_abs_loss'])
|
||||||
|
new['wl_ratio_pct'] = (new.iloc[:, 1] / new.iloc[:, 0] * 100).fillna(0)
|
||||||
new['wl_ratio_pct'] = (new.iloc[:, 1] / new.iloc[:, 0] * 100)
|
new['avg_win'] = (new['profit_abs_wins'] / new.iloc[:, 1]).fillna(0)
|
||||||
new['avg_win'] = (new['profit_abs_wins'] / new.iloc[:, 1])
|
new['avg_loss'] = (new['profit_abs_loss'] / new.iloc[:, 2]).fillna(0)
|
||||||
new['avg_loss'] = (new['profit_abs_loss'] / new.iloc[:, 2])
|
|
||||||
|
|
||||||
new.columns = ['total_num_buys', 'wins', 'losses', 'profit_abs_wins', 'profit_abs_loss',
|
new.columns = ['total_num_buys', 'wins', 'losses', 'profit_abs_wins', 'profit_abs_loss',
|
||||||
'profit_tot', 'wl_ratio_pct', 'avg_win', 'avg_loss']
|
'profit_tot', 'wl_ratio_pct', 'avg_win', 'avg_loss']
|
||||||
@ -249,6 +246,7 @@ def process_entry_exit_reasons(backtest_dir: Path,
|
|||||||
signal_candles = _load_signal_candles(backtest_dir)
|
signal_candles = _load_signal_candles(backtest_dir)
|
||||||
analysed_trades_dict = _process_candles_and_indicators(pairlist, strategy_name,
|
analysed_trades_dict = _process_candles_and_indicators(pairlist, strategy_name,
|
||||||
trades, signal_candles)
|
trades, signal_candles)
|
||||||
|
|
||||||
_print_results(analysed_trades_dict,
|
_print_results(analysed_trades_dict,
|
||||||
strategy_name,
|
strategy_name,
|
||||||
analysis_groups,
|
analysis_groups,
|
||||||
|
Loading…
Reference in New Issue
Block a user