static public method terminal:execute
Brief
Executes the command.
Declaration | ||
|
Parameters | |
cookie |
An unique integer value to be used to call |
valuemap |
A value map with order parameters. |
Details
The method returns two values. The first is a boolean value indicating whether the order has been successfully sent to the server. The second is a string, which contains a request identifier in case the order has been sent or a error text in case the sending of the request has been failed. For ELS orders, the second value contains 3 request id separated by commas. The first is request identifier for main order, the second is limit order request identifier and the third stop order request identifier. If stop or limit order does not specified, the request identifier is empty.
For more information on how to fill the valuemap object, please follow Trading commands section of the documentation.
If the request has been successfully sent, the AsyncOperationFinished
function of the strategy
will be called with the following three parameters:
|
An integer value specified for the operation in the |
|
A boolean flag indicating whether the order has been successfully executed on the server. |
|
A string, which contains:
|
Please note, that the order and/or an associated trade does not appear in the table immediately, even after notification about the successful execution. It usually takes 0.5 to 2 seconds to delivers the objects back to the client workstation.
For example of filling the valuemaps please see the Trading Commands articles for each type of the trading command and each type of the order.
Example: Calling the execute method and getting the result. [hide]
local requestId; local orderId; local stage = 0; function Update() if mySellCondition then local valuemap, success, msg; valuemap = core.valuemap(); valuemap.OrderType = "OM"; -- open market valuemap.OfferID = Offer; valuemap.AcctID = Account; valuemap.Quantity = Amount; valuemap.BuySell = BuySell; success, msg = terminal:execute(100, valuemap); assert(success, msg); requestId = msg; stage = 1; -- executing end end function AsyncOperationFinished(id, success, message) if id == 100 then if not success then stage = 3; -- failed else stage = 2; -- executed orderId = message; -- keep id of the created order end end end