Place an order
-X POST
--header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Authorization: Bearer {token here}'
-d '{ \
"account_number": "12345678@vision", \
"symbol": "BAC", \
"quantity": 1, \
"price": 20, \
"stop_price": 0, \
"time_in_force": "day", \
"order_type": "limit", \
"side": "buy", \
"comment": "any comment", \
"exchange": "Auto" \
}' 'https://api.lime.co/orders/place'
void PlaceOrder(string access_token, string account_number)
{
//--- REST client's HTTP vars
string uri = "https://api.lime.co/orders/place";
char post[];
char result[];
string headersResult;
string header;
int res;
//--- Form the request body
header = "Content-Type: application/json\r\n";
header += "Accept: application/json\r\n";
header += "Authorization: Bearer "+access_token+"\r\n";
string postData = "{ \"account_number\": \"" + account_number + "\", \"symbol\": \"ZVZZT\", \"quantity\": 50, \"price\": 10.00, \"order_type\": \"limit\", \"side\": \"buy\" }";
ArrayResize(post, StringToCharArray(postData, post, 0, WHOLE_ARRAY, CP_UTF8) - 1);
//--- reset last error
ResetLastError();
//--- post data to REST API
res = WebRequest("POST", uri, header, 50, post, result, headersResult);
//--- check errors
if (res == -1)
{
Print("Error code =", GetLastError());
}
else
{
//--- successful
Print("Server response: ", CharArrayToString(result, 0, -1));
}
}
Request example
{
"account_number": "12345678@vision",
"symbol": "BAC",
"quantity": 1,
"price": 20.0,
"stop_price": 0,
"time_in_force": "day",
"order_type": "limit",
"side": "buy",
"comment": "any comment",
"exchange": "Auto"
}
Response example
{
"success": true,
"data": "201710041710516537"
}
The order is accepted immediately, the method returns assigned id. The order is still validated with exactly same logic as in [validate] (#validate-an-order) method and is sent to market on successful validation pass. Otherwise, the order will reject asynchronously and you can query its status by calling the [details] (#get-order-details) method.
Response
name | value |
---|---|
success | true |
data | the id assigned to the order |