Concerning the mandatory delay of 1 second between
changes to an Order...
Just checking, assuming an active order/position in
IOrder.State.FILLED...
Is it possible to change both the StopLoss and the TakeProfit
price simultaneously (in quick succession) without the
mandatory 1 second delay, or...
Must we change Stop Loss, for example, and then wait
1 second before changing the Take Profit level ?
It would be nice to have an "atomic" call in IOrder like
IOrder.setStopLossAndTakeProfit(double stopLossPrice, double takeProfitPrice)
which would be "atomic" and not require any delay.
Even better... I would like to see a "batch" or "transaction"
capability, for example:
// this code would not be reliable, due to
// possible exceptions preventing endBatch from executing
order.startBatch();
order.setStopLossPrice(...);
order.setTakeProfitPrice(...);
order.endBatch(); // order change(s) sent to server
In practice you would have to use a try/catch/finally to ensure
that this works reliably, as in pseudocode:
// this format would ensure that endBatch is called
// even with exceptions
try {
order.startBatch();
// change one or more order properties
// which could result in exceptions
order.setStopLossPrice(...);
order.setTakeProfitPrice(...);
}
catch(Exception e) {
// report exception
}
finally {
order.endBatch(); // ensure endBatch is called
}
Thanks,
HyperScalper