I'm still quite new to coding algos and am having some issues with the indicator extensions. The attached backtest is an attempt at a simple pairs strategy using the ratio of SPY to XLF. However, I can't get it to actually process any data. Can someone help straighten me out on this? Thanks in advance -
Rahul Chowdhury
Hi Taylor,
When we define the identity indicators, we need to specify what data they are subscribed to.
self.spy_close = self.Identity('SPY', Resolution.Daily, Field.Close) self.xlf_close = self.Identity('XLF', Resolution.Daily, Field.Close)
This will ensure that the identity indicators are receiving the proper data. Then we create the ratio.
self.ratio = IndicatorExtensions.Over(self.spy_close, self.xlf_close)
Taylor Robertson
Thanks Rahul, that was helpful. I'd also like to try this by using a FRAMA moving average in place of the EMA. I think the way to do that is by using the IndicatorExtensions.Of extension, but I can't figure out the specifics for initating the FRAMA in that scenario.
Rahul Chowdhury
Hey Taylor,
FRAMA is incompatible with the data type that is out put by the ratio indicator. The FRAMA indicator is a bar indicator which means it takes bar data to updated, while the ratio is a single value. This means that using IndicatorExtensions.Of(frama, ratio) will return an error.
The other option is to create a FRAMA indicator and manually update it with data
self.ratio_frama = FractalAdaptiveMovingAverage(period, longPeriod)
Then using the Updated event handler for the ratio indicator, we can efficiently update the FRAMA indicator.
self.ratio = IndicatorExtensions.Over(self.spy_close, self.xlf_close) self.ratio.Updated = self.OnRatio
We still run into the same issue of needing a bar to update the FRAMA indicator. To work around this, we can create a custom bar with the OHLC values we desire.
self.OnRatio(self, sender, updated): bar = TradeBar(time, symbol, open, high, low, close, volume) self.ratio_frama.Update(bar)
Best
Rahul
Ruming Jiang
hi Rahul,
The example on Documentation - Home - QuantConnect.com
seems to contradict your example of Identity above. May I ask which one is or maybe both are correct? Thanks
Varad Kabade
Hi Ruming Jiang,
Both methods are correct.
The above is the method of QCAlgorithm class, the indicator is created and hooked for an automatic update at Minute Resolution, and the update field is theclose price of the asset (default value). On the other hand, the following statement creates an Identity indicator object using the class construction that needs to be manually updated:
Best,
Varad Kabade
Ruming Jiang
Hi Varad,
Thank you for your answer. I'm still looking for the right way to find references to avoid basic questions. In this case, the default value of close price was mentioned on Documentation - Home - QuantConnect.com. However, I didn't find the Minute Resolution as default value on that page, nor can I find it at the API document. Where should I look further on this? Thanks
Varad Kabade
Hi Ruming,
When I was referring to minute resolution, it was about referring to the default value of data subscription for a symbol(AddEquity) which would have been the resolution of the indicator unless specified. We recommend looking at the example code above this section of the docs on indicators for further information. In the examples, there are demonstrations of using basic indicators at the same resolution as source security and using indicators at a different (higher) resolution to the source security.
We are currently in the process of updating to a new version of the documentation
Best,
Varad Kabade
Ruming Jiang
Hi Varad,
Now I finally get where the default minute resolution comes from. Thanks for your patience. 😊
Is daily considered a higher or lower resolution than hourly? From the screenshot below it sounds like higher while in reality less points in a given time period/distances means lower resolution. I guess that's where another confusion comes from.
Louis Szeto
Hi Ruming
I think Varad means time frame. For resolution, think of an image’s resolution. The higher the resolution, the finer the details you receive.
Cheers
Louis
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.
Ruming Jiang
Hi Louis,
That's what confused me. Daily is lower resolution than hour. In the screenshot example above, the RSI indicator is daily, while the resolution of SPY is hour, thus indicator has lower resolution than the security. It contradicts to what said on the document:
The indicator resolution can be different from the resolution of your securities data. However, the resolution of the indicator should be equal to or higher than the resolution of your security.
Louis Szeto
Emm no need to be picky on words, just embrace the meaning😂😂 If subscribe to minute, you can make minute data consolidate into daily, but not vice versa
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.
Taylor Robertson
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!