Keep getting error module 'backtrader' has no attribute 'Timeframe'
-
Hello
I keep getting the following error module 'backtrader' has no attribute 'Timeframe'
I am trying to plot using intraday data and not many really good samples out there. Plotting daily data is fine
Code is as followsimport os, sys, argparse
import backtrader as bt
import backtrader.analyzers as btanalyzers
import matplotlib
from datetime import datetime
import backtrader.feeds as btfeedsdata = bt.feeds.GenericCSVData(
dataname='C:/Users/brand/NQ21.csv',
datetime=0,
fromdate=datetime(2021, 1, 3),
timeframe=bt.TimeFrame.Minutes,
dtformat=('%Y-%m-%d %H:%M:%S'),
open=1,
high=2,
low=3,
close=4,
)
class Mystrat(bt.Strategy):def __init__(self): self.the_highest_high_4 = bt.ind.Highest(self.data.high, period=4) self.the_lowest_low_4 = bt.ind.Lowest(self.data.low, period=4)
cerebro = bt.Cerebro()
data = bt.feeds.YahooFinanceData(dataname = 'NQ20.csv')
cerebro.adddata(data)cerebro = bt.Cerebro()
cerebro.adddata(data, timeframe=bt.Timeframe.Minutes, compression=5)
cerebro.addstrategy(Mystrat)
cerebro.run()
cerebro.plot(style='bar') -
@bmccoy said in Keep getting error module 'backtrader' has no attribute 'Timeframe':
Timeframe
Try
TimeFrame