Hello,
So I do this:
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9, 0), self.Buy)
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(15, 30), self.Sell)
and then I do this:
def Buy(self):
for security in self.universe:
self.SetHoldings(security,-1/num_symbols)
def Sell(self):
for security in self.universe:
self.Liquidate(security)
and nothing happens.
If I just schedule Buy, it buys stocks.
FYI: self.universe contains 10 stocks (num_symbols) from universe selection that I want bought. I am experimenting with selling just before end of trading to avoid market closures/weekends and public holidays.
If someone could help with this, I would really appreciate it! thank you in advance.
Shile Wen
Hi Alexander,
Most likely you are using data on Daily Resolution, however, scheduled event Daily Resolution execute at midnight no matter what, so what happens is that a buy order is sent and converted to a MOO order, but then it is immediately canceled by the liquidation. To address this, we should change our Resolution to Minute. I've shown these changes in the attached backtest.
Best,
Shile Wen
Alexander Kool
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!