¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Market depth data has been RESET. Error Code: 317, C++ Program


 

I do not get a clear picture of what your client programs do exactly, Brendan, but I have the feeling that you need to go back to the drawing board. Gordon gave you some good pointers already, and there was a recent post titled "updateMktDepthL2 missing data points" you might want to take a look at (the second half that talks about L2 Market Book updates).

What concerns me is that, if I understand your comment correctly, your clients repeatedly call . They should not do that. Calling establishes a subscription that keeps sending you? callbacks until your client calls or disconnects from TWS/IBGW.

While the subscription is active, your client keeps two arrays (lists, maps, ...) of price-value pairs, one each for the buy side and sell side of the market book. Position (index) 0 of the buy side is the current "Bid" price/size while position 0 of the sell side is the "Ask". You would keep and update those two arrays as long as the client holds the subscription.

When the market book changes, IBKR breaks that change into a series of small incremental update indications for each of the positions that were impacted. Those indications specify the side and position that is impacted and the operation you need to perform on that position:
  • Update( side, position, price, size)
  • Delete( side, position )
  • Insert( side, position, price, size)

Occasionally, IBKR decides that it makes more sense (for whatever reason) to just discard the entire market book and to start from scratch. That is when you receive the "RESET Market Book" instruction. And while [IMHO] that would have better been implemented as a fourth operation type for the updateMktDepth callback, designers opted for an . Upon receipt of that message, your client will simply discard the two arrays and rebuild the market book from the updateMktDepth callbacks that follow right away.

While you are looking at this, you might want to keep a couple additional L2 related informational messages in mind as well:
  • Code 316 - Market depth data has been HALTED. Please re-subscribe.
  • Code 2152 - List of exchanges for Level 2 subscription

updateMktDepth sends you streams of update instructions for individual positions, but it does not tell you when the "Update Market Book" transaction is complete and when your copy of the market book is consistent again ("transaction boundaries"). For instruments with very little activity or during the middle of the night, a market book update transaction might have needed only a single updateMktDepth callback. But for heavily traded instruments or when Bid/Ask change, the transaction may take 20 or so updateMktDepth callbacks. The second half of the "updateMktDepthL2 missing data points" post discusses approaches of how you can efficiently detect when your the market book copy is consistent again.

Hope this helps,
´³¨¹°ù²µ±ð²Ô



On Sat, Dec 2, 2023 at 07:21 AM, Brendan Lydon wrote:
What do you mean by "I purge my bank, and de-facto expect to only receive types 2, or 1 only after I received a first set of new insert (0)." Mainly, "purge my bank", because I think me "flushing" the contents on my order book isn't doing what I think it is doing. Because I am actually only flushing the contents in my stored local order book. I am processing messages every time I call reqMktDepth() though, so I am not sure how my bank could be full, if those are the same thing...
On Thu, Nov 30, 2023 at 07:07 PM, Brendan Lydon wrote:
Here is my call -> reqMktDepth(reqId, m_contract, 5, false, TagValueListSPtr());
I am incrementing reqId every time I request, and the contract is for NQ e-mini expiring for december, NQZ3. My algo still gets data after this happens, & I do flush the book at most every second.

Join [email protected] to automatically receive all group messages.