@@ -611,17 +611,18 @@ def _rpc_trade_statistics(
611611 )
612612
613613 expectancy , expectancy_ratio = calculate_expectancy (trades_df )
614- max_drawdown = DrawDownResult ()
615614
615+ drawdown = DrawDownResult ()
616616 if len (trades_df ) > 0 :
617617 try :
618- max_drawdown = calculate_max_drawdown (
618+ drawdown = calculate_max_drawdown (
619619 trades_df ,
620620 value_col = "profit_abs" ,
621621 date_col = "close_date_dt" ,
622622 starting_balance = starting_balance ,
623623 )
624624 except ValueError :
625+ # ValueError if no losing trade.
625626 pass
626627
627628 profit_all_fiat = (
@@ -672,19 +673,19 @@ def _rpc_trade_statistics(
672673 "winrate" : winrate ,
673674 "expectancy" : expectancy ,
674675 "expectancy_ratio" : expectancy_ratio ,
675- "max_drawdown" : max_drawdown .relative_account_drawdown ,
676- "max_drawdown_abs" : max_drawdown .drawdown_abs ,
677- "max_drawdown_start" : format_date (max_drawdown .high_date ),
678- "max_drawdown_start_timestamp" : dt_ts_def (max_drawdown .high_date ),
679- "max_drawdown_end" : format_date (max_drawdown .low_date ),
680- "max_drawdown_end_timestamp" : dt_ts_def (max_drawdown .low_date ),
681- "drawdown_high" : max_drawdown .high_value ,
682- "drawdown_low" : max_drawdown .low_value ,
683- "current_drawdown" : max_drawdown .current_relative_account_drawdown ,
684- "current_drawdown_abs" : max_drawdown .current_drawdown_abs ,
685- "current_drawdown_high" : max_drawdown .current_high_value ,
686- "current_drawdown_start" : format_date (max_drawdown .current_high_date ),
687- "current_drawdown_start_timestamp" : dt_ts_def (max_drawdown .current_high_date ),
676+ "max_drawdown" : drawdown .relative_account_drawdown ,
677+ "max_drawdown_abs" : drawdown .drawdown_abs ,
678+ "max_drawdown_start" : format_date (drawdown .high_date ),
679+ "max_drawdown_start_timestamp" : dt_ts_def (drawdown .high_date ),
680+ "max_drawdown_end" : format_date (drawdown .low_date ),
681+ "max_drawdown_end_timestamp" : dt_ts_def (drawdown .low_date ),
682+ "drawdown_high" : drawdown .high_value ,
683+ "drawdown_low" : drawdown .low_value ,
684+ "current_drawdown" : drawdown .current_relative_account_drawdown ,
685+ "current_drawdown_abs" : drawdown .current_drawdown_abs ,
686+ "current_drawdown_high" : drawdown .current_high_value ,
687+ "current_drawdown_start" : format_date (drawdown .current_high_date ),
688+ "current_drawdown_start_timestamp" : dt_ts_def (drawdown .current_high_date ),
688689 "trading_volume" : trading_volume ,
689690 "bot_start_timestamp" : dt_ts_def (bot_start , 0 ),
690691 "bot_start_date" : format_date (bot_start ),
0 commit comments