¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Conditions on twsactivex api


 

Hi Richard, thank you for all your help and support.

I did not try again your settings because I was a bit busy and a bit disappointed about this behaviour of the API.? I would like some other one in the group that resides or lives currently in Europe,? (maybe J¨¹rgen lives in Germany / vielleicht wohnst Du in Deutschland, J¨¹rgen?) to check if this person also gets the same results as me or I'm the only one. I'm also planning on installing the API & TWS on my wife's computer and checking what she gets, maybe my computer has something wrong ...?

For me these results are very very weird, If I try all your tests without the?decimal point and keeping my settings they?always work but when I add the point then I get the same error message.

I will try to go forward with other computers tests this week and keep you informed

Best wishes?




El dom, 6 feb 2022 a las 19:54, Richard L King (<rlking@...>) escribi¨®:

Well, as I said, I really don't understand why you're seeing something different from me. For me, it just works.

?

The only thing that does occur to me is that perhaps the condition is actually being accepted and the error occurs when parsing something else in the API message ¨C maybe you have some extraneous field set?

?

So can we make sure we're both doing exactly the same thing.

?

On the Conditional Orders worksheet, the only fields I set in the first order row are as follows ¨C all other fields are blank:

?

Symbol:???????????????????????????? IBM

Type:???????????????????????????????? Stock

Exchange:???????????????????????? SMART

Currency:????????????????????????? USD

Action:????????????????????????????? BUY

Quantity:????????????????????????? 100

Order Type:????????????????????? MKT

Filled:??????????????????????????????? 0

Remaining:??????? ????????????? 0

Avg Fill Price:??????????????????? 0

Last Fill Price:???? ????????????? 0

Parent Id:???????????????????????? 0

Conditions:????????????????????? last of bid/ask Price of 376589407(NYBOT) is >= 1.2111

?

Then I make sure the first order row (Row 7) is selected, and click 'Place / Modify Order': I find it's necessary to click it twice, as the first click just selects the button ¨C very annoying!).

?

The order is then sent to TWS and the Id and Status columns are updated more or less instantly. The order appears in TWS, and depending on whether the condition is satisfied it sits there waiting or is executed.

?

?

?

From: [email protected] <[email protected]> On Behalf Of joanmarcel119
Sent: 06 February 2022 15:18
To: [email protected]
Subject: Re: [TWS API] Conditions on twsactivex api

?

Hi Richard, thank you for your explanation. I did not explain myself right.

?

If I leave the decimal point "." on the price then I get the same error 320 and the order is not sent.?

?

If I just leave an integer amount (without decimal part) then the order is processed and sent to TWS.

?

So this is really weird because the only thing that produces the error is the decimal point "." on the price condition -> 1.15

?

What else should I check?

?

Thank you

?

El dom., 6 feb. 2022 14:05, Richard L King <rlking@...> escribi¨®:

Joan

?

When the condition is parsed to extract the price value, it uses the following C# statement:

?

Price = double.Parse(value, NumberFormatInfo.InvariantInfo);

?

You'll find this at line 46 of PriceCondition.cs. The NumberFormatInfo.InvariantInfo parameter means that local culture is not taken into account, so commas in a number are taken to be thousands separators (and are ignored). Thus 1,15 is simply parsed as 115.

?

Note that the API uses the invariant culture everywhere when parsing numbers, because otherwise the API would work differently in different regions.

?

So you do need to use a period as the decimal point, not a comma. But if I understand you correctly, you seem to be saying that if you use 1.15 that also gets parsed as 115? I cannot understand that.

?

Also what changed that you are no longer getting the error?

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