Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
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 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Strange Glitch When Requesting PNL
Which PNL feed are you trying to subscribe to, Marc?
And how does your code wait after requesting PNL? I guess what I am asking is are you using any calls to a "sleep" method with some prescribed time after the PNL subscription request? You could enable the API log in TWS to see whether TWS does not send a PNL at all? or whether TWS does send it but your client logic somehow locks itself up. ´³¨¹°ù²µ±ð²Ô |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: VIX weekly settlement price
Glad this helped. And I learned a few new VIX tidbits, too. ´³¨¹°ù²µ±ð²Ô On Fri, Jul 15, 2022 at 12:30 AM, Despair wrote:Wonderful! Thank you so much. This was exactly what I was looking for. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: can two clients for the same ibgateway share market data?
Does this happen all the time? Which IB Gateway version are you running, and will both clients get the error? We sometimes (but rarely) see "Code: 10197" errors during the nightly IBKR maintenance and reset windows or over the weekend. ´³¨¹°ù²µ±ð²Ô I have 2 clients connecting to the same ibgateway and both of them subscribe to some market data. The 2nd connected client has error - "Code: 10197, Msg: No market data during competing live session". |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Tws Vs Gateway Api
Are you referring to the Global Configuration -> Presets -> ... settings in TWS, Adam? Those only impact orders you manually place from within TWS and they are missing from IB Gateway since it does not provide manual order processing. Those TWS order presets have no impact on orders your client applications place through the TWS API. But you can easily write a small function that initializes presets in the objects you send to the API. ´³¨¹°ù²µ±ð²Ô |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: VIX weekly settlement price
IBKR has some material online about VIX trading. Among them is this . On page 17 they describe "Settlement Pricing" and "Special Opening Quotations" and say on page 18 that SOQ values are available as index symbol VRO. the IBKR long name for contract VROLINDEX is "CBOE S&P 500 Volatility Index SOQ". When you grab daily historical bars for VRO:INDEX you get something like what you see below:. Is this what you are looking for? A count value of 1 seems to indicate a new SOQ. ´³¨¹°ù²µ±ð²Ô
|