search Nothing found
Main Algotrading documentation

Interaction between terminal and robot

Synchronous, asynchronous and pseudo-synchronous operations

Trade methods can be called synchronously or asynchronously. With the synchronous method, the robot sends a request to the server and waits for a response. And then it moves on to the next part of the code. With the asynchronous method, the following parts of the code are executed without waiting for a response from the server. This type of execution is necessary for high-frequency trading. 

But it should be noted that an additional query is required so that the result of executing the called method will be accessible in the subsequent code.

Methods of all the described classes that have the bool isAsync = false parameter (i.e., default false) can be called asynchronously and synchronously (for example, opening/changing/closing a position, opening/changing/deleting a pending order) or pseudo-synchronously, if these action methods still have a timeout parameter, as, for example, in Deals.Select and ExecutedOrders.Select.

The specified action methods always have a return parameter of type int, which takes the value of 0 in successful cases. The successful result of calling such methods, if they are called asynchronously or pseudo-synchronously, does not indicate the final result of the execution of the corresponding operation, but only its successful initiation, i.e. successful sending of the corresponding request to the server.

The timeout parameter in pseudo-synchronous methods determines the time during which a response from the server is expected, and the execution of the specified methods is stopped either when a response is received from the server, or when the timeout expires.

Subscribe to our newsletter and stay up to date with all the news!