For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
GenericCSVData with different start date
-
Hi there,
I am adding several custom csv feeds to my strategy. The files contain data with different starting dates, and hence, the strategy only seems to start trading at the first date where data is available for all assets.
Is there an option to enforce trading before this date and only trade what is available?
Many thanks.
-
@auth87 Yes, the
pre_next
method inStrategy
will be called each time and you can simply callnext
from it. But you then need to check which of the data items inself.datas
have data ready. Something like:def pre_next(self): self.next() def next(self): available = [d for d in self.datas if len(d)] # do something with available list...
-
@auth87 Another option is to pre-process with pandas. Get the longest date index, and join all csv's on that and fillna = 0. Then when you run the backtest, check each data.close[0] == 0. If true, continue.