Overall Statistics
Total Trades
56
Average Win
0.16%
Average Loss
-0.07%
Compounding Annual Return
27.475%
Drawdown
0.300%
Expectancy
0.641
Net Profit
1.249%
Sharpe Ratio
14.681
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
2.28
Alpha
0.215
Beta
-0.033
Annual Standard Deviation
0.014
Annual Variance
0
Information Ratio
0.297
Tracking Error
0.077
Treynor Ratio
-6.239
Total Fees
$81.14
import numpy as np

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        
        self.SetCash(100000)
        self.SetStartDate(2017,2,20)
        self.SetEndDate(2017,3,12)
        # Add assets you'd like to see
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
        self.iwm = self.AddEquity("IWM", Resolution.Minute).Symbol
        # Schedule function     ----------------------------------------
 
 
        self.Schedule.On(self.DateRules.EveryDay(),
        self.TimeRules.AfterMarketOpen(self.spy, 60), 
        Action(self.rebalance))
        
        
        self.Schedule.On(self.DateRules.EveryDay(),
        self.TimeRules.BeforeMarketClose(self.spy, 60),
        Action(self.exit))
        
        

    def OnData(self, slice):
        pass
    
    def rebalance(self):
        # Simple buy and hold template
        if not self.Portfolio.Invested:
            self.SetHoldings(self.spy, 0.5)
            self.SetHoldings(self.iwm, -0.5)
        
        
    def exit(self):
        # Simple exit
        if self.Portfolio.Invested:
            self.Liquidate(self.spy)
            self.Liquidate(self.iwm)