开云体育

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

C++ TWS API reqContractDetails() & reqSecDefOptParams()


 

Hi,
?
Why are these two tasks so slow? I am trying to create an interactive application where a user can just give a ticker, and basic settings like maximum days to expiration, ITM/OTM, and set a minimum dollar value purchase to alert on when a large purchase is observed on any of the calls or puts for the ticker. (I intend to put this in a production algorithm, but just testing right now to see if I can do this fast) The problem seems to be that when I read in the option chain with reqSecDefOptParams() for the ticker, even when drilling down on current selected settings to reduce the number of contracts to stream at once, they come with contract.conId = 0. I have to then reqContractDetails() again to get conId and its painfully slow. Am I missing something with reqSecDefOptParams()? Should they come with conId's filled out? Has anyone else observed this??
?
Thanks


 

Idea -> Create a python script, that finds all the conIds of the tickers I want to watch and potentially execute trades on pre-market. Store them in a database and load them all in my C++ application on initialization. That way I can just monitor the contracts on each one's individual data stream and avoid this painfully slow action while the market is live. Thoughts? I wouldn't have the freedom to allow a user to pick what to watch during the day, but atleast now I could do this faster. Maybe not use python actually, just do it in my C++ app pre-market directly and still store in a database locally to reload if I need a fast restart during the day.


 

I cache the reqContractDetails() requests.? I run a puller once every two or three weeks on the weekend that pulls the contract details for new options chains and then store the contract IDs.? Then when I want to look up later, I just pass in the cached contract ID to get a quote fast.? The updater also deletes expired entries so that the cache does not grow indefinitely.