How to write a function to calculate a stock's max drawdown percentage in the past N-days? Or in a range of time.
The function prototype could be like this:
def calc_max_drawdown(context, data, stock_symbol, past_n_days):
...
return max_drawdown
For example:
calc_max_drawdown(context, data, 'SPY', 30)