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!
|
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.
toggle quoted message
Show quoted text
--- 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!
|
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.
toggle quoted message
Show quoted text
--- 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!
|
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
toggle quoted message
Show quoted text
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!
|
I'm not sure what part you figured out but I'll clear up my post.
I think you must not be placing orders correctly as my method should work for market orders. I'm just saying that I only use limit orders so I haven't verified this.
Just FYI, I use limit orders as you suggest at either the bid or ask if I want an order that fills as fast as a mkt order. I never place mkt orders and don't really miss them.
toggle quoted message
Show quoted text
--- In TWSAPI@..., 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!
|
I meant the parent/child stuff,
Quick question: does API support changing LMT to MKT?
I knew STP to TRAIL will be rejected, cause type change is not supported,
A->B type change is not supported in general or some of them?
toggle quoted message
Show quoted text
--- In TWSAPI@..., "btw12342001" <newguy@...> wrote: I'm not sure what part you figured out but I'll clear up my post.
I think you must not be placing orders correctly as my method should work for market orders. I'm just saying that I only use limit orders so I haven't verified this.
Just FYI, I use limit orders as you suggest at either the bid or ask if I want an order that fills as fast as a mkt order. I never place mkt orders and don't really miss them.
--- In TWSAPI@..., 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!
|
actually, it's easier,
you don't have to change
s_order_parent.transmit = false; s_order_stoploss.transmit = false; s_order_profittaking.transmit = true;
then summit in order
m_pClient->placeOrder(parentId, m_contract, l_order_parent); m_pClient->placeOrder(parentId + 1, m_contract, l_order_stoploss); m_pClient->placeOrder(parentId + 2, m_contract, l_order_profittaking);
all of them will be submitted correctly
toggle quoted message
Show quoted text
--- In TWSAPI@..., Jian Ren <renjian@...> wrote: 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!
[Non-text portions of this message have been removed]
|
Re: "I knew STP to TRAIL will be rejected, cause type change is not supported,"
Is that documented somewhere ? The fact that it is rejected is not that intuitive.
I mean : "what's the rationale ?"
|
nope, I found no information in doc.
tried and rejected, error msg said so.
toggle quoted message
Show quoted text
--- In TWSAPI@..., "Mark Simms" <marksimms@...> wrote: Re: "I knew STP to TRAIL will be rejected, cause type change is not supported,"
Is that documented somewhere ? The fact that it is rejected is not that intuitive.
I mean : "what's the rationale ?"
|
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
This soulution is OK, I have used it with good results. ? Also, once you are a little in the profit zone, cancle the sl and enter a TRAIL order. ? Best ? John? [Non-text portions of this message have been removed]
|
Your first question is very interesting and i am in the same boat (read all responses, looks there was no clear answer)
I need to emphasize order speed over slippage, and have noticed limits are much slower then market order, (EUR.USD, tested in a demo account)
So basically i want to place a market order(entry), with a trailing order (protection), as a bracket order. and must use the market order, limit seems to be to slow (i have seen it take minutes on the demo account, not sure if this is a demo issue), but dont want to test it with real money
i cant understand the rationale now for not supporting this.
-Ray
toggle quoted message
Show quoted text
--- 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!
|
@raysalem619 did you really mean "minutes"? can somebody tell this is not true in a real account? I would like to see rather something less than second.
|
If I remember right he was talking about a limit order which of course will sit until the price is met. Market orders in liquid markets are essentially instantaneous.
toggle quoted message
Show quoted text
On 7/12/2013 2:23 PM, cf16r wrote: @raysalem619 did you really mean "minutes"? can somebody tell this is not true in a real account? I would like to see rather something less than second.
|
IN the demo account it was minutes, not sure if this would be true with real account
thanks ray
________________________________ From: cf16r <piter@...> To: TWSAPI@... Sent: Friday, July 12, 2013 11:23 AM Subject: [TWS API] Re: TWS API child order questions
? @raysalem619 did you really mean "minutes"? can somebody tell this is not true in a real account? I would like to see rather something less than second.
|
nothing is reliable in demo account. you cannot assume anything by induction from your experience with edemo/demouser: this is my opinion after doing initial tests on demo account.
|