Bar data time alignment

Posted By: stevegee58

Bar data time alignment - 09/01/12 22:05

I'm interested in basket trading and was wondering how you handle data gaps in backtest data. I read the help information for asset() which was very helpful. However I want to be sure I understood.

Function run() is called once per bar. Suppose I have data for EURUSD and USDCHF for example. The data is pretty good but there are holes in each file that are in different time periods between the 2 pairs. So there might be a gap from 20120301-20120303 in USDCHF but EURUSD has valid data in that time period.

If run() is called during this gap period what data do I get for EURUSD and USDCHF? I would assume I'd get a valid bar for EURUSD and some kind of error for USDCHF so I'd know it's not valid and handle it somehow.

I noticed in your examples you don't check for data errors or gaps.
Posted By: jcl

Re: Bar data time alignment - 09/02/12 06:53

The first loaded asset determines the bars. If it has a gap, the gap also occurs in all other assets. If the first asset has no gap, but a subsequent asset has a gap, the gap is filled with a copy of the previous bar.

When bars are loaded, the bar contents are checked for plausibility. If a bar has invalid data, like some too high or too low price, it is corrected.
Posted By: stevegee58

Re: Bar data time alignment - 09/02/12 10:10

OK that makes sense.

I'm specifically working on cointegrated pairs/basket trading. So you could see how having time-aligned data is important in that case. This would also be important for correlation analysis as well.
© 2024 lite-C Forums