Trading
This API part grants access to trading operations
This section includes a description of several endpoints that serve trading purposes, for example submitting an order, modifying it, etc.
A full list of available methods and their parameters can be found here:
https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Trading
Submit order
POST/traderevolution/v1/accounts/{accountId}/orders
This method is used to place a new order. Note that the request includes a body in the JSON format. The table below describes a set of parameters required for this process, where required parameters are marked with an asterisk *. The request body example is included as well.
Path/Body/Query
accountId*
integer/path
This parameter specifies the identifier of the account for which the order is submitted.
expireDate
integer/body
Timestamp in milliseconds for the order's expiration date.
price*
float/body
Price at which the order should be placed.
qty*
float/body
Quantity of the order.
side*
string/body
Side of the order: buy / sell
cashOrderQty
float/body
Cash quantity of the order.
stopLoss
float/body
Stop loss price.
stopLossType
string/body
Type of the stop loss. Possible values:
absolute, offset in ticks, tr. offset, offset in %
stopPrice
float/body
Stop price for the order.
strategyId
string/body
Strategy identifier (if used).
takeProfit
float/body
Take profit price.
takeProfitType
string/body
Type of the take profit. Possible values are: absolute, offset in ticks, offset in %
trStopOffset
float/body
Trailing stop offset.
tradableInstrumentId*
integer/body
Identifier of the instrument.
type*
string/body
Type of the order. Possible values are:
Market, Stop, Limit, Stop limit, Trailing stop, Care
userComment
string/body
Any useful information on the order. Available only for Care orders.
validity*
string/body
Validity of the order (e.g., DAY, GTC).
requestId
string/query
Unique identifier of a request (optional).
overnightExecution
bool/body
If true, the order can be placed and filled during overnight trading.
Request body example
CURL
Response
Note: When submitting a market order you will receive the orderId as well (instead of positionId). To get the information on the position, use the GET/accounts/{accountId}/positions request.
It is strongly recommended that the same types be used for stopLoss and takeProfit - both are either absolute or offset.
Standard errors can also be received.
Note that if the order is rejected, you will receive an error response with a message explaining the reason for rejection.
A detailed description of this method can be found here:
https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Trading/placeOrder
Cancel all orders for account
DELETE/traderevolution/v1/accounts/{accountId}/orders
This method is used to cancel all orders for a specified account. Note that orders can also be canceled by the specified instrument (by its tradableInstrumentId).
Path/Query
accountId*
integer/path
Identifier of the account for which orders should be canceled.
tradableInstrumentId
integer/query
Identifier of the instrument in case orders should be canceled by the required instrument only (optional parameter).
CURL
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, a description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Close all positions for account
DELETE/traderevolution/v1/accounts/{accountId}/positions
This method is used to close all positions for a specified account. Please note that you can choose to close either all positions or only the positions for the specified instrument.
Path/Query
accountId*
integer/path
This parameter specifies the identifier of the account for which positions will be closed.
tradableInstrumentId
integer/query
Allows specifying the identifier of the instrument in case positions should be closed by the specific instrument only.
CURL
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, the description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Cancel single order (by its ID)
DELETE/traderevolution/v1/orders/{orderId}
This method is used to cancel an existing order. Note that this method requires only one parameter - order id. TheOrder ID can be found in the response received to the request for submitting the order.
Path
orderId*
integer
This parameter specifies the identifier of the order that should be canceled.
CURL
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, the description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Modify order (by its ID)
PATCH/traderevolution/v1/orders/{orderId}
This method is used to modify an existing order. Note that the request includes a body in the JSON format, the same as for the order submitting. The table below describes a set of parameters required for this process, where required parameters are marked with an asterisk *. The request body example is included as well.
Path/Body/Query
orderId*
integer/path
This parameter specifies the identifier of the account for which the order is submitted.
expireDate
integer/body
Timestamp in milliseconds for the order's expiration date.
price*
float/body
Price at which the order should be placed.
qty*
float/body
Quantity of the order.
stopLoss
float/body
Stop loss price.
stopLossType
string/body
Type of the stop loss. Available values:
absolute, offset, tr. offset
stopPrice
float/body
Stop price for the order.
takeProfit
float/body
Take profit price.
takeProfitType
string/body
Type of the take profit. absolute / offset
trStopOffset
float/body
Trailing stop offset.
userComment
string/body
Any useful information on the order. Available only for Care orders.
validity*
string/body
Validity of the order (DAY, GTC, FOK, GTD, IOC).
overnightExecutrion
bool/body
If true, the order can be placed and filled during overnight trading.
Request body example
CURL
Response
It is strongly recommended that the same types be used for stopLoss and takeProfit - both are either absolute or offset.
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, the description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Close single position (by its ID)
DELETE/traderevolution/v1/positions/{positionId}
This method is used to close an existing position by its ID. To get the information on the position, please use the GET/accounts/{accountId}/positions request, the ID will be included in the response. An optional parameter qty can be specified in the request body for partial closing the position.
Path/Body
positionId*
integer/path
This parameter specifies the identifier of the position that should be closed.
qty
float/body
Request body allows one possible parameter - qty. This parameter is optional.
Example of the request body
CURL
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, a description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Modify single position (by its ID)
PATCH/traderevolution/v1/positions/{positionId}
This method is used to modify an existing position's Stop Loss, Take Profit, or both (including the Trailing offset), the request should contain a body with the appropriate parameters in the JSON format.
Please note that SL/TP for the existing position are real orders, so when modifying it, you can specify SL/TP in price only (not in ticks or points)! See example below.
To get the information on the position, please use the GET/accounts/{accountId}/positions request, the ID will be included in the response. The table below describes a set of parameters required for this process:
Path/Body
positionId*
integer/path
This parameter specifies the identifier of the position parameters of which should be modified.
body
object/body
Request body with following parameters: stopLoss, takeProfit, and trailingOffset (see body example below).
Request body
CURL
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the parameters were changed successfully, and error if there was an issue. If an error occurs, the description of the error will be provided in the errmsg field.
A detailed description of this method can be found here:
Risk and fee information
GET/traderevolution/v1/accounts/{accountId}/riskDetails
This method returns risk and fee information associated with placing a new order for a specific instrument on a specified account. The call triggers a margin check and returns the expected margin and commission impact.
Query/Path
accountId*
integer/path
Identifier of the account.
tradableInstrumentId
integer/query
Specify the instrument ID here.
qty*
integer/query
Quantity in lots for the order.
type*
string/query
Order type with possible values: limit, market, stop, stoplimit, trailingstop, care.
side*
string/query
Order side: buy, sell.
CURL
Response
As a result, you will receive detailed information about risks and fees associated with placing an order for the specified instrument and account. The response includes the potential impact on available funds and margin, as well as a breakdown of applicable commissions.
Standard errors can be received as well. If some value is absent (for example, the Price is not configured), the null value will be returned.
Trading via Webhook
POST/webhook/{apiKey}/{secretKey}
This method is used to perform some trading actions via the Trading webhook mechanism. Read more about generating Trading webhook keys in the following article.
It allows placing, modifying and canceling orders via webhook requests. Webhook requests are sent by external systems to the TE server and trigger one of the actions. The action that will be performed depends on a JSON message body sent within the request.
The method uses API key authentication, where the API key and secret key are generated in the client terminal and must be included in the request URL. Make sure the external system webhook settings are configured to send requests to the correct URL with your credentials included in the path.
Path parameters
apiKey*
string/path
API key generated in the terminal.
secretKey*
string/query
Secret key generated together with the API key.
Body
Depending on the request body parameters, orders can be Placed, Modified or Canceled. Examples of all 3 are below.
Place order
action*
string/body
Action type. Must be "place".
accountName*
string/body
Identifier of the account for which the order is submitted.
symbol*
string/body
Instrument name (uppercase).
symbolType
string/body
Instrument type. Possible values: CRYPTO, EQUITY, EQUITY_CFD, ETF, FIXED_INCOME, FOREX, FUTURES, FUTURES_CFD, OPTIONS, SPREADBET
contractMonth
string/body
Final delivery date. Required for FUTURES, FUTURES_CFD, OPTIONS.
strikePrice
number/body
Strike price. Required for OPTIONS.
strikeType
string/body
Put or Call. Required for OPTIONS.
isin
string/body
ISIN identifier.
type*
string/body
Order type: Market, Stop, Limit, Stop limit, Trailing stop, Care.
price
float/body
Price at which the order should be placed.
stopPrice
float/body
Stop price for the order.
qty*
float/body
Quantity of the order.
side*
string/body
Order side: buy / sell.
cashOrderQty
float/body
Cash quantity of the order.
validity
string/body
Validity type (DAY, GTC, IOC, GTD, FOK, GTS).
expireDate
integer/body
Expiration timestamp in milliseconds (used with GTD).
stopLoss
float/body
Stop loss price.
stopLossType
string/body
Stop loss type (absolute, offset in ticks, tr. offset, offset in %).
takeProfit
float/body
Take profit price.
takeProfitType
string/body
Take profit type (absolute, offset in ticks, offset in %).
trStopOffset
float/body
Trailing stop offset.
userComment
string/body
Additional order comment (Care orders only).
Request body
Response
Modify order
action*
string/body
Action type. Must be "modify".
accountName*
string/body
Identifier of the account for which the order modification is submitted.
orderId*
integer/body
Identifier of the order to be modified.
price
float/body
New price of the order.
stopPrice
float/body
Updated stop price for the order.
qty
float/body
Updated quantity of the order.
validity
string/body
Validity of the order (e.g., DAY, GTC, IOC, GTD, FOK, GTS).
expireDate
integer/body
Expiration timestamp in milliseconds. Used only when the validity type is GTD.
stopLoss
float/body
Updated stop loss price.
stopLossType
string/body
Type of the stop loss (absolute, offset in ticks, tr. offset, offset in %).
takeProfit
float/body
Updated take profit price.
takeProfitType
string/body
Type of the take profit (absolute, offset in ticks, offset in %).
trStopOffset
float/body
Updated trailing stop offset.
userComment
string/body
Additional order comment (Care orders only).
Request body
Response
Cancel order
action*
string/body
Action type. Must be "cancel".
accountName*
string/body
Identifier of the account for which the order is submitted.
orderId*
integer/body
Identifier of the order to cancel.
Request body
Response
As a result, you will receive a status indicating the outcome of the request. The status will be ok if the operation was successful, and error if there was an issue. If an error occurs, a description of the error will be provided in the errmsg field.
Last updated