Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: C++ TWS API reqMktDepth() giving 309 error
Suppose I have windows open in my TWS platform requesting market depth. Would that count against the limit? That seems to be the only thing I can think of as I am 99% sure I am requesting only once in these projects and nothing else is running against TWS in my task manager.
?
Thanks, Brendan |
Re: C++ TWS API reqMktDepth() giving 309 error
No problem here. Just tried NQZ4 as the third subscription through a paper account that already had two active reqMktDepth subscriptions for other instruments. Worked as expected. Any chance you are indeed requesting market depth subscriptions for more than three different instruments simultaneously? Keep in mind that TWS L2 tools count against the three subscription limit, in case you use those. 闯ü谤驳别苍 ?
?
On Tue, Sep 10, 2024 at 08:16 AM, Brendan Lydon wrote:
|
Expired contract & TimeZoneId
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? |
Re: API server failed to start
Assuming your system does not show weird behavior I can only think of two major reasons why TWS/IBGW cannot create the socket they need to accept client connections through:
闯ü谤驳别苍
?
On Mon, Sep 9, 2024 at 08:35 AM, <abc20561225@...> wrote:
|
API server failed to start
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. |
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.
|
C++ TWS API reqMktDepth() giving 309 error
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());
|
Re: reqAccountUpdates() "stuck" after order fill
Thanks ... I will try some things as this section of code came from an online example I found in a tutorial and it appeared to work for the first cycle (ie. returned 0 positions the first time it was called which is correct, then after a trade initiated by the program it correctly returned the new position).? I did discover yesterday that if I stop the Python program right after one of the bracket orders is hit (which closes the open trade), then restart the program, it correctly shows 0 open positions after the call to account updates.? I will delete the unsubscribe line and see if that solves the problem.? Thanks again.? |
Re: reqAccountUpdates() "stuck" after order fill
reqAccountUpdates is a subscription, so you don't really need to start and stop it each time. Check how you implement the callback functions getting the data.
Also you may consider using reqPositions to subscribe to changes in positions which is more concise. Again once subscribed you're going to receive updates as they come. |
reqAccountUpdates() "stuck" after order fill
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.
? |
Re: IB down?
No problems here. All my TWS and IBGW instances have their scheduled daily restart around 16:30 Central (17:30 Eastern), they came back up in about a minute,, and there had been no error 2110 messages before.
?
2110 could relate to your account (did you make any changes earlier today that they'd push out after 17:00?), the IBKR primary server you are connected to, or the various networks between IBKR and the network facing side of TWS/IBGW.
?
闯ü谤驳别苍
?
On Wed, Sep 4, 2024 at 05:06 PM, Mark Chapin wrote:
|
Re: Trading Future CME Group Long/Short contract
开云体育If both the long and short positions are the same contract, I'm quite certain that you can't hold both.? You could use different contracts or hedge with an option contract though. Mel On 8/27/2024 8:13 AM, zzitounti via
groups.io wrote:
|