¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Can IBC be invoked from within Excel?


 

¿ªÔÆÌåÓý

Bill

?

I think you¡¯re misunderstanding something.

?

You seem to think that IBC should just magically handle all these popups for you. But that is a completely false picture.

?

Every window that IBC handles is because it has been specifically programmed to do so. So if during your sequence of four hotkey commands several popup windows occur, I would have to write specific code for each one of them, consisting of code that recognises that particular window, code to decide whether to take any action, and code to actually perform the action. Deciding whether to take any action against a window may depend on user settings, or the current state of the program.

?

So no amount of you fiddling with WAIT commands is going to make the slightest difference to what IBC does.

?

I¡¯ve already told you that IBC CANNOT DO WHAT YOU WANT without a pile of work on my part that I¡¯m not prepared to do. So you are wasting your time and mine by imagining you can somehow coax it into working magic.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of William McMillan
Sent: 22 January 2023 02:00
To: [email protected]
Subject: Re: [ibc] Can IBC be invoked from within Excel?

?

Hi Richard,

?

Thank you very much for a?very?useful interface program.? It saves us having to manually handle all those monotonous popups.

IBC makes life a lot easier.? It handled hundreds of popups for me, although not all of them.? All my?analysis and order decisions are handled in Excel and VBA.? From Excel, I only issue these? 4 hotkey commands and nothing else to TWS.??

?

Shift+Ctrl+B ? ? ? ?Show BasketTrader
Shift+Ctrl+T ? ? ? ? Transmit Page? (Several popup windows)
Shift+Ctrl+X ? ? ? ? Cancel Submitted Orders and Discard Untransmitted Orders ? (One popup window)
Shift+Ctrl+C ? ? ? ?Close All Positions ? (Three popup windows)

?

I am now removing some of the WAIT commands in my VBA code and it may help your IBC to handle more?popup windows.? The wait states might be interfering.? ?I am attaching the log file from this run.? Hope I set it up correctly.

?

Thank you once again,

______

Bill

?

?

On Wed, Nov 30, 2022 at 4:28 AM Richard L King <rlking@...> wrote:

Bill

?

I can tell you absolutely definitively (as I¡¯m the IBC developer) that there¡¯s no way for IBC to do what you suggest in its current form. By all means spend some time trying to get a better understanding of how IBC operates (and actually using it is probably the best way ¨C just looking at the scripts is going to tell you little), but it won¡¯t get you any nearer to finding a solution.

?

My overall feeling is that your current approach is not a good solution to the problem you¡¯re trying to solve, ie getting orders out of Excel and having them executed by TWS. Fiddling around with sendkeys and that sort of thing is always going to be a source of frustration. The simple fact is that if your Excel can generate oven-ready orders (ie no need for any further examination or manipulation in TWS) then you really want to avoid having to try and automate the TWS user interface, because it would be adding no value.

?

That why I suggested my order-placing program. You already generate a file containing order info, so using my additional VBA code to generate the syntax my program expects should be straightforward. Once that is done, the orders will be executed automatically and flawlessly.

?

Of course I wouldn¡¯t expect you to just take my word for it. The time taken so set up the program and start using it against your paper trading account with the sample Excel worksheet that I mentioned before is less than the time that we¡¯ve spend discussing this issue so far.

?

But it¡¯s entirely your choice of course. And to be fair, there¡¯s always a concern when using something produced by a lone developer: what if I¡¯m suddenly not able to continue to develop and support it?... So I entirely understand why you might want to not go down that route, and I¡¯m certainly not trying to pressure you. Just suggesting, and try8ing to arm you with relevant facts.

?

R.

?

From: [email protected] <[email protected]> On Behalf Of William McMillan
Sent: 30 November 2022 02:41
To: [email protected]
Subject: Re: [ibc] Can IBC be invoked from within Excel?

?

Thanks Richard for your frank answer.? I will still look at the structure and content of IBC and examine the Script function to see if I can find a way to use it successfully.? I commend you for all your effort to help and assist other?users.??

______

Bill

?

?

?

?

On Tue, Nov 29, 2022 at 7:54 PM Richard L King <rlking@...> wrote:

Well, as I tried to explain before, if you use IBC then the popups won¡¯t be a problem, unless the Basket Trader itself generates popups : IBC doesn¡¯t currently take any notice of anything coming from there (I suppose I¡¯d better try the basket trader myself to get a better idea of what actually happens).

?

IBC could be enhanced to handle any such dialogs.

?

As far as your 3 questions are concerned, that exactly what the previously suggested (but currently non-existent command) would do. The first part of the command tells it to navigate through to the Basket Trader, the second part tells it what to put in various fields (in this case just the basket file), and the third part tells it what final action to take (load the basket). It may well be that more would be needed to actually execute the orders ¨C I¡¯m not familiar with it ¨C but that kind of command could be easily extended. What you think of as wait times are not an issue as IBC is designed to do this sort of thing for its own purposes.

?

The trouble is this is all a lot of work. It makes life nice for you, but it¡¯s a lot of work I really don¡¯t need.

?

So I think the short answer is that IBC is not going to be able to help you really.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of William McMillan
Sent: 29 November 2022 23:59
To: [email protected]
Subject: Re: [ibc] Can IBC be invoked from within Excel?

?

Richard,? ?Thank you very much for your quick reply with such a clear and thorough answer.

I would like to just verify whether IBC would be a viable solution for me.? At this time, whenever I submit a ¡°basket¡± of orders (Buy to Open and Stop Loss) I just have to ¡°click YES¡± to 2 popup windows, which is a pretty trivial manual task.? But if I have to do that a dozen times a day, my feet are nailed to the floor.

I currently start TWS before the market opens and I have it running for the entire trading day.? I do all my ¡°Quote Retrievals¡± and ¡°calculations¡± in Excel, then make my ¡°order decisions¡± and create a ¡°Basket of Orders¡±.? To ¡°Invoke¡± TWS, I just use the VBA statement ¡°AppActivate ("DU4439928"), True¡±.

I then ¡°Load¡± and ¡°Transmit¡± the orders using ¡°Sendkeys¡± to send just ¡°4 WTS Hotkeys¡±.? Then the dreaded ¡°2 or 3 popups¡± appear.? Of course, occasionally several other popups appear with information or warnings, which also have to be answered and closed before any orders will?be transmitted.

With ¡°Sendkeys¡±, timing is critical, and I have to use ¡°Wait Statements¡± to be sure that the actions are complete before the next keys are sent.? The performance of the Internet can play havoc with the timing, forcing me to over-estimate (which really isn¡¯t a problem) all the wait times.

Can an IBC ¡°SCRIPT¡± be set up to

1. ¡°Send the .CSV filename ¡± after I create the Basket File?

2. ¡°Send 4 consecutive TAB Clicks and an ENTER Click¡±? and

3. Answer and close all the random Popups? ?

And can it manage all the wait times in between??

THEN ¡­ can I ¡°Invoke¡± this script to be executed at any time, from Excel?

______

Bill

?

On Tue, Nov 29, 2022 at 1:52 PM Richard L King <rlking@...> wrote:

Bill

?

There¡¯s certainly no reason in principle why you shouldn¡¯t be able to start IBC from Excel in the same way, assuming SendKeys has the ability to ¡®click¡¯ an entry in File Explorer, or shortcut on the desktop (presumably that¡¯s what you do now?). This would automate the login (if desired), and would avoid the popups.

?

Alternatively you could easily run the IBC start script (.bat file) from Excel VBA.

?

But IBC doesn¡¯t provide a user-accessible equivalent to the SendKeys function, so you wouldn¡¯t currently be able to use IBC itself to poke TWS. However what you¡¯re currently doing using TWS hotkeys would presumably still work ¨C I have no experience of this, but TWS is TWS whether it¡¯s loaded manually or via IBC.

?

Having said that, IBC does have an internal mechanism to navigate the TWS menus (for example to load the Global Configuration dialog). It would, again in principle, be possible to expose this in various ways: for example by using IBC¡¯s command server, to be able to send a command like this to IBC:

?

ACTION path=¡±TradingTools | Basket Trader¡± values=¡±BasketFile:C:\My Baskets\BasketFile1.csv¡± click=LOAD

?

However, I wouldn¡¯t want to underestimate the work involved in doing this, so I¡¯d be unwilling to do it if this were its only application.

?

Another completely different possibility is that my own trading platform has a command line program that can read orders from a file (or interactively by user input) and submit them to TWS via the API for execution. As a simple example, the order file could contain this line:

?

BUY STK:MSFT@SMART 100 MKT

?

As you might guess, this would buy 100 shares of MSFT at market, using SMART routing.

?

A more advanced example:

?

BUY FUT:ES(0)@CME 1 LMT BID[-1T]

?

This would buy 1 contract of the current ES future at CME, using a limit order with the price set 1 tick below the current bid price.

?

An even more advanced example:

?

contract FUT:ES(0[2d])@CME

bracket buy 1

entry lmt /price:bid[-2t]

stoploss stp /trigger:entry[-10t]

target mit /trigger:entry[20t]

endbracket

?

Buy 1 contract of the current ES future (unless we¡¯re within 2 days of its expiry, in which case use the next contract) at CME; enter with a limit order 2 ticks below bid; create a stoploss using a STOP order with the trigger price set 10 ticks below the price achieved by the entry order; create a target (ie take-profit) market-if-touched order with a trigger price 20 ticks above the entry price.

?

As part of this capability, there is an Excel worksheet and associated VBA code that can generate the order files and pass them to the program for action (though it needs some updates to take account of syntax enhancements since I last updated it). This worksheet can be easily incorporated into a workbook such as yours, though some work would be needed to reconcile your current workbook layout with its expectations.

?

If you¡¯re interested in pursuing this last option, let me know. It¡¯s very easy to install the software, and there¡¯s no charge. I¡¯d need to give you a bit of guidance because the documentation hasn¡¯t caught up with the program¡¯s current functionality. By the way, I should point out that this particular command line program is part of a complete trading platform that includes manual trading clients, automated trading capabilities, historical data downloading, charting etc, so it¡¯s a fairly major piece of work developed over the past 18 years.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of william.a.mcmillan@...
Sent: 29 November 2022 05:52
To: [email protected]
Subject: [ibc] Can IBC be invoked from within Excel?

?

Richard,

Right now, I am using Excel to create a TWS ¡°Basket¡± of orders in a .CSV file.? Then I use the ¡°Sendkeys¡± function in Excel to open TWS and send ¡°TWS hotkeys¡±, to ¡°load¡± the .csv basket file and ¡°transmit¡± the orders.? But then TWS sends random POPUP messages which I have to MANUALLY answer and close before the orders are processed.? That defeats the entire automation effort.

Would I be able to open IBC from within Excel (just like I open TWS) and use IBC (instead of Sendkeys) to send the ¡°TWS hotkeys¡± and some TAB and ENTER commands to perform these steps and also ¡°handle and close¡± all the POPUP windows ¨C unattended?
______
Bill

Join [email protected] to automatically receive all group messages.