The callback function which you provide as a parameter to SendOrder() receives success or (first) failure of the request. It receives one parameter: a message which contains an FXB.Result object in a property called result. For example:
Framework.SendOrder({
… request definition
}, function (Msg) {
if (Msg.result.isError) {
// Trading request failed
} else {
// Trading request did not fail. However…
}
});
Broadly, there are four possible outcomes from a trading request:
Request fails. The FXB.Result will return isError=true
Request is carried out and succeeds. The FXB.Result will return isOkay=true and code=FXB.ErrorCodes.OKAY
Request requires no action - for example, asking to do a FLATTEN on the account when there are no open orders. The FXB.Result will return isOkay=true and code=FXB.ErrorCodes.NO_ACTION_REQUIRED
Your request is subject to user confirmation, and the user cancels the request before it is started. The FXB.Result will return isOkay=true and code=FXB.ErrorCodes.CANCELLED
In other words, isOkay=true in the FXB.Result does not necessarily mean that any trading action has been carried out. In particular, if you want to look for cancellation by the user, you need to check the code instead of isOkay or isError. User cancellation is not treated as an error condition by an FXB.Result.