Back

Extended Hour Tests

Hello,

I am a fairly new QuantConnect user and have been playing around with backtesting some extended hours data. I am experiencing some weird behavior and I was wondering what I am doing wrong. I have attached my project. The strange thing is that during the backtest, the algorithm buys three different times on the evening of 2015/07/21 for a total of 30 shares. The next morning the algorithm calls Liquidate but apparently only 20 shares are sold. Near the end of the backtest (on 2015/08/04), the last 10 shares are sold. Could someone explain why this is happening?

Another problem. If I change the symbol to "HAL" instead of "AAPL", and then run the backtest, it claims no trade bars (0 data points) come through to the algorithm. However, if I keep the symbol as "HAL" and use the start date of "SetStartDate(2015, 7, 14);" then data does come through to the algorithm. However, as far as I can tell there is no activity in the extended hours data for "HAL" (i.e., the prices remains constant) which I don't think is correct (comparing to other data providers).

Any suggestions?

Thanks for reading,
Carl
Update Backtest








Hey @Carl, I took a peak and it looks like the third limit order doesn't fill until 8/3.

I've atached the backtest that produced the folowing logs:

2015-07-14 20:00:00 Launching analysis for 0cfe8c3a3d455a66916da4f9c91bec7a with LEAN Engine v2.1.2.10
2015-07-21 16:31:00 OrderID: 1 Symbol: AAPL Status: Submitted
2015-07-21 16:32:00 OrderID: 1 Symbol: AAPL Status: Filled Quantity: 10 FillPrice: 121.520000000
2015-07-21 16:32:00 OrderID: 2 Symbol: AAPL Status: Submitted
2015-07-21 16:33:00 OrderID: 2 Symbol: AAPL Status: Filled Quantity: 10 FillPrice: 120.30000000
2015-07-21 16:33:00 OrderID: 3 Symbol: AAPL Status: Submitted
2015-07-22 09:31:00 OrderID: 4 Symbol: AAPL Status: Submitted
2015-07-22 09:31:00 OrderID: 4 Symbol: AAPL Status: Filled Quantity: -20 FillPrice: 122.650000000
2015-08-03 12:48:00 OrderID: 3 Symbol: AAPL Status: Filled Quantity: 10 FillPrice: 119.20000000
2015-08-04 09:31:00 OrderID: 5 Symbol: AAPL Status: Submitted
2015-08-04 09:31:00 OrderID: 5 Symbol: AAPL Status: Filled Quantity: -10 FillPrice: 117.330000000
2015-08-06 20:00:00 Algorithm Id:(0cfe8c3a3d455a66916da4f9c91bec7a) completed in 1.25 seconds at 13k data points per second. Processing total of 16,319 data points.
2015-08-06 20:00:00 Your log was successfully created and can be downloaded from: http://data.quantconnect.com/backtests/10444/117742/0cfe8c3a3d455a66916da4f9c91bec7a-log.txt
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 responding to my post.

On my Trades tab, the Trades Summary looks like:

2015-08-04 09:31:00 AAPL $117.33 Market -10 Short Filled
2015-07-22 09:31:00 AAPL $122.65 Market -20 Short Filled
2015-07-21 16:33:00 AAPL $119.20 Limit 10 Long Filled
2015-07-21 16:32:00 AAPL $120.30 Limit 10 Long Filled
2015-07-21 16:31:00 AAPL $121.52 Limit 10 Long Filled

So for me it is showing 3 trades on 2015-07-21. I'm confused now.

Also, is it possible the extended hours data is incomplete or does not exist for certain stocks? Because HAL's extended data (see my first post) doesn't seem to match with other data sources.

Thanks,
Carl
0

So I ran your clone and it does show that one of the trades occurred on 2015-08-03. However, in the Trades Summary tab, it shows as being executed on 2015-07-21. So which one is correct?

Thanks,
Carl
0

And another weird thing. In your log, there is:

2015-08-03 12:48:00 OrderID: 3 Symbol: AAPL Status: Filled Quantity: 10 FillPrice: 119.20000000

But it should only buy AAPL afterhours, i.e., after 16:00:00 on any given day. The fill is suggesting that it occurred in the middle of the day at 12:48:00.

Thanks,
Carl
0

I can't speak for other providers Carl -- but we have two "modes" of data. First one (minute/second/hour/daily) uses ticks filtered to show whether they are tradable. Some ticks just aren't tradable to retail users (e.g. banks phoning in completed hand shake trades 30 minutes after they happened). Tick data includes all the raw trades, even if they are unrealistic to trade.

The fill occurring at 12.48pm just means your limit order was placed and not filled until the next day when the price moved into range.

2015-07-21 16:31:00Z Placed Limit for 121.520
2015-07-21 16:32:00Z Placed Limit for 120.30
2015-07-21 16:33:00Z Placed Limit for 119.200
Liquidating at 2015-07-22 09:31:00Z for 122.650
Liquidating at 2015-08-04 09:31:00Z for 117.330

The first two limit orders filled, and liquidated the next morning at 931am. A few days later the next limit order filled (3rd August for a lower price) then on the 4th morning it also liquidated.
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.


@Jared, that's exactly right. @Carl, since you're using limit orders they're not guaranteed to fill, especially since you've set the limit to the low of the bar. You could use the returned OrderTicket object to cancel the order on market open the next day.

Another thing to note is that the time displayed in the trades tab is the time the order was submitted, not filled.
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.


(Edit: Looks like MichaelH posted similar things right before I did - so be prepared for redundancy...)

Thank you for everyone who commented on this thread! I just wanted to summarize what I was doing wrong in case others look at it in the future:

1. I was assuming that limit orders get cancelled at the end of the day but now I see that they are GTC.

2. On the Trades tab under Trades Summary, the third order was listed as:

2015-07-21 16:33:00 AAPL $119.20 Limit 10 Long Filled

However, the timestamp was for when the order was submitted, not when it was filled. As noted by the comments above, the trade was filled on 2015-08-03. I was getting confused by the date discrepancy but now I understand that the Trades Summary is showing the submit timestamp, not the fill timestamp.

I still think there is something weird with extended hours data in general, but I am going to investigate it some more. If I find some concrete evidence, I will start a new thread about it. Thanks for all the help!

Carl
0

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