Back

Multiple Symbols Consolitador-RollingWindow problem

Hello, I have coded the attached algo that use multiple symbols to go long and short based on fundamental and technical conditions. On the current state, the algo doesn't trade any stock because the TradeBar consolidator with the rolling window is not working. I mean the rolling window self.Bars which is defined for each symbol in the SymbolData class, has the same values for today and yesterday. 

On the OnSecurityChange, there is the logic to use the SymbolData class to add indicators as well as rolling window for each symbol.

The problem is that when I create the variables to test for the technical conditions for entries, the variables 

yesterdayBar = symbolData.Bars[1]
todayBar = symbolData.Bars[0]

on line 262-263, has the same values(yesterday close is equal to today close and so on). So any trade could be triggered because this dont allow signals, as one of the signals are based in the comparisson between yesterday and today bars. 

I think that Im missing something regards the update of this bars, but couldn't found a solution yet. I really appreciate any help in this issue.

 

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.


 

Hey Nicolas,

I reorganized your algorithm slightly by moving the data consolidation into the SymbolData class. This way each symbol has its own consolidator and its own OnConsolidated event handler. This fixed the issue with the duplicate bar values and there is also trades occurring now. In general, it is good practice to move datasets/dictionaries keyed by symbol to SymbolData.

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 Rahul, thanks for helping me in this. Your solution seems to work. Also, I would want to ask you if you can point me with some document about the algorithm class. I see that in the symbolData class, you initiliaze the BB indicator using algorithm.BB(), which is really helpful.

algorithm is the root class? can you provide me with some links about the elements that can be accessed with the algorithm class?

Thanks again,

Nicolás 

0

Hey Nicolas,

There is no class named algorithm. The algorithm in algorithm.BB is the same instance of QCAlgorithm that is in the main class MeanReversion(QCAlgorithm). In the MeanReversion class, the QCAlgorithm is referred to as self, however in the SymbolData class, we have passed QCAlgorithm as a parameter into the constructor for SymbolData. We assigned the QCAlgorithm instance to the variable named algorithm.

If you want to take a look at the QCAlgorithm class, you can check out the github.

2

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.


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