Back to Community
Need help un-deprecating an algo

Looking for a hand on removing the deprecated functions from this code

Clone Algorithm
10
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5872857fc7a5d3620d1fc8ec
There was a runtime error.
3 responses

Hey William,

Looks like I got it to work by changing the following lines in the rebalance section, note that for this you will need to "import talib" at the top of your code.

    for s in context.assetclasses:  
        history = data.history(s, 'price',150,'1d')  
        MA = talib.SMA(history,timeperiod=100)  
        if data.current(s, 'price') > MA[-1]:  
            buylist.append(s)  

Hope this helps and good luck!

That worked great, thanks!

William,

There is anoter more native solution without talib:

    for s in context.assetclasses:  
        if data.current(s, 'price') > data.history(s, 'price',100,'1d').mean():  
            buylist.append(s)