开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育
Date   
very different trade volume data compared to other data providers 2
Hi, I'm wondering why I'd be getting very different trade volume data from IB via TWS when compared to other data providers? Here's a sample for 1 day trade bar 'volume' data for QQQ, the first data column is the one from another reputable data provider while the second data column is what IB is returning: 2024-12-10 24237090.0 16029341.0 2024-12-11 32098579.0 19361377.0 2024-12-12 23492804.0 12993718.0 2024-12-13 28656855.0 16873336.0 2024-12-16 31918863.0 17959509.0 2024-12-17 28106770.0 17517398.0 2024-12-18 54521255.0 33075903.0 2024-12-19 46005404.0 29951593.0 2024-12-20 60086561.0 30793425.0 2024-12-23 29346800.0 16918299.0 Using useRTH=False returns somewhat higher volumes, but still not close to other sources. Otherwise, the open high low close values are very similar, at most a $.02 difference for most rows. I wonder what the source of the difference could be? ?kos
Started by ?kos Maróy @ · Most recent @
reqContractDetails for past dates 2
I have historical trading data from past years (received with reqHistoricalData) for a specific contract. I need to know the trading hours / liquid hours for this contract for each day in this historical period. The reqContractDetails only returns trading hours for the upcoming few days, but I need it for past periods. Is there any way to get this information?
Started by yonatand80@... @ · Most recent @
Google Protocol Buffers usage in the latest Java API 11
Would anyone like to comment on the introduction of Google Protocol Buffers in the Latest Java TWS API version 10.35 ? -- https://www.tradingsoftwarelab.com
Started by Orionn @ · Most recent @
TWS Time zone 3
I’m in the central time zone but I have my computers on EDT. When I run TWS on my new computer it displays CDT, not EDT. When I run it on any of my other computers it uses EDT. My new computer is setup for EDT and that’s what it shows in the task bar. Selecting “more options” on the TWS login screen shows the time zone as “(UTC-05:00) America/New York” on the new and old computers. Any ideas? Frank
Started by Frank Bell @ · Most recent @
Anyone has code to show all option chain names for a symbol? 7
Anyone has code to show all option chain names for a symbol?
Started by Marluv @ · Most recent @
Late Prints don't show up when I call reqHistoricalTicks() 3
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???
Started by Marluv @ · Most recent @
reqContractDetails() does not get a callback if secType = "OPT" 7
I had some old code I haven't run for a few years, which used to successfully retrieve an option chain. I've been trying to update it but for the life of me I can't get hold of an option chain through reqContractDetails() with code which used to work. I've updated to IB Gateway 10.33 and also a python client implementing API 10.30.01. I can call reqContractDetails contract = Contract() contract.symbol = "AAPL" contract.secType = "STK" contract.currency = "USD" contract.exchange = "SMART" reqContractDetails(1, contract) This works perfectly and I retrieve the details just fine. If however I then do: optContract = Contract() optContract.symbol = "AAPL" optContract.currency = "USD" optContract.exchange = "SMART" optContract.secType = "OPT" optContract.multiplier = "" optContract.conId = 0 reqContractDetails(2, optContract) Then the contractDetails() callback never gets called, or at least within my 60 second timeout. I have tried with "" for exchange and multiplier - no dice. I can see how if I'm not properly defining a request for the option then it won't find it - but then I'd expect a "security not found" type message - whereas this is more like as soon as the contract type is set to OPT the callback never takes place. Any ideas? Is it possible that I'm doing this on a Sunday and it will work during regular trading hours? Thanks in advance, S.
Started by Stephan Gueorguiev @ · Most recent @
Improvements to Intraday Momentum Strategies Using Parameter Optimization and Different Exit Strategies 7
I published a paper on Improvements to Intraday Momentum Strategies Using Parameter Optimization and Different Exit Strategies, for which I used the TWS API for live validation: https://dx.doi.org/10.2139/ssrn.5095349 Abstract Building on the results of Zarattini, C., Aziz, A., & Barbon, A. (2024). Beat the market: An effective intraday momentum strategy for S&P500 ETF (SPY), we explore improvements to noise boundary based intraday momentum strategies by investigating different exit strategies and applying parameter optimization to all parameters of the strategies. We show that the returns of the momentum strategy can be significantly improved by such an approach. The best results are achieved with exits based on VWAP, VWAP & Ladder and Ladder exit strategies, with Sharpe ratios over 3.0 and annualized returns of over 50%, which are significant improvements against the baseline strategy. All feedback welcome
Started by ?kos Maróy @ · Most recent @
is reqHistoricalData() returning partial trade bars? 2
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
Started by ?kos Maróy @ · Most recent @
How to programatically approve a transaction: Security is under Surveillance 5
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 &ndash; 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
Started by Pranav Lal @ · Most recent @
FX/CASH Pegged to Midpoint Order 3
Hello, As the title suggests, is there any way to send pegged to midpoint orders for CASH instruments? Regards, John
Started by John @ · Most recent @
Using Wall Street Horizon API w/ TWS-API 3
All, I am trying to get some basic functionality working with the Wall Street Horizon API (using the TWS API) but there seems to be some fundamental items that I am missing. I am referencing the documentation here: https://www.interactivebrokers.com/campus/ibkr-api-page/twsapi-doc/#meta-data I feel I need more information than what is provided here. I was hoping to find a more detailed tutorial. 1.) It looks like the first step is to call reqWshMetaData The example shown in the documentation shows: self.reqWshMetaData(1100) What exactly happening here? It is dumping the entire calendar of data? Any further explanation on this I would appreciate. 2.) In the Ewrapper there is the function wshMetaData() def wshMetaData(self, reqId: int, dataJson: str): print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson) What should I be doing at this point? From the documentation this looks to return specific event types. the print() returns a lot of data that looks unfiltered and not focused on what I am looking for. 3.) Request Event Data The example in the documentation shows the call as the following. self.reqWshEventData(1101, eventDataObj) I am not sure here about the eventDataObj. The documentation states that "When making a request to the Wall Street Horizons Event Calendar with the API, users must create a wshEventData Object." In the API documentation I don't see any an example of how to create this eventDataObj. 4.) Receive Event Data In the Ewrapper I then see the function: def wshEventData(self, reqId: int, dataJson: str): print("WshEventData.", "ReqId:", reqId, "Data JSON:", dataJson) How do I filter this to only show data for a specific stock? Is this related to the conID that would be part of the wshEventData? Thanks for any information on this. def wshMetaData(self, reqId: int, dataJson: str): print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson) def wshMetaData(self, reqId: int, dataJson: str): print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
Started by Henk Visser @ · Most recent @
Upcoming stock earnings dates 6
Is there any API request that returns upcoming stock earnings dates? If not, do you use any other services to provide this? I'm interested in both US and foreign exchanges.
Started by ramdukof @ · Most recent @
Closing positions 4
What's the best way to close previous positions when I have new order position sizes calculated by account size? For example, if I enter a position for 1 lot in EURUSD, and (purely hypothetically) that trade doubles the size of the account. My next order position size would be for 2 lots. That makes it difficult to close the first position if all I'm going to do is do an opposite position because the order quantity would change. The help I've received from the api support is to request positions and then do an opposite order based on what comes back. I've never seen that put into code.
Started by donye @ · Most recent @
When to update ibgateway 8
What policy do you use for when to update the ibgateway? It seems like every 4-8 months, my ibgateway fails to login after a daily restart and updating to the newest version fixes it. I haven't found any logging, errors, or other notifications that the old version is no longer being supported. Today, my version 10.30.1g stopped working, and was still failing after I restarted it again, so I updated to 10.34.1c. It is possible the old version does still work, but for some reason upgrading consistently fixes it. It seems odd that they would make the change mid-week and there were no errors in the ibc logs, it just never logged "IBC: Login has completed". I wanted to get it running, so didn't debug it too long. Is there a way to get notifications when IB increases a version, or should I just set a monthly or quarterly upgrade reminder?
Started by Scott Kister @ · Most recent @
Accounting for 2024, always 10% off 8
For my tax declaration I always run a flex-query to get a file over all transactions of the year. The report gives me among many other things a column called CapitalGainsPnl. This should be how much I made on each trade, right? However if I sum this column and compare the total with the difference I see in the account management when I take the balance on 1st January and 31st December the result is off by about 10%. Is there an easy explanation for this?
Started by Despair @ · Most recent @
IBKR currency carry reference benchmarks + history 2
Hello TWS group, Was looking into FX trading recently, and tried to source the below reference benchmark rates from the TWS API without success. https://www.interactivebrokers.com/en/pricing/reference-benchmark-rates-int.php I would need today's rate but also history if possible, it is available from the IBKR website, so I suppose it must be stored somewhere in the API, but can't find it. Any suggestions? Thanks, Jonathan
Started by John @ · Most recent @
"438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ? 6
Can anyone confirm that the errors in the subject have been discontinued in recent API versions ? I have performed the following tests: 1) TWS locked: - using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked" - using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..." 2) client Id already in use: - using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id." - using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..." So it is clear that the issue is in the API, not in TWS. The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use. Can anyone confirm these findings ? -- https://www.tradingsoftwarelab.com
Started by Orionn @ · Most recent @
Is a race condition that causes inconsistent states of position and open orders possible?
If in the messages TWS streams back to the client, it sends the order/execution message first before it sends the position update message, it is possible for the client to be in an inconsistent state as it no longer sees the open order, but the position is not updated. This is dangerous because the program may sneakily go above the risk limits without the program noticing. I have done a search of this forum, and it appears no one has had such an issue in practice. However, in the TWS API official documentation, I also do not see any mention of it talking about synchronization guarantees. Is it something I really need to worry about? I really appreciate any input.
Started by Little Trader @
ERROR -1 2104 Market data farm connection is OK:usfarm.nj 3
Hi all, Each time I started my TWS api program (python) these messages show up. They start with "ERROR" but seems connection status report. Anyone knows why they show up? Using args Namespace(global_cancel=False, port=7496) serverVersion:173 connectionTime:b'20220708 03:54:17 EST' NextValidId: 1 Executing requests doing accountOperations_req done w/ accountOperations_req Executing requests ... finished ERROR -1 2104 Market data farm connection is OK:usfarm.nj Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:usfarm.nj ERROR -1 2104 Market data farm connection is OK:hfarm Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:hfarm ERROR -1 2104 Market data farm connection is OK:usfuture Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:usfuture ERROR -1 2104 Market data farm connection is OK:cashfarm Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:cashfarm ERROR -1 2104 Market data farm connection is OK:usopt Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:usopt ERROR -1 2104 Market data farm connection is OK:usfarm Error. Id: -1 Code: 2104 Msg: Market data farm connection is OK:usfarm ERROR -1 2106 HMDS data farm connection is OK:hkhmds Error. Id: -1 Code: 2106 Msg: HMDS data farm connection is OK:hkhmds ERROR -1 2106 HMDS data farm connection is OK:ushmds Error. Id: -1 Code: 2106 Msg: HMDS data farm connection is OK:ushmds ERROR -1 2106 HMDS data farm connection is OK:fundfarm Error. Id: -1 Code: 2106 Msg: HMDS data farm connection is OK:fundfarm ERROR -1 2158 Sec-def data farm connection is OK:secdefhk Error. Id: -1 Code: 2158 Msg: Sec-def data farm connection is OK:secdefhk
Started by PurpleIce @ · Most recent @
Current Image
Image Name
Sat 8:39am