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
Probabilistic 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 calendar

class HistoryRequestTest(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 8, 4)
        self.SetEndDate(2020, 8, 4)
        self.SetCash(30000)
        
        self.symbol_list = ["AAPL"]
        
        for symbol in self.symbol_list:
            self.AddEquity(symbol, Resolution.Minute)
        
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9, 25), Action(self.HistoryRequest))
    
    def HistoryRequest(self):
        
        """ History request by number of daily bars """
        
        history = self.History(self.symbol_list, 3, Resolution.Daily)
        
        current_date = self.Time
        weekday = calendar.day_name[current_date.weekday()]
        
        self.Debug("Current date for the algorithm is " + (str(self.Time).split(" ")[0]) + " and it is a " + str(weekday))
        
        self.Debug("Historical data request by number of recent daily bars: ")
        self.Log(history)
        
        """ History request by specified datetimes """
        
        startdate = datetime(2020, 7, 30, 9, 30, 0)
        enddate = datetime(2020, 8, 3, 16, 0, 0)
        history = self.History(self.symbol_list, startdate, enddate, Resolution.Daily)
        self.Debug("Historical data request by specified datetime from July 30th to August 3rd: ")
        self.Log(history)
        
        startdate = datetime(2020, 8, 3, 9, 30, 0)
        enddate = datetime(2020, 8, 3, 9, 35, 0)
        history = self.History(self.symbol_list, startdate, enddate, Resolution.Minute)
        self.Debug("Historical data request by specified datetime for first 5 minutes of August 3rd: ")
        self.Log(history)

    def OnData(self, data):
        pass