Back

What is the difference between data[self.symbol].Price and self.Securities['EURUSD'].Close

Hello,

I am a Forex trader and a professional software engineer.

Although I have barebones statistical and financial knowledge I have found quantconnect to be a great resource to learn.

 

I am practicing by writing my own algorithm, there is lots wrong with it but I'll learn by debugging it. For now, I am trying to compare the current price of a currency to a previous close. Trying to find the syntax I found these two variables:

data[self.symbol].Price

self.Securities['EURUSD'].Close

But what does the latter refer to, the previous close price the last time onData was called?

(Also, the docs don't mention this but when is onData called, or when and why is data received?)

Thank you

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

There is no difference between the two commands. The data[symbol].Price is passed to you through the event handler and self.Securities[symbol].Close is automatically set. To compare the current price to the previous close, you will have to store the previous close in a variable or Rolling Window. OnData is called whenever a new bar data become available according to your desired data resolution.

Hope this helps!

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.


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