2019-10-02: The community is currently in read-only mode
preventing labels for all data feeds showing when plotting
sfkiwi last edited by
I have a few hundred data feeds that Im running a portfolio strategy over. I would like to plot just the observer results and perhaps one of the data feeds as a reference but I haven't figured out how to turn off the data labels showing for the trades observer.
I am setting
plotinfo.plot = Falsefor all the data feeds except the first one which seems to work when I use just 6 of the data feeds but when I add all the data feeds I get the plot show below.
With all feeds
With just 6 feeds
#run cerebro = bt.Cerebro() cerebro.addstrategy(St) cerebro.broker.setcash(20000.0) cerebro.addobserver(bt.observers.TimeReturn, timeframe=bt.TimeFrame.NoTimeFrame) cerebro.addobserver(bt.observers.Benchmark, data=benchmark, timeframe=bt.TimeFrame.NoTimeFrame) cerebro.adddata(benchmark, name='SPY') for feed in feeds: cerebro.adddata(feed, name=feed) results = cerebro.run() cerebro.plot(iplot=False, style='candle')
#strategy for d in self.datas: d.plotinfo.plot = False self.data1.plotinfo.plot = True
or all the data feeds except the first one
self.data1.plotinfo.plot = True
That's not the first one, it is the second (arrays are
In any case, if it works for 6 data feeds it shall work for the rest. If a data feed has
False, its name will not get added to the list of labels to be displayed. The code doesn't know if you added 6 or 1006 data feeds. The label will simply not be added (because the entire code that plots a data feed and its indicators will be skipped)
In the plot above there are many labels for data feeds, which is an indication that the code was executed.