¿ªÔÆÌåÓý

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

Re: Expiring Limit order

 

I believe this should work in C# for a start:
order.Tif = "GTD";
order.GoodTillDate = "20210228 12:00:00";
Note that this will refer to TWS default timezone. Another timezone can be specified with the date-time, though I'm not sure which format to use. I rarely code raw api objects from scratch nowadays since I use a higher level of abstraction, so I can forget some details. See the api documentation for more information.


Excel VBA Code for downloading Interactive Brokers price history and Option Chains

 

Does anyone have excel VBA code that downloads interactive brokers price history and current option chains?


Re: Expiring Limit order

 

ds-avatar, can you please put an example with order expiring at noon? Thanks a lot!


Re: Expiring Limit order

 

Setting order's expiry time using the field GoodTillDate with Tif="GTD"?will usually be much less cumbersome and limiting in many ways than attaching the condition.

Despite the name, this option allows setting a precise time of day beside the date.



§ã§Ò, 27 §æ§Ö§Ó§â. 2021 §Ô., 07:52 Alex Gorbachev <ag@...>:

I'd like to place a limit order that expires in 60 seconds.

I'm using the ib-insync Python module.
After reading docs, googling and some experiments I figured that this works:
? ? order = ibi.LimitOrder('BUY', 100, 42)
? ? until_time = ibi.util.formatIBDatetime(datetime.datetime.utcnow() + timedelta(seconds=60))
? ? order.conditions = [ibi.TimeCondition(isMore=False, time=until_time)]
? ? order.conditionsCancelOrder = True
? ? trade = ib.placeOrder(contract, order)

I wanted to confirm if this is the correct way of doing it or there are better ways.

Also, I wanted to place a stop limit order where limit order would expire 60 seconds after it becomes active (i.e.?once it's activated by price touching the stop level). Is that even possible or I just need to subscribe to ticks/market data and place my expiring stop limit order manually?

Thanks in advance,
Alex


Expiring Limit order

 

I'd like to place a limit order that expires in 60 seconds.

I'm using the ib-insync Python module.
After reading docs, googling and some experiments I figured that this works:
? ? order = ibi.LimitOrder('BUY', 100, 42)
? ? until_time = ibi.util.formatIBDatetime(datetime.datetime.utcnow() + timedelta(seconds=60))
? ? order.conditions = [ibi.TimeCondition(isMore=False, time=until_time)]
? ? order.conditionsCancelOrder = True
? ? trade = ib.placeOrder(contract, order)

I wanted to confirm if this is the correct way of doing it or there are better ways.

Also, I wanted to place a stop limit order where limit order would expire 60 seconds after it becomes active (i.e.?once it's activated by price touching the stop level). Is that even possible or I just need to subscribe to ticks/market data and place my expiring stop limit order manually?

Thanks in advance,
Alex


Re: FXCONV support in API?

 

Hi Josh,

Where is supported? in market data streaming or in orders? I don't see any mention of it in API. Is it spelled as fxconv?

For virtual positions reporting you mean settings of TWS or settings of account from Web Portal?

Thanks,


Re: Getting full list of Exchange Listings via API.

 

There are 253 now on IBKR. You can request this from API using?reqMktDepthExchanges().



- Bruce


On Thu, Feb 18, 2021 at 06:28 PM, Aquiles P¨¢ez wrote:
Hello,?

Is it possible to request the complete list of Exchanges permitted? by IB using the API??

Also, are the contents of the all there is available for trading inside TWS??

I appreciate in advance any help you might provide.?


What are smart-routing groups?

 

Hi,

From contract details, what is a "smart-routing group"? I see that some bonds and forex have 4, 7, 12, etc...returning as AggGroup and most rest of the market don't have a number attached to them. I understand there may be different ways SMART routing works or different routes it takes for submissions but what do these numbers signify? For example for Forex, does it mean IBKR SMART routes certain currencies only to Asian markets, and rest to London, and rest to Chicago? If yes, can we as users have any control over this or no?

AggGroup
Aggregated group Indicates the smart-routing group to which a contract belongs. contracts which cannot be smart-routed have aggGroup = -1.

Thanks,


Re: Getting full list of Exchange Listings via API.

 

Unfortunately no there¡¯s nothing like that from the API. The website should be up to date with available exchanges, there are quite a few on there.?


Re: How can I get yesterday's volume at some moment of time for a stock?

 

You would need to call reqHistoricalData from the equivalent period from the prior day and sum the volume of the returned bars.?


Re: FXCONV support in API?

 

Yes it¡¯s supported, you just have to set the exchange field that way (instead of ¡®IDEALPRO¡¯). By the the way, you can also turn off the virtual positions reporting through the settings if you don¡¯t want to receive them.?


Re: Excel RTD "DelayedLast"

 

just as an fyi the PlPrice is the mark price, a calculated theoretical price of an instrument (which is why it¡¯s free), not always exactly equal to the last traded price.?


Re: How place orders before AND after market hours?

 

The ¡°Outside Rth¡± setting in the API applies to both before and after regular trading hours. You just have to make sure you have the ¡°Pre-Open session¡± flag unchecked in the TWS settings because it¡¯s incompatible.?


Re: question about server support and login best practice

 

Thank you Richard for pointing that out and huge thanks for maintaining IBC (and all your prior efforts in IBController as I learned).


On Sat, Feb 20, 2021 at 7:26 PM Richard L King <rlking@...> wrote:

No no no!

?

IBController is a defunct project that is no longer maintained.

?

It was superseded three ?years ago by IBC, which you can find at

?

?

IBC is fully maintained (by me as it happens) and works with every version of TWS/Gateway (a new release is imminent to cope with a change by IBKR in the installation location for the macOS version of TWS/Gateway 981.2r).

?

I don't know why the current owner of the old IBController project persists in not marking it as defunct: it is in no-one's interest to leave it in its current state.

?

Richard

?

?

?

From: [email protected] <[email protected]> On Behalf Of Alex Gorbachev
Sent: 20 February 2021 18:37
To: [email protected]
Subject: Re: [TWS API] question about server support and login best practice

?

I think you should look at IBController -?

Official from IBRK.

?

Or check a docker image like this -?

?

I took the latter and adapted for me.

I also managed to hack my way into running IB gateway on Google Colab to experiment.

?


Re: question about server support and login best practice

 

Sorry for the delayed?reply.. It worked out of the box for me but it uses an old version of the gateway.
I tweaked it to adjust to the latest gateway version but I am currently just using a bastardised version to run inside Google Colab (has to jump through some hoops) for my ongoing experiments.

There are some other docker examples available if you google.

On Sat, 20 Feb 2021 at 16:50 dent <1152dent@...> wrote:

how is your docker image working out for you Alex? GREAT intel by the way. I was wondering about this and the github is EXCELLENT!! thanks so much

On 2/20/21 12:36 PM, Alex Gorbachev wrote:
I think you should look at IBController -?
Official from IBRK.

Or check a docker image like this -?

I took the latter and adapted for me.
I also managed to hack my way into running IB gateway on Google Colab to experiment.

Alex

On Fri, 19 Feb 2021 at 07:37 Stuart Cracraft via <smcracraft=[email protected]> wrote:
My sens is that the current nature of IB is to provide two tools which either can be run.

One is a headful client cumbersmoe and poor UI called TWI and the other is a thinner client.

But that NEITHER of these can be programmed to?

?a) autostart at system boot (I run my clients on AWS and need absolutely no U/I.
? ? ?It is all done in CLI, with NO DESKTOP, to AUTOMATE it.

?b) NEVER require human interaction for the server to authenticate and login to the
? ? ?IB sservers to make paper and cash trades

?c) avoid a ¡°Sunday required U/I human login¡± - what is that? It went out in the 1970¡¯s¡­

My sense is that IB is backwards on the above, does not provide a mechanism for
serverless auto-login password WITHOUT mouse, keyboard, etc. but potentially
with the account + password sitting in a file, run automatically by a Unix/Linux (I use
Ubuntu) daemon, and doing the automation needful with HANDS-OFF.

Please correct me if my above perception is correct or incorrect and then the next question
is why possibly IB would not correct the above and take the final step to automate it all
the way out. This is supposed to be a platform to automate both paper and cash trading
to fully remove emotion and human activity from most market decisions about what to buy
and sell, when to do so, for improved performance.

The best analogy is , , and other platforms
which do ALL the selection and analysis robotically, the rebanacing robotically, and minimize all
human error, as the markets are too error-prone for humans to be in may confer extra security
in situations requiring robotic, boring, precise analysis and actions taken.

Pardon for the length of this question but I never got what think is a bottom line answer from
this list for the above

Stuart Cracraft

P.S. When replying to this email, please ensure you cc my personal email at smcracraft@...

And thanks for taking your time.



Re: How place orders before AND after market hours?

 

That isn't working.? Can you elaborate?? Calling outsideRth(true) does not allow me to trade both before and after market hours.? Details above in my first message.? This apparently requires the correct combination of calling outsideRth(true) and settings in TWS.


Re: How place orders before AND after market hours?

 

¿ªÔÆÌåÓý

You have to set the parameter rth.

Only works for supported markets/products




On 26 Feb 2021, at 09:22, FreeGoldRush <mike@...> wrote:

?Just wanted to give this one more chance to find some expertise.? Is anyone placing orders through the API both before and after market hours?


Re: How place orders before AND after market hours?

 

Just wanted to give this one more chance to find some expertise.? Is anyone placing orders through the API both before and after market hours?


Re: "update order" VS "cancel and creating order"

 

Well, I made the formula up based upon the US portion of the fee table and . There is also the article on that sheds more light on what this is about and the fine print under the examples:
Many exchanges charge fees to their members for orders that are cancelled or modified, and IB charges certain related fees to its customers to help cover these exchange fees. Please note however, that the Modify/Cancel fees listed above are not intended to be a direct "pass-through" of exchange fees. The Modify/Cancel fees that IB charges to its customers may be higher or lower than the fees that an exchange may impose on IB. IB may charge Modify/Cancel fees to its customers for orders sent to exchanges that do not impose such fees, or vice versa.
Just looking at this again I would probably change the wording slightly to:

In the US on each day, no fees are due unless (#Order Modifications + #Order Cancellations) / (#Order Executions) > 25

I don't know for sure, but I assume your example would work like this:
  • You'd get a credit of $0.25 since there was an order execution
  • You also get charged $0.01 since there was an order cancellation
  • So you end up with a net credit of $0.24
  • If that was the only order that day, you'd own nothing, the credit will expire, and you'd start from scratch the next day
But you could reach out to IB for clarification.and let us know what they say.



On Thu, Feb 25, 2021 at 01:41 AM, <tegicof991@...> wrote:
On Wed, Feb 24, 2021 at 12:10 PM, JR wrote
to pay fees if your ratio of (#Orders Cancelled or Modified / #Orders Executed) > 25
Thanks for these facts. Can you provide any IB link to the description of this formula?

You say, the above formula is only valid for direct routed orders, not for SMART.

The #Orders Executed is a little vague for me: Imagine an order with order quantity of 20. If 10 was filled, and 10 not, will this order be registered as already executed? If I cancel the order (where 10 is already filled, and the remaining 10 is discarded), will this order be registered as executed?
So (#Orders Cancelled or Modified / #Orders Executed) = 1 (the quantity of 10 canceled) = 1 (the quantity of 10 filled) < 25. Correct?


Re: "update order" VS "cancel and creating order"

 

On Wed, Feb 24, 2021 at 12:10 PM, JR wrote
to pay fees if your ratio of (#Orders Cancelled or Modified / #Orders Executed) > 25
Thanks for these facts. Can you provide any IB link to the description of this formula?

You say, the above formula is only valid for direct routed orders, not for SMART.

The #Orders Executed is a little vague for me: Imagine an order with order quantity of 20. If 10 was filled, and 10 not, will this order be registered as already executed? If I cancel the order (where 10 is already filled, and the remaining 10 is discarded), will this order be registered as executed?
So (#Orders Cancelled or Modified / #Orders Executed) = 1 (the quantity of 10 canceled) = 1 (the quantity of 10 filled) < 25. Correct?