Back

Scheduled event to liquidate

Hello, I was trying to backtest a volatility strategy and I found that VXX is listed differently before 17 Jan 2018 so i want to liquidate the position and switch from VXX1 to VXX. Thus, I have the following defined:
 

self.VXXO = self.AddEquity('VXX.1', Resolution.Minute).Symbol

self.VXX = self.AddEquity('VXX', Resolution.Minute).Symbol

--> works: self.Schedule.On(self.DateRules.On(2018, 1, 20), self.TimeRules.At(15,15), self.VXXDate)
--> does not work: self.Schedule.On(self.DateRules.On(2018, 1, 20), self.TimeRules.BeforeMarketClose(self.VXXO, 5), self.VXXDate)

def VXXDate(self):
        # VXX data
        self.Liquidate(self.VXXO)

Does anyone know why I cannot use slf.TimeRules.BeforeMarketClose to trigger the method?

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.


Hi John,

That is because the Scheduled Event is fired on a Saturday, when the stock markets are closed, which means a Before Market Close event won't execute. As a fix, we can change the date to 2018-1-19, a Friday. I've shown this fix in the attached backtest.

Best,
Shile Wen

1

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