Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: reqContractDetails() does not get a callback if secType = "OPT"
Yep, you need to specify the option multiplier ("100").
?
You don't need to set conId = 0 unless you're reusing the same contract for the option as for the underlying; otherwise, I've noticed TWS will simply retrieve the contract associated to the conId if not 0. |
Re: Anyone has code to show all option chain names for a symbol?
You're welcome :)
?
Regarding Open Interest, I don't use it but found this (very old) thread that mentions the tick types you could set in your reqMktData() call:
?
Basically, it says that you should add generic tick 101 to the reqMktData() function:
m_pClient->reqMktData( ++m_requestId , retContract, "101" , false , false , NULL ); ?
This should return a value in the tickSize() callback.
?
In the callback, just check the value of the field parameter and if it's field = 27, then the?size parameter will be the call open interest, and if field = 28 then it will be the put open interest. |
Re: Anyone has code to show all option chain names for a symbol?
Hey, I use these functions to get the options chain:
?
First, create a Contract for the underlying, as well as 2 vectors to capture options chain details (one of type std::string to retrieve expiry dates, and the other of type double to retrieve strike prices).
?
First, get the underlying contract ID to retrieve the options.
?
In the callback for reqContractDetails, we retrieve the contract ID and assign it to our underlying contract.
?
Once you have the conId, you can retrieve the options chain.
?
The response will be returned in the following callback:
?
|
Late Prints don't show up when I call reqHistoricalTicks()
I am trying to download all tick data for SPY
?
?m_pClient->reqHistoricalTicks(19001, ContractSamples::SPY_ETF(), TimeCode, "", 1000, "TRADES", 1, true, TagValueListSPtr());
?
I am getting all the data for 9:30 -> 16:00 hours Using this method
?
?
//! [tickbytickalllast]
void TestCppClient::tickByTickAllLast(int reqId, int tickType, time_t time, double price, int size, const TickAttrib& attribs, const std::string& exchange, const std::string& specialConditions) { ?
?
?
BUT when I look they are some prints that are late but don't show up calling reqHistoricalTicks()? (beyond 16:00 hours) See attached image.
?
Anyone know how I can get all the late prints that come after 16:00 hours???
?
?
?
?
? ?? |
Re: How to programatically approve a transaction: Security is under Surveillance
Glad that worked, Pranav, and thank you for sharing the solution. You asked about files where you can read TWS/IBGW settings from. Each account folder under the TWS/IBGW installation folder (the random looking folder names with 40 lower case characters) contains a file called tws.xml (for TWS), ibg.xml (for IB Gateway), or both depending on what you used for login. Those files contain all configuration and layout information. There are also daily backup copies such as tws.Wed.xml. Unfortunately, those files are encrypted and, in order to decrypt them, you'd have to log into TWS/IBGW:
The XML documents are length and have sections for many different layout and operational settings. Among them sections for API "Settings", "Precautions", and "News Configuration". I always wanted to make some tools to automate the monitoring and changing of TWS/IBGW configurations as well as TWS tabs so that I can guarantee consistency between multiple accounts. Reading and updating the XML files once decrypted is not that hard, but the decryption and recovery steps have to be done manually at this point (as far as i know). 闯ü谤驳别苍 ? ? ? On Thu, Mar 27, 2025 at 11:40 AM, Pranav Lal wrote:
|
Re: How to programatically approve a transaction: Security is under Surveillance
开云体育Hi all, ? Problem solved. I had to use a key value pair when specifying the string in the advancedErrorOverride property. advancedErrorOverride="8229,SURVEILLANCE" ? Pranav |
Re: How to programatically approve a transaction: Security is under Surveillance
开云体育Hi 闯ü谤驳别苍, Thanks for the welcome. <smile ? I made the changes but no go. Here is the log output. ERROR -1 1743033608079 2104 Market data farm connection is OK:hfarm ERROR -1 1743033608080 2107 HMDS data farm connection is inactive but should be available upon demand.apachmds ERROR -1 1743033608080 2158 Sec-def data farm connection is OK:secdefhk 56989180,SRF,STK,,,0,,,NSE,NSE,INR,SRF,SRF,False,,,,combo: eason:Security is under Surveillance Measure - The scrip PE is greater than 50 for the previous 4 trailing quarters.<br><br><br>Would you like to continue?. {"rejects":[{"buttons":[{"options":[{"fixstr":"8229=SURVEILLANCE","text":"Yes, transmit the order."}],"style":"chk"}],"id":2,"text":"Security is under Surveillance Measure – The scrip PE is greater than 50 for the previous 4 trailing quarters. <br><br>Would you like to continue?","textsep":"125"}],"version":"1.0"} ? <snip I'd check that the option API -> Settings -> "Show advanced order reject UI always" is unchecked. PL] Is there a configuration file where I can check this value? ? I use a screen reader and given that TWS uses its own jvm, the screen reader is unable to talk to java unless I can put the java access bridge into the jvm. ? Pranav |
Re: How to programatically approve a transaction: Security is under Surveillance
Welcome Pranav! I'd check that the option API -> Settings -> "Show advanced order reject UI always" is unchecked. Also, select all bypass options you are comfortable with in API -> Precautions. And your thought about the advancedErrorOverride field of the Order class may help. The documentation says that "advancedErrorOverride accepts a comma-separated list with parameters containing error tags. This list will override the mentioned errors and proceed with the order placement". From your log it sounds like you could try setting the field to "8229". 闯ü谤驳别苍 ? ? ?
On Wed, Mar 26, 2025 at 10:09 AM, Pranav Lal wrote:
Hi all, |
How to programatically approve a transaction: Security is under Surveillance
Hi all,
Sorry about the poor subject line. I am trying to buy a stock and am getting the following error in my logs. 56989180,SRF,STK,,,0,,,NSE,NSE,INR,SRF,SRF,False,,,,combo: eason:Security is under Surveillance Measure - The scrip PE is greater than 50 for the previous 4 trailing quarters.<br><br><br>Would you like to continue?. {"rejects":[{"buttons":[{"options":[{"fixstr":"8229=SURVEILLANCE","text":"Ye s, transmit the order."}],"style":"chk"}],"id":29,"text":"Security is under Surveillance Measure – The scrip PE is greater than 50 for the previous 4 trailing quarters. <br><br>Would you like to continue?","textsep":"125"}],"version":"1.0"} How do I get around this? Is the answer to use the advancedErrorOverride property of the order object? If yes, what do I enter as its value? Pranav |
is reqHistoricalData() returning partial trade bars?
Hi, I seem to be witnessing the following behaviour: if I request historical data with a timestamp?that is not aligned with the trade bar size I'm requesting, the last trade bar will be a partial trade bar, 'up to' the requested timestamp. Is this a correct assumption? To be a bit specific, for example requesting 2 minute trade bars with an endDateTime of 15:02:30 will return a trade bar for 15:02:00 but contain data only for the half minute period between 15:02:00 - 15:02:30. An alternative would be that the API only returns complete trade bars, which?seems not to be the case. ?kos |