Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
1949.727%
Drawdown
1.600%
Expectancy
0
Net Profit
0%
Sharpe Ratio
10.243
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.611
Beta
-1.115
Annual Standard Deviation
0.192
Annual Variance
0.037
Information Ratio
11.914
Tracking Error
0.359
Treynor Ratio
-1.765
Total Fees
$2.59
import numpy as np

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        
        self.SetCash(100000)
        self.SetStartDate(2016,1,4)
        self.SetEndDate(2016,1,8)
        
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
        
        self.Schedule.On(self.DateRules.EveryDay(),
        self.TimeRules.AfterMarketOpen(self.spy, 15), 
        Action(self.rebalance))
        
        
    def OnData(self, slice):
        pass
    
    def rebalance(self):
        # Simple buy and hold template
        if not self.Portfolio.Invested:
            self.SetHoldings(self.spy, -1.0)
            
        spy_hold_val = round(self.Portfolio["SPY"].HoldingsValue, 2)
        spy_abs_val = round(self.Portfolio["SPY"].AbsoluteHoldingsValue, 2)
        spy_pnl = round(self.Portfolio["SPY"].UnrealizedProfit, 2)
        
        self.Log('SPY_HoldVal : ' + str(spy_hold_val))
        self.Log('SPY_AbsHoldVal : ' + str(spy_abs_val))
        self.Log('SPY_pnl : ' + str(spy_pnl) +'\n')