Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Flushing the Incoming Message Buffer - C++ Multi-threading
Even after you cancel a request there may be messages wandering around the Internet that may appear many seconds later.
You need to accept any message at any time. If you receive tick data you're no longer interested in then you need to ignore.it. |
DAX data feed via API
开云体育Hi, ? I trade DAX with Ninjatrader connected to Interactive Brokers via TWS (connect to API). ? Since Monday, no data is available for DAX futures when I connect Ninjatrader to TWS to get data feed. ? DAX futures cannot be traded as if the instrument is not known. ? Have someone heard of any problem ? Any solution ? ? Thanks ? David G |
Flushing the Incoming Message Buffer - C++ Multi-threading
I have a C++ GUI application which on which at a user request, the list of symbols will be cleared and all the market data requests will be cancelled, and ultimately the buffer holding the records for the GUI display is cleared.
The issue I have is that every now and again I get a crash because there are still incoming tick messages (price, volume, etc.) in the queue after the display and buffer are cleared. Is there any way I can test the incoming message queue to see if there are any messages to process? Is there a way to clear that queue to prevent further GUI update calls from the reader thread? |
Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows
Great! Here you have tha API reference guide, and also the function which gets the account information: it displays an important?message: "Important:?only?two?active summary subscriptions are allowed at a time!" So if you press the button more times maybe you will get unexpected behaviour or no data sent from TWS.? Hope this helps El lun, 25 jul 2022 a las 14:59, <redcorolla95@...> escribió: Here's the screenshot of what I just downloaded today. |
Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows
Here's the screenshot of what I just downloaded today.
I realized the problem goes away if I don't change to an xlsx file and leave it in xls - then its like all the lines are populated at once instead of waiting for a few seconds each line like this. |
Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows
Sorry I do not understand your problem, you downloaded?your account info and it sends you 5/10/40 rows? Could you explain please? And also an image of the issue would help. El dom, 24 jul 2022 a las 10:04, <redcorolla95@...> escribió: Hi all, new to this forum and ActiveX API here. |
TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows
Hi all, new to this forum and ActiveX API here.
Started using the standard sample TwsActiveX.xls and trying to get it download my account info. But after downloading about 5/10/40 rows it stops downloading anymore rows.? (This seemed to work on Wed, but yesterday and today it's not working). Am I missing something on my configurations?? |
Re: About commissionReport.realizedPNL
Brendan is correct about the UNSET_DOUBLE or Double.MAX_VALUE the various languages use to indicate "undefined value". The same is true for integer fields where the Integer.MAX_VALUE (2^31)-1 = 2,147,483,647 is used as the UNSET_INTEGER indicator. You should get "undefined realizedPNL" only for commission reports of entry trades, since there is no PNL from price changes yet. Commission reports for exit trades will show the actual realized PNL for that trade. Depending on how you think about PNL, you could set "realizedPNL = -commission" for entry positions (when realizedPNL is undefined) since the commission you pay for entering into the position is a small loss right from the start. 闯ü谤驳别苍 On Thu, Jul 21, 2022 at 12:37 PM, Brendan Caffrey wrote:
|
Re: SPX Betas?
I'm afraid unless someone here is feeling generous you are going to have to 1) get the price feeds, 2) do the maths according to your own flavouring and 3) make it robust to all the errors, data failures and other issues that are part of real trading. If you have problems with 1) or 3) we are definitely the right place to ask. 2) is more of a personal choice. Best of luck with it all, M On Thu, 21 Jul 2022, 16:47 , <jthechu365@...> wrote: Hi all - new to this forum, hoping to learn a lot here!? |
Re: About commissionReport.realizedPNL
That value (1.797...e+308) is the maximum value a double can hold. IB uses that to indicate the value is unset. In the C++ API code, they have an UNSET_DOUBLE constant that you can compare against, there may be something similar in the python code. Also, my python is a little rusty, but I think you need to pass an array to writerow, something like: writer.writerow([commissionReport.realizedPNL]) On Thu, Jul 21, 2022 at 10:01 AM <david03kimo@...> wrote: When I execute an order I get the?commissionReport.But I cannot read the?commissionReport.realizedPNL such like?1.7976931348623157e+308. |
About commissionReport.realizedPNL
When I execute an order I get the?commissionReport.But I cannot read the?commissionReport.realizedPNL such like?1.7976931348623157e+308.
When I create a new position, the?commissionReport.realizedPNL shows?1.7976931348623157e+308.After the position closed,the?commissionReport.realizedPNL shows the normal profit and loss amount. I'd like to export the Profit and loss to csv after every positions closed.But I don't know how to handle the??commissionReport.realizedPNL such like?1.7976931348623157e+308. It cannot export?commissionReport.realizedPNL to csv by?writer.writerow(commissionReport.realizedPNL).It shows error message:csv.Error: iterable expected, not float I don't know how to do? Any ideas is welcome. -- ------ Forex trader David Liao |
Re: difference between Good Till Cancel and autuCancelDate
Richard already pointed the relevant time-in-force options out and you can learn more about GTC orders in . Interesting read, since there are a few (not so obvious) events that can cancel your order. Your question made me curious about the autoCancelDate field you mentioned. I had seen it before but never paid attention to it so I did a little research. The order object field autoCancelDate, and one called autoCancelParent must have been around for quite a while, but at least since APII 976.1. Documentation is very thin but the reference guide says:
And the for 10.10 say "Added AutoCancelParent attribute to placeOrder/openOrder". I read that as "the order object field autoCancelParent is now sent to and received from TWS/IBGW". autoCancelDate is not mentioned in the release notes so I checked the API source code. At least in the Java API, values for autoCancelDate are ignored when order objects are sent to TWS/IBGW via placeOrder. In other words the field can not be used to cause order cancellation at a certain point in the future. But the field is properly initialized in order objects received from TWS/IBGW via openOrder callbacks. So the field could possibly carry the date/time when an order was cancelled related to autoCancelParent = true. But that is just a guess. 闯ü谤驳别苍 On Mon, Jul 18, 2022 at 11:03 AM, <ajinkya@...> wrote:
Hi All,? |
Re: difference between Good Till Cancel and autuCancelDate
开云体育You can’t specify a date with ‘Good Till Cancel’. It just means that the order will remain valid until either it is filled or it is cancelled (for example via CancelOrder): so it will persist beyond the end of the day’s trading session, whereas a ‘DAY’ order is only valid till the end of the session. ? Don’t confuse ‘Good Till Cancel’ with ‘Good Till Date’ and ‘Good After Time’, where you can specify a date and time. ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of ajinkya@...
Sent: 18 July 2022 16:17 To: [email protected] Subject: [TWS API] difference between Good Till Cancel and autuCancelDate ? Hi All,? |
Re: Strange Glitch When Requesting PNL
闯ü谤驳别苍,First let me apologize, somehow I must have missed your original response with questions, thanks again for taking the time to respond.? I am glad you were able to replicate the issue so that I am not alone. I agree that this is not a high priority issue since it can be easily compensated for, and usually you only need to call reqPNL once.? My issue is that I am still building my platform and debugging.? My code keeps track of the PNL based on responses to trades, specifically I listen for the??call back and record entry and exit trade prices.? As a redundancy I subscribe to reqPNL to make sure the number match. Since my code is ( or was ) prone to crashing the first thing my code does is reqPNL so it knows what the starting PNL is.? I mostly use IB gateway which does not have this issue.? But I noticed at random times my code froze, after digging I realized it froze waiting for the first PNL. I will need to look into perhaps the update account value as an alternative, to waiting for the reqPNL On Sun, Jul 17, 2022 at 11:22 PM 闯ü谤驳别苍 Reinold via <TwsApiOnGroupsIo=[email protected]> wrote: I had a couple minutes and a paper account with no positions and was able to replicate the TWS behavior you report: |
Re: Strange Glitch When Requesting PNL
I had a couple minutes and a paper account with no positions and was able to replicate the TWS behavior you report:
In this case, subscriptions to trigger a single callback only for the first client that connects to TWS, and dailyPnL,, unrealizedPnL,, and realizedPnL? are reported as 0. That client does not receive any further callbacks (there are no positions) and all subsequent clients of that TWS do not event receive the initial callback. That behavior is definitely inconsistent, but your client should not have to lock up. In fact, for my taste, I would not have expected a callback for the first client to take place:
You may want to take a look at your client architecture and consider a "PortfoilioModel" or "AccountModel" implementation similar to those used in Model-View-Controller architectures. Callbacks from TWS API subscriptions update values in the model when they happen and your client reads the most recent values from the model when it needs one. During startup, all model values are either initialized with 0 (or "undefined" if that is what you prefer) and your client operates properly with and without the callback. The TWS API is asynchronous and event oriented in nature and your client must be resilient and always be prepared that an event just does happen (for many reasons). A couple other quick observations:
You could file a trouble ticket with IBKR for this, but I think it would get a very low priority or may even be rejected by engineering right away. Hope this helps, 闯ü谤驳别苍 |
Re: can two clients for the same ibgateway share market data?
I ran two and more clients connected to the same IB Gateway 981.3o in paper and real accounts and received no error conditions. Everything worked fine, as expected, and just like always, and I cannot confirm any changes in the policy for sharing of market data by multiple clients connected to the same IB GW/TWS. My clients subscribed to a wide range of instruments (40 to 80 each), including TickByTick and Level II data feeds. Maybe you could enable API logging in your IB Gateway and share the occurrence of 10197 errors in your setup? 闯ü谤驳别苍 On Sat, Jul 16, 2022 at 10:42 AM, <liulinglll@...> wrote:ibgateway is 981 and only the 2nd connected client has 10197...it happens consistently |