The problem doesn't seem to be printing the data. You are making an error initializing an object. You need to share the other part of the code.
I wanted to help you by developing a test application. The test application was based on the Plotting application. I used this link to fix the "Fix ImportError from matplotlib.dates" error. I used this link to use the test data (2005-2006-day-001.txt
) in the application. Below is a demo sample:
from __future__ import (absolute_import, division, print_function, unicode_literals)
import backtrader as bt
class St(bt.Strategy):
def __init__(self):
self.sma = bt.indicators.SimpleMovingAverage(self.data)
data = bt.feeds.BacktraderCSVData(dataname='dataset.txt')
cerebro = bt.Cerebro()
cerebro.adddata(data)
cerebro.addstrategy(St)
cerebro.run()
cerebro.plot()
Current matplot
version causes "Fix ImportError from matplotlib.dates". The way to avoid this error is to use older matplot
version by running the following codes:
pip uninstall matplotlib
pip install matplotlib==3.1.1
Below is the application test image:
