volume data for stock
Hi All, one question on volume data received from IBKR. I know that requesting data for STK, on past days with reqHistoricalData, for example the ohlcv with 1 min bar, for past days the volume is divided by 100 (I don't know why but comparing with other sources that is...). I noticed anyway if I use the reqHistoricalData to request data for CURRENT session (for example last 5 or 30 minutes), the volume data is correct, without the division by 100. if my understanding is correct, this is not a big issue, but is there any option to configure ibapi to return consistent volume numbers for both current sessions and past days? thanks! Marco
|
Auto Restart & Auto Login w/ IB Gateway and Linux
Hi Bredan: I'm also having issues with IB Gateway crashes. Is it possible to restart it without manual intervention? Regards, Jes¨²s
|
Live data on multiple contracts - Python
3
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() app_underlying.connect("127.0.0.1", port, 0) threading.Thread(target=app_underlying.run).start() and give each one a unique clientid and run threading on every one of them? Thanks in advance!
|
Securities for this order were not immediately available for short sale, but not asking to short...
18
Hi, I've been receiving this error for a long time now. Can't find anything online regarding this issue. In this example: I buy 2 stocks. I have 1 Sell OCA group with 3 orders. I have 1 other Sell OCA group with 4 orders. Any help would be much appreciated. Thanks
|
missing contract details ie PCUSEQTR or COR1M COR3M COR70D
3
using the IB contract lookup tool I can enter PCUSEQTR, COR1M ,COR3M ,COR70D and they all are contracts BUT there is no information pertaining to Type,Symbol,Exchange,Currency. I can also add them to a watch list ( ie PCUSEQTR right now is c0.54) but the tear sheet has nothing either. In cases like this how can I handle populating a request for historical data?
|
Some Paper trade Orders not filling after updating to 10.30
10
Hi, I'm new on this forum. I found after updating, that some of my orders never filled despite the price conditions and time conditions being hit. I do an exit sell order using an OCA Group; one an optimistic LMT order, another is a pessimistic STP order and lastly have a MKT order set 3 minutes in the future. This worked well up until I updated to 10.30; The MKT and STP orders don't activate on some stocks while using a Paper Trading account. I read that some users here had issues with 10.30 and moved onto a later version. I would like to at least try that. For people that found success moving on to a new version what version did you move on to where you didn't have any issues?
|
Paper Trading Account orders stuck in PendingSubmit
Does anyone have this issue? This is the case for orders submitted through the API, manually through TWS, or entered manually on the website. The paper trading API also has all kinds of weird slowness. For example, reqMarketTime can be 30 seconds different from the local clock occasionally, and qualifyContract takes 20 seconds. I have never had this issue until 2-3 days ago.
|
Streaming Market Data
I have a TWS account. I am looking to get a price list every 5 seconds from a list of stocks (about 40) - using IBKR API - and log to a file. Do I need any "Streaming Market Data" subscription? Thanks
|
TWS Time zone
5
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
|
IB via Lightspeed
8
Hello, Slightly off group topic, received an email from Lightspeed, saying they launched a new API that allows IB clients to do algo trading via direct API calls to their platform. Link Below. They claim it doesn't require IB Gateway running not sure if that's good or bad. - has anyone experience with it? - has anyone concerns with using this type of alternatives Thank you. https://lightspeed.com/trading/api-trading-at-IBKR
|
TwsApi.jar and TwsApi_debug.jar
Does anyone know the difference between "TwsApi.jar" and "TwsApi_debug.jar" in IBJts/source/JavaClient of the Java TWS API ? Thank you. -- https://www.tradingsoftwarelab.com
|
Place Trailing Stop Limit Order
Hi, I would like to place a trailing stop order based on execution details received back from IBKR. The original order is a market order, so using the trailing order for risk management and profit taking if any. I am struggling with: I need to ensure I only book the trailing limit stop order for new (original order), not get stuck in an infinite loop of booking at this point. How can I identify/tag the original order. If I use parent/child order (on execution Details not using brackets), I get error that stop orders can be attached to limit or stop limit, not market orders. The executionDetails callback sometimes fires n times for an order of quantity n. Should I be booking the trailing order each time or wait for when fill=totalOrder? Please advise. Thank you. Mugu
|
Maximum number of symbols for live prices
What is the maximum number of symbols the API can support getting live prices at the same time? I am wondering if I need a different price feed solution soon.
|
Confirm/Cancel Pending Orders via Web API
Hi, I am currently in the process of testing for the first time newly implemented code that I have written which uses the IBKR web API to create Orders. Currently, when I make a call to REST API endpoint iserver/account/$accountId/orders to create an Order, I get a response back with body: ``` [ { "id" : "12e3f456-a123-12c3-40f5-a123d45d678a", "message" : [ "The following order \"BUY 5 MU NASDAQ.NMS @ 93.88\" price exceeds \nthe Percentage constraint of 3%.\nAre you sure you want to submit this order?" ], "isSuppressed" : false, "messageIds" : [ "o163" ] } ] ``` But, when I send a reply back to confirm this Order to REST API endpoint iserver/reply/12e3f456-a123-12c3-40f5-a123d45d678a with body: ``` {"confirmReply": true} ``` I get a response back with body: ``` {"error":"reply id not found: '12e3f456-a123-12c3-40f5-a123d45d678a'"} ``` So, what step or steps am I missing? When I make a call to REST API endpoint iserver/account/orders, I get a JSON response back with Order details which includes key values: "orderId":123456789, "status":"Inactive" and "order_ccp_status":"Pending Submit". These Order status values make sense as the confirmReply call was NOT successful. At this point, I don't know what I can do to either confirm or cancel the Order. The confirmReply fails and, If I try to cancel the Order altogether by making a call to DELETE REST API endpoint iserver/account/$accountId/order/123456789, I get a response back with body: ``` {"error":"OrderID 123456789 doesn't exist"} ``` So not sure what I can do in order to get my Order either confirmed or cancelled? All I can do at the moment is wait until tomorrow as by then, IBKR will have cancelled the pending Order itself but this is not helpful to me when I am trying to test and debug Order creation/confirmation/cancellation calls from within my code base in order to make progress. Thanks in advance for any help on this.
|
Stock screener not working anymore after automatically disconnect and connect at 6.00
My own source code has a stock screener. This was functioning fine. Since several weeks (I guess after I was forced to update from my 2024 version but I don't know for sure) the scanner stops working after it automatically disconnects and then reconnects every day at 6.00AM see log blow. Why? I don't know where to search, was it the update, bug in my code, problem with Mexem, etc. See my errors from my code. [2025-04-15 02:04:52] ScannerData found stock to analyze. 7002 - Rank: 39, Symbol: HKPD, SecType: STK, Currency: USD, Distance: , Benchmark: , Projection: , Legs String: [2025-04-15 02:04:52] ScannerData found stock to analyze. 7002 - Rank: 40, Symbol: SHMD, SecType: STK, Currency: USD, Distance: , Benchmark: , Projection: , Legs String: [2025-04-15 02:05:20] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 02:05:48] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved ... [2025-04-15 05:44:36] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 05:45:11] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 05:45:33] Error. Id: -1, Code: 2157, Msg: Sec-def data farm connection is broken:secdefnj [2025-04-15 05:45:45] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 05:45:47] Error. Id: -1, Code: 2158, Msg: Sec-def data farm connection is OK:secdefnj [2025-04-15 05:46:16] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 05:46:49] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved ... [2025-04-15 05:59:38] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 06:00:00] Connection Closed [2025-04-15 06:00:00] Sleeping 10 seconds before next attempt [2025-04-15 06:00:10] Attempt 23 of 50 [2025-04-15 06:00:10] Error. Id: -1, Code: 504, Msg: Not connected [2025-04-15 06:00:10] Connecting to 127.0.0.1:4001 clientId:0 [2025-04-15 06:00:10] Error. Id: -1, Code: 502, Msg: Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled and connection port is the same as "Socket Port" on the TWS "Edit->Global Configuration...->API->Settings" menu. Live Trading ports: TWS: 7496; IB Gateway: 4001. Simulated Trading ports for new installations of version 954.1 or newer: TWS: 7497; IB Gateway: 4002 [2025-04-15 06:00:10] Cannot connect to 127.0.0.1:4001 clientId:0 [2025-04-15 06:00:10] Sleeping 10 seconds before next attempt [2025-04-15 06:00:20] Attempt 24 of 50 [2025-04-15 06:00:20] Error. Id: -1, Code: 504, Msg: Not connected [2025-04-15 06:00:20] Connecting to 127.0.0.1:4001 clientId:0 [2025-04-15 06:00:21] Connected to 127.0.0.1:4001 clientId:0 [2025-04-15 06:00:21] Account List: Uxxxxx [2025-04-15 06:00:21] Next Valid Id: 1 [2025-04-15 06:00:21] Error. Id: -1, Code: 2104, Msg: Market data farm connection is OK:usfarm [2025-04-15 06:00:21] Error. Id: -1, Code: 2106, Msg: HMDS data farm connection is OK:ushmds [2025-04-15 06:00:21] Error. Id: -1, Code: 2158, Msg: Sec-def data farm connection is OK:secdefnj [2025-04-15 06:00:22] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 06:00:51] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 06:01:27] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:no items retrieved [2025-04-15 06:01:48] Error. Id: -1, Code: 2105, Msg: HMDS data farm connection is broken:ushmds [2025-04-15 06:01:48] Error. Id: 7002, Code: 165, Msg: Historical Market Data Service query message:HMDS server disconnect occurred. Attempting reconnection... [2025-04-15 06:01:55] Error. Id: -1, Code: 2106, Msg: HMDS data farm connection is OK:ushmds [2025-04-15 06:01:55] Error. Id: 7002, Code: 165, Msg: Historical Market Data Ser
|
reqSecDefOptionParams returns wrong trading class
9
Hi guys, so i have a complete pipeline setup for the data back and through my application for options data. The only problem i am facing right now is that if i am trying to get data for NVDA via reqSecDefOptionParam, i am getting back 2NVDA as trading class and that doesnt have data. Now i am stuck what to do, its similar with AMZN, i am getting back 2AMZN as trading class with no data.
|
Futures stop market orders execution logic during non liquid hours?
I'm having some trouble getting consistent paper-trading executions with stop orders and I cannot figure out the rhyme or reason behind it. Anyone have insights about the IBKR logic about what kinds of orders will adjust/trigger/fill during non-liquid hours? I see this page about futures stop orders: https://www.interactivebrokers.com/en/trading/us-futures-stop-order.php Details: Setting up a set of orders as an OCA group All orders are set to fill outside rth = True on the order When placing the orders: This error is shown: "Warning 2109, reqId 9: Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed" This warning happens during all times of the day and my experience is consistent with this post /g/twsapi/message/40699 where if that is not set, no STP orders execute. Ticked the box in ibgateway -> Presets -> Futures -> Allow orders to activated triggered filled outside regular trading hours A stop order set as a stop loss: these seem to fill consistently A market exit order with a time condition: these seem to fill consistently An adjustable trailing stop order: these seem to fill inconsistently. All last week, zero executions even though the price went far beyond the triggers & stops. However today, 1 order that did fill around 3am EST. An adjustable stop order that adjusts to a profit level on a trigger: these seem to never fill. I am trying to figure out the logic but due to the inconsistency, nothing makes sense. Questions: I vaguely recall a discussion somewhere noting difference between execution of stop loss orders & other stop orders. Could this be why the STP order below my entry price seems to fill consistently? Anyone aware of logic during non-liquid hours that may impact order adjustments and/or executions of stop orders? Could the inconsistency in executions be simply related to the paper trading account? I've read that the IBKR paper account shouldn't be trusted aside from "am I pushing the buttons correctly..." Maybe it's just related to the triggering logic and all the volatility last week? https://www.ibkrguides.com/traderworkstation/define-order-preset-value.htm From the doc: "Last must be within the bid/ask (i.e. >=bid and <= ask) or within leeway percentage outside the bid/ask (i.e. >=bid-0.5% of last and <=ask+0.5% of last). This 0.5% amount of leeway is subject to change at any time without notice" If that's the case -- seems like bid/ask triggers are more reliable? I sincerely appreciate any insights in advance.
|
reqContractDetails for past dates
4
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?
|
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
|
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
|