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
Estimated Strategy Capacity
$0
Lowest Capacity Asset
# region imports
from AlgorithmImports import *
import time
# endregion

class FetchTopGappers(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 5, 11)  # Set Start Date
        self.SetEndDate(2021, 5, 11)
        self.SetCash(100000)  # Set Strategy Cash

        self.tanh = self.Symbol("TANH VZ4JMWEY6VS5")
        self.tbltu = self.Symbol("TBLTU WYKN02HPCNS5")

        self.AddEquity("SPY", resolution=Resolution.Minute, extendedMarketHours=True)        

        # Add universe
        self.UniverseSettings.Resolution = Resolution.Minute
        self.UniverseSettings.ExtendedMarketHours = True
        self.UniverseSettings.FillForward = True
        self.AddUniverse(self.CoarseUniverseSelection)

        self.AddUniverseSelection(ScheduledUniverseSelectionModel(
            self.DateRules.EveryDay("SPY"), 
            self.TimeRules.AfterMarketOpen("SPY", -5),
            self.ScheduledSymbolSelect))

    def CoarseUniverseSelection(self, coarse):
        for c in coarse:
            if c.Symbol in [self.tanh, self.tbltu]:
                self.Debug(f"{self.Time} - {c.Symbol} coarse Price: {c.Price} // coarse adjusted price: {c.AdjustedPrice}")
        return [self.tanh, self.tbltu]
    

    def ScheduledSymbolSelect(self, date):
        history = self.History(
            tickers=[self.tanh, self.tbltu], 
            start=self.Time - timedelta(minutes=1),
            end=self.Time,
            resolution=Resolution.Minute, 
            fillForward=True, 
            extendedMarket=True,
            dataNormalizationMode=DataNormalizationMode.Adjusted, 
        ) 
        self.Debug(f"Minute data (adjusted): \n{history.to_string()}")

        history = self.History(
            tickers=[self.tanh, self.tbltu], 
            start=self.Time - timedelta(minutes=1),
            end=self.Time,
            resolution=Resolution.Minute, 
            fillForward=True, 
            extendedMarket=True,
            dataNormalizationMode=DataNormalizationMode.Raw, 
        ) 
        self.Debug(f"Minute data (raw): \n{history.to_string()}")

        history = self.History(
            tickers=[self.tanh, self.tbltu], 
            start=self.Time - timedelta(days=1),
            end=self.Time,
            resolution=Resolution.Daily, 
            fillForward=True, 
            extendedMarket=True,
            dataNormalizationMode=DataNormalizationMode.Adjusted, 
        ) 
        self.Debug(f"Daily data (adjusted): \n{history.to_string()}")

        history = self.History(
            tickers=[self.tanh, self.tbltu], 
            start=self.Time - timedelta(days=1),
            end=self.Time,
            resolution=Resolution.Daily, 
            fillForward=True, 
            extendedMarket=True,
            dataNormalizationMode=DataNormalizationMode.Raw, 
        ) 
        self.Debug(f"Daily data (raw): \n{history.to_string()}")
        return []