开云体育

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

Re: Cannot connect to Production API, test is OK.

 

We have not experienced any issues on our end, Lou, but then our setup is very different. Let me throw out a few thoughts, some or all of them you may have thought about yourself already:
  • Which version of TWS/IBGW are you running? Latest/Stable and Standalone/Autoupdate? Reason why I ask is that IBKR recently switched the stable track from the 981 level to the 10.12 level. There have been a lot of changes introduced in version 10 and I believe there are a couple new settings in the General API screen. Having said that, those TWS/IBGW changes should impact paper and real accounts equally.
  • Have you confirmed that the port for your real account in the TWS/IBGW API settings has not changed somehow? In other words, is the TWS/IBGW port really identical to the one you use in your client?
  • And finally, have you tried to get a "second opinion", meaning have you tried an API client that is very different from what you normally use? One that comes to mind is

Hope there is something here that gets you a step closer.

闯ü谤驳别苍

On Tue, Jul 5, 2022 at 06:36 PM, Lou Dudka wrote:

Hi All,

I suddenly (over the weekend) cannot connect on:
Call objTWSControl.m_TWSControl.Connect(connectionHost, connectionPort, clientId, False)
connectionHost is blank
connectionPort is correct in TWS API setup
clientId is correct and unique.

ONLY when trying to connect to Production.
I know we've all heard it before, but (to the absolute best of my knowledge) I've changed nothing.? This code is "as is" from IB and has not been changed ever.

If I simply switch (same XLS/VBA code) the connectionPort to the Test API port everything works.

My app (Excel/Win7/ActiveX) just hangs on the call. Old API code, don't know version.

Something changed over the weekend.

Thanks, as always, and Be Well,
Lou Dudka


Cannot connect to Production API, test is OK.

 

Hi All,

I suddenly (over the weekend) cannot connect on:
Call objTWSControl.m_TWSControl.Connect(connectionHost, connectionPort, clientId, False)
connectionHost is blank
connectionPort is correct in TWS API setup
clientId is correct and unique.

ONLY when trying to connect to Production.
I know we've all heard it before, but (to the absolute best of my knowledge) I've changed nothing.? This code is "as is" from IB and has not been changed ever.

If I simply switch (same XLS/VBA code) the connectionPort to the Test API port everything works.

My app (Excel/Win7/ActiveX) just hangs on the call. Old API code, don't know version.

Something changed over the weekend.

Thanks, as always, and Be Well,
Lou Dudka


Re: TWS Gateway: Requested market data is not subscribed

 

With a browser there's standard information passed back to the server (browser & version, OS & version, screen size, etc). When TWS or the Gateway connects who knows what is sent. It might send all sorts of data including it's own version number, the MAC address, the processor serial number, etc. Anything to identify a unique device.


Re: TWS Gateway: Requested market data is not subscribed

 

开云体育

I just wanted to add that I’m not trying to suggest we should actually try to get round this restriction on any kind of real usage, just that this experiment might confirm that it is in fact the MAC address that is used to check for the same device.

?

We should of course abide by the terms and conditions that IB holds us to.

?

?

From: [email protected] <[email protected]> On Behalf Of Richard L King
Sent: 04 July 2022 10:48
To: [email protected]
Subject: Re: [TWS API] TWS Gateway: Requested market data is not subscribed

?

Interesting thought, but as that Wikipedia article also says, ‘Many network interfaces, however, support changing their MAC address’ and ‘two NICs connected to two different networks can share the same MAC address’.

?

So if your guess is correct, that would give a potential way to overcome this restriction. For example, I run a set of virtual machines under Hyper-V, and that allows the virtual network adapters’ MAC address to be changed. So I could potentially set up clients on two different virtual networks, give them the same MAC address, and see if that bypasses the restriction. Might be an interesting experiment to try (when there’s nothing better to do…).


Re: TWS Gateway: Requested market data is not subscribed

 

开云体育

Interesting thought, but as that Wikipedia article also says, ‘Many network interfaces, however, support changing their MAC address’ and ‘two NICs connected to two different networks can share the same MAC address’.

?

So if your guess is correct, that would give a potential way to overcome this restriction. For example, I run a set of virtual machines under Hyper-V, and that allows the virtual network adapters’ MAC address to be changed. So I could potentially set up clients on two different virtual networks, give them the same MAC address, and see if that bypasses the restriction. Might be an interesting experiment to try (when there’s nothing better to do…).


Re: TWS Gateway: Requested market data is not subscribed

 

My guess is that the device's MAC address is analyzed because it is unique to every device.
https://en.wikipedia.org/wiki/MAC_address


Sample code for most common use cases?

 

开云体育

Hi all,

I wonder if there are sample codes of recommended methods for the most common use cases. I know IB API has sample code, but it's on very low level (e.g. get price of a stock). Sample codes of such use cases can be very helpful:
  1. monitor the price of stock XYZ. If the price reaches x1, send a limit order of price x2. If the price drops to x3, cancel the order if not executed yet.
  2. get option chain of SPX, filter the expirations and strikes by some defined rules, and monitor the prices (bid/ask) for the options filtered. If some condition is met, send an order to buy a spread (buy x and sell y)
I know IB API takes an async approach and implementing the above use cases can have various ways. I think any method from an experienced programmer would be good to start. It teaches newbies how to organize all pieces into a functional trading software.

Thank you!


Re: TWS Gateway: Requested market data is not subscribed

 

Out of curiosity, how does it know/detect that is the "same device"?


reqHistoricalData returns live data with date in the future

 

Hi all

As topic title, have a bit of an unusual one. So sometimes IBKR returns live daily data with date in the future, has anyone come across this problem?

I can handle it easily by restarting Gateway, but it irks me to no end that it happens, and more importantly I'm concerned that I have missed something somewhere that will manifest in a much nastier way down the track.

To illustrate the problem, on this just past Friday (1st July):
Using IBC, I run my script at 845am AEST(Sydney), and using reqHistoricalData it backfills daily data correctly up to and including 30th of June, and then it sits quietly until 10am (AEST) for market open to update me with live data.

-------------------------------------------
2022-07-01 08:45:25.529 [GS] INFO? [JTS-PostAuthenticateS2-23] - Started on 20220630-22:45:25
2022-07-01 08:45:25.529 [GS] INFO? [JTS-PostAuthenticateS2-23] - Default timezone:Australia/Sydney name:Australian Eastern Standard Time (New South Wales) dst:3600000
/////////////////////TRUNCATED///////////////////////////////
2022-07-01 09:59:53.444 [GS] INFO? [JTS-CCPDispatcherS2-35] - CCP reported time: 2022-06-30 23:59:53.000 (GMT) [1656633593000], local time: 2022-06-30 23:59:53.442 (GMT), local time: 2022-07-01 09:59:53.442 (AEST), difference in seconds: -0.442, handling delta:0 [Msg1]
2022-07-01 10:00:11.010 [GS] INFO? [JTS-EServerSocketNotifier-93] - [1:157:157:1:0:90:-1:INFO] Sending historical data update [requestId: 2]...
2022-07-01 10:00:11.012 [GS] INFO? [JTS-EServerSocketNotifier-93] - [1:157:157:1:0:90:-1:DET] [90;2;541;20220702;40.830;40.740;40.840;40.710;40.82844666903462;413859]
-------------------------------------------

As a test, I sat and watched it feed me data from the '2nd of July' for more than an hour before manually handling it.

It seems that the Gateway reads my login screen settings correctly and knows that my computer is in AEST timezone, and gives me historical data correctly, but when it returns live data, it adds 1 day to the date which in this case, the 2nd of July being a Saturday and therefore not a trading day, makes no sense.

From my understanding of the IBKR github, with reqHistoricalData and keepUpToDate=True, there is no way to set a timezone as it just reads off the TWS login screen. I have checked my TWS login screen timezone, Windows timezone settings, combed through this group's topics as well as done a code review and nothing has come to mind.

If this wasn't an intermittent problem then I would just subtract 1 from the date to make it work properly or perhaps use reqRealTimeBars, but the fact that restarting Gateway can usually resolve this problem suggests to me the issue is somewhere else.

Has anyone else come across this or have any ideas/thoughts?

Cheers and thanks in advance


Re: Gateway disconnects multiple times daily at around 2pm, sometimes failing to reconnect

 

On Wed, Jun 29, 2022 at 06:05 PM, Kevin wrote:
e
I have the same experience as you Kevin, not sure why, since I've selected 'Asia' server in the TWS/Gateway login screen. I've found the IB response rate on tickets this year has also been abysmal, they must be snowed in. I might give them a call one of these days and see if they can offer any further insight or solutions. Otherwise, I'll keep using IBC to handle the disconnects


Re: tickPrice tick type "4" (last price) not being emitted for Forex?

 

开云体育

I can’t imagine that they would have trade prices either. Try it and see for yourself?

?

As I understand it, the raw data for the Forex feeds from IDEALPRO come from a wide variety of different sources, and many (all?) of them just don’t disseminate trade info.

?

?

From: [email protected] <[email protected]> On Behalf Of dam5h
Sent: 01 July 2022 19:41
To: [email protected]
Subject: Re: [TWS API] tickPrice tick type "4" (last price) not being emitted for Forex?

?

Got it, does that mean the the 5 sec real time bars also don't contain actual trade prices but rather mid points too?? I suppose tick-by-tick subscription won't have last either then, is that right?

Best,

Dave


Best method to get prices of a batch of options?

 

开云体育

Hi everyone,

This might?be a silly question but I do appreciate your idea: I want to get the tick prices (bid and ask) of ~400 options (stock_symbols, expirations and strikes are known) to do some monitoring.

What's the best method to do this?

Currently I can use reqMktData(), but I wonder if there's any better way.

My code:
self.reqMktData(1111, ContractSamples.USOptionContract(), "", False, False, [])

? ? def USOptionContract():
? ? ? ? contract = Contract()
? ? ? ? contract.symbol = "NDX"
? ? ? ? contract.secType = "OPT"
? ? ? ? contract.exchange = "SMART"
? ? ? ? contract.currency = "USD"
? ? ? ? contract.lastTradeDateOrContractMonth = "20220705"
? ? ? ? contract.strike = 11600
? ? ? ? contract.right = "C"
? ? ? ? contract.multiplier = "100"
? ? ? ? return contract

Thanks!


Re: tickPrice tick type "4" (last price) not being emitted for Forex?

 

Got it, does that mean the the 5 sec real time bars also don't contain actual trade prices but rather mid points too?? I suppose tick-by-tick subscription won't have last either then, is that right?

Best,

Dave


Re: tickPrice tick type "4" (last price) not being emitted for Forex?

 

开云体育

They don’t transmit “last” because they don’t have that information. I believe this is documented somewhere, but I don’t recall where.

?

What you see as “last” in TWS is actually the bid/ask midpoint. If you watch very intently, you can see that “last” changes every time the bid or ask changes, and it takes values ending in .3 or .8 if the spread is a half-tick multiple.

?

Richard


Re: tickPrice tick type "4" (last price) not being emitted for Forex?

 

Thanks @Orionn.? I did assume that about volume since that is usually the case with forex, but crazy they don't tell you about the actual trades. They clearly show "last" in TWS, wonder why they don't transmit it.? I suppose that leaves the 5 sec real time bars as the only way to understand what prices were actually traded on spot.

I may try a tick by tick last request and see if that provides any streams for last.? Do you happen to know if that may work?

Best,

Dave


Re: tickPrice tick type "4" (last price) not being emitted for Forex?

 

That is the expected behavior. IB never provided last price nor volume data for Forex (and metals like XAUUSD). Only bid/ask data is provided. To get last price and volume data you need to request data for Forex futures contracts. Hope this helps.

--


tickPrice tick type "4" (last price) not being emitted for Forex?

 

I am working on an application and using the free forex feed for now, GBPUSD.? When I subscribe to market data using "233" as the generic tick type, which should be RTVolume, I am only getting tick Price updates for tick type 1 and 2, or bid and ask.? I never seem to get a tick type of 4 (which is last), even though I am seeing plenty of trades and GBPUSD is obviously very active.? Could this be related to forex vs other contract types?

Thanks!


IB Gateway Error: AccountTradingSummary was not resolved for account U****

 

开云体育

I started noticing that my request positions queries fail, but only when connecting via the IB Gateway.? Using the API through TWS Workstation seems fine.? I enabled logging in the IB Gateway and it prints the following error messages.? The errors appear to be internal to Gateway, but it was working in the past.? I think it was fine the day before yesterday.? Anyone else seeing this?

2022-06-30 10:37:56.843 [UK] INFO ?[JTS-CCPDispatcherS2-37] - FixDailyPnL received: requestId=PLR.16 referenceRequestId=null account=F23.
2022-06-30 10:37:56.843 [UK] WARN ?[JTS-CCPDispatcherS2-37] - Error
twslaunch.jutils.SLogging$Warning: AccountTradingSummary was not resolved for account F23.
??????at twslaunch.jutils.au.z(au.java:287)
??????at feature.pnl.s.a(s.java:1072)
??????at jconnection.usermsg.q.a(q.java:42)
??????at jconnection.usermsg.X.a(X.java:246)
??????at jconnection.ae.b(ae.java:849)
??????at jconnection.ae.a(ae.java:666)
??????at jconnection.ac.a(ac.java:585)
??????at jconnection.ac.o(ac.java:299)
??????at twslaunch.jconnection.aC.run(aC.java:172)
2022-06-30 10:37:56.843 [UK] INFO ?[JTS-CCPDispatcherS2-37] - FixDailyPnLFrozenPrice received: requestId=PLR.16 referenceRequestId=null account=F23.
2022-06-30 10:37:56.843 [UK] WARN ?[JTS-CCPDispatcherS2-37] - Error
twslaunch.jutils.SLogging$Warning: AccountTradingSummary was not resolved for account F23.
??????at twslaunch.jutils.au.z(au.java:287)
??????at feature.pnl.s.a(s.java:1460)
??????at feature.pnl.s.a(s.java:1444)
??????at feature.pnl.s.b(s.java:1386)
??????at jconnection.usermsg.p.a(p.java:45)
??????at jconnection.usermsg.X.a(X.java:246)
??????at jconnection.ae.b(ae.java:849)
??????at jconnection.ae.a(ae.java:666)
??????at jconnection.ac.a(ac.java:585)
??????at jconnection.ac.o(ac.java:299)
??????at twslaunch.jconnection.aC.run(aC.java:172)
2022-06-30 10:37:56.926 [UK] INFO ?[JTS-CCPDispatcherS2-37] - FixDailyPnL received: requestId=PLR.17 referenceRequestId=null account=U137****.
2022-06-30 10:37:56.926 [UK] WARN ?[JTS-CCPDispatcherS2-37] - Error
twslaunch.jutils.SLogging$Warning: AccountTradingSummary was not resolved for account U137****.
??????at twslaunch.jutils.au.z(au.java:287)
??????at feature.pnl.s.a(s.java:1072)
??????at jconnection.usermsg.q.a(q.java:42)
??????at jconnection.usermsg.X.a(X.java:246)
??????at jconnection.ae.b(ae.java:849)
??????at jconnection.ae.a(ae.java:666)
??????at jconnection.ac.a(ac.java:585)
??????at jconnection.ac.a(ac.java:853)
??????at jconnection.ac.a(ac.java:477)
??????at jconnection.ac.o(ac.java:299)
??????at twslaunch.jconnection.aC.run(aC.java:172)
2022-06-30 10:37:56.932 [UK] INFO ?[JTS-CCPDispatcherS2-37] - FixDailyPnLFrozenPrice received: requestId=PLR.17 referenceRequestId=null account=U137****.
2022-06-30 10:37:56.932 [UK] WARN ?[JTS-CCPDispatcherS2-37] - Error
twslaunch.jutils.SLogging$Warning: AccountTradingSummary was not resolved for account U137****.
??????at twslaunch.jutils.au.z(au.java:287)
??????at feature.pnl.s.a(s.java:1460)
??????at feature.pnl.s.a(s.java:1444)
??????at feature.pnl.s.b(s.java:1386)
??????at jconnection.usermsg.p.a(p.java:45)
??????at jconnection.usermsg.X.a(X.java:246)
??????at jconnection.ae.b(ae.java:849)
??????at jconnection.ae.a(ae.java:666)
??????at jconnection.ac.a(ac.java:585)
??????at jconnection.ac.a(ac.java:853)
??????at jconnection.ac.a(ac.java:477)
??????at jconnection.ac.o(ac.java:299)
??????at twslaunch.jconnection.aC.run(aC.java:172)
2022-06-30 10:37:56.933 [UK] INFO ?[JTS-CCPDispatcherS2-37] - FixDailyPnL received: requestId=PLR.18 referenceRequestId=null account=U237****.
2022-06-30 10:37:56.934 [UK] WARN ?[JTS-CCPDispatcherS2-37] - Error
twslaunch.jutils.SLogging$Warning: AccountTradingSummary was not resolved for account U237****.
??????at twslaunch.jutils.au.z(au.java:287)
??????at feature.pnl.s.a(s.java:1072)
??????at jconnection.usermsg.q.a(q.java:42)
??????at jconnection.usermsg.X.a(X.java:246)
??????at jconnection.ae.b(ae.java:849)
??????at jconnection.ae.a(ae.java:666)
??????at jconnection.ac.a(ac.java:585)
??????at jconnection.ac.a(ac.java:853)
??????at jconnection.ac.a(ac.java:477)
??????at jconnection.ac.o(ac.java:299)
??????at twslaunch.jconnection.aC.run(aC.java:172)


updateAccountValue callbacks received but not accountDownloadEnd

 

Hi Everyone,

I'm subscribing to account updates with reqAccountUpdates(True, account_id) and receiving both?updateAccountValue and?accountDownloadEnd on the initial callback; however following that I only receive updateAccountValue?callbacks (every 3 minutes as expected) but with no accountDownloadEnd?callback. I though accountDownloadEnd?callbacks are also provided every 3 minutes, but it appears to not be so?? Anyone understand this behaviour?

Thanks in advance...

Dave


Can I get the dividend history of an ETF through API?

 

Hi All
I found there are only 2? related topics wshMetaData and wshEventData. but the sample codes from API document are too simple there.
Anyone has done some work with those API by any chance? if there is any demo code would be very helpful!
thanks a lot,

Annie