RTD Server and FUnds 3
All, I just had to switch computers and my excel spreadsheet is no longer populating all of my pricing information for a bunch of funds. This worked on my other computers, but doesn't appear to be working on my new one. I have installed the TWS API and my stocks seem to be populating ok. Has anyone noticed a change since last week? Regards, Jim
Розпочато JimInNeavitt @ · Останніх @
Order rejected - reason:COULD NOT VALUE THIS CONTRACT AT THIS TIME 2
Hello Members, While sending the order from either TWS WorkStation or TWS API . I'm encountering the error. ""Error. Id: 1730135681, Code: 201, Msg: Order rejected - reason:COULD NOT VALUE THIS CONTRACT AT THIS TIME"" Any suggestions would be highly appreciated.
Розпочато tarun.joshi@... @ · Останніх @
Getting historical data for continuous futures (Python) 10
Hi, I'm trying to read historical data for a continuous futures contract. But I get "Error 10339: Setting end date/time for continuous future security type is not allowed". Here's my code: con = Contract() con.symbol = 'CL' con.secType = 'CONTFUT' con.exchange = 'NYMEX' con.currency = 'USD' con.multiplier = 1000 client.reqHistoricalData(req_id, con, date.strftime('%Y%m%d %H:%M:%S') + ' EST', '1800 S', '1 min', 'MIDPOINT', 0, 1, False, []) It looks like there's a problem with the second argument of reqHistoricalData. But I don't know how to set the desired time without it. Any ideas? Thanks, Zack
Розпочато zackscar @ · Останніх @
Java tws api 972.03 too old? Causing errorCode 505 not found 15
Hello, Starting today, after placing an order I'm getting this strange error all of a sudden: id=-1 errorCode=505 msg=Fatal Error: Unknown message id. It comes back via the general error method public void error(Exception e) in the implementation of EWrapper. Nothing has changed in the code, it's the same binary jar. The order is placed correctly though, but after the error, tws disconnects. From the 972 api doc, there does not seem to be an error code 505. And the more current documenation (IBKR Campus) this error says indeed Fatal Error: Unknown message id. My TWS is on 10.30.1l of Aug 13 2024. My feeling is that the 972 api is just too old, but I may have missed something. I believe tws would show a warning when an certain api is getting outdated. Is anyone else working succesfully with api 972.03 and tws 10.30.1l ? Changing everything to api 1019.04 does have a big impact so it seems. It's not just a few parameters and types, but reqMktData and depth seem to work in a different way. The demo client app 1019.04 works fine, so I'll just have step through that I think. Or is there an api version that does work, but with lower impact? So that I have more time to make the big jump to 1019.04 which will happen some day of course. Thanks for any advice! Greetings, Raoul
Розпочато Raoul Suurmeijer @ · Останніх @
reqMktData() - not receiving open price ... 6
Using the Interactive Brokers C# TWS API Version 10.19.04 (very new to this API). I am using the reqMktData() method to retrieve market data for some option contracts. I do receive live data, however, I never seem to receive the open price -- from what I can tell from the documentation, the "Open Tick" tick type (14) should be included automatically when the reqMktData() method is used, but I never seem to receive this tick type. Is this a bug in the API or is there something I need to do in order to retrieve this tick type? Thanks in advance.
Розпочато bdcoder @ · Останніх @
Finstat query not working 7
Please can someone tell me if fundamental data request with report type "finstat" is working on your TWS? Since my last TWS update I get a 430 error, telling me that fundamental data is not available, no matter which ticker I try. Estimates and snapshot requests work fine. Cheers Marc
Розпочато ApiMadness @ · Останніх @
All or None order for multi-leg options trades 3
What is the best way to implement a multi-leg options strategy using the TWS API? Basically, all of the legs in the strategy should immediately execute or none of them should. Placing orders for each leg one by one can result in some of the legs not executing due to margin issues. So, I want all of the orders to get rejected in case of insufficient margin. Thanks in advance for your response.
Розпочато nkmrao @ · Останніх @
Interactive Brokers TWS API - how are standard deviation moves being calculated?
Using the Interactive Brokers C# TWS API Version 10.19.04, I am wanting to calculate the min and max values for the various standard deviation groups as displayed in the Trader WorkStation (TWS) for option chains, i.e.: In the screen snapshot above the strike prices are grouped by color to indicate the number of standard deviation moves (I added the red lines to separate the color groups). I want to know how the min and max values in each group are calculated or is there an API call that does this for you? Unfortunately, the TWS code is NOT open source (as far as I know), so I was hoping someone could shed some light on how this is calculated or provide a resource or algorithm for doing so. Thanks in advance.
Розпочато bdcoder @
Error 105 - Order being modified does not match original order 7
I am trying to modify (bump) an equity options spread order. I sent the original spread order with a limit price. It returns a status of submitted - no problem (I can see it on TWS in the API tab). I then send the exact same order again (same line of Java code duplicated) just to test the waters, and I get error 105. I have read on this board about making sure Order and Contract fields are filled in properly to modify an open order. I have filled in as many fields as I know of, but I must be missing something. Java code snippet below: Contract contract = new Contract(); // For combo order use "USD" as the symbol value all the time contract.m_symbol = "USD"; // BAG is the security type for COMBO order contract.m_secType = "BAG"; contract.m_exchange = "SMART"; contract.m_currency = "USD"; //including combo order in contract object contract.m_comboLegs = legs; Order order = new Order(); order.m_orderId = IBInfo.getNextOrderID(); order.m_action = "SELL"; order.m_totalQuantity = 1; order.m_orderType = "LMT"; order.m_tif = "GTC"; order.m_lmtPrice = 1; Any suggestions would be appreciated. Fred
Розпочато fredquatro @ · Останніх @
what data subscription do I need to get real-time data via the TWS API? 4
Hi, What kind of data subscription do I need to be able to access live market data through the TWS API in python? This is for US stock data such as QQQ or NVDA. I've subscribed to the following data packages: NASDAQ (Network C/UTP)(NP,L1) NYSE (Network A/CTA) (NP,L1) NYSE American, BATS, ARCA, IEX, and Regional Exchanges (Network B) (NP,L1) But when I'm requesting live or close to live data via the python API, I'm not getting any data back, but I'm getting an error, for example: ERROR Error 162, reqId 35: Historical Market Data Service error message:HMDS query returned no data: QQQ@SMART Trades, contract: Stock(symbol='QQQ', exchange='SMART', currency='USD') I seem to be getting the live data in Trader Workstation. I spent over an hour reading up on your market data offerings, but I just can't figure out what I need to do. Can you please share specifics? Best regards, Ákos
Розпочато Ákos Maróy @ · Останніх @
Close Orders Rejected 12
Hi, This is not a twsapi issue, but If you can give me any help I would appreciate it. I use a real margin account, trading stocks with TWS. I have issues with closing the positions. Attached you can find the orders for NVDA. Starting from bottom to top you can see that 1. I've opened a short position with 92 shares with a limit order 2. Closed the position with a Buy Market 3. Opened a new short position with 92 shares using a limit order 4. Triggered a Buy Mkt order that is rejected : with the message that " I don't have enough funds ... etc" How is this possible, it is "buy to close" not a buy to open a new position, for me the situation is perplexing. I have to exit other trades to be able to close that one... IBKR support keeps telling me that I don't have enough funds. No funds to exit the trade? Thank you, Flaviu
Розпочато Flaviu Paul @ · Останніх @
reqHistoricalData returns low volumes 5
sorry to be so dense but I'm missing something basic here. I'm still getting low volumes irrespective of useRTH=0 or useRTH=1 . I can run it at 3am or 9pm and I get the same results. What am I missing???? I just want the OHLC for stocks. I know it's my code but I'm not seeing it. Symbol Date Open High Low Close Volume AAPL 20241011 228.5 229.55 227.2 227.4 234818.72 AAPL 20241014 228 231.73 227.12 231.3 255318.34 AAPL 20241015 231.34 237.49 230.3 234.1 427936.92 AAPL 20241016 234.34 234.44 229.84 231.65 184033.79 the contract looks like this 0,AAPL,STK,,0,,,SMART,,USD,,,False,,,,combo: and the function looks like this def request_historical_data(self): if self.tickers: ticker_info = self.tickers.pop(0) ticker = ticker_info['Ticker'] logger.info(f"Requesting historical data for {ticker}...") contract = Contract() contract.symbol = ticker contract.secType = ticker_info['Type'] contract.currency = "USD" contract.exchange = ticker_info['Exchange'] print(contract) if ticker and ticker_info['Type'] and ticker_info['Exchange']: self.req_id_to_symbol[self.req_id] = ticker try: self.reqHistoricalData( reqId=self.req_id, contract=contract, endDateTime='', durationStr='3 Y', barSizeSetting='1 day', whatToShow='TRADES', useRTH=0, formatDate=1, keepUpToDate=False, chartOptions=[] ) self.req_id += 1 except Exception as e: logger.error(f"Request failed for {ticker}: {e}") self.request_historical_data() # Retry with the next ticker else: logger.error(f"Invalid ticker information for {ticker}. Skipping...") self.request_historical_data() # Move on to the next ticker else: logger.error("All tickers processed.") self.disconnect()
Розпочато comicpilsen @ · Останніх @
Procedure Declaration does not match Error 2
Hello everyone, Recently I inherited a spreadsheet that connects to the TWS API and have been trying to get it to work as intended I keep getting the error message pictured below and am at a loss on how to fix it. I am completely new to dealing with VBA and wouldn't know how to fix / address this issue. Thanks
Розпочато vicente@... @ · Останніх @
duplicate rows from a simple api request reqHistoricalData 4
I'm sending self.reqHistoricalData( # https://www.interactivebrokers.com/campus/ibkr-api-page/twsapi-doc/#requesting-historical-bars reqId=self.req_id, # Use a unique request ID contract=contract, endDateTime='', durationStr='3 Y', barSizeSetting='1 day', whatToShow='TRADES', useRTH=1, formatDate=1, keepUpToDate=False, chartOptions=[] and getting two rows per day all the time but don't know why? Symbol Date Implied_Volatility Open High Low Close Volume 71611 NVDA 2021-10-13 33.684118 20.94 20.99 20.72 20.94 66359.50 71612 NVDA 2021-10-13 33.684118 20.92 20.99 20.71 20.94 1070657.50 71613 NVDA 2021-10-14 32.698311 21.29 21.75 21.13 21.75 78571.30 71614 NVDA 2021-10-14 32.698311 21.27 21.76 21.12 21.75 1575756.20 71615 NVDA 2021-10-15 30.701298 21.81 21.93 21.66 21.86 80737.50 71616 NVDA 2021-10-15 30.701298 21.78 21.93 21.66 21.86 1486919.50 Am I missing something in the call please?
Розпочато comicpilsen @ · Останніх @
Looking for coder to implement changes from different files, some structural and logic changes 3
Hello, I´m looking for someone competent and fair to implement some changes to a python software. Dificulty should be low but complexity is significant. No testing is necessary. If interested please contact directly. Thanks
Розпочато IBmark @ · Останніх @
the scope of order revisions
When processing the execDetails() callback, the passed Execution object has a ExecId field. The documentation describes that field as follows: The execution's identifier. Each partial fill has a separate ExecId. A correction is indicated by an ExecId which differs from a previous ExecId in only the digits after the final period, e.g. an ExecId ending in ".02" would be a correction of a previous execution with an ExecId ending in ".01". In my logic, after the first time it is reported that the order is fully filled, I increment order ids, reset state and just destroy all held information about that particular order. I am concerned that a revision can come up late and cause my program to enter into an untenable state. What assumptions can I make about the scope of revisions? Do they only involve price (not quantity)? Will they ever imply that a fully filled order wasn't in fact fully filled?
Розпочато tbrown122387@... @
execId format documentation 3
Hey folks, apparently the execId field of an order has a well defined structure. execId = AAAAAAAA.BBBBBBB.CC.DD Is there any documentation on what those numbers mean. For example DD seems to be partial fills counter. thanks
Розпочато Brocksdorff @ · Останніх @
partial fills orders
Hello, I have an issue handling the partial fills orders, in my code, I need to make sure that all partial orders are executed to process the next steps, I use the remaining function from trade object to check if the remaining shares is equal to 0 or not, below is my code, the issue here is that it give always remaining == 0 even there are some remaining shares. I use this event: self.ib_client.execDetailsEvent += self.on_exec_details` ` def on_exec_details(self, trade, fill): symbol = trade.contract.symbol if symbol in self.positions: trade_type = trade.order.orderType side = fill.execution.side order_id = trade.order.orderId shares = fill.execution.shares while not trade.isDone(): logger.info(f"{symbol} : Trade type: {trade_type}/{side}, Trade Status {trade.orderStatus.status}," f"remaining shares: {trade.orderStatus.remaining}") self.ib_client.sleep(1) logger.info( f"Execution of {trade_type} order for {symbol}, side = {side}, " f"shares = {shares}, order_id = {order_id}, Trade Status = {trade.orderStatus.status}" f"remaining shares: {trade.orderStatus.remaining}" ) self.ib_client.sleep(1) if trade.remaining() != 0: return Could you please help me understand why this is not working properly?
Розпочато hadry.hamza@... @
Cannot invoke "java.io.DataInputStream.read(byte[], int, int)" because "this.m_dis" is null
Lately, since a couple of weeks, am I getting this error message every now and then: Exception: Cannot invoke "java.io.DataInputStream.read(byte[], int, int)" because "this.m_dis" is null I have tried to figure out whether it is somehow related to my application software. It occurs after I disconnect a client from Gateway. I believe that this exception message is coming from the API Java class EClientSocket (method eConnect()), but am not sure. I am using API10.19 and Gateway 10.31. Is this an indication that there is something wrong in my application software? Or should I simply ignore this because I already disconnected the client?
Розпочато J G @
One cancels all : Group contains orders for Personal Account 3
Hello, I get this error while creating the trail and the stop order using the one cancels all logic (OCA), it's working fine in the paper account but not in the live account, below is the error message: ERROR - Error 10224, reqId 673: One-cancels-all group of orders should contain orders with exactly the same account. OCA group '0913e328-d9c4-4b4a-99b8-f6b921824f25' contains orders for Personal Account (account_name), Undefined. What can be the issue here please ? below is the code if this help : oca_group_name = str(uuid.uuid4()) if position["enable_trailing_stop"]: trailing_stop_order = Order( orderType="TRAIL", action="SELL", totalQuantity=position["current_shares"], trailingPercent=position["trailing_stop"] * 100, tif="GTC", outsideRth=True, ocaGroup=oca_group_name, ocaType=1, ) trade = self.place_order(position["contract"], trailing_stop_order) position["trailing_stop_order_id"] = trade.order.orderId position["trailing_stop_order"] = trade.order stop_loss_order = StopOrder("SELL", position["current_shares"], stop_loss_price, tif="GTC", outsideRth=True) stop_loss_order.ocaGroup = oca_group_name stop_loss_order.ocaType = 1 trade = self.place_order(position["contract"], stop_loss_order)
Розпочато hadry.hamza@... @ · Останніх @
Current Image
Image Name
Sat 8:39am