Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
50.056%
Drawdown
1.500%
Expectancy
0
Net Profit
1.644%
Sharpe Ratio
5.134
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
1.283
Beta
-51.597
Annual Standard Deviation
0.073
Annual Variance
0.005
Information Ratio
4.865
Tracking Error
0.074
Treynor Ratio
-0.007
Total Fees
$29.00
import numpy as np
import pandas as pd


class BootCampTask(QCAlgorithm):
    
        
    def Initialize(self):

        self.SetCash(1000000)
        # Start and end dates for the backtest.
        self.SetStartDate(2017,6,1)
        self.SetEndDate(2017,6,15)
        
        
        # Manually Select Data     
        self.spy = self.AddEquity("SPY", Resolution.Minute)
        self.iwm = self.AddEquity("IWM", Resolution.Minute)
        
        # Schedule the rebalance function
        self.Schedule.On(self.DateRules.EveryDay("SPY"), 
        self.TimeRules.AfterMarketOpen("SPY", 30), 
        Action(self.rebalance))
        
        
    
    def OnData(self, data):
        pass


    def rebalance(self):

        # Do something here
        
        if not self.Securities["SPY"].Invested:
            self.SetHoldings("SPY", 0.5)
        
        if not self.Securities["IWM"].Invested:
            self.SetHoldings("IWM", 0.5)
            
        
        invested = [ x.Symbol.Value for x in self.Portfolio.Values if x.Invested ]
        self.Log("Invested:  " + str(len(invested)) + ':  '+ str(invested))