开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育
Date

Re: best way to display info from ibgateway client

 

You can create a second user for the same IB account and use it to log in to a local TWS instance while the gateway is active on a remote server. Note that if you want market data you will need to pay again for the second user, but if you just want to be able to view your positions, orders, trades, and delayed market data, there is no extra cost and it works great.


Re: New home for ib_insync / ib_async

 

开云体育

Done (plus a number of other changes, clarifications and corrections).

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of Mel
Sent: Friday, May 17, 2024 10:26 PM
To: [email protected]
Subject: [TWS API] New home for ib_insync / ib_async

?

In you group page you have the following (crossed out): Note: If you have a question about the IB-insync library, don't post it here: use the IB-insync Python framework User Group at /g/insync.

Please change it to: Note: If you have a question about the ib_insync or new ib_async library, don't post it here: use the ib_ansync Python framework User Group at /g/ib-async.

Please remove the line: Note: The future of the insync group is currently uncertain. You can follow the most recent developments in our topic /g/twsapi/topic/104781778

Thank you, Mel Pryor


New home for ib_insync / ib_async

 

In you group page you have the following (crossed out): Note: If you have a question about the IB-insync library, don't post it here: use the IB-insync Python framework User Group at /g/insync.

Please change it to: Note: If you have a question about the ib_insync or new ib_async library, don't post it here: use the ib_ansync Python framework User Group at /g/ib-async.

Please remove the line: Note: The future of the insync group is currently uncertain. You can follow the most recent developments in our topic /g/twsapi/topic/104781778

Thank you, Mel Pryor


Re: best way to display info from ibgateway client

 

开云体育

I run a module to get current data for portfolios.? I have a GUI one that has tabs for holdings per account, Change in NAV and Trades, as well as a command line one that writes it all to a file.??

I also retrieve all my portfolio data daily by using the api to get the flex reports (those won't give RT data) and those are currently written to Excel sheets.? I may switch to writing it all to mySQL if I get around to it.

Mel

On 5/17/2024 12:42 PM, tbrown122387 via groups.io wrote:

I recently moved all my execution apps to a remote Ubuntu server. It's tough to run two instances of TWS without killing the CPU, so I switched from TWS to IB Gateway. I can still run both live and paper accounts and share data, but this is less resource intensive.

When I was running TWS, I would occasionally use a remote Desktop client to log in and check out my pnl, orders and open positions. What is the best way to display this information on IB Gateway?

What I'm thinking about doing now is pretty janky. When I run my trading client it looks something like this

./my_strat 127.0.0.1 $TWS_LIVE_PORT &> ~/Desktop/todays_trading_log.txt

Then I just `tail` the end of that file to look at recent information. Any recommendations? Ideally it would pop up in the IB Gateway window.


best way to display info from ibgateway client

 

I recently moved all my execution apps to a remote Ubuntu server. It's tough to run two instances of TWS without killing the CPU, so I switched from TWS to IB Gateway. I can still run both live and paper accounts and share data, but this is less resource intensive.

When I was running TWS, I would occasionally use a remote Desktop client to log in and check out my pnl, orders and open positions. What is the best way to display this information on IB Gateway?

What I'm thinking about doing now is pretty janky. When I run my trading client it looks something like this

./my_strat 127.0.0.1 $TWS_LIVE_PORT &> ~/Desktop/todays_trading_log.txt

Then I just `tail` the end of that file to look at recent information. Any recommendations? Ideally it would pop up in the IB Gateway window.


Closing a position in two steps

 

Hello group,

At the beginning of the day my strategy attempts to open a huge position (worth around $100M). The position is opened using one of IB's algos during a limited time interval (assume it is between 9:30-9:55)

As soon as the entry algo is done I would like to place two orders to close the position, as follows:
- a % Volume algo order working between say 11:30-13:00, attempting to close the whole position
- a VWAP algo order working between 13:00-16:00, attempting to close whatever position is left over at 13:00

The aim is to fully close the position by 16:00. The first order might not close the whole position in the time interval set, hence the need of the second order.

Is there a way to send in these two orders immediately at 9:55 (when the entry algo is done)? I will not know beforehand if the first position closing order will be able to close the full position, or if not, how many shares will be left over to the second position closing order.

What I'm currently doing is sending the first order at 9:55, and then at 13:00 I check what position is left over and place the second order for the remaining shares.
This is not ideal and I'm looking for a way to send the two orders at once and then walk away.


Re: what happens with a gtd oca order after partial fill?

 

开云体育

Dmitry,

Thanks, I was thinking along the same lines. It's probably the only way to really test this scenario.

Greetings,
Raoul


On 15-05-2024 17:03, Dmitry Shevkoplyas wrote:

Raoul,

I strongly?believe it is easy to create partial fills.
Here are some ideas to facilitate your partial fill tests.

IB supports "Scale Order" for futures, which means you can put some aggressive?price increments, so that even during volatile liquid times only 1st step of your order will have a chance to be executed and others will be too far from the current price.

You can also chose different:
? - contract (choose one with less?liquidity, (m)es are too popular)
? - expiration (choose one less "hot" contract)
? - trade time (choose one with less volatile time, not around market open / close)
? - size: odd size to may be increase partial fill chances?
? - size: much bigger order sizes might also help

Also instead of "gtd set to 1 minute into the future" tighten?this time?to smaller or even send cancellation as soon as 1st fill is reported.

Another thing: I guess the behaviour you're trying?to investigate would be exactly the same on different types of contract (futures and stocks), thus you can move your testing to stocks, which is a vastly bigger space to play with. "If you can make it there, you can make it anywhere" (c)?Frank Sinatra
And don't forget to post your results here ;)

Cheers,
Dmitry

On Wed, May 15, 2024 at 10:18?AM Raoul Suurmeijer via <raoul=[email protected]> wrote:
Ok, I see. The problem is, in the mes or es futures, fills are almost always in full instantly, maybe with a second in between. So I've never seen the situation of a partial fill lasting for a long time, but it could happen. Even in a less liquid market, you can almost not force that situation to see what happens.

What I'm curious about is what happens if the parent is still not fully filled before the gtd ends and the parent gets cancelled and what that does with the connected child orders. I assume they will still be there for the partial fill (with adjusted size), but that's an assumption....?

It's just a scenario that's very difficult to test on a (paper) account.


On 15-05-2024 15:56, Richard L King wrote:

I think you may have misunderstood me. If things have worked as you hope, the gtd parent (albeit partially filled) will disappear from the API page in TWS, but the other child orders should still be there with the correctly adjusted size and appropriate status, in exactly the same way as happens when the parent is fully filled (with or without a gtd).

?

If the child orders are not still visible in the API page, then this would suggest that they have indeed been cancelled. In this case I would expect to see appropriate ‘cancelled’ errorMsg callbacks for the child orders.

?

?

?

From: [email protected] <[email protected]> On Behalf Of Raoul Suurmeijer
Sent: Wednesday, May 15, 2024 11:30 AM
To: [email protected]
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul


On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?

?




Re: what happens with a gtd oca order after partial fill?

 

开云体育

That would be the case with a 'normal' gtc order I think. With a gtd order, at some point the parent will be cancelled. On a partial fill with such a gtd order, I do not want the child orders cancelled. They should only be reduced in size but not cancelled completely when the gtd is triggered.

Greetings,
Raoul

On 15-05-2024 17:23, Mel wrote:

Usually if I get a partial fill (eg: 47 of 100) I will still see an order for 53 shares.? I have never had partial fills via the api that didn't get the remainder filled before close, so I expect it to be there the next day, but can't verify.





-------- Original message --------
From: "Raoul Suurmeijer via groups.io" <raoul@...>
Date: 2024-05-15 3:30 a.m. (GMT-08:00)
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul



On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?




Re: what happens with a gtd oca order after partial fill?

 

开云体育

Usually if I get a partial fill (eg: 47 of 100) I will still see an order for 53 shares.? I have never had partial fills via the api that didn't get the remainder filled before close, so I expect it to be there the next day, but can't verify.





-------- Original message --------
From: "Raoul Suurmeijer via groups.io" <raoul@...>
Date: 2024-05-15 3:30 a.m. (GMT-08:00)
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul



On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?



Re: what happens with a gtd oca order after partial fill?

 

Raoul,

I strongly?believe it is easy to create partial fills.
Here are some ideas to facilitate your partial fill tests.

IB supports "Scale Order" for futures, which means you can put some aggressive?price increments, so that even during volatile liquid times only 1st step of your order will have a chance to be executed and others will be too far from the current price.

You can also chose different:
? - contract (choose one with less?liquidity, (m)es are too popular)
? - expiration (choose one less "hot" contract)
? - trade time (choose one with less volatile time, not around market open / close)
? - size: odd size to may be increase partial fill chances?
? - size: much bigger order sizes might also help

Also instead of "gtd set to 1 minute into the future" tighten?this time?to smaller or even send cancellation as soon as 1st fill is reported.

Another thing: I guess the behaviour you're trying?to investigate would be exactly the same on different types of contract (futures and stocks), thus you can move your testing to stocks, which is a vastly bigger space to play with. "If you can make it there, you can make it anywhere" (c)?Frank Sinatra
And don't forget to post your results here ;)

Cheers,
Dmitry

On Wed, May 15, 2024 at 10:18?AM Raoul Suurmeijer via <raoul=[email protected]> wrote:
Ok, I see. The problem is, in the mes or es futures, fills are almost always in full instantly, maybe with a second in between. So I've never seen the situation of a partial fill lasting for a long time, but it could happen. Even in a less liquid market, you can almost not force that situation to see what happens.

What I'm curious about is what happens if the parent is still not fully filled before the gtd ends and the parent gets cancelled and what that does with the connected child orders. I assume they will still be there for the partial fill (with adjusted size), but that's an assumption....?

It's just a scenario that's very difficult to test on a (paper) account.


On 15-05-2024 15:56, Richard L King wrote:

I think you may have misunderstood me. If things have worked as you hope, the gtd parent (albeit partially filled) will disappear from the API page in TWS, but the other child orders should still be there with the correctly adjusted size and appropriate status, in exactly the same way as happens when the parent is fully filled (with or without a gtd).

?

If the child orders are not still visible in the API page, then this would suggest that they have indeed been cancelled. In this case I would expect to see appropriate ‘cancelled’ errorMsg callbacks for the child orders.

?

?

?

From: [email protected] <[email protected]> On Behalf Of Raoul Suurmeijer
Sent: Wednesday, May 15, 2024 11:30 AM
To: [email protected]
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul


On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?

?



Re: what happens with a gtd oca order after partial fill?

 

开云体育

Ok, I see. The problem is, in the mes or es futures, fills are almost always in full instantly, maybe with a second in between. So I've never seen the situation of a partial fill lasting for a long time, but it could happen. Even in a less liquid market, you can almost not force that situation to see what happens.

What I'm curious about is what happens if the parent is still not fully filled before the gtd ends and the parent gets cancelled and what that does with the connected child orders. I assume they will still be there for the partial fill (with adjusted size), but that's an assumption....?

It's just a scenario that's very difficult to test on a (paper) account.


On 15-05-2024 15:56, Richard L King wrote:

I think you may have misunderstood me. If things have worked as you hope, the gtd parent (albeit partially filled) will disappear from the API page in TWS, but the other child orders should still be there with the correctly adjusted size and appropriate status, in exactly the same way as happens when the parent is fully filled (with or without a gtd).

?

If the child orders are not still visible in the API page, then this would suggest that they have indeed been cancelled. In this case I would expect to see appropriate ‘cancelled’ errorMsg callbacks for the child orders.

?

?

?

From: [email protected] <[email protected]> On Behalf Of Raoul Suurmeijer
Sent: Wednesday, May 15, 2024 11:30 AM
To: [email protected]
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul


On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?

?



Re: what happens with a gtd oca order after partial fill?

 

开云体育

I think you may have misunderstood me. If things have worked as you hope, the gtd parent (albeit partially filled) will disappear from the API page in TWS, but the other child orders should still be there with the correctly adjusted size and appropriate status, in exactly the same way as happens when the parent is fully filled (with or without a gtd).

?

If the child orders are not still visible in the API page, then this would suggest that they have indeed been cancelled. In this case I would expect to see appropriate ‘cancelled’ errorMsg callbacks for the child orders.

?

?

?

From: [email protected] <[email protected]> On Behalf Of Raoul Suurmeijer
Sent: Wednesday, May 15, 2024 11:30 AM
To: [email protected]
Subject: Re: [TWS API] what happens with a gtd oca order after partial fill?

?

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul


On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?

?


Re: what happens with a gtd oca order after partial fill?

 

开云体育

No, that's not the problem. I can see everything in tws. When the parent is completely filled, or completely cancelled by the gtd, everything is fine. But it's the scenario with a partial fill on a gtd parent that worries me. Thanks!

Greetings,
Raoul



On 15-05-2024 11:42, Richard L King wrote:

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?



Re: what happens with a gtd oca order after partial fill?

 

开云体育

Surely you can see in TWS whether the child orders are still extant, and whether they have the correct sizes?

?

If your response is ‘I can’t see them because I’m using Gateway’, then I would say that this is a good reason NOT to use Gateway during development.

?

Richard

?


what happens with a gtd oca order after partial fill?

 

开云体育

Hello all,

The scenario with partial fills is very difficult to test on a live/paper account because you want to see the actual callbacks. Maybe somebody has run into the following scenario. I wasn't able to find anything on this specific subject in the archive.

My algo sends an oca order to tws, 1 parent, 4 child orders. The parent is a lmt order with gtd set to 1 minute into the future. If the lmt is not triggered within 1 minute, I get the cancel callback, and everything is fine.

Suppose the trade is to go long 5 x mes future contracts. The order is partially filled with only 2 within 1 minute and then price goes higher. After 1 minute, the remaining part of the parent (3 x mes) is cancelled. I hope/assume that this does not cancel all child orders(?) Because that way, I would be left with an unprotected position of 2 x mes. In my tws futures presets, I have 'Oca group -> Reduced size' selected and also 'Overfill protection' checked. (and also set as an attribute by the algo on the oca orders).

Can anyone confirm that the partial position still has all child orders connected (but with size 2) after the parent is partially cancelled?

Also, I heard of the Order attribute 'allOrNone' to add to the parent, but this does not seem to work with mes futures. Such a thing would even be better. I've worked with crypto exchange api's, and there's something like fillOrKill, same thing.

Any suggestions for handling the partial fill on gtd oca order in a reliable way are welcome, thanks!

Greetings,
Raoul


Re: Dividend Plan available via API?

 

Dividends via RTD API still working fine with generic type 456.?
Documentation still available:

Cheers,
Marcos



En martes, 14 de mayo de 2024, 11:49:53 CEST, Gonzalo Saenz <yo@...> escribió:


This is … well… interesting

I was reading available tick types, and realised that 258 (fundamental data) is not in documentation anymore. However it still works

A tick list “258,456” would return bot fundamental ratios and dividend information. I don’t know for how long.


On 30 Apr 2024, at 22:44, ApiMadness <mwboxtwo@...> wrote:

Good news...

I opened a ticket with IB support on this issue asking them if there?s an option to retrieve upcoming dividends via API. Maybe it?s interesting for others as well.

Dividend data can be retrieved with?reqMktData?query using?generic tick 456 and tick ID 59.?

A full overview of tick types can be found here:



Not sure if I?ll be able to implement this query but I?ll try. :)

Nevertheless it would interesting to know why my request for wshEventData doesn?t work.?

Cheers
Marc



Am So., 28. Apr. 2024 um 20:24?Uhr schrieb Mel via??<climbermel=[email protected]>:

It appears there is.? I haven't tried it but here is the link:

Mel


On 4/28/2024 1:10 AM, ApiMadness via??wrote:
Hi there,

can someone tell me if dividend plans for single stocks including upcoming dividends are avaiable via API?

Cheers,
Marc




Re: Dividend Plan available via API?

 

开云体育

This is … well… interesting

I was reading available tick types, and realised that 258 (fundamental data) is not in documentation anymore. However it still works

A tick list “258,456” would return bot fundamental ratios and dividend information. I don’t know for how long.


On 30 Apr 2024, at 22:44, ApiMadness <mwboxtwo@...> wrote:

Good news...

I opened a ticket with IB support on this issue asking them if there?s an option to retrieve upcoming dividends via API. Maybe it?s interesting for others as well.

Dividend data can be retrieved with?reqMktData?query using?generic tick 456 and tick ID 59.?

A full overview of tick types can be found here:



Not sure if I?ll be able to implement this query but I?ll try. :)

Nevertheless it would interesting to know why my request for wshEventData doesn?t work.?

Cheers
Marc



Am So., 28. Apr. 2024 um 20:24?Uhr schrieb Mel via??<climbermel=[email protected]>:

It appears there is.? I haven't tried it but here is the link:

Mel


On 4/28/2024 1:10 AM, ApiMadness via??wrote:
Hi there,

can someone tell me if dividend plans for single stocks including upcoming dividends are avaiable via API?

Cheers,
Marc




Re: Historical short fee data from IB FTP

 

I have that file daily from 2022-03-23 to the present day. Let me know if you still need it.


Re: Problem with RTD and Excel

 

Reverting to the 10.19 version did fix it. I typically use the online version and the automated updates seems to have got me in this case. IB seems to be pretty lax in their regression testing.
Thanks very much 闯ü谤驳别苍.

Jim


Re: Problem with RTD and Excel

 
Edited

I am not familiar with the Excel and RTD Server integration details. Maybe someone who is would know how to specify a genericTickList from within the spreadsheet. According to the "" page, no special "generic ticks" need to be specified during data subscription to get Last and Close prices.

The RTD Server source code contains some hard wired genericTick lists in file TwsRtdServerData.cs. The two types 576 and 578 are included in the list for STOCK market data requests even for TWS API 10.29. So for now, the only immediate workaround I can see is to use TWS 10.19.

And I would not call 10.19 an "old" version. It is the most stable TWS version available and while the "latest" 10.29 may have a few more features, it is the bleeding edge, very likely contains somewhat serious bugs, and definitely code that has not been battle tested yet. In fact the rejection of ticks 576 and 578 may actually be a bug since the TWS 10.29 release notes do not mention any generic tick retirement. Zou should file a ticket with IBKR.

I exclusively use TWS "standalone stable" versions in production.

闯ü谤驳别苍






On Sun, May 12, 2024 at 03:47 PM, JimInNeavitt wrote:
Thanks 闯ü谤驳别苍.
Where can I edit the list of ticks? Is that possible within the RTD
client or something it calls? I merely ask for 1 tick value (Last or
Close depending on Stock/Fund) in my cell formula, I assume a process
making the request for all tick types and something in the RTD is
filtering for just what I asked for.

Or am I stuck with reverting back to the older version of TWS?

Jim

On Sun, May 12, 2024 at 4:10?PM 闯ü谤驳别苍 Reinold via groups.io
<TwsApiOnGroupsIo@...> wrote:

Your problem is very likely not related to the Excel/RTD integration but all languages will experience this.

Over the years, the legitimate lists of generic ticks for each SecType changed occasionally. In many cases, new ticks were added, but in others, ticks were retired. If you have such retired ticks in your genericTickList upon reqMktData() subscription, the request will fail with the error message you describe.

I found that the error message and the API documentation were never quite accurate as to which ticks are legitimate and which ones aren't. A long time ago I wrote a small utility that that simply, in a brute force way, tries out all integer values between 100 and 699 for all SecTypes and displays the legitimate ones.

Apparently the "stable" TWS 10.19 allows two more tick types than the "latest" TWS 10.29. Those are 576 and 578 that you seem to have in your genericTickList. So I'd expect your spreadsheet should work with TWS/IBGW 10.19 but fail on 10.29 (and maybe others). Or just remove them from your list.

闯ü谤驳别苍

TWS 10.19 STK 100, 101, 104, 105, 106, 165, 220, 221, 225 232, 233, 236, 258, 292, 293, 294, 295, 318, 375, 411, 456, 460, 576, 577, 578, 586, 587, 588, 595, 614, 619, 623
TWS 10.29 STK 100, 101, 104, 105, 106, 165, 220, 221, 225, 232, 233, 236, 258, 292, 293, 294, 295, 318, 375, 411, 456, 460, 577, 586, 587, 588, 595, 614, 619, 623