Paper Trading Has Filled Me At Previous Bar's Price?
Author: sedelstein
Creation Date: 5/20/2016 8:35 PM
profile picture

sedelstein

#1
I am paper trading a strategy based on 1 minute bars. The strategy checks the time stamp to see if the time is a specific time (in this case 09:31) and generate some buy and sell orders.

This post is related to a previous post https://www.wealth-lab.com/Forum/Posts/In-Strategy-Monitor-not-all-trades-are-executed-due-to-insufficient-capital-38315

The execution of the paper trades seemed odd in their timing

From the previous post

What is also a little strange and I am trying to understand is that I generated an order for AMAT to short and it appears to have filled at a price that never traded today. (See attachments 4,5,6, and 7)

It appears to have filled me at the high of the previous day.

The Strategy Monitor went off at 9:31 (every minute as it's supposed to). The code checks that the time stamp on the latest bar is (in this case) 9:31 and generates an alert to trade at bar+1 The local trade history has a trade at 9:31 and a price of 19.91 the high of the 4pm bar from yesterday.

Thanks for your help
profile picture

Eugene

#2
Not just AMAT. You can see that the Price for all stocks is from the close of the last trading session (4:00pm yesterday) so trade @HOD is pure coincidence. I guess this is due to not having activated Streaming Updates in the tool.
profile picture

sedelstein

#3
Fwiw, I was using the Google provider. I had found earlier that the prices update w/ Google provider

I think there is something else going on though

The code below is what generates the orders
CODE:
Please log in to see this code.


I embed the Close of the bar, my sorting criteria, and the volume at the bar for my own testing purposes.

For CME in capture4.png, under the signal, you can see 95.58 which is where the google provider had the close of the 1-minute bar at 9:31
Capture2 also reports the Fill Price as 95.78 the close of the previous 4pm bar. So I'm not sure why the signal had the correct price at 9:31 but the fill was at the previous bar. The signal had an up-to-date price but the fill did not.

profile picture

Eugene

#4
Glad you mentioned it. The Google provider is not compatible with Paper Trading. AFAIR, of MS123 data providers only Morningstar, Nasdaq and Yahoo! support this feature. Unfortunately they are strictly EOD data providers. I'm not sure if this has any connection to what you're experiencing.
profile picture

sedelstein

#5
Ok, Well you recall from the other post that the fidelity 1minute data could not be loaded from disk using 1minute data and still have enough time to "run" before the minute was up. That was the reason to go to the Google provider in the first place.

It doesn't sound like there is a solution (for simulated paper trading) at this time scale.
profile picture

Eugene

#6
Sure I recall it. I will implement Paper Trading support in the Google provider (end of May or early June) irrelatively to whether it's going to fix the previous bar fill problem or not. I'm pretty sure it's not the case.

So we're back to the drawing board with the previous bar's price fill problem.
profile picture

Eugene

#7
If you say that the strategy is set to check the price at 9:31, shouldn't the order have been filled at 9:32 i.e. bar+1?

Despite the timestamp on capture7.png, ALL of your 5/19 trades have also been executed at the 2:54pm open price. Check TSCO prices at 2:53pm and 2:54pm - being a not that liquid stock it simply wasn't trading at 92.11 on 2:53pm.

Another 1 minute difference between the time stamp and the real execution that we need to explain.
profile picture

sedelstein

#8
QUOTE:
If you say that the strategy is set to check the price at 9:31, shouldn't the order have filled at 9:32 i.e. bar+1?


I agree. I was sitting there watching with a seconds timer on my iphone when the strategy activated promptly at 9:31 and the alarm sound and the alerts/trades happened about 30-40 seconds later.
profile picture

Eugene

#9
Did this happen with the Fidelity data? Let's either discard Google as a factor or make it the culprit. Could you run the test on Monday using F. data? Reduce the number of stocks in the DataSet appropriately so that your strategy wouldn't be affected by the delay.
profile picture

sedelstein

#10
Will be away Monday but will try Tuesday with a smaller dataset
profile picture

Eugene

#11
Okay, and I plan to test/repro using Google provider 2016.06 this AM.
profile picture

Eugene

#12
Unfortunately, I missed the open today so I may have a chance to retry it tomorrow.

Nevertheless, what I've discovered under debugger is that Google's intraday data is apparently marked start-of-bar whereas WL expects end-of-interval timestamps. (I'm under impression that it was mentioned before, perhaps by you?)
profile picture

Eugene

#13
Using Google v2016.06 (with GetQuote() support for PaperTrading and data timestamped end-of-bar), I was unable to reproduce the fill at previous day's close. The following script was being used:

CODE:
Please log in to see this code.



Let's get back to it early June when we release the updated provider.
profile picture

sedelstein

#14
Fidelity on 1 minute bars (tested at 11:08 today) on a dataset consisting of 6 symbols ran in a timely fashion and prices seem reasonable/timely.

Unfortunately, it doesn't solve the problem of Fidelity data on 1-minute dataset that has say, 100 symbols or so.


I didn't explicitly mention that Google's data was start of bar, only that the their 1-minute data happened to start at 9:30 vs 9:31 for the Fidelity data
profile picture

Eugene

#15
QUOTE:
I didn't explicitly mention that Google's data was start of bar, only that the their 1-minute data happened to start at 9:30 vs 9:31 for the Fidelity data

If you peek into Google's raw intraday data at any second between 9:30 and 9:31 you'd see that first bar timestamped 9:30:xx. That's what "start-of-bar" convention is, and that's not what WLP expects. Starting from v2016.06, this bar will be timestamped 9:31. As a consequence the 4:00pm bar will be marked as 4:01pm though you should be able to hide it applying the Market Manager (which the Google provider is compatible with). Still, I would prefer intraday data by Fidelity or IQFeed (paid).

QUOTE:
Unfortunately, it doesn't solve the problem of Fidelity data on 1-minute dataset that has say, 100 symbols or so.

Probably because you're overlooking Cone's latest solution - post #69 in mother thread.
profile picture

Eugene

#16
I've compared the Google intraday data to such by IQFeed and have to take back my words from 05/24/2016. I shouldn't be mangling with Google's timestamp, thus erroneously marking the last bar of day 4:01pm or making 5-minute bars end on funny intervals like 15:56. The data is comparable to IQFeed and has identical timestamps. Thus, only GetQuote() aka PaperTrading support will make it into v2016.06.
profile picture

sedelstein

#17
Thanks Eugene

I'll look forward to it.
profile picture

Eugene

#18
Steve, it's already available (switch to Other Extensions in the Extension Manager to see the update). I don't expect that it'd change things as the build only adds streaming updates via Google to the Accounts window. Make sure to experiment with Cone's latest solution, though.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).