The framework provides two types of trading requests:
Standard requests for an individual order: opening, closing, or modifying it
Aggregated actions on a market or on the whole account. For example, you can issue a request of type
In addition, you can either send a single request or an array containing a batch of requests. If you issue a batch, then you get a response either after all requests succeed or when the first one fails. (You don't get a response from a batch listing each individual request and whether it succeeded or failed.)
You issue trading requests using
| Parameter | Description |
| Definition of an individual request, or an array of requests | |
| Callback function which asynchronously receives success of the request or (first) failure | |
| Optional settings controlling how the request is processed. For example, the default is that the framework will automatically display an error message if a trading request fails, but you can use the |
For example:
Framework.SendOrder({
// Buy 10K (0.10 lots) EUR/USD
tradingAction: FXB.OrderTypes.BUY,
instrumentId: "EUR/USD",
volume: 10000
}, function (MsgResult) {
// Asynchronously called with the result of the request
});
Or, using a batch of multiple requests, with optional settings specifying forced confirmation by the user before the batch is started:
Framework.SendOrder([
{
// Close all EUR/USD orders and trades
tradingAction: FXB.OrderTypes.CLOSEPOSITION,
instrumentId: "EUR/USD"
},{
// Buy 5K GBP/USD, specifying the volume in lots
tradingAction: FXB.OrderTypes.BUY,
instrumentId: "GBP/USD",
volume: {lots: 0.05}
}
]}, function (MsgResult) {
// Asynchronously called when the whole batch has succeeded or on the first failure
}, {
// Force confirmation by the user before the batch is processed
confirm: true
});
The asynchronous
Framework.SendOrder( … , function (MsgResult) {
if (MsgResult.result.isOkay) {
// Succeeded
} else {
// Failed
// For example, can get a textual description of the error using:
var errText = Framework.Translation.TranslateError(Msg.result);
}
});