Thanks Dan for your response. Indeed, your proposed algorithm solves the issue. But I still have some questions if you don't mind.
I am trying to go over the several criterias for the contest and explore them one by one, the different ways to satisfy them...
I thought that the Tradable Universe criteria would be the easiest to comply to. For the first algorithm, I went over the different positions it held in the backtest and it has traded 6 stocks: NVR
, RAD
, FBC
, TAT
, GSS
and CLWR
.
I have to manually check if these stocks belong to the QTradableStocksUS
universe, probably using a notebook.
So, in your opinion Dan, do you think it is a simple bug or one of the 6 stocks above are outside of Quantopian's universe?
Another thing I noticed: the line you added is supposed to limit the maximum percentage of the portfolio invested in a single stock, whether it is long or short, to 5%? I ran the backtest and the criteria "Position concentration" is not satisfied.
Which brings me to a more general question:
- Is there some inherent margin of errors/differences/variance/incongruity... between the algorithm (in this case, defining constraint) and the results of the backtest (due to the way the backtest is simulated maybe)?
I come from a development background and I may be missing something related to the inner working of the Pipeline, or the way it simulates a real market.
I hope my last question was not too broad.
Thanks in advance