resample for extra information in lines
i add the extra information like P/E in the line, if i use the resample, the P/E line will be gone.
I checked the source code and find that in _Bar class only the OHLC volume openinterest will be resampled,
after resampled, the P/E line value is NAN.
can you just keep the P/E original value ? thanks
vladisld last edited by
As you've correctly mentioned, resampling will ignore any extra information added to the feed ( it was already discussed in this post )
However, it seems that the resampling process could be customized.
As was described here the resampling is implemented in Backtrader as a data filter that will be attached to the given data upon a call to the
celebro.resampledata. Looking at the implementation of this method:
def resampledata(self, dataname, name=None, **kwargs): if any(dataname is x for x in self.datas): dataname = dataname.clone() dataname.resample(**kwargs) self.adddata(dataname, name=name) self._doreplay = True
we may see that
resamplemethod of the data is eventually called. This method is implemented in
AbstractDataBaseclass which is ancestor class for all data feeds
def resample(self, **kwargs): self.addfilter(Resampler, **kwargs)
Reimplementing this method in your custom data feed will allow you to use a custom
Resamplerfilter that may use a custom
_Barclass that is free to implement whatever aggregation behavior for the extra fields you choose.
I never used it this way myself, but at least it seems theoretically feasible.
@vladisld good idea. i will try. thanks a lot.
run-out last edited by