softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Duplicate order id error #28

Open jcka22 opened 6 years ago

jcka22 commented 6 years ago

Everything seems to be working, but when I try to place an order using "

session.eClientSocket.placeOrder(8855,contract,order); pause(1); "

I get this error: "8855 103 Duplicate order id"

I've defined contract and order in the ways instructed in the tutorial.

Any suggestions?

Thanks!

softwarespartan commented 6 years ago

Hi Jcka

Thanks for reaching out.

That message just means you need to have a unique order id. TWS keep track of every order placed and increments by +1 for every order.

You can use TWS.NextOrder object to get uniq IDs. The TWS.NextOrder object makes an API call to TWS to get the latest order ID and then will help give sequential order ids.

You can also brute force some random number in there but that’s not a great idea. Although, there is a setting in TWS where you can reset order ids back to 0.

Let me know if that solves your issue. Don’t hesitate to reach out if need anything additional.

Cheers -abel

On Jun 10, 2018, at 9:29 PM, jcka22 notifications@github.com wrote:

Everything seems to be working, but when I try to place an order using "

session.eClientSocket.placeOrder(8855,contract,order); pause(1); "

I get this error: "8855 103 Duplicate order id"

I've defined contract and order in the ways instructed in the tutorial.

Any suggestions?

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/softwarespartan/IB4m/issues/28, or mute the thread https://github.com/notifications/unsubscribe-auth/AEWq1OeKMGsrbC9q2KjRq049osy4rqlSks5t7cfggaJpZM4Uh9Gp.