Back to Community
simple moving average (updated on a minute basis)

Trading the intel stock based on multiple timeframes

Clone Algorithm
5
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

def initialize(context):
    context.intl = sid(3951)
    #Intel Corp Ticker
    schedule_function(rebalance, date_rule=date_rules.every_day())
     
     
def rebalance(context, data):
    #Getting price history update every minute
    price_history = data.history(context.intl, 'price', 1440, '1m')
    
    #hourly
    s_mavg = price_history[-60:].mean()
    
    #daily
    l_mavg = price_history.mean() 
       
    if data.can_trade(context.intl):
           
        if s_mavg > l_mavg:
               
            order_target_percent(context.intl, 1.0)
          
        elif s_mavg < l_mavg:
        
            order_target_percent(context.intl, 0)
            
    record(short_mavg = s_mavg,long_mavg = l_mavg)

There was a runtime error.