Keyboard Shortcuts
Likes
Search
What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
¿ªÔÆÌåÓý
The latest TWS API for Java added a new required parameter to the existing method EClient::cancelOrder.? It now takes a string for manualOrderCancelTime which can be left null.? What does this parameter do?? Cancel an order if not already filled at a specific
time in the future?? It's not documented:
|
Just guessing here, Edward, but this is probably related to the new field and feels like a regulatory thing for brokers and advisors. So I guess unless you are a broker or advisor, pass the empty string. ´³¨¹°ù²µ±ð²Ô From:Limit Order With Manual Order TimeThe Limit Order With Manual Order Time is a with ManualOrderTime property.Order order = OrderSamples.LimitOrder(action, quantity, limitPrice); Placing a Limit Order With Manual Order Time client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), OrderSamples.LimitOrderWithManualOrderTime("BUY", Util.StringToDecimal("100"), 111.11, "20220314 13:00:00")); Canceling a Limit Order With Manual Order Time client.cancelOrder(nextOrderId - 1, "20220314 19:00:00");
|
Thanks a lot for such an elaborated answer. I guess you're right.? I was wondering if anybody is really using 10.16 API and what do they pass as this parameter. There are two options-empty string ot null. Ed On Sat, 9 Jul 2022 at 1:01 ´³¨¹°ù²µ±ð²Ô Reinold via <TwsApiOnGroupsIo=[email protected]> wrote:
--
Ed Gonen |
No problem, Ed. If you follow the call path in the Java API source code you will find that either option (null or "") is fine and yields the same result. The Order class uses Order.EMPTY_STR to initialize manualOrderTime and you could use that, since it is a public constant. It happens to be defined as "". ´³¨¹°ù²µ±ð²Ô
|
Thanks again, Jurgen E On Sat, 9 Jul 2022 at 7:49 ´³¨¹°ù²µ±ð²Ô Reinold via <TwsApiOnGroupsIo=[email protected]> wrote:
--
Ed Gonen |
Joel If you can, please update on your results. I didn't have a chance to check this yet as after my failure with cancellation I had reverted to the "old" API.? Thanks in advance Ed On Fri, 12 Aug 2022 at 20:46 Joel Gross <joelrgross@...> wrote: I tried passing in a datetime string and it ended up not cancelling my orders properly. I will try the empty string. --
Ed Gonen |
Joel Gross
The empty string appears to work normally. On Fri, Aug 12, 2022, 11:26 AM Edward <ed.gonen@...> wrote:
|
Thanks a lot On Fri, 12 Aug 2022 at 21:29 Joel Gross <joelrgross@...> wrote:
--
Ed Gonen |
Hey guys,
?
I was searching for some information about manualOrderCancelTime and came across this thread. I have been having some issues when attempting to cancel orders by way of Order ID. The orders are placed via the API and not via the TWS directly. I am using the following command in my python program to cancel orders by Order ID:
?
self.cancelOrder([orderId], "")?
?
This throws the following error and the program terminates:
?
'str' object has no attribute 'manualOrderCancelTime'
?
When I use the following command instead, to close all active orders, this works without any issues:
?
self.reqGlobalCancel()
?
I cannot figure out what is wrong here as I have seen by the earlier responses in this thread that I should only need to specify a single argument (the Order ID) and an empty string in order for this command to execute order cancellation.
?
Any assistance with this would be most appreciated.
?
Regards,
Scott. |
This looks so weird that I felt curious enough to sift through the source further.
?
The Python IBAPI source does not contain text 'manualOrderCancelTime' at all so it totally escapes me how it could even throw an error message that you quoted, featuring this text. Beside all this, the error message itself does not follow from anything I see in the API source code.
?
That said, in Java and C# API that same argument is named 'manualOrderCancelTime'. But Python API is not dependent on either.
?
Pretty mind-boggling to say the least, and I still have only questions, no answers...
?
--
Best, DS |
Scott did not tell us, which TWS API version caused the issue. But I suspect it is 10.30 or higher. Looks like 10.30.01 changed the cancelOrder() request signature:
That is true for all languages, not just Python. The new class OrderCancel has several fields, among them a string field called manualOrderCancelTime. Programing languages other than Python should give you compilation errors since the second argument changed from type String to type OrderCancel.?Also, cancelOrder requests will likely fail unless and instance of OrderCancel is passed. An object with default fields might work, but I have not checked that. The shiny new official TWS API documentation on IBKR Campus does not reflect that change yet and still suggests passing "" will work.
?
´³¨¹°ù²µ±ð²Ô
?
On Tue, Sep 10, 2024 at 01:39 PM, ds-avatar wrote:
|
Hello ´³¨¹°ù²µ±ð²Ô,
?
Thank you for your reply and apologies for not providing the version number I am using. I can confirm that I am using version 10.30.01 and so it seems that passing an empty string as per the original (and latest) documentation is no longer correct.?
?
In this case, would you know what should be passed for OrderCancel instead of an empty string? I searched the latest API documentation in IBKR Campus but I was unable to locate any information regarding the fields of the new OrderCancel class, so I am unable to adjust my call to include the default fields of this class in order to test it.
?
I appreciate your assistance with this.
?
Regards,
Scott. |
If in doubt, the source code is still the best documentation, Scott. I am not a Python practitioner, but I assume the OrderCancel class has a no-argument constructor that initializes the four fields with meaningful "empty" values. At least the Java implementation has one. Assuming you cancel orders infrequently, I'd replace the empty string "" parameter with something like new OrderCancel()?or the equivalent in Python. My framework already has a convenience method void cancelOrder( int orderId ) that hides the extra parameters from the business logic (since I don't need the manualCancelTime or OrderCancel logic). In that case, a single shared and constant OrderCancel object will work, too. ´³¨¹°ù²µ±ð²Ô ? ? On Tue, Sep 10, 2024 at 06:32 PM, <scott_hopgood@...> wrote:
|
Hello ´³¨¹°ù²µ±ð²Ô,
?
Thank you for this additional information. I have done as you suggested and changed the call for order cancellation to the following:
?
self.cancelOrder([orderId], OrderCancel)
?
Unfortunately this results in the following error, which terminates the program:
?
type object 'OrderCancel' has no attribute 'manualOrderCancelTime'
?
I have taken a look at the source code for Python for order cancellation (order_cancel.py)? and it looks like this:
?
"""
Copyright (C) 2024 Interactive Brokers LLC. All rights reserved. This code is subject to the terms ?and conditions of the IB API Non-Commercial License or the IB API Commercial License, as applicable. """ from ibapi.const import UNSET_INTEGER
from ibapi.object_implem import Object from ibapi.utils import intMaxString ?
class OrderCancel(Object):
? ? def __init__(self): ? ? ? ? self.manualOrderCancelTime = "" ? ? ? ? self.extOperator = "" ? ? ? ? self.externalUserId = "" ? ? ? ? self.manualOrderIndicator = UNSET_INTEGER ?
? ? def __str__(self):
? ? ? ? s = "manualOrderCancelTime: %s, extOperator: %s, externalUserId: %s, manualOrderIndicator: %s" % ( ? ? ? ? ? ? self.manualOrderCancelTime, ? ? ? ? ? ? self.extOperator, ? ? ? ? ? ? self.externalUserId, ? ? ? ? ? ? intMaxString(self.manualOrderIndicator), ? ? ? ? ) ?
? ? ? ? return s
?
Unfortunately I am not well versed in Python beyond the basics from what I have learned from the sample code provided in the IBKR tutorials, so I am just unsure what I am doing wrong here and why this error is occurring. It is disappointing that the API documentation has not been updated by IBKR to reflect the changes made to this function from version 10.30+ so I at a loss as to how I can move past this error.
?
I am most grateful for your assistance.
?
Regards,
Scott.
?
|
You should use OrderCancel() for the operand in question. This is how Juergen's suggestion of instantiating an object is translated to Python.
?
Seeing that you are highly dependent on the documentation you might consider installing the "stable" client API 10.19 which I believe most of docs are centered around.
?
Also while this group is dedicated mostly to the original IBKR's client API, when it comes to Python the excellent independent alternative ib_async package is arguably much easier to use. But even then limitations of a naive copy-and-paste approach without learning key concepts and practices of the underlying programming language will betray themselves pretty soon. (Note that beside Python, the original client API is also available in C, C# and Java, so there's plenty of choices that could be more suitable to your experience).
?
--
Best, DS |