@davidavr thank you very much, now it works
Latest posts made by hangouts91
Pandas df with multiple stocks
I have a CSV dataset from CRSP, which contains daily prices of about 5000 stocks from 1999. When I try to backtest using the data I get the error "TypeError: can only concatenate tuple (not "str") to tuple". I am a newbie and I am dumb, would really appreciate any help
Below my code. There is no strategy because I am stack data importing. I suppose I get the error because in my data frame I have 5000 stocks, while PandasData is created to operate with only one instrument.
crspdata=pd.read_csv ('crsp2.csv') crspdata['datetime'] = pd.to_datetime(crspdata['datetime'], format='%Y-%m-%d') crspdata = crspdata[['datetime','ticker','open','close','high','low','volume','numtrd']] cerebro = bt.Cerebro() class PandasData(bt.feeds.PandasData): lines = ('numtrd') params = ( ('datetime', 'datetime'), ('open','open'), ('high','high'), ('low','low'), ('close','close'), ('volume','volume'), ('openinterest',None), ('numtrd','numtrd'), ('name','ticker')) data=PandasData(dataname=crspdata) cerebro.adddata(data) cerebro.broker.setcash(100000.0) cerebro.run()
Event based backtesting
Hello, i am new to backtrader. I want to test how company announcements affect intraday stock prices. Announcements may come during the regular hours, pre or after-markets.
I have this list of events (announcements). Can i use backtrader to test the effect of those events on stocks prices. I am thinking using 5 mins bars.
I can actually write my own backtesting code, but i think it would be a lot better if backtrader could handle it.
If there is an option, could have please give me directio8 where to look.