Back

Future leak question

After reading this answer in Quora. I realized that I always use close price in the OnData mehotd.

So, if I send an order based on the actual bar close; Am I using future data to make decisions?

Thanks in advance.
Update Backtest






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.



Just as an example:

This is the performance of an trend following algorithm using the close price (Sharpe: 3.5):
And this is the same algorithm using the open price (Sharpe: 1.2):
0

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.


Hi Juan,

I am pretty sure that any orders placed in the OnData(TradeBars data) function get executed at the bar's close price.

For your convenience I coded a little example to showcase this behaviour:
The algo prints OHLC prices of one bar, and places an order. In the OnOrderEvent([...]) function the actual fill price gets printed. You will see that the fill price is equal to the close price, so that there should be no future bias.

I have not yet played around with that, so feel free to experiment!
2


As far as I can tell from the structure of QC, even if you use the closing price to make trading decisions, there shouldnt be data snooping bias. OnData only gives you bars that are complete. QC seems to be built to completely avoid data snooping bias all together.

Although that is still an important point to understand, if you were to code your algo into a system that didn't take care of this bias for you.
2

Thank you very much @Tobias and @Riley!
0

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.


Based on the performance on open and close I guess real life performance is going to be in between or even lower.

What QC needs are Monte Carlo methods but I guess it takes some consideration to code.

I have some python code to do that based on the executed trades and reshuffling those 10000 times. From that you can say with high confidence the CAGR will be so and so.

Maybe I can port it to QC.

Also boot strap tests are interesting.
1

Close[0] will try to convert to MarketOnClose if I remember. It's impossible to get, so I assume difference is due overnight or one day miss (pen[0]). If you use Quandl, you should delay data by 1 day.
1

When I read the @Tobias and @Riley answers, I thougth, of course! isn't future leak, the first day's minute is 9:31 a.m.!

But is good to to be sure.

The algorithm wasn't tested with money yet, is kind of a draft of a maybe good algorithm.

I agree, @Christoffer, BTW Quantopian developed a very interesting backtest analyzer, have you seen it?

I haven't use Quandl data yet, but I'll take the advice; thanks @Tadas.
0

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.


We're definitely getting there! Optimization is fast moving to the top of the todo list! :) Its exciting to see so many major features getting crossed off at QC!

@Juan, we recently upgraded our statistics panel so you can actually see a lot of those advanced statistics on QC already :) e.g. check out the rolling sharpe mini chart.
1

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.


@Juan,

That backtest analyzer looks good. Might be interesting if one could port it to C#.
0

@Christoffer, the analyzer is great indeed, check the create_bayesian_tear_sheet method.

@Jared, I saw the new QC features and I can imagine the huge amount of work it means. But it shows the information as the developer wants, the user can't dive much more if they want to analyze the backtest.

I know that you have to secure provider's data, but is very hard to analyze a serious (not that long just 2-3 yrs) backtest at minute frame with just 100kb of log or with mini charts. Seems they found with the research environment a way to empower the user giving all the information and the plotting capabilities to analyze the backtest without risking the data.

Even more, in the research environment all the databases are available so you can use it to test hypothesis, develop algorithms and optimize. Something like that in QC would be great!
0

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.


Thanks for your feedback Juan, its pretty easy to do - a few charts of existing data we have isn't difficult. I don't think the backtest performance analysis is limited by debugging log limits, but I see your point about enhancing our analysis further.
0

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.


Update Backtest





0

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.


Loading...

This discussion is closed