¿ªÔÆÌåÓý

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

Re: WAP value provided by 'realtimeBar' vs. that shown in the TWS quote panel

 

VWAP involve a duration over which the averaging is done,
Assuming what you call RT bar are 5 sec bar, What time frame is TWS bar ? if it's day then it is perfectly normal they don't show same thing.
Does TWS on chart use use chart time frame ?
suggestion : ask Historical Day bar for current day with keepUpToDate =true? and compare it with TWS in Tab view, or see on chart, using chart time frame with historical bar updated.


Re: Question regarding reboot of trader workstation

 

When you connect you will get a call back that fire: nextValidId(OrderId orderId)
Which give you the next valid id you can use (seems more to be used as an index, so you are free to use anything higher as long as you commit yourself to be consistent in numbering. I can even guess that you can recycle old number, just a guess, it's a bad practice)
So you will never reach the 'long' limit. BTW: Hypothetical case if reset did not existed, 10 call/sec non stop 24 h/days then you can run ~7 Years before you hit the limit.

Not sure I understand your question about "will then all results be gone ?", yes all pending request is aborted (and that is good as it avoid to reconcile requestid),
This happens around 23:00 ~adjusted to your time zone so unlikely you are doing anything critical.
As per existing order/position if I understand your question there, no impact, it's unrelated, and it work as you would do it with TWS


Re: Getting news providers code

 

What you get is the exhaustive list of what you are allowed to use (normally linked to what you subscribed for)
Don't be lured by TWS that seems to work differently than Gateway, allowing you to see in the UI news you can't fetch trough the API.
Anyway even with TWS you cannot catch trough the API all you can read, (or I don't know how to do that)
I guess this is for copyright reasons as there is less risk that theses UI display news are "caught and forwarded" by bots, which is what providers are scared by.

FYI:
Once you get this list you should use it to call contractDetails which will give the exhaustive sub list of all feeds for each providers.
In your case it should come out with something essentially? like that (take what is after the ":" before is raw custom log)

+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_SMU,'Stock Market Update'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_ALL,'All News'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_STS,'Story Stocks'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_DSW,'Daily Sector Wrap'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_TECS,'Tech Stocks'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_RTB,'Rate Brief'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_FEDB,'Fed Brief'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_WKW,'Weekly Wrap'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_PONE,'Page One'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_TBP,'The Big Picture'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_MV,'Market View'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_WIP,'Week In Perspective'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_BIP,'Bond in Play'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_EDR,'Economic Data Review'
+>IBK? 120: reqInitNews contractDetails: BRFG:BRFG_UPDN,'Up/Downgrades'
+>IBK? 122: reqInitNews contractDetails: DJNL:DJNL_ALL,'All News'
+>IBK? 121: reqInitNews contractDetails: BRFUPDN:BRF_ALL,'All Briefing.com Events'


Re: Can not get more historical data.

 

You are requesting data for Nasdaq only ("ISLAND") and that's probably what you get. I say "probably" because meaningful historical data are not easy to get from IBKR, at least?in terms of specifying what exactly is?required. Equities frequently change symbols and move between exchanges, and to add insult to injury perform all sorts of mergers, splits and spin-offs. Data providers need do some stock forensics to keep track of all of this so as to get all the different varieties of adjusted current data, including gluing together data from different exchanges and for different symbols, all referring to the same stock. I'm not sure IBKR is very good at this.

TLT is likely no stranger to such disruption as Blackrock moved a lot of their iShares ETF's between ARCA, BATS and NMS in the previous decade. Therefore it is completely credible that there must be no Nasdaq (NMS) data for this stock between its inception date in 2002 and some more recent date in the past.

Unfortunately it doesn't get much easier from here. Generally I would suggest just using "SMART" for the exchange so that the API aggregates data from all exchanges for the equity in question. This seems to work with TLT but only partially. Indeed, with SMART we get 5 times as much volume as with ISLAND supporting the suggestion that this time it's data collected from many more venues than just NMS. However the historical period now is even shorter - we only get data from 2016 and later.

I have no sensible interpretation for this other that 2016 was yet another of those years when some significant event took place in the history of this equity and IBKR probably messed up its aggregation. Usually I believe SMART should naturally yield both the biggest volume and the longest historical period.

FWIW I managed experimentally to get data right from the very inception of TLT in 2002 using exchange="ARCA". I guess that was the original exchange where TLT started to trade. But even though this data is available for the whole lifespan of TLT from 2022 right to 2023, the volume is again much smaller than with SMART (when it's available) since, naturally, we only get data for a single trading venue rather than the whole market, and one that has not even been primary for some years now, suggesting that the critical EOD prices in this period may not precisely match the official consolidated tape closing prints widely used for daily price tracking.


Getting news providers code

 

I tried to follow the instructions?
on how to get list of news providers codes,?but ended up only with:?

NewsProviders:?
NewsProvider. Code: BRFG, Name: Briefing.com General Market Columns
NewsProvider. Code: BRFUPDN, Name: Briefing.com Analyst Actions
NewsProvider. Code: DJNL, Name: Dow Jones Newsletters

How can I get Reuters code for example?


Question regarding reboot of trader workstation

Arthur
 

Hi all,
i read somewhere in the documentation that the trader workstation is designed to reboot every day. If this is the case, will then all results be gone ? No historical Profits ? The more important question is the variable that is incremented for every request, can it then start with value '1' again ?? Because if this isnt the case (the datatype is long ) theres a limit for the number of requests that one can send.

Please clarify

regards,
Arthur


Re: Can not get more historical data.

 

Sure, thanks!
I mean I got the earliest available data point of SPX from CBOE is 20040304.
--
_QX


Re: link with symbol that open the symbol on tws client ?

 

On Thu, Aug 3, 2023 at 08:58 PM, ´³¨¹°ù²µ±ð²Ô Reinold wrote:

That will definitely void your warranty big time

Lol, I didn't know there was a warranty!


Re: link with symbol that open the symbol on tws client ?

 

That will definitely void your warranty big time, buddy, will be a lot of work, easily breaks whenever TWS is updated, and inherits all kinds of other problems.

I think @frodfrog's comment about display groups is a good one. The interface is simple but allows the TWS API client:
  • to query which groups exist and understand which instruments are assigned to each group
  • to subscribe to display group events such that the client gets a real-time update whenever the TWS user uses a different display group
  • to change the display group currently used by TWS
  • to define or redefine the mapping of instruments to groups

Beyond that, Richard King's IBC may possibly be the base for a more involved TWS/IBGW automation (Groups.io, ). It is very reliable, but Richard needs to maintain it frequently when new TWS updates arrive.

And finally, there are several JavaFX automation frameworks. TWS/IBGW are built on-top of the JavaFX GUI framework which provides hooks for automation (usually for automated application testing). There are several "robot" libraries out there that can query the current structure of the display and mimic all user input (typing, mouse movement, clicking).

But anything other than the TWS API display groups requests will definitely require much more effort than "a weekend and a few six packs".

´³¨¹°ù²µ±ð²Ô


On Thu, Aug 3, 2023 at 03:04 PM, buddy wrote:

The IntelliJ Java de-compiler also seems to be pretty robust if you're that determined. I took a gander at the jar files and there isn't as much obfuscation going on as I expected.

find ~/Jts/1019/jars/ -type f | xargs -I% unzip -l % | grep -Po 'com/ib/.*?/[^/]+' | sort | uniq | grep -v '\.class$'

So, I'm not sure you couldn't re-arrange your class path in an order such that TWS is effectively wrapped by a custom Java application.

Practically speaking however, I'm not in favor of this idea... strikes me as a potentially fun academic exercise though. I'd just stick to using the API as intended.


Re: link with symbol that open the symbol on tws client ?

 

The IntelliJ Java de-compiler also seems to be pretty robust if you're that determined. I took a gander at the jar files and there isn't as much obfuscation going on as I expected.

find ~/Jts/1019/jars/ -type f | xargs -I% unzip -l % | grep -Po 'com/ib/.*?/[^/]+' | sort | uniq | grep -v '\.class$'

So, I'm not sure you couldn't re-arrange your class path in an order such that TWS is effectively wrapped by a custom Java application.

Practically speaking however, I'm not in favor of this idea... strikes me as a potentially fun academic exercise though. I'd just stick to using the API as intended.


Re: Pairs trading: Parent vs Child order placement

 

You might want to read-up on the subtle differences between Bracket orders, Hedge orders, and Once Cancels All orders (OCA). A good start is the of the TWS API Guide and the I explorer..
  • Bracket orders are limited to one symbol but they are linked together very closely so that IBKR even adjusts quantities should the entry order fill only partially.
  • OCA have the least limitations and you can wrap orders for different instruments, brackets, BUY and SELL orders for the same instrument, ...

You can combine Bracket, OCA, and Hedge orders to model quite complex order constructs that are active r pending within the IBKR system regardless of your TWS/IBGW and client application status.

Below an example of an order with several generations of attached orders. This works as long as you meet the of "20 active orders per contract per side per account". The example bracket order has four layers and a total of 12 individual orders:
  • The parent order is a limit entry order
  • It has three child orders in the bracket: profit taker, stop loss, and an auto position close order for 15 min before market close.
  • The profit taker and stop loss orders each are parents for the same construct (profit, loss, auto close)

This was just an example and may not make sense in real trading.

´³¨¹°ù²µ±ð²Ô


Re: Pairs trading: Parent vs Child order placement

 

Quick follow up, it is possible to have parent, child and grandchild (and so on) orders when submitted via the API.



WAP value provided by 'realtimeBar' vs. that shown in the TWS quote panel

 

Hello,
Does anyone know the difference of?WAP value provided by 'realtimeBar' vs. the VWAP value shown by the TWS quote panel? I saw some 10+ years old post here and seems folks thought the WAP provided by 'realtimeBar' is either wrong or is using some unknown algo. I wasn't sure if it's still true? For me they do come out to be quite different. For e.g. today I checked WAP value for NFLX reported via 'realtimeBar' API as $440.22 while on TWS quote panel (which is same as drawn on chart) it showed as $437.30.
I contacted IB customer support and they asked me to submit my logs, which I did.. yet to hear from them.
Also, do any API provide the VWAP value shown in TWS quote panel Or is it just better to calculate it locally?

Thanks.


Re: link with symbol that open the symbol on tws client ?

 

An alternative is to write a CSV file according to the format that IB support for export/Import a tab. Try save a tab (export Instrument) and analyze the aspect of it.
This can be quit convenient if you need to format a tab, It allows a Header "HED" with custom content and to specify a list of symbols. start with "DES", and allow to add empty lines, ...
But still need manual action (or a robot) to load it

CSV contain look like:

HED,GAIN
DES,AIG,STK,SMART/AMEX,,,,,
DES,QGEN,STK,SMART/AMEX,,,,,
DES,USB,STK,SMART/AMEX,,,,,
DES,CTRA,STK,SMART/AMEX,,,,,
DES,MRO,STK,SMART/AMEX,,,,,


Re: Can not get more historical data.

 

I don't see a way to do it because if you call HeadTimeStamp for TLT you will get: Wednesday, May 13, 2009 11:00:00 AM

This say that there is no data available before this date and show that what you got is relevant with this information.
I am not sure I understand what you mean by "And there is more data from 'CBOE', around 2004." ?


Re: Pairs trading: Parent vs Child order placement

 

Came across this behaviour and find it equally perplexing.

Essentially

- Parent orders cannot have child orders on different contracts
- Hedging orders do not allow you to specify quantity
- It doesn't seem to allow children of children orders (at least not in my tests, i might not have been thorough enough here)

This basically means that if you want to do any kind of custom hedging with different contracts or currencies you have to have an IB server locally to respond to all the incoming order updates, vs. just setting up all of the order trees and just forgetting about it.


Can not get more historical data.

 

I found that I only can get the historical data from 2009/05/13 to now from 'ISLAND'. And there is more data from 'CBOE', around 2004. How to get more historical data?
Here is my code:

Stock_name = "TLT"
mycontract = Contract()
mycontract.symbol = Stock_name
mycontract.secType = "STK"
mycontract.exchange = "ISLAND"
mycontract.currency = "USD"
self.reqHistoricalData(orderId, mycontract, "20230802 16:00:00 US/Eastern", "25 Y", "1 Day", "TRADES", 0, 1, 0, [])
--
QX


[Moderator edit: Removed unrelated code]


Re: How can I get the SPX closing price?

 

I don't think this is correct if today's close price is required because tick #9 always reflects previous day's close price, even after current day's liquid trading close.

This is true for stocks though I can't be certain about indexes.

With stocks AFAIK there is no reqMktData tick that shows today's closing price in the API. However many workarounds exist such as requesting the last RTH price after the close (tick #57) or getting today's 1-day historical price bar limited to RTH and extracting the closing price from it.

--
Best,
DS
?


Re: What API does Sterling Trade Tech use?

 

Ah I thought it was the case, thanks for clarifying, then the best is to just stick to the IB Gateway indeed.


Re: What API does Sterling Trade Tech use?

 

But the Client Portal API still requires you to install and run an IBKR supplied small (most likely locally hosted) Java gateway. The OP wanted to avoid having to install some IBKR gateway. The REST services provided by Client Portal API do not talk with IBKR servers directly.

´³¨¹°ù²µ±ð²Ô


On Tue, Aug 1, 2023 at 02:31 PM, John wrote:
An option not mentioned thus far is the web API which doesn't cost anything to my knowledge, and only requires an internet connection. If your trading app is simple enough and doesn't require low latency. Of course this only gives like 1% of the features available via the full fledged TWS/GW API but there are cases where that's enough to manage a portfolio.