Move stats generation to the top

This commit is contained in:
Matthias 2020-05-25 20:22:22 +02:00
parent 46f1470e28
commit 462c35cf75

View File

@ -249,18 +249,22 @@ def generate_edge_table(results: dict) -> str:
def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame], def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame],
all_results: Dict[str, DataFrame]): all_results: Dict[str, DataFrame]):
for strategy, results in all_results.items(): for strategy, results in all_results.items():
print(f"Result for strategy {strategy}")
pair_results = generate_pair_results(btdata, stake_currency=config['stake_currency'], pair_results = generate_pair_results(btdata, stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'], max_open_trades=config['max_open_trades'],
results=results, skip_nan=False) results=results, skip_nan=False)
sell_reason_stats = generate_sell_reason_stats(max_open_trades=config['max_open_trades'],
results=results)
left_open_results = generate_pair_results(btdata, stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'],
results=results.loc[results['open_at_end']],
skip_nan=True)
# Print results
print(f"Result for strategy {strategy}")
table = generate_text_table(pair_results, stake_currency=config['stake_currency']) table = generate_text_table(pair_results, stake_currency=config['stake_currency'])
if isinstance(table, str): if isinstance(table, str):
print(' BACKTESTING REPORT '.center(len(table.splitlines()[0]), '=')) print(' BACKTESTING REPORT '.center(len(table.splitlines()[0]), '='))
print(table) print(table)
sell_reason_stats = generate_sell_reason_stats(max_open_trades=config['max_open_trades'],
results=results)
table = generate_text_table_sell_reason(sell_reason_stats=sell_reason_stats, table = generate_text_table_sell_reason(sell_reason_stats=sell_reason_stats,
stake_currency=config['stake_currency'], stake_currency=config['stake_currency'],
) )
@ -268,10 +272,6 @@ def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame],
print(' SELL REASON STATS '.center(len(table.splitlines()[0]), '=')) print(' SELL REASON STATS '.center(len(table.splitlines()[0]), '='))
print(table) print(table)
left_open_results = generate_pair_results(btdata, stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'],
results=results.loc[results['open_at_end']],
skip_nan=True)
table = generate_text_table(left_open_results, stake_currency=config['stake_currency']) table = generate_text_table(left_open_results, stake_currency=config['stake_currency'])
if isinstance(table, str): if isinstance(table, str):
print(' LEFT OPEN TRADES REPORT '.center(len(table.splitlines()[0]), '=')) print(' LEFT OPEN TRADES REPORT '.center(len(table.splitlines()[0]), '='))