Open brw59 opened 3 years ago
Sorry I missed this.
I'm not 100% sure what you're trying to do. It sounds like you are trying to buy and use a OCO bracket to exit. If so you would:
1) enter a buy order 2) when filled,, enter an OCO order w/ a stop below the market and a limit above
This could probably be combined into an OTO w/ the initial buy being the 'primary' order and the OCO being the 'conditional' order. (Have never tried a OCO w/ an OTO so not sure how this would work.)
NOTE: when you use the Equity.Stop builder you are simply creating a stop order, not an order w/ a separate/conditional stop order attached. To do that you would use an OTO. Also, just adding a child order directly won't do anything unless you also use the .set_strategy_type(...) method - in these cases its best to use the OCO or OTO builders.
I am looking to do this, but I don't know if it is possible.
1) build a buy order with a stop 2) create a sell order higher than being bought with the stop order 3) attach a child cancel order to the sell order ... The idea here is to auto cancel the 'stop' part of the stop order if the 'sell' order goes through first 4) attach a child cancel order to the buy stop order ... similarly, the idea is to cancel the 'sell' order if the stop was executed due to the price dropping
Here's what I came up with so far, but it won't work because the 'cancel_order' doesn't return an 'order' object, it just executes. Is there a way to make this happen?
Note: I do realize that I have to run the 'send_order' of the 'sell' or 'stop_builder' first in order to obtain the oid used in the 'cancel_order', but I don't think this would be the case if there was a way to build the cancel order before executing it. Or at the very least, I'd have the choice to choose 1 to tie to the other (opposed to tying them both to each other)