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
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?
@auth87 Yes, the
Strategywill be called each time and you can simply call
nextfrom it. But you then need to check which of the data items in
self.datashave 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...
run-out last edited by
@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. If true, continue.