¿ªÔÆÌåÓý

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

Re: How to get all VALID options

juxeiier
 

Hi Michael,

you might wanna try this little tool I have written, see /g/twsapi/topic/little_tool_for_option_chain/81408600?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,81408600
It basically frees you from doing all of this and provides a fast caching mechanism if? you reload your application.

Cheers,
Juergen


Re: Help getting realtime data stream via TWS API for TICK-NYSE and TRIN-NYSE

 

Go into TWS and right click on any instrument (TRIN or TICK) and select Financial Instrument Info -> Description.? The correct information to put into the Contract object will be specified on the left side of the window that pops up.? In the case of TICK you get:

Underlying = TICK-AMEX
Security Type = IND
Currency = USD
Exchange = AMEX
Symbol = TICK-AMEX

That's what you set for TICK-AMEX.

Hunter

On Thursday, March 18, 2021, 2:20:03 AM PDT, Ullas Diwakar <ullasdiwakar96@...> wrote:


Hi,

I want to get the data stream for the index TICK and TRIN. I read around the group and saw that i need to create the contract with the name TICK-NYSE and TRIN-NYSE with secType as "IND".

After that, I tried to subscribe to realtime data using both reqMktData and?reqRealTimeBars but I am not getting any ticks for it.

I want to know how to get the real time data stream for these two indices.?

Thanks


Help getting realtime data stream via TWS API for TICK-NYSE and TRIN-NYSE

 

Hi,

I want to get the data stream for the index TICK and TRIN. I read around the group and saw that i need to create the contract with the name TICK-NYSE and TRIN-NYSE with secType as "IND".

After that, I tried to subscribe to realtime data using both reqMktData and?reqRealTimeBars but I am not getting any ticks for it.

I want to know how to get the real time data stream for these two indices.?

Thanks


Re: How to get all VALID options

 

Filtering on SMART when dealing with US stocks is OK, but when you deal with foreign or commodities exchanges (MONEP, GLOBEX, NYMEX...), SMART doesn't work anymore.
This is my algo, compliant with any symbol any exchange:
I collect all answers from reqSecDefOptParams.
If SMART is present in the answers, I only keep SMART.
If SMART is NOT present, I keep all answers.


Re: event when a stock reaches a certain price

 

50 messages per second do not apply to this. However, there is some other limit, based on available market data lines.
But polling snapshots have another problem (at least it had a couple of years ago) - snapshot could be cached if polled too frequently. So instead of new prices, you are getting something stale.



On Thu, Mar 18, 2021 at 3:16 AM <sudhin_deshpande@...> wrote:
Instead of subscribing, why not poll each ticker to get the last price?
I think IB has a limit of 50 messages per second (correct me if I am wrong)
For 800 tickers, that would be 16 seconds. So you would poll each ticker about every 16 seconds.
Would that work for you?



--
Best regards,
Chernikov Aleksandr,
e-mail:?me@...
skype:?
RU:?+7-904-179-49-78


Re: Little tool for option chain contract creation

juxeiier
 

Thx Hartmut,

that is a good source to enhance the one I am working on.
I already have something working, which returns a pandas dataframe to do further analysis on the option data.

Cheers
Juergen


Re: Little tool for option chain contract creation

 

Hi,

ib-ruby () has the ability to work on atm, itm and otm-option-chains.

documentation


implementation


Perhaps its worth to take a look, to complete your program


Re: event when a stock reaches a certain price

 

You might have just solved that riddle for me, Bruce, why sometimes only four of the five TickByTick subscriptions succeed. I don't always subscribe to Level II data, so that seems to free up extra TickByTicks.

I tried to stay with IB terminology, so when I referred to market data for the ~75 contracts it means data streams from reqTopMktData() requests. No TickByTick or Level II data. But we determine all valid tick ids for each equity type (STK, FUT, IND, ..) and request everything they are willing to give. So while there is no TickByTick or Level II for those 75, the amount of data is quite substantial.

A long time ago we switched to mostly immutable objects, flow processing, and a logging strategy that favors logging complete objects over human readable text. That way we can drill down after the fact and are not limited to deciphering incomplete information in the log messages. Objects are being serialized into Json strings and saved with some rich extra context. Log files are being rolled every 15min and compressed with "gzip --best" n the background at low system priorities. That all is handled asynchronously in a couple threads and does not slow down IB API callback processing even under the heaviest of loads.

I just grabbed a random day that had 35 million IB callbacks:
  • With all the extra context and object serialization overhead, the average uncompressed object is 224 bytes long for a total of just shy of 8GB
  • But Json serialized objects compress very nicely so that that we store less than 12 bytes per object in average after compression or just over 400MB
This may sound like a lot of unnecessary overhead and long delays but it actually is not. Data stream serialization/compression and decompression/deserialization happen on the fly and it is quite liberating that you can insert any object type into the streams and get high-level language objects back into your business logic (without any extra work).

Processing can takes place in parallel on multi-processors and most systems have ample idle and otherwise unused CPU power for this.

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


On Wed, Mar 17, 2021 at 08:22 PM, Bruce B wrote:
JR,
?
You must have 8 market depth level 2 subscriptions.
?
I seem to have 6 subscriptions and can pull 6 full book depth level 2 but if I use?TickByTickBidAsk?that also counts towards marketdepthlevel2. Do you see the same?
?
By "That is *all available market data for ~75 contracts" I think you mean partial data as you do not get market depth level 2 for all 75.
?
What you mean by "I ask for five and most of the days I get five"? Some days you intentionally dont ask for five or something is not available on some days or not worth pulling based on your strategies?
?
Sounds like you have a good system running. I am interested to know how you store all this streaming data or if you do not see a point in storing it?
?
- Bruce


On Wed, Mar 17, 2021, 7:11 PM JR <TwsApiOnGroupsIo@...> wrote:
Can you be more specific what you consider huge? Did you buy quote boosters so that you can subscribe to more than 100 contracts?

From what you are doing, I'd say you'd only need to subscribe to monitor the Last Price and Last Size ticks. So you would look at roughly 4 - 5 call backs per contract per second.

You might want to review your approach and code. I am subscribing to a pretty massive amount of data (process and log them in a Json format) and my server does not break a sweat. And it's a very small server for today's standards. Just to give you some idea:
  • The total volume is between 30million and 60million ticks per day and sometimes more than 1,000 callbacks per second for busy days
  • That is all available market data for ~75 contracts
  • Plus TickByTickLast and TickByTickBidAsk for five contracts (yes five. I ask for five and most of the days get five)
  • Plus Level II for three contracts
We use the standard Java API..

´³¨¹°ù²µ±ð²Ô
On Wed, Mar 17, 2021 at 03:54 PM, corneliu maftuleac wrote:
Hi,

I am trying to monitor a list of tickers (lets say the list is big).
I want to know when one of the tickers reaches a certain price. The target price is generated by an algo so it's not just a %-change.

I tried subscribing to realtime data to all of the instruments but this generates HUGE amount of network traffic to the point that my code is not really able to process all of the events.
Is this possible to do with scanner subscriptions?
I dont find where I can specify that scanner subscriptions to work only with a specific ticker or a list of tickers.

?

?


Re: event when a stock reaches a certain price

 

Instead of subscribing, why not poll each ticker to get the last price?
I think IB has a limit of 50 messages per second (correct me if I am wrong)
For 800 tickers, that would be 16 seconds. So you would poll each ticker about every 16 seconds.
Would that work for you?


Re: event when a stock reaches a certain price

corneliu maftuleac
 

Thank you for the reference, that is good info to know.


Re: event when a stock reaches a certain price

corneliu maftuleac
 

> So each of your ticker has its own trigger price
That is correct, each ticker has its own trigger price. Criteria is not generic and is absolute (not in %).


Re: event when a stock reaches a certain price

 

So each of your ticker has its own trigger price or your trigger criteria is generic?


Re: event when a stock reaches a certain price

 

JR,

You must have 8 market depth level 2 subscriptions.

I seem to have 6 subscriptions and can pull 6 full book depth level 2 but if I use?TickByTickBidAsk?that also counts towards marketdepthlevel2. Do you see the same?

By "That is *all available market data for ~75 contracts" I think you mean partial data as you do not get market depth level 2 for all 75.

What you mean by "I ask for five and most of the days I get five"? Some days you intentionally dont ask for five or something is not available on some days or not worth pulling based on your strategies?

Sounds like you have a good system running. I am interested to know how you store all this streaming data or if you do not see a point in storing it?

- Bruce


On Wed, Mar 17, 2021, 7:11 PM JR <TwsApiOnGroupsIo@...> wrote:
Can you be more specific what you consider huge? Did you buy quote boosters so that you can subscribe to more than 100 contracts?

From what you are doing, I'd say you'd only need to subscribe to monitor the Last Price and Last Size ticks. So you would look at roughly 4 - 5 call backs per contract per second.

You might want to review your approach and code. I am subscribing to a pretty massive amount of data (process and log them in a Json format) and my server does not break a sweat. And it's a very small server for today's standards. Just to give you some idea:
  • The total volume is between 30million and 60million ticks per day and sometimes more than 1,000 callbacks per second for busy days
  • That is all available market data for ~75 contracts
  • Plus TickByTickLast and TickByTickBidAsk for five contracts (yes five. I ask for five and most of the days get five)
  • Plus Level II for three contracts
We use the standard Java API..

´³¨¹°ù²µ±ð²Ô
On Wed, Mar 17, 2021 at 03:54 PM, corneliu maftuleac wrote:
Hi,

I am trying to monitor a list of tickers (lets say the list is big).
I want to know when one of the tickers reaches a certain price. The target price is generated by an algo so it's not just a %-change.

I tried subscribing to realtime data to all of the instruments but this generates HUGE amount of network traffic to the point that my code is not really able to process all of the events.
Is this possible to do with scanner subscriptions?
I dont find where I can specify that scanner subscriptions to work only with a specific ticker or a list of tickers.


Re: historical open interest

 

So I did some reverse engineering of TWS and found that the WhatToShow enum is just turned into a string in the protocol.? It seems that when open interest data is being requested, WhatToShow is set to either "Option_Open_Interest Call" or "Option_Open_Interest Put" in the protocol.? Is this a valid thing to do for reqHistoricalData (not just reqHistoricalTicks) and this is just a short coming of the Java API (that the WhatToShow enum is missing some things)?? Or is this some weird hack that shouldn't work which is why it isn't documented by IB?

thanx,
Hunter

On Saturday, March 13, 2021, 8:48:31 PM PST, Hunter C Payne via groups.io <hunterpayne2001@...> wrote:


Hi all,
?? I was wondering if anyone knew a way to get historical open interest data on equities from IB.? Is it buried in reqFundamentalData somewhere these days?? I know I can find it in TWS itself but I can't seem to determine which API calls return this specific data.

thanx,
Hunter


Re: event when a stock reaches a certain price

 

I am not aware of a scanner that does what you are looking for. Please keep in mind the IB API is mostly for the support af TWS and if TWS does not need it, it's probably not there.

If you are only interested in price changes, subscribing to tick id 4 (Last Price) should suffice.That tick will only be sent when the trade price changes, Take a look at . Even at 800 contracts, data volume will be quite reasonable.

But your 800 contracts simultaneously will run against the data lines limitation. Take a look at the ":How Market Data is Allocated" in
For 800 market lines you'd need:
  • $6,400 in commission monthly
  • $8,000,000 in equity
  • or purchase 7 quote boosters at $30 each per month (210 per month)

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


On Wed, Mar 17, 2021 at 07:28 PM, corneliu maftuleac wrote:
I think the list of tickers is around 800 (I am using ibinsync python api, but the general idea is the same).

So, your suggestion is to just use regular market data (ex: reqMktData(conId, contract, 221)) and it should be fine?
I was thinking there should be a more advanced solution like a scanner subscription or something, because in fact I dont need the data itself rather just a notification when price reaches certain level.


Re: event when a stock reaches a certain price

corneliu maftuleac
 

I think the list of tickers is around 800 (I am using ibinsync python api, but the general idea is the same).

So, your suggestion is to just use regular market data (ex: reqMktData(conId, contract, 221)) and it should be fine?
I was thinking there should be a more advanced solution like a scanner subscription or something, because in fact I dont need the data itself rather just a notification when price reaches certain level.


Re: How to create a performance efficient trading app so each sub process runs smoothly in Python?

 

You can also think of using something like ZeroMQ as your messaging/concurency backbone.
Python has a bindings module for it - pyzmq.

On Wed, Mar 17, 2021 at 2:40 AM Alex Gorbachev <ag@...> wrote:
I love Python but it has its own place and it's not good for real-time-ish parallel compute. You can hack around things but in the end it won't be crazy.

You can consider Go and node.js from mainstream languages (apart from C++).
I personally always wanted to try Elixir but never got around - perfect for highly concurrent stuff.?

On Sat, Mar 13, 2021 at 2:52 PM matt <rmdeboer82@...> wrote:
What would be the best way to do on-the-fly computations using Numpy, Pandas for trading using IB TWS API, writing to/from mySQL, and in the meanwhile receive and send data and orders?

From (and ) I conclude that CPU-bound programs, those that spend most of the their time processing data (like on the-fly computations using Pandas which is synchronous single threaded), solutions like threading (pre-emptive multitasking) and asyncio are inferior (and may disrupt the sending/receipt of data or introduce some lag or data drops) since there is only one Python interpreter on a single core/processor (asyncio aligns I/O processes more efficiently) that takes care of both the CPU computations and checking for socket data.

I know there is? a ib_insync library that implements cooperative multitasking (asyncio) in Python, but will the overall program be fast enough if you do computations using large dataframes? I read that on a socket level there might not be any limitations (¡°socket itself is actually thread-safe¡±), as suggested by . I do not assume that Ptyhon has it implemented this way since the Global Interpreter Lock is in place (single thread, synchronous). From :

IB.sleep(0); may be an alternative, but I do not think a Pandas groupby() can be interrupted once called.

Should I use the Multiprocessing library and do every task on its own processor (thus dataframe calculations, mySQL connection read/write, sending and receiving orders and data)?
Or should I combine some things using (I think some next level threading which can be combined with the normal way of interpretation of code by Python) or the (has to do with built-in async for Scikit-Learn, Pandas, etc. functions, if I understand correctly) library? I think this is next level, and may be an overkill.

Or should stick to Java (I do not know if there is a Pandas like alternative which allows easy manipulation of data and performing machine learning for example, but threading may be organized better)?

Any suggestions or tutorials?

(I read something about was well, but that¡¯s a whole different story since it is not directly applicable to IB TWS API, and may be prone to delays resulting from single core processing/interpreting by Python as well, if I understand correctly)


unable to build with visual studio 2019 and cpp API 9.81

 

Hi,
I get the error?
Error MSB8020 The build tools for v142 (Platform Toolset = 'v142') cannot be found.
Do I need to make changes to project solution after downloading it?
I did install v142, not sure why it is not finding it.
Thank you


Re: event when a stock reaches a certain price

 

Can you be more specific what you consider huge? Did you buy quote boosters so that you can subscribe to more than 100 contracts?

From what you are doing, I'd say you'd only need to subscribe to monitor the Last Price and Last Size ticks. So you would look at roughly 4 - 5 call backs per contract per second.

You might want to review your approach and code. I am subscribing to a pretty massive amount of data (process and log them in a Json format) and my server does not break a sweat. And it's a very small server for today's standards. Just to give you some idea:
  • The total volume is between 30million and 60million ticks per day and sometimes more than 1,000 callbacks per second for busy days
  • That is all available market data for ~75 contracts
  • Plus TickByTickLast and TickByTickBidAsk for five contracts (yes five. I ask for five and most of the days get five)
  • Plus Level II for three contracts
We use the standard Java API..

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

On Wed, Mar 17, 2021 at 03:54 PM, corneliu maftuleac wrote:
Hi,

I am trying to monitor a list of tickers (lets say the list is big).
I want to know when one of the tickers reaches a certain price. The target price is generated by an algo so it's not just a %-change.

I tried subscribing to realtime data to all of the instruments but this generates HUGE amount of network traffic to the point that my code is not really able to process all of the events.
Is this possible to do with scanner subscriptions?
I dont find where I can specify that scanner subscriptions to work only with a specific ticker or a list of tickers.


event when a stock reaches a certain price

corneliu maftuleac
 

Hi,

I am trying to monitor a list of tickers (lets say the list is big).
I want to know when one of the tickers reaches a certain price. The target price is generated by an algo so it's not just a %-change.

I tried subscribing to realtime data to all of the instruments but this generates HUGE amount of network traffic to the point that my code is not really able to process all of the events.
Is this possible to do with scanner subscriptions?
I dont find where I can specify that scanner subscriptions to work only with a specific ticker or a list of tickers.