I added a continuous future with daily resolution, but I found that the behaivour of tradebar and open interest is quite different: when a new day begins like 8 Oct, the last day's daily bar (7 Oct) is available which is expected because we hate look-ahead bias. The problem is the open interest of 8 Oct is not of 7 Oct but 8 Oct. How could I know the open interest of 8 Oct before that day ends?
The future I added is “es”, and the raw data is like:
20131007 00:00,1676.75,1679.5,1664.75,1667.5,1582476
20131008 00:00,1667.5,1671.5,1646.5,1654.5,2357542
20131009 00:00,1654.5,1658.25,1640,1652,2441771
Its open interest data:
20131007 00:00,2674467
20131008 00:00,2692235
20131009 00:00,2723644
20131010 00:00,2703379
The backtest will print out the close price & open interest when there is daily bar available as the log below shows. From the log we clearly see that the open interest's date is one day ahead of the daily bar date.
/ES20131220@10/7/2013 8:00:00 PM (10/8/2013 12:00:00 AMUTC): price = 1667.5, oi = 2692235
391
/ES20131220@10/8/2013 8:00:00 PM (10/9/2013 12:00:00 AMUTC): price = 1654.5, oi = 2723644
392
/ES20131220@10/9/2013 8:00:00 PM (10/10/2013 12:00:00 AMUTC): price = 1652, oi = 2703379
393
/ES20131220@10/10/2013 8:00:00 PM (10/11/2013 12:00:00 AMUTC): price = 1682, oi = 2703379
I attach the backtest to reproduce this issue.
Laye
Anyone has a clue on this?
Louis Szeto
Hi Laye
We do not see the issue from the attached backtest or logs. Could you provide any source to point out any discrepancy?
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Laye
The raw daily data of “es” I pasted shows that the close price and open interest of 7 Oct is 1667.5 and 2674467:
| Time | Open | High | Low | Close | Vol | OpenInterest
| 20131007 00:00 | 1676.75 | 1679.5 | 1664.75 | 1667.5 | 1582476 | 2674467
I suppose this daily bar will not be available until 8 Oct, so I expect the daily close price and open interest at the beginning of 8 Oct will be the one of 7 Oct which should be 1667.5 and 2674467. But the log I got is:
/ES20131220@10/7/2013 8:00:00 PM (10/8/2013 12:00:00 AMUTC): price = 1667.5, oi = 2692235
The log above says "Now the backtest date is 8 Oct, and we know the close price of 7 Oct is 1667.5, open interest is 2692235”. So the close price is indeed the previous day's one which is 1667.5, but the open interest is not. I checked the open interest data file and found that 2692235 is the open interest of 8 Oct. This is definitely a look-ahead bias: how come I know the open interest of 8 Oct when that day is not yet finished?
Louis Szeto
Hi Laye
The DateTime of the first column is the Time property. For daily bar, the EndTime would be the next day's 00:00. However, OpenInterest is not a bar but a snapshot data. So 10/8/2013 00:00 is not only its Time but also its EndTime. The logs were showing the expected and correct data.
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Laye
It sounds reasonable. I see OpenInterest is tick.
Thank you for your clarification.
Laye
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!