I have atarted a new topic as although about the same algo, it is a completely different issue:
I am trying to implement an exponential regression within an algo. In theory this is an indicator of momentum in a stock.
The problem is I already implement this in a python algo and it correctly identifies positive momentum stocks for me.
When I have tried to implement it with almost identical(this may be the issue!) it identifies negative momentum stocks as positive.
I have tried to compare a mock up in a notebook (attached) to the backtest(also attached). It is clear that when it carries out what appears to be the same calcualtion in the algo it returns positive results(for slope and r value in particular) where it should be identifying them as negative values (and does in the notebook and in my python algo).
This of course leads the algo to be an extreme loss maker where it should be moderately profitable, as it is going long on stocks that are screaming shorts.
If anyone can help by pointing out where the error or amendment is required I would be appreciative.
Thanks
Mark
Mark Gahagan
Apologies. I have finally solved the issue myself
It realtes to my incorrect use of deque.
I need to add each incoming close price to the right end not the left so the offending line in my original code is shown below.
Now it does not try to long stocks with downward momentum and vice versa which is a bonus!!!
This can be closed thanks
Mark Gahagan
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!