Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Live data on multiple contracts - Python
Hello!
?
I am not a programmer by trade. I started messing around with the TWS API as a side project to learn a little bit of coding.
?
I have figured out how to get historical data, get a full option chain etc. A friend of mine helped me figure out how to dump all the data I want into a CSV file.
?
I recently also took a day off of work to play with the code during market hours to see how live data works and because there is no greeks and no volume for options available in historical data.
?
Now, the line of code that requests live data is:
app_underlying.reqMktData(app_underlying.nextId(), option_contract, "", False, False, []) ?
where app_underlying is the instance of TestApp (I kept the name the same as in the IBKR documentation and basic tutorials on IBKR campus) and option_contract is an instance of Contract().
?
Now, suppose there is 50 contracts between all calls, puts, strikes, and expirations. I was thinking of instantiating Contract() class for every single one of those options.
?
But, how do I live stream all of them? Do I also have instantiate 50 TestApp() classes:
app_underlying = TestApp() and give each one a unique clientid and run threading on every one of them?
?
Thanks in advance!
? |
You would have only one TestApp(). But you would remember the value of app_underlying.nextId() used for the subscription of each contract since future data callbacks will contain that requestId. That way you know which market data item belongs to which contract. Hope that helps. ´³¨¹°ù²µ±ð²Ô ? On Thu, Apr 24, 2025 at 09:21 PM, <danielsojka1@...> wrote:
...
?
?
?
|
to navigate to use esc to dismiss