I need the time data from the yrmn and others to move on in the algo.. towards the end of this snippet.
class BotSetUp(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetCash(10000)
FinvizSymbols = ("CLPS", "JOB", "MYMD", "SPY") #however we decide to get our universe
self.indicators_by_symbols = {}
for symbol in FinvizSymbols:
sym = self.AddEquity(symbol, Resolution.Daily).Symbol
self.Debug(symbol)
self.indicators_by_symbols[sym] = {}
self.indicators_by_symbols[sym]['year_min'] = self.MIN(sym, 365, Resolution.Daily)
self.indicators_by_symbols[sym]['year_max'] = self.MAX(sym, 365, Resolution.Daily)
self.indicators_by_symbols[sym]['month_max'] = self.MAX(sym, 30, Resolution.Daily)
self.SetWarmup(365, Resolution.Daily)
def OnData(self, data):
for symbol, value in self.indicators_by_symbols.items():
if not self.indicators_by_symbols[symbol]['year_min'].IsReady:
return
holdings = self.Portfolio[symbol].Quantity
profit = self.Portfolio[symbol].UnrealizedProfit
tpv = self.Portfolio.TotalPortfolioValue
price = self.Securities[symbol].Price
close = self.Securities[symbol].Close
yrmn = value['year_min'].Current.Value
yrmx = value['year_max'].Current.Value
mthmx = value['month_max'].Current.Value
#yrmn_day = self.Securities[symbol][yrmn].Time.day
self.Debug(yrmx)
if mthmx == yrmx:
top = mthmx
else: return
self.Debug(top)
whole_fib = top - yrmn
tft = 0
if self.Time.day - top.Time.day == tft:
pass
else:
tft = tft + 1
Varad Kabade
Hi Joshua Hughes,
To get the time data of the Min/Max indicator, use the following property of the indicator.
Â
self.PeriodsSinceMaximum
Refer to the attached backtest. Note, we have made the following changes
1.Removed SetWarmup outside the loop in Initialize method
2.Used SymbolData class to maintain indicators
3.Used NumPy array to maintain yrmx time.
Best,
Varad Kabade
Joshua Hughes
Thank you so much Varad!!
Joshua Hughes
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!