When backtesting one of my algo I got executions on days when market was closed.
SPY on 2015-02-03
HYG on 2015-02-16
How accurate is Quantopian data and backtesting engine?
When backtesting one of my algo I got executions on days when market was closed.
SPY on 2015-02-03
HYG on 2015-02-16
How accurate is Quantopian data and backtesting engine?
Was this a backtest in minute mode or daily mode? I suspect that it's neither a data or back-end bug, but rather a display confusion.
Fills in daily mode happen at Midnight UTC. The displayed timestamps is the time derived from your browser's time. Take a look at the explanation here: https://www.quantopian.com/posts/why-is-my-algo-trading-on-sundays
I realize this can lead to confusion and we can work to make the UI more intuitive. In general, I'd recommend to backtest your algo in minute mode because the simulation is closer to live trading.
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Hi Alisa
The following is a copy of part of Transaction details after running Full backtest which was generated by Quantopian backtest engine using daily data (It has nothing to do with my browser time or display confusion as you mistakenly stated)
2015-02-01 - Sells $320,925.60 (1 transactions)
SPY
SELL
-1590
$201.84
($320,925.60)
2015-02-03 - Buys $362,685.70 (1 transactions)
SPY
BUY
1777
$204.10
$362,685.70
2015-02-16 - Buys $358,335.63 (1 transactions)
HYG
BUY
3933
$91.11
$358,335.63
As You see two orders were executed on not market days :
2015-02-01-Sunday
2015-02-16-Presidents Day
Is this a bug of Backtest Engine or Data it used or Quantopian Platform?
If the market was closed on that days where you get prices from?
Hi Vladmir,
I was able to duplicate this problem. Looks like the backtester simulates trades on President's Day in 2014 and 2015.
It only occurs for daily mode, not minutely mode.
Thanks for the heads up, we will fix the issue.
Josh
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Hi Vladimir,
The issue you're seeing is because the backtester often executes trades in UTC if you're trading in DAILY MODE. I think this is why you're seeing orders execute on 2015-02-01 when, if you tried the same code in minutely mode, it'd exeucte it on 2015-02-02
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Mea culpa. I think Seong is correct here. I misunderstood what was happening with respect to the timezones in daily mode.
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Josh, I am asking not "why" the backtester often executes wrong trades, but "when" it is going to be solved?
Vladimir, Josh and Seong are saying that there is nothing to solve. It isn't a bug. The timestamps you are seeing are in UTC. If you convert them to Eastern time you will find they fall on the correct days.
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
As Seong has already said, when you run a backtest in daily mode, fills come in at midnight UTC on the day they are filled. The date displayed in the transaction details is for the previous day because we convert the date to US/Eastern, which is four or five hours earlier than UTC, so it moves to the previous day. No, this isn't a good user experience; I've just filed an issue in our bug-tracking system asking for us to stop doing the time-zone conversion on these dates so they show up in the UI as the correct date.
In the meantime, you should simply understand that when you run a daily mode backtest, the date shown in the transaction details for an order fill is one day earlier than the order was filled.
In terms of logging order fill times within your algorithm, we do not currently make the times when orders are filled accessible through the API. There is an enhancement request in our queue to make this information easy accessible, and I'm sure we'll get to it eventually, but I can't say exactly when.
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.
Jonathan Kamens ,
Yours quotations:
... when you run a daily mode backtest, the date shown in the
transaction details for an order fill is one day earlier than the
order was filled....there is nothing to solve. It isn't a bug.
Then what it is?
Vladimir, I misspoke when I said it wasn't a bug. I thought I made that clear in my most recent comment above, when I said that I have filed an issue about it in our bug-tracking system. I'm sorry for the confusion.
I think at this point we are beating a dead horse.
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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.