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.017
Tracking Error
0.109
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
from QuantConnect.Data.Custom.CBOE import CBOE
from QuantConnect.Data.Custom.Fred import *

class RSIAlgorithm(QCAlgorithm):

    def Initialize(self):
        
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2020, 2, 1)

        self.SetCash(1000000)
        
        self.buffer = 0.02
        self.Settings.FreePortfolioValuePercentage = self.buffer
        self.UniverseSettings.Resolution = Resolution.Minute
        self.UniverseSettings.ExtendedMarketHours = True

        self.SetBrokerageModel(BrokerageName.AlphaStreams)

        self.vix          = self.AddData(CBOE, 'VIX', Resolution.Daily).Symbol
        self.value        = self.AddEquity("SPY", Resolution.Minute).Symbol
        tickers = [self.value]
        self.SetUniverseSelection(ManualUniverseSelectionModel(tickers))
        
        ValueDailyConsolidator = TradeBarConsolidator(timedelta(days=1))
        ValueDailyConsolidator.DataConsolidated += self.ValueDailyBarHandler
        self.SubscriptionManager.AddConsolidator("SPY", ValueDailyConsolidator)

        self.valuesma            = self.SMA(self.value, 1, Resolution.Daily)

        self.Schedule.On(self.DateRules.EveryDay(self.value), self.TimeRules.AfterMarketOpen(self.value, -30), Action(self.trade))
        
        self.SetWarmUp(100)
        self.valueClose = None
        
    def ValueDailyBarHandler(self, sender, bar):
        
        self.Log(f'New Bar: {bar.Close} @ {self.Time}')
        
        # Saving new bar to variable:
        self.valueClose = bar.Close

            
    def trade(self):
        
        # if self.valueClose is not None:
        self.Log(f'Time: {self.Time}')
        self.Log(f'Value Close: {self.valueClose}')
        self.Log(f'Value SMA: {self.valuesma.Current.Value}')
        self.Log("-------------------")
            

    def OnData(self, data):
        pass