¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date   
What is manualOrderCancelTime param of Eclient::cancelOrder( int id, String manualOrderCancelTime) 24
The latest TWS API for Java added a new required parameter to the existing method EClient::cancelOrder. It now takes a string for manualOrderCancelTime which can be left null. What does this parameter do? Cancel an order if not already filled at a specific time in the future? It's not documented:
Started by Crow @ · Most recent @
Expired contract & TimeZoneId 2
I found that when I request ContractDetails for an expired future contract, the contractDetails object I receive has TimeZoneId propertiy set to Null. But if I want to download HistoricalData for that contract I need to know its TimeZoneId to correctly send the request. So how can I to solve the problem?
Started by luca.chiaravalloti@... @ · Most recent @
Rolling futures to the next expiry 2
Hi all, I was trying to roll my future to the next expiry (RTY Sep, CME -> RTY Dec, CME) with a negative current position (RTY Sep, CME: -1) on TWS GUI, i.e. from RTY Sep, CME: -1 RTY Dec, CME: 0 to RTY Sep, CME: 0 RTY Dec, CME: -1 I'm also connecting to TWS through TWS API. However, when the callback function "openOrder" is called, i get the wrong action (BUY/SELL) for the respective orders. Details: 637533627: RTY Sep, CME 654503362: RTY Dec, CME contract.comboLegsDescrip: 637533627|-1|CME,654503362|1|CME Leg. conId: 637533627 action: SELL Leg. conId: 654503362 action: BUY To my best knowledge, isn't it supposed to be contract.comboLegsDescrip: 637533627|1|CME,654503362|-1|CME Leg. conId: 637533627 action: BUY Leg. conId: 654503362 action: SELL However, in the end, i'm able to get the correct execution details: 637533627: BOT 654503362: SLD So I was wondering if I misunderstood the definition, or could this be a bug from TWS?
Started by Brian @ · Most recent @
Using Excel
I appreciate this may have been answered (please point me to the thread - or a vba code example). I have the TWS_ActiveX.xls working But I am unable to automate pulling down Account, Portfolio and Open order data using one button - I have to go to each tab and request data. I am sure its a scoping/hierarchy within the code but I have been unable to make it work . Any pointers - just want to press one button (preferably not on either of the account portfolio or open order tabs) and all data is refreshed Many thanks P
Started by paul@... @
C++ TWS API reqMktDepth() giving 309 error 6
Hi, I have had the same setup for streaming the level 2 market depth for a long time now. Yesterday, I started receiving this error "[20240905-12:58:19] Error [Id, Code, Msg]: 1001 : 309 -> Max number (3) of market depth requests has been reached". My code makes the stream request right before entering my main trading logic loop, and it only makes it once, so I am confused as to why this is happening now. The contract I am trying to stream is a future w/ these details: TICKER -> "NQ" EXP_MONTH -> "202412" LOCAL_SYMBOL -> "NQZ4" EXCHANGE = "CME" CURRENCY = "USD" Any help would be appreciated, especially if a change has been made to the API without my knowledge. Here is the line where I am making the request, m_sPtrIbc is a smart pointer that represents the client I built out. ReqMarketDepth() is simply a one liner -> m_pClient->reqMktDepth()... //launch streaming of orderbook depth... m_reqMktDepthId += 1; m_sPtrIbc->ReqMarketDepth(m_reqMktDepthId, m_contract, 5, false, TagValueListSPtr());
Started by Brendan Lydon @ · Most recent @
API server failed to start 2
Can anyone help me please.. My paper trading account's API server fails to start. Every time i log into TWS, it says the API server failed to start since the specified port 7497 is already in use by another application. I don't have another TWS application running but it keeps on saying socket port in use. Tried reinstalling the TWS, changed the versions, even tried changing the socket port number but nothing is working.
Started by abc20561225@... @ · Most recent @
TWS 10.30.1.e bug 8
Heads up. New TWS 10.30.1.e from July 1, appears to have a problem. If you just receive data / history for the market.. its OK. If you place an order, then the return order status, the message text, is prefixed with an extra byte. This makes the header 5 bytes long, and then disaster follows trying to decode it. All message sent from here on, have a 5 byte header. (msg header is supposed to be 4 bytes). Even closing your app and restating it, the TWS API keeps the 5 byte header bug. Only a TWS restart will clear the bug, until the next order. Enjoy
Started by rossh_yh @ · Most recent @
how to buy call option at the certain delta?
Hello, I try to write a program to buy SPY 0DTE call option at 70 delta during the day. It seems complicated to me. I am thinking: 1. get all the strike prices. 2. use reqMktData() for those 20 strike call contracts below the stock market price. 3. scan to find the contract whose delta is closest to 0.7. 4. send the order to buy. Is there a better way? Thanks.
Started by zlzhao22@... @
reqAccountUpdates() "stuck" after order fill 4
I've been fighting a problem for some time now and cannot find the cause, so posting here in case someone else has encountered it. I have a Python program that connects to the native IB API, makes trades, etc. and this all works correctly. The program works on 5-minute bars and runs only during normal trading hours (9:30am to 4:00 pm eastern US time). It places an initial bracket order for entry if conditions are met (entry long or short, then take profit and stop loss orders which are held at IB). Once entered, the program simply waits for the next 5-minute bar, downloads data to update an EMA and current price (it trades SPY), and makes a call to reqAccountUpdates() to get the current SPY position and price. So far so good. This account update call correctly reports the initial starting position (ie. 0 SPY), and once an entry is made it also correctly reports the new position (eg. 100 shares if long, -100 if short) for subsequent 5-minute bars. However, if either of the bracket orders is hit (take profit or stop loss), all subsequent calls to reqAccountUpdate() are "stuck" at whatever the open position was, and it stays this way for as long as the program runs (hours). The TWS UI correctly shows a 0 SPY position as the open position was closed, but reqAccountUpdate() always returns the prior open position values (for average cost and position size) even though the trade was properly closed. I've tried adding various delays (up to 5s) after the call to reqAccountUpdates() to no avail. I'm using this call to make new trade entries after the initial trade is closed, but since reqAccountUpdates() does not reset to 0 SPY when one of the bracket orders is hit it thinks the initial trade is still open. The code is simply: 1) Call a function to update the account: app.account_updates() time.sleep(2) # Give 2s for results to be available 2) This is the function called: def account_updates(self): self.reqAccountUpdates(True, self.account) ib_event.wait() ib_event.clear() self.reqAccountUpdates(False, self.account) # stop the updating loop Anyone ran into this problem before, or have an idea how to resolve it? Thanks.
Started by rmayNC @ · Most recent @
IB down? 3
Anyone else able to connect to TWS or IB Gateway? I can not. From the Error callback Error: 2110 "Connectivity between Trader Workstation and server is broken. It will be restored automatically." I has been like this since 17:20 ET on Wednesday
Started by Mark Chapin @ · Most recent @
How to get IV data for option chains? 7
I'm able to get the IV of every option by requesting market data and looking at the "Option Implied Volatility" tick from tickGeneric. The issue is that I can't request market data for the entire option chain (or can I?). So, how do I get the IV of the entire chain? This the value the I'm trying to get (the one on the right) Thank you!
Started by uselessblack@... @ · Most recent @
Trading Future CME Group Long/Short contract 4
Hello, I would like to open 2 positions on CME Group NQ (Nasdaq 100 Future contract). First position must be long with 2 contacts and second position short with 1 contract (the second position is considered as hedging in case if the market moves suddenly). Question: is it possible through the api to open and hold the 2 positions on the same time ? (the second position will not close 1 contract from the first position) Thanks
Started by zzitounti@... @ · Most recent @
Eurex orderbook lines missing
Requesting Market Depth (L2) data of Eurex futures (FDAX, FDXM, FGBL) with 10 lines (orderbook levels) currently I only get lines 1 to 5 with 'normal' price (index) data and lines 6 to 10 with more or less constant values not related to the top bid/ask price changes. This phenomenon started 9. Aug. at 06:00 (UTC+2) and currently goes on. I try to find out if this is genuine missing data from the exchange (caused by low liquidity?) or maybe caused by some software issues/effects (at IB or my side).
Started by Greg Angelow @
default histogram period
Hi all, I'm trying to reproduce the BookTrader window. I'm able to get the histogram column, but I don't know the default period used, so I'm unable to get the actual value. Example: using '1 day' period I get volume 5000 over the BookTrader window and by the api I get the volume 6124 to the same price (MES contract today) using REALTIME market data. Someone knows the default period of the BookTrader Histogram column? Best Regards, Fernando
Started by Fernando Ribeiro @
Trailing Stop/Stop-Loss Combo 13
Hey guys, I have created a Python program that connects to the TWS API and places bracket trades when certain market conditions are met. The program is working as intended with one exception. I would like to be able to place a combined Stop Loss and Trailing Stop Loss instead of just a Stop Loss to take advantage of this combo in an attempt to reduce losses. An article on Investopedia refers to the strategy as being available on Active Trades and provides the following example which illustrates exactly what I am seeking... "For example, you could set a stop-loss at 2% below the current stock price and a trailing stop at 2.5% below the current stock price. As share price increases, the trailing stop will surpass the fixed stop-loss, rendering it redundant or obsolete." This is exactly the behaviour I would like for my bracket trades. As I was unable to find a way to do this in a single order (I thought there might be an option to add a Stop Loss to a Trailing Stop Loss or visa versa), I instead placed an additional child order. So I have the following: Parent > child: Take Profit > child: Stop Loss > child: Trailing Stop Loss This is submitted and works perfectly, with one unfortunate exception. In the scenario when the Trailing Stop Loss moves to the exact price of the Stop Loss and remains there as the price movement reverses, if the Stop Loss/Trailing Stop Loss orders are triggered together, both orders are filled, so I end up with one of the orders closing out my position, and the other opening a new position for the same quantity. Is there a way to do either of the following: 1) Include a Stop Loss within a Trailing Stop Loss order (or visa versa) 2) Cancel the Stop Loss order when the Trailing Stop Loss reaches or moves beyond the Stop Loss price I very much appreciate any insights to this issue. Regards, Scott.
Started by scott_hopgood@... @ · Most recent @
"Ignore Rth" Error with PriceCondition 6
I am using C# TWS API and my code has been working fine with most of the APIs being used. REcently I wanted to try PriceCondition to the order but after the order was submitted, I got an error from EWrapper. Here is a code snippet how I add the PriceCondition. The rest of the code has been working for 2 years so I won't worry about it. var priceCondition = new PriceCondition(); priceCondition.Price = 125.00 priceCondition.ConId = contract.ConId; priceCondition.IsMore = true priceCondition.Exchange = contract.Exchange; order.Conditions.Add(priceCondition); order.ConditionsCancelOrder = true; order.OutsideRth = true; order.ConditionsIgnoreRth = true; It doesn't matter what value i set to OutsideRth and ConditionsIgnoreRth. I always got this error. errorCode:320,str:Error reading request. Unable to parse field: 'Ignore Rth' for input string: 'o',advancedOrderRejectjson:, Has anyone hit this issue before?
Started by Robby @ · Most recent @
TWS not connecting throwing a timeout error as port is stuck in (CLOSE_WAIT) state 4
Hey, guys. I hope everyone is doing great. I have a sporadic problem occurring when I cannot connect with TWS, it gives a timeout error, and on checking the port it's usually stuck in the CLOSE_WAIT status and only way I can clear that is by restarting TWS. Can someone please explain why the port goes stuck into CLOSE_WAIT state, what are the ways to avoid that? My personal understanding is it happens when the client doesn't disconnect properly, but in my strategy I have handled exceptions etc and have made sure to call disconnect() at the end. This only time I connect is at the opening bell to trade i.e. 9.30 Eastern Time, most of the times it works like a charm, but sometimes it doesn't. One important thing to mention, we have a basic flask backend to respond on HTTP requests to track TWS status & which account is logged into through this code: def is_port_open(port): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(1) # 1 second timeout result = sock.connect_ex(('127.0.0.1', port)) sock.close() return result == 0 def check_tws_account_status(): paper_port = 7497 dollar_port = 7496 if is_port_open(paper_port): return 'paper' elif is_port_open(dollar_port): return 'dollar' else: return 'none' Do you think this may have been causing the issue? I would really appreciate any resources to understand this CLOSE_WAIT status situation. Thanks!
Started by mubbashirali35@... @ · Most recent @
Create a self updating list of executions 2
Is there a possibility to create a self-updating list of executions iwthin the API? Right now I use every account update to pull executions for the updated contract and isolate the last trade but there must be a more elegant way to do this.
Started by domahan@... @ · Most recent @
irregular behavior of cancelled orders
Hi: After recent TWS updates I started to observe some irregular behavior of cancelled orders, that never happened before. I catch an OpenOrder order cancelled message as usual, but the order appears to be stuck in TWS after that. When mouse over in TWS it says 'Active on CFE', however it appears not be active at all, as it doesn't get executed after all even when the limit price is good to be executed. When I proceed to cancel it in TWS manually, my app catches the error 202 (order cancelled), although it's already been accounted for as cancelled before based on the OpenOrder message. There's no apparent reason for this happening as I made no changes to my app in weeks. And it only happened to my futures orders so far. Anyone else observe the same recently?
Started by bespalex @
secID empty 3
I am trying to retrieve all executions with according ISIN by using secID but the response to secID seems to be empty. Can anyone tell me what I am doing wrong? ... class TradingApp(EWrapper, EClient): def __init__(self): EClient.__init__(self, self) def position(self, account: str, contract: Contract, position: Decimal, avgCost: float): print("Position.", "Account:", account, "Symbol:",contract.symbol,"secId:", contract.secId, "Position:", position, "Avg cost:", avgCost) def positionEnd(self): print("PositionEnd") ... Response: Position. Account: **** Symbol: AAPL secId: Position: **** Avg cost: **
Started by domahan@... @ · Most recent @
Current Image
Image Name
Sat 8:39am