开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: Duplicate Order ID


 

开云体育

Robert

?

You have set .auxPrice = 1 for the DAX contract. The auxPrice field is the trigger price for your stop order. For EUR.USD that is a possible value since the current price for this contract is around 1.019. But the current DAX price is around 13486, so your trigger price of 1 is completely unreasonable and is almost certainly being rejected with an error message.

?

You are handling errorMsg events, presumably? If not, you stand no chance of getting the API to do anything useful…

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of Metrodus79
Sent: 29 July 2022 13:27
To: [email protected]
Subject: Re: [TWS API] Duplicate Order ID

?

Hello Jürgen,

first of all I thank you very much for your fast reply and your time! I'm absolutely with you that my kind of solution is not perfect but at the time when i started it was the best what i could manage with my knowledge.?

1. "One area I'd review is the code that determines the next order ID. As the Placing Orders chapter of the API Reference Guide suggests, clients generally maintain their own sequence of order IDs and do not make API calls for the nextOrderId unless they somehow lose the sequence. During the initial connection request, clients are automatically informed of the next valid order ID and, from that point on, simply increment an internal nextOrderId field as needed. "

So for my understanding now, it is not necessary to make always a request for a validOrderid and it save process time to increment the order id in a own sub. I get the first valid id with the first connection in the morning. I implemented this and of course the problem with the duplicate order id is gone :)

2. "our code needs to be structured event oriented as well and needs to wait for the arrival of a callback (or the corresponding error) and not sleep for a fix period of time after the request."

The Code really wait and not sleep. There is a timer in the backround who started the code again and then it follows a validation phase to check the answer from the API. I'm use unique strings that the program always know the correct sequence entry point. IMO there is no way to use multithread with excel so i have to do everything step by step. Of course this need time but still now it is not relevant for my trading.

3. Unfortunately now the wrapper send no response for my DAX contract. If i change the contract to EUR.USD i get the response without any problem. So is there a way if you can make a order request to look if you get an answer?

Kontraktinformationen:
With objTWSControl.m_contractInfo
???? .Symbol ="DAX"
???? .secType = "FUT"
???? .lastTradeDateOrContractMonth = "202209"
???? .multiplier =5
???? .exchange = "EUREX" changed from DTB on monday this week and this was the time when my problem with duplicate Order id started
???? .currency ="EUR"
End With

Orderinformationen:
With objTWSControl.m_orderInfo
???? .Action =? "BUY"
???? .totalQuantity = 1
???? .orderType = "STP"
???? .auxPrice = 1
???? .timeInForce = "DAY"
???? .whatIf = 1
End With

When I make the request with EUR.USD I get the response without any problem:

Kontraktinformationen:
With objTWSControl.m_contractInfo
???? .Symbol ="EUR"
???? .secType = "CFD"
???? .lastTradeDateOrContractMonth = ""
???? .multiplier =1
???? .exchange = "SMART"
???? .currency ="USD"
End With

Orderinformationen:
With objTWSControl.m_orderInfo
???? .Action =? "BUY"
???? .totalQuantity = 1
???? .orderType = "STP"
???? .auxPrice = 1
???? .timeInForce = "DAY"
???? .whatIf = 1
End With

My question is now if i have to change anything in the contractinfo object in the way to get a response from TWS via API. IMO it is strange that the problem started for me with the change of the exchange from DTB to EUREX. Do you or anyone know something about this or have the same issue with requests on EUREX-Exchange via API and TWS?

Thanks again for your help!!!

Robert


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