softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Nesting orders with different assets #137

Open giovannetti87 opened 2 years ago

giovannetti87 commented 2 years ago

Let' suppose I want to execute, in order, three trades, for example "buy SPY" and then "buy QQQ" and then "buy nuix". I understand IBKR allows for bracketed and hedged orders are showed in Spartan's example. However, I see that nested orders with different underlying (as in my example) are rejected by IBKR. I can see the bracketing doing what I want, but only the parent order gets executed, whereas the remaining branches are killed.

Is there a way to nest orders across different assets using the ParentId method?

thanks,

Despair2000 commented 2 years ago

I doubt this can be done with the "parentId method". Maybe this can be done with a conditional order (I never tried). Otherwise you have always the option to do this yourself in MATLAB.

giovannetti87 commented 2 years ago

I see. Yes, indeed. I hoped for a server-based solution, but I guess local sequencing won't be too bad. I was looking forward conditional orders, but it appears they only relate to external market conditions rather than user-induced conditions.