Hi, I am stuck and cannot figure out why my algorithm is not working. If someone could help me that would be great.
Thanks,
Aditya Holla.
Its not letting me attach a backtest so the code is copied below:
class FocusedSkyBlueSalmon(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2010, 1, 1) # Set Start and End Date
self.SetEndDate(2021, 6, 15)
self.SetCash(100000) #Set Cash
self.SpySymbol = self.AddEquity("SPY", Resolution.Minute) #Request Data
self.TMFSymbol = self.AddEquity("TLT", Resolution.Minute)
Quandl.SetAuthCode("zkdoRxRXbAQdUxzXZKBy")
self.shiller = self.AddData(QuandlCustomColumns, "MULTPL/SHILLER_PE_RATIO_MONTH", Resolution.Daily )
def OnData(self, data):
if self.shiller < 10:
self.SetHoldings("SPY", .40,)
self.SetHoldings("TLT", .60)
elif self.shiller < 14 and self.shiller.Current.Value > 10:
self.SetHoldings("SPY", .60,)
self.SetHoldings("TLT", .40)
else:
self.SetHoldings("SPY", .8)
self.SetHoldings("TLT", .20)
class QuandlCustomColumns(PythonQuandl):
def __init__(self):
self.ValueColumnName = "Value"
Louis Szeto
Hi Aditya
You have imported this Quandl data as a Security object, using the column “value” as input. So you can use it as Security object: by .Close, you get the latest value. If you need to use it as frame, you can create a rolling window (+consolidator if needed) then update it like indicator, just replacing .Current.Value as .Close.
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.
Vladimir
Aditya Halla, Louis Szeto,
I would also add a schedule function to trade monthly data only once a month.
This saved $ 36,000 in trading costs, reduced drawdown, and improved annual return.
Aditya Holla
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!