3.3.10Validating trading requests without execution

You can use Framework.ValidateOrder() to validate trading requests without executing them. As well as checking that a request passes the framework's internal validation, this also does two other things:

It splits a bulk action such as FLATTEN into the individual jobs for closing each open order or trade

It converts variable definitions such as openPrice:{offset:0.0020} or volume:{equityPercent:2} into fixed amounts

ValidateOrder() takes two parameters: the same trading request which you pass to SendOrder(), and an asynchronous callback function. For example:

Framework.ValidateOrder({

tradingAction: FXB.OrderTypes.SELL_LIMIT,

openPrice: {offset: 0.0020},

instrumentId: "EUR/USD",

volume: {lots: 0.20}

}, function (Msg) {

… result of validation

});

The Msg which is passed to the callback function can contain two properties:

Property

Description

result

An FXB.Result object. If validation succeeded then isOkay will be true. If validation failed, then isError will be true, and the code will be one of the framework's error codes.

tradingJobs[]

If successful, an array of the individual trading jobs after validation

For example, after validation of the above request, tradingJobs[] will have a single entry such as the following:

{

instrumentId: "EUR/USD",

tradingAction: FXB.OrderTypes.SELL_LIMIT,

volume: 20000, // conversion of {lots:0.20}

openPrice: 1.23456 // conversion of variable {offset:0.0020} to fixed price

}