开云体育

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

Re: TWS API child order questions


Jian Ren
 

This is called "Bracket orders" in TWS. When you set the transmit to false,
no matter the parent is market or limit, it won't be sent until you set
transmit back to true and submit the 3rd order.
Actually all the three are sent as one transaction, which should work for
you.
Jian

On Wed, Apr 4, 2012 at 4:52 PM, ustcbbc <no_reply@...> wrote:

**


I figured that part out. thank you.

but the thing for scapling is,

I can afford slippage from MKT order than the opportunity cost from LMT
order.

--- In TWSAPI@..., "btw12342001" <newguy@...> wrote:

I only use limit orders but I think you should send the parent order
with transmit = false. On the last child order set transmit = true and then
they all get sent.

--- In TWSAPI@..., ustcbbc <no_reply@> wrote:

Hi,

I am writing a forex scalping program with IB POSIX C++ API,

there is one question:

I need to submit one parent order and attach one trailing stop order
and one profit taking order.

parent order is market order as I don't want to miss any opportunity,
filling as fast as need. but trailing order can't be attached to market
parent order.

if I attach a stop order first, I am not able to change it to TRAIL
type later.

So what kind of solution you use?
1. submit parent order with limit order, you could put limit price
higher than market price (for buy) to simulate a market order, but in this
case I have to track the bid/ask as fast as I could, I don't even know IB
is capable of it (no real tick price and latency between my computer and
their servers).

2. submit parent order with MKT type, no child order, put a trailing
order afterwards?

3. manually implement a TRAIL order by modifying stop price for STP
order attached whenever necessary.


Second question,
m_pClient->placeOrder(m_orderId, m_contract, order_parent);
m_pClient->placeOrder(m_orderId + 1, m_contract, order_stoploss);
m_pClient->placeOrder(m_orderId + 2, m_contract, order_profittaking);


trying to make a MKT parent order,
and two child orders, one sl with STP type, one tp with LMT type.

problem is,

I have to submit three orders in turn. parent order first.
but after I submitt the parent order, it will be filled immediately.

child orders will produces error msg like:

Error id=59, errorCode=201, msg=Order rejected - reason:The parent
order is bein
g canceled.

And another question, In TWS, I am able to submit stop with stop price
of actually traded price of parent order, How should I do it via API? the
trade price of parent order is unknown when submitting attached child stop
loss order.

right now,
I am submitting two child orders with very wild sl and tp level and
modified it once parent order gets filled. apparently this is not a good
solution


Any idea?

Thanks a lot for your help!

Join [email protected] to automatically receive all group messages.