stoqey / ib

Interactive Brokers TWS/IB Gateway API client library for Node.js (TS)
https://stoqey.github.io/ib-doc/
MIT License
212 stars 48 forks source link

Underrun error on COMPLETED_ORDER: End of message reached. Please report to https://github.com/stoqey/ib - code: 505 - reqId: -1 #223

Open icocoding opened 2 months ago

icocoding commented 2 months ago

https://github.com/stoqey/ib/blob/d521e2a448e98f45666e9c3dccf5eb6dcac705fe/src/core/io/decoder.ts#L451 In IB Gateway 10.19, an error occurred in orderDecoder.readShareholder() because the string has ended.

In the Decoder.readStr() method, if the string is no longer available, it should not throw an exception; instead, it should return null or an empty string. Additionally, in the Decoder.readBool() method, it should return a default value if the boolean is not available.

LimePixel commented 3 weeks ago

``I have also received this error on IB Gateway 10.19.

EDIT: It has started happening since the 29/10/2024 and hasn't stopped. In my case what appears to be happening is an extra field has been added to the message received by the COMPLETED_ORDER API. My orders usually have combo legs on the contract so this extra field pushes everything up: ;;;731155060|1,732397574|-1,732829836|-1,734264089|1;4;731155060 https://github.com/stoqey/ib/blob/d521e2a448e98f45666e9c3dccf5eb6dcac705fe/src/core/io/decoder.ts#L3081 This causes the comboLegsDescription to be blank and the next field comboLegsCount to be the description. https://github.com/stoqey/ib/blob/d521e2a448e98f45666e9c3dccf5eb6dcac705fe/src/core/io/decoder.ts#L3085 It decodes it as 731155060 and therefore expects to find 731155060 comboLegs. This causes the appearance of an UnderrunError. To get everything working again I updated line 3081: this.contract.comboLegsDescription = this.decoder.readStr() || this.decoder.readStr(); which fixed the comboLegsDescription and got things running again. I would love to work out why this has started happening and what could possibly have caused it. Is there a way to check if there have been updates on IB's side?