¿ªÔÆÌåÓý

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

Re: Cannot transmit order (main order and stop loss orders)


 

That is correct, because you are using a legitimate Python feature that has nothing to do with the TWS API. There is nothing "wrong" with your code (from a Python point of view), it just does not work the way you want it to work. Let me quote from a :

"In general, any Python object can have an attribute of any name assigned to it at any time. Unlike in languages like Java, where an object's full memory layout needs to be known at compile time, in Python object attributes are stored in dictionaries. Dictionaries can hold any number of items, so there is nothing to keep you from assigning to any attribute at any time."

So if you want, you can write legitimate Python such as: order.ToiToiToi= 'You can do it! Be profitable!". In your specific case, TWS API has no idea that you opted to add the extra attribute "OrderType" for your order objects. An attribute that is different from the attribute "orderType" TWS API as defined.

But TWS API does realize that one of the two orders has no "orderType" attribute and you will get an . callback immediately after you call placeOrder. You just do not handle errors in the code segment in your original post.

None of the other language allows the assignment to undefined class attributes and you would get errors well before you even start a program with such an assignment. You might want to consider some kind of Python Interactive Development Environment (IDE) that flags and color codes cases of misspelled class attributes, or a tools chain that checks your code before you run it. IDEs also give you convenient pull-down menus for all defined class attributes so that you never have to type long field names in the first place.

´³¨¹°ù²µ±ð²Ô

On Tue, Jan 10, 2023 at 02:05 PM, GreenGreen wrote:

I am sorry for keeping this chat grow, but I feel this is important. I confirmed that when I submit stopLossOrder.OrderType = "STP" (incorrect capitalization), there is neither error message in console nor record in log file.

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