开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: 10326 - OCA group revision is not allowed

 

闯ü谤驳别苍,
?
Success! And epiphany #1: when I skip setting ocaGroup (while keeping parentId as in initial order) the problem goes away. The execution engine is once again purring happily!
?
I appreciate your explanation of how you use openOrder(). I do use it (and the other callbacks you list) to track fills, cancellations, cross check positions etc., but it never occurred to me to look beyond .status and .totalQuantity.?
I am going to take a closer look at this as it has clear potential for debugging if nothing else. Some aspects of your PositionController have equivalents in my code, but this is a good opportunity for me to think it through again.
?
Thanks again, this has been most helpful.


Re: in a hedge pair, is it possible to have IBKR set the limit price of the child as a multiple of the execution price of the parent?

 

Unfortunately IB does not offer this capability, to the best of my knowledge. Generally speaking, IB system does not seem to allow repricing of an order based on the execution price of another one. I guess that would introduce an additional separate layer of computational and probably legal complexity into their brokerage routine.


ср, 12 мар. 2025?г., 17:36 Neal Young via <youngneal=[email protected]>:

?
Is it possible to submit a hedge pair of stock limit orders where, when the parent executes, IBKR sets the limit price of the child (which is a limit order) to a given multiple of the execution price of the parent? ?
?
That is, when I set up the hedge pair, can I somehow preconfigure some ratio X, so that if the parent executes at some price P, the child then becomes active with a limit price of X * P ?
?
At the moment I am attempting this as follows.? When I set up the hedge pair, I set the limit price of the parent to some price P, and I set the limit price of the (not yet active) child to X * P.? Then, whenever I update the price of the parent order to some price P', I update the price of the child order to P' * X. But this approach has two shortcomings.? First, the price updates often don't reach the market at the same time, and when that happens the two prices are momentarily out of sync.? Second, the parent order may execute at a price other than its limit price.? When that happens the limit price of the child is X * (the limit price of the parent).? I want it to be X * (the execution price of the parent).
?
(Possibly relatedly, one of the hedge-pair parameters is "dontUseAutoPriceForHedge". ? says only to set this to "not use auto pricing for the hedge".? But "auto pricing" seems to be mean something else, such as automatically raising the limit price at a configured rate when the order is active and not filling.)
?
Thanks, -Neal


--
Best,
DS


Re: 10326 - OCA group revision is not allowed

 

After you call placeOrder() for an order (or in the bracket case call it once for each of the three orders), IBKR keeps your client aware of the order progress through a variety of callbacks: openOrder(), orderStatus(), execDetails(), commissionReport(), possibly error().

The openOrder() callback provides you with an Order object that reflects all the information, IBKR has about the order. The Order object you receive in the first openOrder() callback after placeOrder(), for example, has fields such as clientId, accountId, permId, ocaGroup, ... initialized by IBKR. As the order progresses, subsequent openOrder() callbacks provide Order objects that reflect whatever change took place since the last call (quantity changes due to partial fill, trigger price changes for TRAIL orders, ....)

My framework instantiates (among others) a PositionController for each instrument the client places orders for. That controller:
  • makes order objects and initializes the least number of required fields when an order is initially placed (what you see as "The original bracket order" in my post)
  • receives all callbacks related to the order and monitors the order progress
  • maintains copies of the updated and changed Order objects it receives from time to time from IBKR )what you see in "The Profit Taker order as updated by and received from IBKR")

When it is time to make a change to an already open order (in our case the Profit Taker order), my client simply makes a call such as changeLimitPrice(). IN that case, PositionController makes a copy of the last Order object it received through openOrder(), adjusts in the copy whatever needs to be changed (in our case the limit price) and calls placeOrder() with that order object.

That approach has the advantage that I never really have to worry about what IBKR needs initialized in order for order changes to work.

Hope that makes it more clear.

闯ü谤驳别苍

?

On Thu, Mar 13, 2025 at 11:49 AM, Max Payne wrote:

闯ü谤驳别苍,
Pardon my ignorance, but when you say
'The Profit Taker order as updated by and received from IBKR'
how do you receive and examine the updated order details?
?


Re: 10326 - OCA group revision is not allowed

 

闯ü谤驳别苍,
Pardon my ignorance, but when you say
'The Profit Taker order as updated by and received from IBKR'
how do you receive and examine the updated order details?
?


can't seem to find IB information on PCUSEQTR

 

Hi all not too familiar with IB's financial instrument lookup web approach. Normally I'd just use TWS desktop enter the ticker into a watch list ( done and working) and look at the tearsheet.

For PCUSEQTR there doesn't seem to be one. Can someone give me the link on IB's site where I can research what IB has to say about this? thanks


Re: 10326 - OCA group revision is not allowed

 

闯ü谤驳别苍,
?
Thank you for your reply.
I am not sure how to answer your question about API level. I have API_Version=10.30.01 and a message 'serverVersion:177' pops up on the console when my (Python) client launches. TWS build 10.34.1c. Does this contain the answer? I should have probably mentioned this was happening in paper trading.
?
I am going to take a very close look at my order parameters.
?
But one thing that jumps out upon reading your post is that you do not appear to set ocaGroup, and it would further appear that the server does it. This stands in contrast to my approach of generating and setting ocaGroup explicitly.
I'm not sure whether this matters, but at this stage this is the only item that stands out for me, while everything else you describe sounds familiar and exactly as I think I am doing it myself.
To be honest I don't remember why I set ocaGroup. I wrote this execution engine some years ago, and it has served me well without any major overhaul, allowing me to focus on the analytics engine, which is the thing that decides what and when and sends it to EE. I expect I must have followed some example, possibly from IB online resources.
?
It also appears as though you are leaving the original parentId=2 when you modify the profit taker. That is what I used to do, but I have come across something in one of the posts from a fellow named Raoul:
'In the old situation, I always updated an oca child order with the same parameters, including the parentId . That no longers works. And the error message is actually helpful ;-) Leave parentId out when updating a child oca order when the parent has already been triggered. Worked for me.'
I thus tried setting parentId=0, to no avail.
?
I am going to do more digging now using the leads in your post and will update with any epiphanies that might reveal themselves.


Re: 10326 - OCA group revision is not allowed

 

Works just fine for me on TWS 10.30.1u, TWS API level 173, and ESH5. Both for the IBKR default OCA type 3 as well as type 2 as you use.

What API level does your client use?

My approach is rather simple:

  • I get a properly initialized Contract object for ESH5 from IBKR via reqContractDetails().
  • I construct a regular bracket order with a LMT BUY entry (parent order), LMT profit taker, and STP stop loss order, and place it with the Contract object received from IBKR. The Entry order is priced at the current ask price and fills pretty much immediately. The profit and loss orders are priced 100 ticks away from the entry price (just that they do not trigger right away).
  • My OrderController/TradeManager listens for openOrder() callbacks and maintains the most recent Entry, Profit, and Loss Order states and objects received from IBKR.
  • 60 seconds after the entry order fills, the profit taker price is moved10 ticks closer to the entry price. This is done by changing the limit price of the most recent Profit Order object received from IBKR at that point.

Hope this helps.

闯ü谤驳别苍

?

The original bracket order:
[ {
? "orderId" : 2,
? "parentId" : 0,
? "action" : "BUY",
? "totalQuantity" : 1,
? "orderType" : "LMT",
? "lmtPrice" : 5618.75,
? "tif" : "GTC",
? "orderRef" : "Entry",
? "ocaType" : 0
}, {
? "orderId" : 3,
? "parentId" : 2,
? "action" : "SELL",
? "totalQuantity" : 1,
? "orderType" : "LMT",
? "lmtPrice" : 5643.75,
? "tif" : "GTC",
? "orderRef" : "PTaker",
? "ocaType" : 2
}, {
? "orderId" : 4,
? "parentId" : 2,
? "action" : "SELL",
? "totalQuantity" : 1,
? "orderType" : "STP",
? "auxPrice" : 5593.75,
? "tif" : "GTC",
? "orderRef" : "SLoss",
? "ocaType" : 2
} ]

?

The three orders in TWS:

?

The Profit Taker order as updated by and received from IBKR:

{
? "clientId" : 1741825477,
? "orderId" : 3,
? "permId" : 2088634287,
? "parentId" : 2,
? "action" : "SELL",
? "totalQuantity" : 1,
? "orderType" : "LMT",
? "lmtPrice" : 5643.75,
? "tif" : "GTC",
? "account" : "XXXXXXXX",
? "clearingIntent" : "IB",
? "ocaGroup" : "2088634286",
? "orderRef" : "PTaker",
? "ocaType" : 2,
? "transmit" : true
}

?
The only change to that order object:
?
{
? "lmtPrice" : 5641.25
}
?
?
The updated Profit Taker order in TWS:
?
?
On Wed, Mar 12, 2025 at 03:58 PM, Max Payne wrote:

This appeared as I migrated from 10.23 to 10.34 (tested with 10.30, same thing). Previously it worked fine.
I have read all previous posts related to this error. I made sure parentId=0, but it made no difference. I turned off all precautions and warnings. No love. Other points discussed did not seem immediately relevant to my situation.
The error code does not appear in any IB documentation I have been able to find.
?
What I do is very simple. For ES or NQ (mini futs) I enter a bracket, let's say to buy (LMT) with 2 OCA children, one profit-taking sell (LMT), the other sell STP.
I get filled and all looks good, two open orders appear. Let's call this state of affairs 1. If either gets filled, the other disappears as one would wish. So far so good. We can call this state 2.
But ... the problem occurs if in state 1, with the 2 OCA children still open, I decide to change the price in the profit-taking LMT.
That's when I get?
10326 OCA group revision is not allowed
The request is ignored, and the 2 OCA orders stay open unaltered.
?
This probably doesn't matter much, but my rationale for changing the price is to trigger the sell and close the position with minimal hassle, because my model views further waiting under the circumstances as unlikely to bear fruit. I suppose I could cancel and exit via MKT sell, but this seems simpler, more graceful, it used to work fine, and I miss those days.
?
I use ocaType=2, in case this is relevant.
?
Any help would be greatly appreciated.
?
?


10326 - OCA group revision is not allowed

 

This appeared as I migrated from 10.23 to 10.34 (tested with 10.30, same thing). Previously it worked fine.
I have read all previous posts related to this error. I made sure parentId=0, but it made no difference. I turned off all precautions and warnings. No love. Other points discussed did not seem immediately relevant to my situation.
The error code does not appear in any IB documentation I have been able to find.
?
What I do is very simple. For ES or NQ (mini futs) I enter a bracket, let's say to buy (LMT) with 2 OCA children, one profit-taking sell (LMT), the other sell STP.
I get filled and all looks good, two open orders appear. Let's call this state of affairs 1. If either gets filled, the other disappears as one would wish. So far so good. We can call this state 2.
But ... the problem occurs if in state 1, with the 2 OCA children still open, I decide to change the price in the profit-taking LMT.
That's when I get?
10326 OCA group revision is not allowed
The request is ignored, and the 2 OCA orders stay open unaltered.
?
This probably doesn't matter much, but my rationale for changing the price is to trigger the sell and close the position with minimal hassle, because my model views further waiting under the circumstances as unlikely to bear fruit. I suppose I could cancel and exit via MKT sell, but this seems simpler, more graceful, it used to work fine, and I miss those days.
?
I use ocaType=2, in case this is relevant.
?
Any help would be greatly appreciated.
?
?


in a hedge pair, is it possible to have IBKR set the limit price of the child as a multiple of the execution price of the parent?

 

?
Is it possible to submit a hedge pair of stock limit orders where, when the parent executes, IBKR sets the limit price of the child (which is a limit order) to a given multiple of the execution price of the parent? ?
?
That is, when I set up the hedge pair, can I somehow preconfigure some ratio X, so that if the parent executes at some price P, the child then becomes active with a limit price of X * P ?
?
At the moment I am attempting this as follows. ?When I set up the hedge pair, I set the limit price of the parent to some price P, and I set the limit price of the (not yet active) child to X * P. ?Then, whenever I update the price of the parent order to some price P', I update the price of the child order to P' * X. But this approach has two shortcomings. ?First, the price updates often don't reach the market at the same time, and when that happens the two prices are momentarily out of sync. ?Second, the parent order may execute at a price other than its limit price. ?When that happens the limit price of the child is X * (the limit price of the parent). ?I want it to be X * (the execution price of the parent).
?
(Possibly relatedly, one of the hedge-pair parameters is "dontUseAutoPriceForHedge". ? says only to set this to "not use auto pricing for the hedge". ?But "auto pricing" seems to be mean something else, such as automatically raising the limit price at a configured rate when the order is active and not filling.)
?
Thanks, -Neal


Simplest Way to know if Individual Candle Data is Pre-market, Market or After-hours.

 

if I request Market data with `outsideRth=true`, I get the data for the whole pre-market, market, and after-hours market hours which is great.
?
However, when I inspect each candle in the data, I get the candle's time (t) but, at this point I have no way of knowing whether that one candle sits in pre-market, market or after-hours market hour.
?
So my question is, what would be the simplest way to establish whether a single candle sits in pre-market, market or after-hours market hour?
?
Is executing date/time calculations for each candle's time (t) the only way of doing this? This could be quite complex as would need to take into account different time zones, time of year (daylight savings time), etc. when carrying out each calculation.
?
One option in my head is to request the market data twice; once with `outsideRth=true` and a second time with `outsideRth=false` where I would then take the difference between one set and the other which would leave me with the outsideRth candles separated from the RTH candles but, the outsideRth candles would still include both pre-market and after-hours candles and therefore, I would still need to make calculations for each candle to know exactly which period any one candle belongs in (e.g. pre-market, market, after-hours).
?
Thanks in advance for any answers to this question.
?
PS: This is my first time posting here and I have tried searching to see if this has been asked before but I did not get any results back so, apologies if I am not using the search tool properly or not posting the question properly either.


Re: reqMktData callbacks are missing data with gateway 10.30 and 10.31 sporadically, works fine with 10.19 and older gateways/TWS

 

Thank you very much Andrei, your research (troubleshoot) is very helpful..!!!

Rgds,
Idjoel


On Fri, Dec 20, 2024 at 12:56?AM ajn via <andrei.jefremov=[email protected]> wrote:
Just run a couple of more tests (using the app I posted, just changed False to True and commented cancel request). Snapshot works 100% reliable as Daniel experiences i.e. snapshot delivers all that is expected and no errors printed
self.reqMktData(orderId,?contract,?"", True,?False, [])
live data (4th argument is False) oth is the case which has the problems
self.reqMktData(orderId,?contract,?"",?False,?False, [])
It is live data is bit broken in gateway 10.30+ . We are making some progress :)
?


Re: ISSUES WITH SMOOTH FAILOVER IN TWS APPLICATION - IBKR SERVER CONECTION DROP.

 

Must be brand-new then. It is in TWS and IBGW 10.30.1u on Linux.
?
?
On Fri, Mar 7, 2025 at 08:39 AM, ds-avatar wrote:

I don't have this option in TWS 10.30.1t and IBGW 10.30.xx.
?
--
Best,
DS


Re: ISSUES WITH SMOOTH FAILOVER IN TWS APPLICATION - IBKR SERVER CONECTION DROP.

 

I don't have this option in TWS 10.30.1t and IBGW 10.30.xx.
?
--
Best,
DS


Re: Using Wall Street Horizon API w/ TWS-API

 

Take a look at the WSH section in the deprecated (but generally much superior) TWSAPI documentation at . It is not a full tutorial either, but it describes the process for requesting WSH meta data, making filters, and requesting event data. It should have the info you need to make this work for you.

TWSAPI is an asynchronous, event driven, request/response API. Your client code calls request methods of the EClient class and handles (overrides) the corresponding callback method defined in the EWrapper class.

闯ü谤驳别苍

?

?
?
On Thu, Mar 6, 2025 at 08:57 PM, Henk Visser wrote:

All,
?
I am trying to get some basic functionality working with the Wall Street Horizon API (using the TWS API) but there seems to be some fundamental items that I am missing.
?
I am referencing the documentation here:
?
?
I feel I need more information than what is provided here.? I was hoping to find a more detailed tutorial.
?
1.) It looks like the first step is to call reqWshMetaData
?
The example shown in the documentation shows:
?
self.reqWshMetaData(1100)
?
What exactly happening here? It is dumping the entire calendar of data? Any further explanation on this I would appreciate.
?
2.) In the Ewrapper there is the function wshMetaData()
?
def wshMetaData(self, reqId: int, dataJson: str):
? print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
What should I be doing at this point? From the documentation this looks to return specific event types.? the print() returns a lot of data that looks unfiltered and not focused on what I am looking for.?
?
3.) Request Event Data
?
The example in the documentation shows the call as the following.
?
self.reqWshEventData(1101, eventDataObj)
?
I am not sure here about the eventDataObj. The documentation states that "When making a request to the Wall Street Horizons Event Calendar with the API, users must create a wshEventData Object."? In the API documentation I don't see any an example of how to create this eventDataObj.
?
4.) Receive Event Data
?
In the Ewrapper I then see the function:
?
def wshEventData(self, reqId: int, dataJson: str):
? print("WshEventData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
How do I filter this to only show data for a specific stock?? Is this related to the conID that would be part of the wshEventData?
?
Thanks for any information on this.
?
?
?
?
?
?
def wshMetaData(self, reqId: int, dataJson: str):
  print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
def wshMetaData(self, reqId: int, dataJson: str):
  print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
?


Using Wall Street Horizon API w/ TWS-API

 

All,
?
I am trying to get some basic functionality working with the Wall Street Horizon API (using the TWS API) but there seems to be some fundamental items that I am missing.
?
I am referencing the documentation here:
?
?
I feel I need more information than what is provided here.? I was hoping to find a more detailed tutorial.
?
1.) It looks like the first step is to call reqWshMetaData
?
The example shown in the documentation shows:
?
self.reqWshMetaData(1100)
?
What exactly happening here? It is dumping the entire calendar of data? Any further explanation on this I would appreciate.
?
2.) In the Ewrapper there is the function wshMetaData()
?
def wshMetaData(self, reqId: int, dataJson: str):
? print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
What should I be doing at this point? From the documentation this looks to return specific event types.? the print() returns a lot of data that looks unfiltered and not focused on what I am looking for.?
?
3.) Request Event Data
?
The example in the documentation shows the call as the following.
?
self.reqWshEventData(1101, eventDataObj)
?
I am not sure here about the eventDataObj. The documentation states that "When making a request to the Wall Street Horizons Event Calendar with the API, users must create a wshEventData Object."? In the API documentation I don't see any an example of how to create this eventDataObj.
?
4.) Receive Event Data
?
In the Ewrapper I then see the function:
?
def wshEventData(self, reqId: int, dataJson: str):
? print("WshEventData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
How do I filter this to only show data for a specific stock?? Is this related to the conID that would be part of the wshEventData?
?
Thanks for any information on this.
?
?
?
?
?
?
def wshMetaData(self, reqId: int, dataJson: str):
  print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
def wshMetaData(self, reqId: int, dataJson: str):
  print("WshMetaData.", "ReqId:", reqId, "Data JSON:", dataJson)
?
?


Restoring combo in position update

 

When I place a combo order via the API, TWS shows the options spread as I sent via the API:
image.png

However, position callbacks give only the?individual?option leg positions. Is there a way to restore the combo composition via the API? (I can store the?composition info in DB, but I'm interested in whether there is an API way.)

Thanks,
Zsolt


Re: TBill Maturity date

 

Thanks for verifying.? Disappointing. For bills, the name of the instrument doesn't have the date in it. But for bonds, I can pass the maturity date from the name and have had some luck converting that to something I can use in my software.?


Re: TBill Maturity date

 

开云体育

The ContractDetails class does indeed contain a Maturity field in the source code.

?

In the C-Sharp API it’s defined like this:

?

?????? /**

??????? * @brief he date on which the issuer must repay the face value of the bond.

??????? * This field is currently not available from the TWS API.

??????? * For Bonds only. Not currently implemented due to bond market data restrictions.

??????? */

?????? public string Maturity

?????? {

?????????? //! @cond

?????????? get;

?????????? set;

?????????? //! @endcond

?????? }

?

So it looks like you’re out of luck. All you get is a blank field.

?

?

?

Richard

?


Re: TBill Maturity date

 

Sure - Right now, in my portfolio and in my risk management software, I am trying to find out the maturity for:?
TBILL:? ?CON_ID: 756373753? ??This is a Jul 24, 2025 91279PF8 contract, which I can see in my portfolio. And I can use IBKR TWS platform to ask about the description, which comes up with CUSIP, ISIN, Maturity Date etc (from the trading platform, not the API).? ?Ideally, I would be able to get that symbol string, and parse the maturity date from the contract details in the API. But I don't see it in my request of contract details.? ? From the platform, description comes up with a msg box - would love to get the Maturity Date in the API!
Underlying ???? US-T ?
Coupon ???? No Coupon ?
Currency ???? USD ?
?
Bond?Description
Symbol ???? IBCID756373753 ?
Security?Type ???? BILL ?
Exchange ???? SMART ?
CUSIP ???? 912797PF8 ?
ISIN ???? US912797PF82 ?
Issue?Date ???? JAN 23 '25 ?
?
Details
Exchange?Listed ???? No ?
?
Issuer?Information
Bond?Issuer?Type ???? GOVT ?
Face?value ???? 1000.0 ?
Maturity?Date ???? JUL 24 '25 ?
Contract?ID ???? 756373753 ?
Min.?Tick?Size ????
0.00001???? Min_Tick_Size


Re: TBill Maturity date

 

开云体育

It might help if you give us a concrete example. The contract id would do for a start.

?

Richard

?