esvirsky / ib_java_getting_started

Interactive Brokers API getting started in Java
MIT License
3 stars 0 forks source link

clientId #2

Open yezhengli-Mr9 opened 4 months ago

yezhengli-Mr9 commented 4 months ago

I am beginner for ibkr java client. I doubt my clientId is referred wrongly. From https://www.queworx.com/blog/getting-started-with-interactive-brokers-api-in-java/

before we issue any requests to IB we wait for nextValidId to be set. We use that Id when creating an order, but in general it indicates that the connection has been established and TWS is ready to receive requests. https://github.com/esvirsky/ib_java_getting_started/blob/06a97e691b0640b5c257ae9676c9bade0110e419/com/queworx/IBBroker.java#L12

[INFO] --- exec:3.1.0:java (default-cli) @ ibkr ---
java.lang.Exception: Didn't get a valid id from IB

https://github.com/esvirsky/ib_java_getting_started/blob/06a97e691b0640b5c257ae9676c9bade0110e419/com/queworx/Main.java#L13 https://github.com/esvirsky/ib_java_getting_started/blob/06a97e691b0640b5c257ae9676c9bade0110e419/com/queworx/Main.java#L24-L32

esvirsky commented 4 months ago

You get the nextValidId in the IBReceiver

@Override public void nextValidId(int id) { __ibDatastore.nextValidId = id; }

IB is supposed to send that ID to you through an event