Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
Hello DS,
?
Thank you for your response to my query. So if I understand correctly, should my call for cancellation of an order look like this instead?
?
self.cancelOrder([orderId], OrderCancel())
?
Kind regards,
Scott. |
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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 |
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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.
?
|
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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:
|
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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. |
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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:
|
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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 |
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
The error is pretty strange but, FWIW, judging by the API source, the correct spelling must be 'manualCancelOrderTime' instead of 'manualOrderCancelTime':
?
?
?
--
Best, DS |
Using Excel
I appreciate this may have been answered (please point me to the thread - or a vba code example).
?
I have the TWS_ActiveX.xls working?
?
But I am unable to automate pulling down Account, Portfolio and Open order data using one button - I have to go to each tab and request data.
?
I am sure its a scoping/hierarchy within the code but I have been unable to make it work .
?
Any pointers - just want to press one button (preferably not on either of the account portfolio or open order tabs) and all data is refreshed
?
Many thanks
?
P
? |
Re: What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime)
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. |
Re: C++ TWS API reqMktDepth() giving 309 error
Suppose I have windows open in my TWS platform requesting market depth. Would that count against the limit? That seems to be the only thing I can think of as I am 99% sure I am requesting only once in these projects and nothing else is running against TWS in my task manager.
?
Thanks, Brendan |
Re: C++ TWS API reqMktDepth() giving 309 error
No problem here. Just tried NQZ4 as the third subscription through a paper account that already had two active reqMktDepth subscriptions for other instruments. Worked as expected. Any chance you are indeed requesting market depth subscriptions for more than three different instruments simultaneously? Keep in mind that TWS L2 tools count against the three subscription limit, in case you use those. ´³¨¹°ù²µ±ð²Ô ?
?
On Tue, Sep 10, 2024 at 08:16 AM, Brendan Lydon wrote:
|
Expired contract & TimeZoneId
I found that when I request ContractDetails for an expired future contract, the contractDetails object I receive has TimeZoneId propertiy set to Null.
But if I want to download HistoricalData for that contract I need to know its TimeZoneId to correctly send the request.
?
So how can I to solve the problem? |
Re: API server failed to start
Assuming your system does not show weird behavior I can only think of two major reasons why TWS/IBGW cannot create the socket they need to accept client connections through:
´³¨¹°ù²µ±ð²Ô
?
On Mon, Sep 9, 2024 at 08:35 AM, <abc20561225@...> wrote:
|
API server failed to start
Can anyone help me please.. My paper trading account's API server fails to start. Every time i log into TWS, it says the API server failed to start since the specified port 7497 is already in use by another application. I don't have another TWS application running but it keeps on saying socket port in use. Tried reinstalling the TWS, changed the versions, even tried changing the socket port number but nothing is working. |