For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
how to add data more quickly?
-
I wanna test one strategy with multiple stock data and multiple time frame. So, I add multiple stock data as below.
'''
dataframe = pd.read_pickle(datapath+'daily_total.pickle') for i in items['code']: #3099 dataframe = dataframe[dataframe['code'] == i] data_1 = bt.feeds.PandasData(dataname=dataframe, datetime='new_date', volume='vol') # Add the Data Feed to Cerebro cerebro.adddata(data_1) tframes = dict( daily=bt.TimeFrame.Days, weekly=bt.TimeFrame.Weeks, monthly=bt.TimeFrame.Months) cerebro.resampledata(data_1, timeframe=tframes['weekly'], compression=args.compression,) cerebro.resampledata(data_1, timeframe=tframes['monthly'], compression=args.compression )
'''
and my strategy code is as below
'''def next(self): if not self.position: # not in the market for i in range(len(self.datas)//3): if cond_A and cond_B and cond_C and cond_D: close = self.datas[i].close[0] size = 1 self.buy(size=size) self.log('BUY CREATE, %.2f' % self.datas[i].close[0])
'''
-
Is it right way to test?
-
If it's right, how can i reduce execution time? I tried to add data in parallel, but it's fail.. (cerebro couldn't be rightly executed in parallel)
I think, i can reduce time in (1) add data, (2) strategy(backtest).
thank you for your watching. have a nice day!
-