Hi!
I'm trying to calculate the stocks 1 day return (based on the adjustedPrice) in the universe selection function (in this case the Coarse one).
But I keep getting the same returns for more days, it seems like the first time is correct and the others no...
For instance, looking at the console output I get by using self.Debug in CoarseSelectionFunction, I have FUBO with always 26% as previous day return:
2020-12-22 00:00:00 symbol: FUBO 0.26063694267515913
2020-12-23 00:00:00 symbol: FUBO 0.26063694267515913
2020-12-24 00:00:00 symbol: FUBO 0.26063694267515913
Emiliano Fraticelli
I know I could follow these guidelines, like the suggestions on this post, but I would like to use the RollingWindow object istead of accessing the Dataframe of historical Data Prices.
Shile Wen
Hi Emiliano,
Because of the filter in line 63, stocks that are around the ~$1 or ~$50 dollar range might fluctuate, causing them to jion in or drop out of the list of Symbols whose SymbolDatas will be updated due to the filter, thus some Symbols may not be consistently be updated.To address this, we can iterate over all of the coarse to update any data in our SymbolDataDictionary using the following snippet of code:
for c in coarse: if cf.Symbol in self.SymbolDataDictionary: self.SymbolDataDictionary[cf.Symbol].update(cf.EndTime, cf.AdjustedPrice, kvp.DollarVolume)
Please see the attached backtest for reference.
Best,
Shile Wen
Emiliano Fraticelli
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!