Apologies for not articulating the problem well enough in the first post. However, you have correctly inferred that I am facing issues with not being able to see intraday positions and returns from PyFolio analyzer.
My run strat function looks like this:
def runstrat1():
args = parse_args()
# Create a cerebro entity
cerebro = bt.Cerebro(stdstats=True)
# Add a strategy
cerebro.addstrategy(strategy1.TestStrategy)
# Get a pandas dataframe
datapath = ('./dataset/data2.csv')
dataframe = pd.read_csv(datapath,parse_dates=True,index_col=0)
# Pass it to the backtrader datafeed and add it to the cerebro
data = PandasDataExpanded(dataname=dataframe)
cerebro.adddata(data)
# Add PyFolio Analyzer
cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
# Run over everything
strats = cerebro.run()
returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()
for each in strat0.analyzers:
each.print()
print(positions['cash'])
# Plot the result
if not args.noplot:
cerebro.plot(style='bar')
return positions
My class for pandas data feed look like this:
class PandasDataExpanded(btfeeds.PandasData):
lines = ('barCount',)
params = (('barCount', -1),)