trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool      T-17

Back

High Low at 3:45pm consolodator

Hi,

I am trying to get the high and low of the trading day on SPY just before trading ends at 3:30pm or 3:45pm.  Therefore i thought that a consolidator could do the job.

I tried to modify the template consolidator algo to my porpose with no success after many iterations, many of them are still commented out.

I tried every 6 hours, 465min and other values.

I also tried to aggregate 15, 30 minutes consolidator  but this did not work either.

I must be close, can someone help?

See code below.

Thanks

def Initialize(self):
        self.SetStartDate(2015, 2, 1)  
        self.SetEndDate(2015, 2, 14)
        self.SetCash(10000)
        
        #self.AddEquity("SPY")
        self.AddEquity("SPY", Resolution.Minute)
        #self.AddEquity("SPY", Resolution.Hour)

        #thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=465))
        thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(hours=3))
        #thirtyMinuteConsolidator = TradeBarConsolidator(TimeSpan.FromHours(6))
   #thirtyMinuteConsolidator = TradeBarConsolidator(TimeSpan.FromMinutes(465))

        thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteBarHandler
        self.SubscriptionManager.AddConsolidator("SPY", thirtyMinuteConsolidator)
        
    #========================================
    
        oneDayConsolidator = TradeBarConsolidator(timedelta(minutes=30))
        threeCountConsolidator = TradeBarConsolidator(15)
three_oneDayBar=SequentialConsolidator(oneDayConsolidator,  threeCountConsolidator)
       three_oneDayBar.DataConsolidated += self.ThreeDayBarConsolidatedHandler
        self.SubscriptionManager.AddConsolidator("SPY", three_oneDayBar)

        
    def ThirtyMinuteBarHandler(self, sender, bar):
        '''This is our event handler for our 30-minute trade bar defined above in Initialize(). So each time the consolidator produces a new 30-minute bar, this function will be called automatically. The sender parameter will be the instance of the IDataConsolidator that invoked the event '''
        #self.Debug(str(self.Time) + " " + str(bar))
    
    def ThreeDayBarConsolidatedHandler(self, sender, consolidated):
        self.Log(f"{consolidated.Time} >> Plotting!")
        #self.Plot(consolidated.Symbol, "3HourBar", consolidated.Close)
        self.Debug(str(self.Time) + " " + str(consolidated.Close))
        
    def OnData(self, data):
        self.data = data
       

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed