Hi,
I'm running into an issue that, I get different results every time when I build and backtest the same code base. The portfolio could range from 5% to 13%. This issue didn't happen when I use `AddUinverse(Coarse, Fine)` type of way to add filter. Not I've tried to add universe through `AddUniverseSelection(UniverseSelectionClass())`, everything now looks so different.
Can anyone help me out here and have a look?
Thank you so much!
AK M
Very interesting, I had something similar happen to me and made this thread:
Also have reached out to the Admins directly. I think this is a critical issue.
Michael Hsia
I've run a quick analysis from the `order` perspective, and here's what is really intriguing:
I have my universe selection process in place, and I have even sorted these stocks by a certain order. Theoretically speaking, the orders placed should be identical in two different backtest. However, the results show that on a certain date the order of the stock is no longer the same. Gotta do some more research to find out why is that.
Would also be appreciated if anyone could help me out here.
Michael Hsia
Found out the cause that even if you sort your stocks in the finefilter, the order of the stock symbols won't be the same in the `OnData()` function.
Is there any formal way to preserve the order of the symbols after sorted in the coarse and fine filter?
Michael Hsia
AK M
For your case, I can make a wild guess that, the stocks that you traded were not added during the universe selection step, but like they were added in your universe while you created the symbol. You can double check by clicking the `Order` in your backtest result, and see if there are only stocks that you created were traded.
Jared Broad
List type order isn't guaranteed; you can sort them afterward in OnData if needed.
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.
Michael Hsia
Hi Jared Broad ,
What if I want to sort them by fundamental, can we do that in Ondata function?
Michael Hsia
In the end, the only solution that I can figure out is to store the sorted stock list in the local variable in main.py. Therefore, it means we can't use the `self.AddUniverseSelection(SelectionModel())` method. Instead using `self.AddUniverse(coarse, finefilter)` so that you can store the sorted stock list.
Michael Hsia
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!