Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: reqPositionsMulti does not work as intended
Fair enough if that was the case but then what is modelCode good for? I don't seem to be able to make use of it. Orders can be supplied with a model code and that modelCode can be entered into reqPositionsMulti. I don't see the benefit of that if it does not work...?
|
Re: reqPositionsMulti does not work as intended
Dojo321 wrote: ".. net position in TWS would be 0 but when I request positions I want to see two positions, .. "
This is not possible with an IB account. Your IB account is a netting account, meaning that only the net result of all trading activities in a ticker symbol is available as position size. IB does not provide a so-called "hedging account", which is what you would need for your purpose. |
Re: Suggestions on how to deal with blocking pop up from TWS (like last week)
Great question. I didn't get a popup at all. But all orders stopped. And I had to a web interface to actually see to popup and agree.? |
Re: Best method for getting level 2 market depth snapshots on a large number of equities
Thanks for the response Jurgen, really appreciate it. Everything you said about the cancellation requests makes sense to me.
On average, I find I'm able to get about 1 per second if I limit myself to one stream maximum. With a two stream maximum I can get somewhere between 1.5 and 1.8 per second. With a three stream maximum I was getting a bit over 2 per second, but that's my maximum number of streams alas. This is all trading on my own account, so unfortunately I'm a wee bit short of the account values needed to get awarded bonus streams :-)??? and I'm not currently paying for any booster packs. Cheers, Colin On Tue, 2 Aug 2022 at 17:34, 闯ü谤驳别苍 Reinold via <TwsApiOnGroupsIo=Reinold.org@groups.io> wrote:
|
Re: About commissionReport.realizedPNL
?The various options for PNL feeds are described in 闯ü谤驳别苍 On Tue, Aug 2, 2022 at 02:17 AM, <david03kimo@...> wrote:Thanks,I think your quick example is exact what I want. |
Re: Best method for getting level 2 market depth snapshots on a large number of equities
I would have used the same approach and cannot see a way to do it differently. How long does it take to grab a snapshot for 30 instruments? When you are done with a snapshot it will take a while for your request to be finalized. TWS sees it right away, but I am sure they won't add the feed back to the "available" pool until TWS receives a cancellation confirmation from the IBKR back-end. So I am not surprised that the next might get denied until TWS has received a cancellation confirmation from IBKR. Unfortunately, has no callback that indicates to you when it is safe to make the next request. This could potentially be an ongoing area of instability. The hard limit for the number of simultaneous Level 2 streams must have been increased, since now says you can have up to 60. But you can only get 10 of them by purchasing booster packs. To get to 60 you must have enough equity or commission to "earn" them. According to the fine print in
If my math is correct, $48,000 in monthly commission or an account value of $60Mio gets you to the 6,000 market line allocations you'd need for 60 simultaneous market depth feeds. Or half of that for 30 feeds :-) 闯ü谤驳别苍 |
Re: No historical market data for AAL/STK@VALUE Last 1d
When you say "I'm retrieving the contract object fresh" are you talking about reqContractDetails? If so, how many contracts does the request return? When I ask for AAL:STOCK (no other fields initialized in the query contract) I get 31 contracts for three instruments:
Only that last contract for "AVIAAM LEASING AB" trades on the VALUE exchange. Any chance wires might get crossed and the historical data request sees that contract? Attached a quick CSV with the contracts I get. 闯ü谤驳别苍 On Tue, Aug 2, 2022 at 12:02 AM, David Walker wrote:Hi Everyone, |
Best method for getting level 2 market depth snapshots on a large number of equities
Hi all.
As most probably know, even if paying for extra streams, there is a hard limit of around 10 market depth streams that can be open at any one time. If I wanted to see a snapshot of level 2 depth data on, say, 30 stocks, what is the best way of accomplishing this? What I currently do is this: Let's say I'm allowed to have 5 open depth streams at once. Then in my code I have a loop that iterates through my list of 30 stocks, but ensuring that only a maximum of 5 streams are open at any one time. While a stream is open, the code checks whether I have data down to a specified depth, say, 10 levels, and as soon as I reach that depth on both bid and ask sides, I close the stream and open a new one. I also have a timeout, so that if any one stream has been open for too long it gets automatically closed. In this way I iterate through the list of 30 stocks, such that at the end, I have a snapshot of the depth across all 30 stocks. Obviously some of the data will be stale at this point, but for lightly traded stocks I haven't found it to be too much of an issue. One other point I should add is that in practice, I've found that I need to have one less stream than my maximum open at a time, otherwise sometimes things overlap and I get an automatic disconnection for attempting to open too many streams at once. So, are there any clever ways for improving on this approach that people are aware of, or is this about the best I can expect to do? BTW, I usually trade ASX equities, if that makes any difference. Cheers all, Colin |
No historical market data for AAL/STK@VALUE Last 1d
Hi Everyone,
I'm receiving this error callback when making an historical data request for AAL: "No historical market data for AAL/STK@VALUE Last 1d"? (error code 162) I can't work out what's going on!? I'm retrieving the contract object fresh before sending the reqHistoricalData request.? The exchange in the contract object is 'SMART' and primaryExchange is 'NASDAQ', but the error message seems to indicate AAL is looking at the VALUE exchange. TWS shows historical data for AAL in the last 1 D, so it's not clear why the API would say there is no data. Most of my historical data requests are working fine (with all the same request parameters, except the contract object) - though there are a handful of others (say 1 in 100) that are also giving the same error above. Can anyone help solve this? |
Re: reqPositionsMulti does not work as intended
To add, my goal is to tag orders with different modelCodes in order to keep positions apart. For example. If I buy 100 shares of Apple with modelCode "Strategy1" and short 100 shares of Apple with modelCode "Strategy2" my net position in TWS would be 0 but when I request positions I want to see two positions, one for each modelcode with their own averagePrice and positions. But I do not seem to be able to get there....
|
reqPositionsMulti does not work as intended
I am having trouble with the C# API requesting positions via reqPositionsMulti with a modelCode. When I query with an empty string I get all open positions, however, when I populate modelCode with a non-empty string that was attached to the modelCode parameter in the Order class when submitting orders then? "positionMulti" does not return anything.?
Is there a special string that returns ALL positions, regardless of which modelCode was used when submitting orders? At this moment neither works.? |
Re: opt out from: Secure Login required for trading
Thanks. Sounds like IB is moving towards 2fa. Guess it is time to bite the bullet. I was just I was hoping IB would do something more algo trading friendly, but of course any solution has pros/cons.? I am big fan of IBC. Been using it for 3 years, zero issues. One of my commits was even accepted in the code :) I tested over weekend how the latest version is handling 2fa. Very impressive, exactly how I was hoping a 3rd party app. would do it. I am switching 2fa on now with IBC. fingers crossed it will be as stable as without 2fa |
Re: Duplicate Order ID
Hello Folks,
thanks a lot for your help again. I don't want to use more of your time. I have a workaround that works for me with creating a contract object. Its time for me now to figure out how i can use the contractdetails object and if i manage this i will publish this here. So thanks again for all the information and have a good time! Best wishes Robert |
Re: Duplicate Order ID
You should not have to create all that code in order to use a contract object you received from reqContractDetails. And you should be able to use the entire object without having to copy individual fields. That defeats the purpose. Unfortunately, I don't have enough experience with Excel/VB (nor do we use MS/Office programs, LibreOffice/OpenOffice works much better for us) and I cannot give you additional pointers here. Maybe, for now, you should create contracts from scratch again. Using reqContractDetails to retrieve contract objects that IBKR creates for you with all fields they care about initialized is a "best practice" (but clearly not the only approach):
But again, this only makes sense if you can convince the Excel/VB environment that it should use the contract object from reqContractDetails without any extra coding or field copying. 闯ü谤驳别苍 On Mon, Aug 1, 2022 at 05:37 AM, Metrodus79 wrote:Hello joanmarcel119, hello 闯ü谤驳别苍 |
Re: Duplicate Order ID
I think the best for you is to get the excel file which comes with the IB API and do some tests in their code.? What you have now developed I can not check if it is valid or it will work. I started the same way, by copying first the excel file of IB and then doing some minor changes and debugging. So if you already did this, then I recommend starting again. You should also debug the code to see how it works, like for example, setting a breakpoint?into the procedures called by the TWS usually?placed in the API module after your request has been sent. Hope that helps El lun, 1 ago 2022 a las 12:37, Metrodus79 (<robert.metasch@...>) escribió: Hello joanmarcel119, hello 闯ü谤驳别苍 |