Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
import numpy as np
import pandas as pd


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

        self.SetCash(100000)
        # Start and end dates for the backtest.
        self.SetStartDate(2019,9,1)
        self.SetEndDate(2019,9,15)
        
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol

        # Schedule (3:59pm)
        self.Schedule.On(self.DateRules.EveryDay("SPY"), \
                        self.TimeRules.At(15, 39), \
                        Action(self.rebalance))
    
    
    def OnData(self, data):
        pass


    def rebalance(self):

        # History (Hourly)
        history = self.History(self.spy, 90, Resolution.Hour)
        spy_history = history['close'].unstack(level=0)
        
        self.Debug(str(self.Time) + " Getting Hourly SPY: " + '\n'+ str(spy_history.tail()))
        
        # History (Minute)
        min_history = self.History(self.spy, 10, Resolution.Minute)
        spy_min = min_history['close'].unstack(level=0)
        current_spy = spy_min.iloc[-1] 
        
        self.Debug(str(self.Time) + " Getting Minute SPY: " + '\n'+ str(spy_min.tail()))
        self.Debug(str(self.Time) + " Current SPY: " + '\n'+ str(current_spy))