Drawdown

Financial Trading in Python

Chelsea Yang

Data Science Instructor

What is a drawdown?

A drawdown is a peak-to-trough decline during a specific period for an asset or a trading account.

Drawdown chart

Financial Trading in Python

Max drawdown

$\text{Max Drawdown} = (V_p - V_l)/ V_l $

$V_p$: Peak value before the largest drop

$V_l$: Lowest value before a new high value

Max drawdown example

Max drawdown

= (Point A value - point D value)/Point A value = (1700 - 800)/1700 = 53%

Financial Trading in Python

Obtain drawdowns from backtest stats

resInfo = bt_result.stats

# Get the max drawdown max_drawdown = resInfo.loc['max_drawdown'] print('Maximum drawdown: %.2f'% max_drawdown)
# Get the average drawdown avg_drawdown = resInfo.loc['avg_drawdown'] print('Average drawdown: %.2f'% avg_drawdown)
# Get the average drawdown days avg_drawdown_days = resInfo.loc['avg_drawdown_days'] print('Average drawdown days: %.0f'% avg_drawdown_days)
Maximum drawdown: -0.59
Average drawdown: -0.11
Average drawdown days: 22
Financial Trading in Python

The Calmar ratio

CALMAR: CALifornia Managed Accounts Report

 

$ Calmar = CAGR / \text{Max Drawdown} $

  • The higher the Calmar ratio, the better a strategy performed on a risk-adjusted basis.
  • Typically a Camlar ratio larger than 3 is considered excellent.
Financial Trading in Python

Calculate the Calmar ratio manually

resInfo = bt_result.stats
# Get the CAGR
cagr = resInfo.loc['cagr']
# Get the max drawdown
max_drawdown = resInfo.loc['max_drawdown']

# Calculate Calmar ratio mannually calmar_calc = cagr / max_drawdown * (-1) print('Calmar Ratio calculated: %.2f'% calmar_calc)
Calmar Ratio calculated: 4.14
Financial Trading in Python

Obtain the Calmar ratio from backtest stats

resInfo = bt_result.stats

# Get the Calmar ratio
calmar = resInfo.loc['calmar']
print('Calmar Ratio: %.2f'% calmar)
Calmar Ratio: 4.14
Financial Trading in Python

Let's practice!

Financial Trading in Python

Preparing Video For Download...