Hi QC Community, Web developer turned novice here trying to get average momentum percentage from a universe of symbols every x period…Thought maybe could append SymbolData to a dictionary- thinking someone might know a good approach?
class MarketBreadth(QCAlgorithm):
def __init__ (self, momp_period = 1, resolution = Resolution.Minute):
self.MOMPeriod = momp_period
def Initialize(self):
self.momentum_percent = { }
def OnData(self, data)
self.momentum_percent[data[symbol]] = symbol_data.momp.Current.Value
avg_momentum = sum(self.momentum_percent.values())/len(self.momentum_percent)
algorithm.Debug("Average momentum: " + str(avg_momentum))
class SymbolData():
def __init__(self,
security,
algorithm,
momp_period,
resolution):
self.symbol = symbol
self.momp = MomentumPercent(security.Symbol, momp_period)
Any help or direction would be most appreciated!
Louis Szeto
Hi Papa Bear
We have an existing example in QuantConnect.com - Embedded Backtest Results.
Best
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.
Papa Bear
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!