@@ -194,6 +194,7 @@ def text_table_strategy(strategy_results, stake_currency: str, title: str):
194194
195195
196196def text_table_add_metrics (strat_results : dict ) -> None :
197+ stake = strat_results ["stake_currency" ]
197198 if len (strat_results ["trades" ]) > 0 :
198199 best_trade = max (strat_results ["trades" ], key = lambda x : x ["profit_ratio" ])
199200 worst_trade = min (strat_results ["trades" ], key = lambda x : x ["profit_ratio" ])
@@ -202,23 +203,19 @@ def text_table_add_metrics(strat_results: dict) -> None:
202203 [
203204 ("" , "" ), # Empty line to improve readability
204205 (
205- "Long / Short" ,
206+ "Long / Short trades " ,
206207 f"{ strat_results .get ('trade_count_long' , 'total_trades' )} / "
207208 f"{ strat_results .get ('trade_count_short' , 0 )} " ,
208209 ),
209- ("Total profit Long %" , f"{ strat_results ['profit_total_long' ]:.2%} " ),
210- ("Total profit Short %" , f"{ strat_results ['profit_total_short' ]:.2%} " ),
211210 (
212- "Absolute profit Long" ,
213- fmt_coin (
214- strat_results ["profit_total_long_abs" ], strat_results ["stake_currency" ]
215- ),
211+ "Long / Short profit %" ,
212+ f"{ strat_results ['profit_total_long' ]:.2%} / "
213+ f"{ strat_results ['profit_total_short' ]:.2%} " ,
216214 ),
217215 (
218- "Absolute profit Short" ,
219- fmt_coin (
220- strat_results ["profit_total_short_abs" ], strat_results ["stake_currency" ]
221- ),
216+ f"Long / Short profit { stake } " ,
217+ f"{ strat_results ['profit_total_long_abs' ]:.{decimals_per_coin (stake )}f} / "
218+ f"{ strat_results ['profit_total_short_abs' ]:.{decimals_per_coin (stake )}f} " ,
222219 ),
223220 ]
224221 if strat_results .get ("trade_count_short" , 0 ) > 0
@@ -231,27 +228,34 @@ def text_table_add_metrics(strat_results: dict) -> None:
231228 drawdown_metrics .append (
232229 ("Max % of account underwater" , f"{ strat_results ['max_relative_drawdown' ]:.2%} " )
233230 )
231+ drawdown_account = (
232+ strat_results ["max_drawdown_account" ]
233+ if "max_drawdown_account" in strat_results
234+ else strat_results ["max_drawdown" ]
235+ )
234236 drawdown_metrics .extend (
235237 [
236238 (
237- ( "Absolute Drawdown (Account)" , f" { strat_results [ 'max_drawdown_account' ]:.2% } " )
238- if "max_drawdown_account" in strat_results
239- else ( "Drawdown" , f" { strat_results [ 'max_drawdown' ] :.2%} " )
239+ "Absolute drawdown" ,
240+ f" { fmt_coin ( strat_results [ 'max_drawdown_abs' ], stake ) } "
241+ f"( { drawdown_account :.2%} )" ,
240242 ),
241243 (
242- "Absolute Drawdown" ,
243- fmt_coin (strat_results ["max_drawdown_abs" ], strat_results ["stake_currency" ]),
244+ "Drawdown duration" ,
245+ strat_results ["drawdown_duration" ]
246+ if "drawdown_duration" in strat_results
247+ else "N/A" ,
244248 ),
245249 (
246- "Drawdown high " ,
247- fmt_coin (strat_results ["max_drawdown_high" ], strat_results [ "stake_currency" ] ),
250+ "Profit at drawdown start " ,
251+ fmt_coin (strat_results ["max_drawdown_high" ], stake ),
248252 ),
249253 (
250- "Drawdown low " ,
251- fmt_coin (strat_results ["max_drawdown_low" ], strat_results [ "stake_currency" ] ),
254+ "Profit at drawdown end " ,
255+ fmt_coin (strat_results ["max_drawdown_low" ], stake ),
252256 ),
253- ("Drawdown Start " , strat_results ["drawdown_start" ]),
254- ("Drawdown End " , strat_results ["drawdown_end" ]),
257+ ("Drawdown start " , strat_results ["drawdown_start" ]),
258+ ("Drawdown end " , strat_results ["drawdown_end" ]),
255259 ]
256260 )
257261
@@ -299,15 +303,15 @@ def text_table_add_metrics(strat_results: dict) -> None:
299303 ),
300304 (
301305 "Starting balance" ,
302- fmt_coin (strat_results ["starting_balance" ], strat_results [ "stake_currency" ] ),
306+ fmt_coin (strat_results ["starting_balance" ], stake ),
303307 ),
304308 (
305309 "Final balance" ,
306- fmt_coin (strat_results ["final_balance" ], strat_results [ "stake_currency" ] ),
310+ fmt_coin (strat_results ["final_balance" ], stake ),
307311 ),
308312 (
309313 "Absolute profit " ,
310- fmt_coin (strat_results ["profit_total_abs" ], strat_results [ "stake_currency" ] ),
314+ fmt_coin (strat_results ["profit_total_abs" ], stake ),
311315 ),
312316 ("Total profit %" , f"{ strat_results ['profit_total' ]:.2%} " ),
313317 ("CAGR %" , f"{ strat_results ['cagr' ]:.2%} " if "cagr" in strat_results else "N/A" ),
@@ -335,16 +339,16 @@ def text_table_add_metrics(strat_results: dict) -> None:
335339 "Avg. daily profit" ,
336340 fmt_coin (
337341 (strat_results ["profit_total_abs" ] / strat_results ["backtest_days" ]),
338- strat_results [ "stake_currency" ] ,
342+ stake ,
339343 ),
340344 ),
341345 (
342346 "Avg. stake amount" ,
343- fmt_coin (strat_results ["avg_stake_amount" ], strat_results [ "stake_currency" ] ),
347+ fmt_coin (strat_results ["avg_stake_amount" ], stake ),
344348 ),
345349 (
346350 "Total trade volume" ,
347- fmt_coin (strat_results ["total_volume" ], strat_results [ "stake_currency" ] ),
351+ fmt_coin (strat_results ["total_volume" ], stake ),
348352 ),
349353 * short_metrics ,
350354 ("" , "" ), # Empty line to improve readability
@@ -362,11 +366,11 @@ def text_table_add_metrics(strat_results: dict) -> None:
362366 ("Worst trade" , f"{ worst_trade ['pair' ]} { worst_trade ['profit_ratio' ]:.2%} " ),
363367 (
364368 "Best day" ,
365- fmt_coin (strat_results ["backtest_best_day_abs" ], strat_results [ "stake_currency" ] ),
369+ fmt_coin (strat_results ["backtest_best_day_abs" ], stake ),
366370 ),
367371 (
368372 "Worst day" ,
369- fmt_coin (strat_results ["backtest_worst_day_abs" ], strat_results [ "stake_currency" ] ),
373+ fmt_coin (strat_results ["backtest_worst_day_abs" ], stake ),
370374 ),
371375 (
372376 "Days win/draw/lose" ,
@@ -404,17 +408,17 @@ def text_table_add_metrics(strat_results: dict) -> None:
404408 ),
405409 * entry_adjustment_metrics ,
406410 ("" , "" ), # Empty line to improve readability
407- ("Min balance" , fmt_coin (strat_results ["csum_min" ], strat_results [ "stake_currency" ] )),
408- ("Max balance" , fmt_coin (strat_results ["csum_max" ], strat_results [ "stake_currency" ] )),
411+ ("Min balance" , fmt_coin (strat_results ["csum_min" ], stake )),
412+ ("Max balance" , fmt_coin (strat_results ["csum_max" ], stake )),
409413 * drawdown_metrics ,
410414 ("Market change" , f"{ strat_results ['market_change' ]:.2%} " ),
411415 ]
412416 print_rich_table (metrics , ["Metric" , "Value" ], summary = "SUMMARY METRICS" , justify = "left" )
413417
414418 else :
415- start_balance = fmt_coin (strat_results ["starting_balance" ], strat_results [ "stake_currency" ] )
419+ start_balance = fmt_coin (strat_results ["starting_balance" ], stake )
416420 stake_amount = (
417- fmt_coin (strat_results ["stake_amount" ], strat_results [ "stake_currency" ] )
421+ fmt_coin (strat_results ["stake_amount" ], stake )
418422 if strat_results ["stake_amount" ] != UNLIMITED_STAKE_AMOUNT
419423 else "unlimited"
420424 )
0 commit comments