Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A Good Volatility Calculator

Any advice on writing a good volatility calculation function?

I wrote a function to use (high-low)/high to get it. But it seems not so good.

def volatility(context, data, stock, days):  
    low = min(data.history(stock, 'low', days, '1d'))  
    high = max(data.history(stock, 'high', days, '1d'))  
    return (high-low)/high  
2 responses