Hi All-
I've been struggling to create even the simplest of beta indicator (B) whether manual or automatic. I started in a dynamic universe but moved to an isolated algo based on the example in the documentation. Even in this simplified environment I can't get an automatic or manual (using registration) B indicator to backtest.
Also, the documentation is confusing for a manual B indicator: the reference benchmark is set to “SPY” in self.b = Beta("SPY", 20) but RegisterIndicator also passes in SPY again (where is our target AAPL passed in)? In the code below I changed it to the target symbol to be measured against SPY. Either with the target or SPY, I can't get anything to backtest.
Any help is appreciated.
# region imports
from AlgorithmImports import *
# endregion
class CrawlingBlueArmadillo(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2023, 1, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
self.target = self.AddEquity("AAPL", Resolution.Daily).Symbol
self.SetWarmup(25, Resolution.Daily)
self.b = Beta("SPY", 20)
self.RegisterIndicator(self.target, self.b, Resolution.Daily)
def OnData(self, data):
if self.b.IsReady:
self.Plot("Beta", "b", self.b.Current.Value)
Derek Melchin
Hi Justin,
Thanks for reporting this issue with the docs. We create this GitHub Issue to resolve the problem. Subscribe to it to be notified when the docs are updated.
For the time being, refer to the attached backtest to see how to use a manual Beta indicator.
Best,
Derek Melchin
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.
Justin E
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!