开云体育

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

Re: Conditions on twsactivex api


 

Thank you Richard, I reviewed again the Conditional?Orders tab on the Excel Demo and you are right this object comes from the Conditions settings that I need to use in order to meet my requirements, I thought first time that this was about the Conditional statements on same tab columns AA to AF.

I did an investigation and navigated through the TWSlib.dll source code displaying messages through the full hierarchy of abstract objects:?
Tws.ParseConditions -> OrderCondition -> PriceCondition -> ContractCondition -> OperatorCondition.. So finally I found out that the cell "Conditions" (DN column on excel) needs to be parsed as: " Price of XXXXXXXXX(MMMMMM) is >= PPPPP" where XXXXX = conid of the instrument, MMMMMM = Exchange, PPPPP = Price, you also can use the operator <= instead of >=. And yes there?must be a space before the first "Type" condition word Price.

After 4 hours testing I was able to send an order to the TWS but it got rejected with this message:
? ?Error: 320 Error reading request.Message id 1879051720.? Unable to parse data. java.lang.NumberFormatException: For input string: "NYBOT"

After searching on the web, I found this error could be due to different versions API-TWS, as I had the LATEST API version available on I tried to run the LATEST version of tws instead of the STABLE... But the same error persists after sending the order. I tried to find the log of TWS but I cannot find it unter jts directory, just found the?launcher.log...

Anyone have any clue where to investigate, what to test?

Thank you




El lun, 31 ene 2022 a las 23:40, Richard L King (<rlking@...>) escribió:

Looking at the ActiveX API implementation, the comOrder class has a 'conditions' property that is accessible in Excel. This takes an ArrayList of OrderCondition, and to create this you call the ParseConditions method of the Tws class.

?

This is available in the Excel Demo on the ConditionalOrders tab – see the OrderConditions columns towards the end of the worksheet.

?

I've never used order conditions so I don't know what the syntax is, or whether it would allow you to do this sort of cross-contract conditional. But it looks like you should be able to define contract conditions, if you know the correct syntax.

?

The API reference contains a section on Order Conditioning, but the version I have is not up-to-date and doesn't mention contract conditions.

?

Perhaps someone who has used order conditioning can give more info on the syntax.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of joanmarcel119
Sent: 31 January 2022 21:10
To: [email protected]
Subject: [TWS API] Conditions on twsactivex api

?

Hi there, I hope this is the right forum to ask.

I'm using twsActivex API and would like to add a price condition on one instrument/expiration and once this condition is achieved send a market order to a different expiration... so I suppose by attaching an order to one contract and link it to a price condition to another contract (same instrument but different expiration), is that possible through the excel API?
I think this should be possible as I'm able to do it through the usual Order ticket and its Conditional tab on TWS and I also found some information in this group about conditional price and volume orders, but I can not get to work this on the excel api. I also did not find any information nor COM Object (to declare and set Conditions) about this on the Excel Demo provided by IB .

So, anyone of the group has had success aplying conditions through the Excel api? Anybody on this group can help me on this please?

Thank you in advance

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