trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool

Back

Understanding coarse selection with custom indicators

I have this algo, that select stocks based on fundamental variables and technical values. In the coarce function I use the selectionData() object to update values of short and long moving average as well as volume in order to make calculations and then pick stocks based on these values.

 

Im trying to understand all this logic. What I not understand is that in the first filter, that I called "filtered", ,the lenght of stocks are around 90 to 100. And then when these stocks are passed to the stateData dictionary in order to update for the target indicators, then when I filter the list of stocks where is_ready is true, in the values list comprehension, it returns only a few stocks at first, and then that list start to increment. But both list are very different in length and I dont understand why.

 

My question is, why the "values" list is so small in relation to the "filtered" list?

 

Thanks,

Nicolás 

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 Nicolas, 

The key issue is that the `filtered` universe is changing every day in your strategy. That is, a specific symbol may be selected one trading day and be out of the universe for the next trading day. Hence, the SMA indicators will not be ready (i.e., "self.is_ready" in SelectionData() will not be True) until the accumulated EFFECTIVE trading days reach your specified moving average length, e.g., 45 in `self.LongAvg = SimpleMovingAverage(45)`. That's why the "values" list is much smaller than the "filtered" list as you observed. As time passes, the "values" list will eventually have the same length as the "filtered" list once "self.is_ready" becomes True. 

Additionally, you may want to modify the if condition in the update() definition. In "if A and B" statement, when A is False, B will not be executed. I think your strategy wants to update all SMA indicators and then check if all of them are ready. So, the three Update() methods should not be in the "if ... and ..." statement condition. 

Please see my attached backtest for implementation details. If you run the backtest, you'll be able to see the effective trading days for all symbols in Logs. Please let me know if you have further questions. 

Xin

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.


Hello Xin,

I find valuable all comments and support that you provide in your response. Many thanks for that. 

Analyzing what you had written, you are right in that the three updates methods should be outside the if statatement. Also, now I have a better idea of why the two list(filtered and values lists) have different length in the initial period of the backtesting.

Overall, my strategy need to use sma short, sma long and volume indicators to filter stocks in the universe, so with this approach, I think the selection process will be much more accurate.

I will run backtest and see the results.

Many thanks,

Nicolás 

0

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