Keyboard Shortcuts
Likes
Search
strange execution price for a stop loss
Hello
Yesterday, my bot was running in a paper trading environnement. It interacts with IB API and TWS. The bot bot 3 contracts NQ at 09:31:45 (15:31:45 in my french local time) at 14916.25 , and placed a Stop order at 14909.? Then the price went down and the stop loss has benn executed in two partials orders : - the first at 09:31:57? with 2 contracts for an average price of 14908.50 => OK - the second also et 09:31:57, with 1 contract for a price of 14893.75 !!! => how strange, since the price has always benn above 14907.75 at this time. Il effectively touched this price at 09:32:44 ??!!? I've checked in TWS interface, and I have the same times / prices / orders... Up to you, is this a TWS bug in paper trading environnement ? Or am I wrong somewhere ?? Thanks a lot |
Results from simulated trading in the paper account will be different from trading in a live account, but the basic principles tend to be correct and quite accurate. I think what you have experienced is expected behavior for the regular STOP order. s you will see that, once the STOP trigger is reached, IBKR places a order for you. For market orders, they say:
I don't have access to Level II data for NQZ3 to know for sure, but TickByTick BidAsk data shows very small BidSizes (mostly 1 or 2) for the 10 seconds before 08:32 (US/Central, NQ trades in Chicago). So it is quite likely that some market orders could? briefly have filled well below the prices you would expect. Live trading may not have gone all the way down to 14893.75, but that price was reached less than a minute later, so the order book was probably pretty empty. You need to decide how important it is for you to close the position (partially and completely) and what you are willing to pay for it. You may decide to make the STOP order so that the STOP only triggers when real trading took place at or beyond the trigger price. Or you may use a so that you are not exposed to the unlimited risk of the market order. If you set the limit too tight to the trigger price, though, you run the risk that the stop only closes a portion of your position or nothing at all. ´³¨¹°ù²µ±ð²Ô On Fri, Oct 6, 2023 at 07:18 AM, FrenchFlorent wrote:Hello |
i'd just add that the trigger method also determines what will happen during simulated trading. that is, the order might get triggered when ask price reaches the stop price, but for simulated trading the order then gets executed at the bid price, if there is someone willing to buy sufficient quantity at the real market(s). as the simulated algorithm (imo) works the same for mostly all assets, there is a very low chance that it would from time to time behave in a different way. they take the orders, the market data flowing in, and based on that they simulate the executions.
|
forgot to add one more thing that is related to this case, and that is the way the price is verified. if the chart displays mid price, it does not really display the lowest bid price but just the average of the ask and bid price (= mid price). i guess for simulated trading charting trades might not be very relevant. so it would be good to check the ask price and the bid price to verify the simulated execution. also, if ask price is the trigger in this case, the price is not triggered by the mid price, the mid price gets lower before the ask price triggers the stop order. and then the bid price for the simulated execution is even lower.
|
Thank you for your answers.
I totally agree that the stop order is a MKT type order and offer no garanty on the price effectively executed. But I've checked order book at this time (8:31:57 ECT), via reqhistoricalTicks and?whatToShow=BID_ASK, and it seems to have great activity (not surprising, at the market opening). So I am quite sceptical that there were such a huge gap on the priceBid between?14908.50 and?14893.75. I'd like to go further in the analyze, what is?Level II data and how I can I get it ? Thank's a lot? |
I experienced this with the sim account as well, it¡¯s not accurate. Frustrated me for awhile, but many people I have talked with said while the sim account is good to make sure your algorithm submits orders properly as well as get live data, and other api functionality, price execution of the simulated account is not feasible to use for tracking results. Forced me to make my own simulated account hooked to a local database and adjusted my fills according to liquidity on the order book. I experienced the same issues and went this route to solve. I may have been doing something wrong but didn¡¯t want to take the chance before going live as price execution clearly did not match order liquidity for market and other orders at times in IB¡¯s sim. On Sun, Oct 8, 2023 at 5:57 AM FrenchFlorent <fcourtin@...> wrote: Thank you for your answers. |
The data that was attached to your post seems to be for 08:32:57 US/Central, one minute later than when the STOP order happened at 08:31:57 US/Central. Prices during the STOP order second were much jumpier. Just looking at changes of Bid and Ask price does not give you a good picture of what the order book looks like and whether there is "great activity". Level II can help since it is a snapshot of the sizes for all prices in the order book at and above Ask as well as at and below Bid. At the end of the post is a snapshot for NQZ3 just after trading started at 17:00 US/Central on Sunday. If you have subscribed to Level II data for CME, you can use the TWS "Level II" window (the top window below) and the "Book Trader" (bottom window) to look at 10 levels for the buy and sell side each and your client can request the data as well:
Paper trading is a simulation, and as such, "always wrong but mostly useful". So you cannot expect that executions exactly match those that would have taken place in a live account at the same time. But as @fordfrog indicated, executions in the paper account closely follow those in the real exchange and in thin order books (such as NQZ3 at start of trading today and on the morning of October 5) even in live trading prices can briefly take place $10 or more away from Bid and Ask. I can't think of anything more you can analyze for this historical case. Going forward, you could subscribe to Level II data, record the 20 levels of order book details IBKR provides, and use them for analysis for case where you feel simulated trade prices were "too far away" from Bid/Ask. But keep in mind that not all orders make it into the order book and that some (even large) trades are not reporable or reported. So there will always be a some uncertainty. ´³¨¹°ù²µ±ð²Ô On Sun, Oct 8, 2023 at 04:57 AM, FrenchFlorent wrote:
Thank you for your answers. |