Back

Comparing QuoteBars past and present

I'm not sure how to formulate this question but the goal is to compare one closing price to the prior closing price using Python

I'm using Forex data and can see the log generate the sequence of closing prices with the following OnData() code:

fxClose = data['EURUSD'].Close
self.Log(fxClose)

I can't figure out the procedure to compare one closing price to a prior one as in:

if CurrentClose > PriorClose

I know this is a rudimentary question but I can't seem to locate any examples that show how this can be done.

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

You can use RollingWindows for this purpose. Please see this documentation article for more help.

Good luck!

0

I have tried to observe the behavior of the sample code given that illustrates rolling windows in action but I'm getting an AtributeError.

----------------------------------------------------

During the algorithm initialization, the following exception has occurred: AttributeError : 'RollingWindowAlgorithm' object has no attribute 'Updated'at Initialize in main.py:line 38
AttributeError : 'RollingWindowAlgorithm' object has no attribute 'Updated'
--------------------------------------

Any thoughts on why this sample code is not working? Some package missing?

0

I figured it out.  I removed references to the indicator and focused on just the tradebar data and it worked.  While porting this code to my own algo, I got a similar error and disovered that self.window.Add() requires a very specific format else it returns an error that makes it seem as if the .Add method was not available.   It's working just fine now.

1

Glad to hear it! Thanks for sharing what you've learned, it helps other users in the same position. 

0

Richard,

The documentation is always a good place to start debugging, but we're glad the community could help you out. Thanks Douglas!

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.


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