Hello Everyone.
I'm simply trying to plot the percentage change of an asset over a given period. I'm doing this so I can workout the percentage change over a given period of time of different assets within the same plot.
I tried using the SetDataNormalization as TotalReturn but unfortunately seems like total return does something irrelevent
My workaround was to use the close price of the frst day, but that would be quite tedious if I do this for multiple assetts.
Thanks!
Yuxin Guan
Hello Hamad,
There are a few indicators that can be used to track the percentage change of an asset during a certain period of time. For example, WilliamsPercentR (WILR). I’ve also attached a backtest to shown how to plot the indicator WILR for different assets. To see the plot, check the corresponding option as shown below. Please refer to this documentation for more information about indicators and indicator-plotting.
Best,
Yuxin Guan
Adam W
def Initialize(self): self.symbols = ['SPY', 'AAPL', ] for symbol in self.symbols: self.AddEquity(symbol, Resolution.Minute) self.lastClose = {} self.Schedule.On(self.DateRules.EveryDay('SPY'), # Change this to frequency of returns you want to plot self.TimeRules.BeforeMarketClose(0), self.PlotReturns) def PlotReturns(self): for symbol in self.symbols: close = self.Securities[symbol].Close # Track last closing prices if symbol not in self.lastClose: self.lastClose[symbol] = close continue # Plot returns returns = (close / self.lastClose[symbol])-1 self.Plot('Returns', f'{symbol}', returns) # Update last close self.lastClose[symbol] = close
Yuxin Guan
Sorry the backtest is attached here.
Hamad Al Ali
Many thanks for the answers!!
I never got notifications for the this thread not sure why.
Once again thanks for the contribution :)
Derek Melchin
Hi Hamad,
Since you started the thread, you should be automatically subscribed to new posts. I recommend checking your spam folder.
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.
Hamad Al Ali
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!