Back

How to plot Portfolio.Cash on custom chart

I am trying to plot the value of Portfolio.Cash to my chart as a line series but can not make it work. I have something like this so far.

#initialize

plot = Chart('Trade Plot')
self.AddChart(plot)

// only plots a single scatter plot
self.Plot('Trade Plot', 'Cash', self.Portfolio.Cash)

// also doesn't work
self.cash = self.Identity(self.Portfolio.Cash, Resolution.Daily, Field.Low);
self.PlotIndicator('Trade Plot', 'Cash', self.cash)

I am trying to make it work in the initialization function because my equity has a resolution time of hourly and if I just plot individual points of my PortfolioCash on the OnData function then I get an error stating I've exceeded the maximum amount of points to plot per series

Update Backtest







0

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.


def Initialize(self):
self.Schedule.On(self.EveryDay('SPY'),
self.TimeRules.BeforeMarketClose(0), # Change to desired frequency of plotting
self.PlotStuff)
def PlotStuff(self):
self.Plot('Trade Plot', 'Cash', self.Portfolio.Cash)

 

2

Update Backtest





0

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.


Loading...

This discussion is closed