Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
parentPermId always 0 (zero)
I am placing a parent order with two attached bracket orders in TWS and when transmitting the orders, my client application connected to TWS sees the parentPermId of the bracket orders as always 0 (zero). I would expect the parentPermId field of the bracket orders to be set to the permId of the parent order. Has anyone had success using the parentPermId effectively ?
-- |
Re: Live data on multiple contracts - Python
Hi Jurgen,
?
Your advice. I instantiated only one TestApp() and set up a loop to pass multiple contracts.
?
I have a couple more questions for now:
?
1. I got all expirations and strikes with reqSecDefOptParams() and set up a nested loop to go through every combination. I was trying to pull historical data since I was coding after market hours.
Some combinations worked, some did not, because they simply did not exist. Anyway, I noticed that the terminal stopped dumping data at around reqId 72.
When I try to retrieve so much data, do I need to set up a pause after certain amount of iterations? Is there a limit to how many contracts per second I can request?
?
2. After realizing that I am iterating over contracts that may not exist, I tried retrieving them with reqContractDetails() method. I only specified contract.symbol, contract.secType, contract.exhcnage, and contract.currency. When I ran the code, the terminal gave me all contracts on the chain. Sometimes it took as little
as few seconds, sometimes it would take a minute or more before I saw anything appear in the terminal. When I tried saving conIDs to a list, I was only able to save the very last one. When I compared the code between reqContractDetails() and reqSecDefOptParams() in decoder.py, I realized that the former returns only one value, and the latter returns a set. I guess this is more of a coding question than how the API functions, but is there a way to save all the conIDs returned by reqContractDetails() to a list?
?
3. I will have another question regarding greeks, but I still have a couple methods to explore, so I'll check back in later with that.
?
Thank you! |
Re: Some Paper trade Orders not filling after updating to 10.30
@Patrick Yeah I think we're experiencing the same bug. These are paper orders so it may just be an issue with simulating the fills on the server. I think you're right; these might go away when running on a real account. Thank you for your insight.
?
I also contacted IBKR support before I contacted this forum; they gave a few suggestions but couldn't pin it down. As requested, I emailed them the gateway log files but they were too large to be sent via email so gmail stored the 255mb zip on google drive for them to open and IB has an understandable policy against opening files on a google drive. Because of this, the technician wasn't able to open the file and I wasn't able to get a final answer from them.
?
@Jurgen Thanks, I'll check that out and see if it resolves the issue.
?
If somebody else encountering this issue is reading this, I started finding this issue on a daily basis after the update to IBGateway 10.30. I was running on IBGateway 10.19 without issue. The issue persists in paper trading while running tws api on 10.19 or 10.30, IBGateway 10.30 or 10.35. I rolled my code back to the way it was in early March before I started seeing this every day and the issue is still there with the old code. In my research, I found that there had been issues with paper orders filling on server side in the past. I can't guarantee that is the cause of this but it seems that way. Again, this doesn't seem to be happening with real money and IB is properly directing their priorities to accounts that are actively risking money.?
?
You can see how my exit order code works above. In a separate function, 20 seconds after the mkt order becomes active, if it hasn't filled the order is replaced. This is for the very unusual case in which an order is routed to a venue but the venue is down. (It happened once or twice in 2024) It happened twice between February and March and replaced the exit once each before closing. The recent issue is that it happens 6 or 7 times in a row. I don't think this is an issue with my code; if it was I think it would have stopped when I rolled my code back. If I find an issue with my code, I'll post the fix to this forum.
?
Thanks |
Re: Some Paper trade Orders not filling after updating to 10.30
OCA types 2 and 3 do not cancel orders and both work by "Remaining orders are proportionately reduced in size":
If you set type 3 in your orders, you override IBGW presets and you will have no overfill protection.
?
´³¨¹°ù²µ±ð²Ô
?
On Tue, Apr 29, 2025 at 07:07 PM, <plborgprograms@...> wrote:
|
Re: Some Paper trade Orders not filling after updating to 10.30
¿ªÔÆÌåÓýThere seems to be a correlation between your OCA issues and my OCA issues View/Reply Online (#54129) ? I did contact IBKR support. Pretty much discarded because it was a paper account, they said they would check if it were a real account. They found it complicated there were so many orders(you would think they can do an easy search lol). ? I guess it¡¯s also possible this wouldn¡¯t happen in a real account too. ? Will be interested to see if your issue is resolved. ? Still happening every day on my end. ? Thanks |
Re: Some Paper trade Orders not filling after updating to 10.30
Thank Jurgen. Since this was going back to examine orders placed today, the invalid marker is what it should say.
?
Ocatype 3 is what I've been setting it to. In cases of partial fills, type 3 seems to be the only one that keeps all the orders active. Overfill protection seems to be active if specified in ib gateway even if it's type 3. (Correct me if I'm wrong)
?
Since the order was placed during active hours, this looks like it should be active.
?
So far it looks like a valid order. |
Re: Some Paper trade Orders not filling after updating to 10.30
There is no issue with the "INVALID" time in force. TWS will show "INVALID" for orders that are not open any longer (filled, cancelled). You can control the OCA OverfillProtection from the API. When you create the OCA, you select its behavior with the Order field. The "with block" OCA types 1 and 2 are overfill protected, OCA type 3 is not. If you do not set the field (e.g. it is initialized with 0), IBKR will select the OCA type for you. The order you show is limited to the regular trading hours only, but the EndTime is set to 20:00 US/Eastern. That by itself is not an issue, but the order will not have been active before 09:30 and between 16:00 and 20:00 US/Eastern. ´³¨¹°ù²µ±ð²Ô ? On Tue, Apr 29, 2025 at 05:24 PM, <plborgprograms@...> wrote:
|
Re: Some Paper trade Orders not filling after updating to 10.30
@Orionn I was able to get the output but through a different way. I'm wondering if the "INVALID" time in force is the issue. Some seem to be filling anyway. In the API, OverfillProtection is decided in the gateway rather than per order so it should be checked if anything. I haven't looked at enough orders in this view to know if anything here would block it from filling.
?
|
Re: Missing bid delta for some options
?"Thank you, but I don't understand the response.? My question is simple: Why does IB calculate only some of the bid, ask, and model deltas, but not all of them??? On Tue, Apr 29, 2025 at 9:18?AM mov_ebpesp via <mov_ebpesp=[email protected]> wrote:
--
?dv, Zsolt |
Re: Missing bid delta for some options
The market prices (bid, ask or last) do not give a smooth IV smile curve as a function of strike price. TWS fits these "rough" IV's to a smooth curve called the "option model" and returns what the IV and other parameters (like delta) on that curve should be - those are the model prices.
?
In theory if you buy low and sell high based on the model price, you can do arbitration. In practice, like with all things related to trading, it's not that simple (limited margin & similar).
?
For example if you have (bid, ask) pair for a call and just a (bid) but no (ask) for a put, all at the same strike, you could in theory compute what the other ask should be (assuming same midpoint/spread). You could then become the "market maker" by entering your own LMT order at the theoretical put ask price. |
Missing bid delta for some options
Hello, I use What do you think? Also, I have another question: in the picture, the model delta lies between the bid and ask deltas. However, sometimes the model delta falls outside the range defined by the bid and ask deltas. Why does this happen? Thanks, ?
?
|
VC and 10.35 and Protocol Buffers
In MSVC, has anyone succeeded in downloading the protocol buffer code, and the extra linked project ABSL code, and gotten it to compile with the sample API projects?? Not me so far.
?
The TWS-API revision # of PB in the supplied files is 5029003, and it needs the .h files from the protocolbuf project to compile.
The closest I can find for PB source version is the 29.x branch.? Though this build is actually 5029005 - so I adjusted the # to match.
?
Next is the linked ABSL (abseil-cpp) project and the branch with LTS 2024-07-22 was likely the current one to match PB 29 at the time, and avoids a bunch of function / link errors that the master and other branches cause.
?
Next adjust the VC source to the PB demanded C++ v17 code.
?
This combination gets me almost compiled, but with one error I cannot solve:? error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file.? All the included files are there, so something is still a miss.?? The google side is built without a global include file, but the VC project uses the stdafx.h.??? I can't get anything to agree here.
?
Stumped.
?
?
? |
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 |
Re: Live data on multiple contracts - Python
You would have only one TestApp(). But you would remember the value of app_underlying.nextId() used for the subscription of each contract since future data callbacks will contain that requestId. That way you know which market data item belongs to which contract. Hope that helps. ´³¨¹°ù²µ±ð²Ô ? On Thu, Apr 24, 2025 at 09:21 PM, <danielsojka1@...> wrote:
...
?
?
?
|
Live data on multiple contracts - Python
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() and give each one a unique clientid and run threading on every one of them?
?
Thanks in advance!
? |
Re: Securities for this order were not immediately available for short sale, but not asking to short...
I will try to lower LMT price.
This is for the STP LMT to work.
Original issue I'm having are orders that get an error message about not being able to short the stock.
I never ask to short a stock.
I only buy stocks then create OCA group sell orders...
Any idea what can be done for this? |