Fix compression only scenarios when resampling and resampling after
changes in 184.108.40.206
Final correction for rollover fix introduced in 220.127.116.11
Cover use case for mininum period calculation when all
operations/indicators don't use the data feeds directly but lines of it
hi @Ta-Tum, the parameters of PandasData are programmed as below:
May be you fit ur dataframe as follow:
df = pd.DataFrame(index = dataframe .index)
df['Open'] = dataframe ['Open'].values
df['High'] = dataframe ['High'].values
df['Low'] = dataframe ['Low'].values
df['Close'] = dataframe ['Close'].values
df['Volume'] = dataframe ['Volume'].values
df['openinterest'] = dataframe ['Signal'].values
Then at class MLSignal:
def log(self, txt, dt=None):
# Keep a reference to the "close" line in the data dataseries
self.dataclose = self.datas.close
self.datasignal = self.datas.openinterest
self.log(' Close, %.2f' % self.dataclose)
self.log(' Signal, %.2f' % self.datasignal
if self.action == 1.0:
self.log('BUY CREATE, %.2f' % self.dataclose)
self.order = self.buy()
if self.action == 2.0:
self.log('SELL CREATE, %.2f' % self.dataclose)
self.order = self.sell()
I think this should pass dataframe data signal into the strategy part.
Hope this helps. I've been looking for this solution for quite long too. ;) Thanks
One of goals of backtrader was to not rely on libraries which are not part of the standard Python distribution, no matter how many million users it may have.
Adding a as_dataframe method would break that goal. Furthermore, understanding your point, you have to consider that the internal representation of the lines is not a table-like structure (like it is the case for a dataframe).
You can slice, so to say, with the get method of a line and pass the resulting array to the dataframe constructor.
See: Docs - Platform Concepts - Section: Slicing
You shouldn't be addressing 100 in any case. That's the future and it only works because you are working with preloaded data (which speeds up things). The len of the data does only tell you how many actual points have been processed by the system for the backtesting so far.
It's not about py-foo abilities, it has to do with documentation:
Docs - Platform Concepts - Section: Indexing: 0 and -1*
Docs - Cerebro and see the available execution options
A data feed in backtrader is not a Dataframe.