Use temporary variable to clean up code

This commit is contained in:
Matthias 2020-05-25 20:47:48 +02:00
parent 6a9a8f927e
commit abf79e4ab4

View File

@ -248,31 +248,34 @@ def generate_edge_table(results: dict) -> str:
def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame],
all_results: Dict[str, DataFrame]):
stake_currency = config['stake_currency']
max_open_trades = config['max_open_trades']
for strategy, results in all_results.items():
pair_results = generate_pair_metrics(btdata, stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'],
pair_results = generate_pair_metrics(btdata, stake_currency=stake_currency,
max_open_trades=max_open_trades,
results=results, skip_nan=False)
sell_reason_stats = generate_sell_reason_stats(max_open_trades=config['max_open_trades'],
sell_reason_stats = generate_sell_reason_stats(max_open_trades=max_open_trades,
results=results)
left_open_results = generate_pair_metrics(btdata, stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'],
left_open_results = generate_pair_metrics(btdata, stake_currency=stake_currency,
max_open_trades=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=stake_currency)
if isinstance(table, str):
print(' BACKTESTING REPORT '.center(len(table.splitlines()[0]), '='))
print(table)
table = generate_text_table_sell_reason(sell_reason_stats=sell_reason_stats,
stake_currency=config['stake_currency'],
stake_currency=stake_currency,
)
if isinstance(table, str):
print(' SELL REASON STATS '.center(len(table.splitlines()[0]), '='))
print(table)
table = generate_text_table(left_open_results, stake_currency=config['stake_currency'])
table = generate_text_table(left_open_results, stake_currency=stake_currency)
if isinstance(table, str):
print(' LEFT OPEN TRADES REPORT '.center(len(table.splitlines()[0]), '='))
print(table)
@ -282,11 +285,11 @@ def show_backtest_results(config: Dict, btdata: Dict[str, DataFrame],
if len(all_results) > 1:
# Print Strategy summary table
strategy_results = generate_strategy_metrics(stake_currency=config['stake_currency'],
max_open_trades=config['max_open_trades'],
strategy_results = generate_strategy_metrics(stake_currency=stake_currency,
max_open_trades=max_open_trades,
all_results=all_results)
table = generate_text_table_strategy(strategy_results, config['stake_currency'])
table = generate_text_table_strategy(strategy_results, stake_currency)
print(' STRATEGY SUMMARY '.center(len(table.splitlines()[0]), '='))
print(table)
print('=' * len(table.splitlines()[0]))