Knowledgebase:
NewOrder
Posted by Mohammad Rahhal, Last modified by Rawan Al Hourani on 02 March 2017 11:10 AM

Syntax 

NewOrder( AccountId As Long, Symbol As Integer , BuySell As Integer , Lots As Double, Optional Note As String )

Description

The NewOrder operation is used to  place a new market order at the specific given account number.

Request Parameters

Name Description  Required
AccountId
  • The intended account identifier.
  • Type: Long.
  • Default: None.
  • Constraints: Must be a valid account ID, and accessible by logged in client.
Yes
Symbol
  • The identifier of the symbol to place market order on it.
  • Type: Integer.
  • Default: None.
  • Constraints: Must be a valid symbol identifier.
Yes
buySell
  • New market order type.
  • Type: Integer.
  • Default: None.
  • Constraints: Must be a valid buy or sell identifier.
  • BuySell: Value of type as the following:
     1: Means Buy type.
    -1: Means Sell type.
Yes
Lots
  • Order amount of Lots.
  • Type: Double.
  • Default: None.
Yes
Note

Optional. Comment of type string, in order to bypass the auto broker for both real/demo clients you can put the following token#$CHAT$# in the note field. Even if AUTO BROKER is on, with this tag in the comment order will be sent to the dealing room "CHAT SCREEN" and handled by dealers according to the dealing room regular configuration.

NO

Response Elements

Name Description 
Result

This operation returns a string array that holds the following data ordered as listed below in case of success:

  • Ticket ID: Ticket number for the new position.
  • Position time: Time.
  • BuySell: Value of type as the following:
     1: Buy type.
    -1: Sell type.
  • Lots: Lots.
  • Symbol ID: Symbol ID.
  • Symbol price: Price value of type double.
  • Position or Order: If 1 it means the position was Accepted automatically,2 means the order transferred to BackOffice side and it’s pending.

Otherwise see error codes.

Type: JSON Object as String array.

Sample

Download sample as text file.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>NewOrder</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script >
$(document).ready(function () {
var urlStr = "http://5.10.64.199/vertexweb10/WebService.svc";
jQuery.support.cors = true;
$("#progress").ajaxStart(function () { $(this).css("display", "block"); });
$("#progress").ajaxComplete(function () { $(this).css("display", "none"); });
$("#resultAction").ajaxError(function (result) { $(this).html('An error occured'); });
function onSuccessResultOrder(dataResult) {
var result = eval(dataResult);
var rst = ""
if (result[0] > 0) {
//if result[6]=1 , then Open Position has been done
if (result[6] == 1) {
rst += "Order has been done successfully! the following is the open position details : </br>"
rst += "Ticket ID:" + result[0] + " Time :" + result[1] + " Amount :" + result[3] + " Symbol ID:" + result[4] + " Open Price:" + result[5]
$("#resultAction").html(rst);
}
//if result[6]=2 , then pending order has been done
else if (result[6] == 2) {
rst += "Order has been done successfully! the following is the pending Order details : </br>"
rst += "OrderID:" + result[0] + " Time :" + result[1] + " Amount :" + result[3] + "Symbol ID:" + result[4] + "Open Price:" + result[5] + "Order/Position :" + result[6]
$("#resultAction").html(rst);
}
else {
var rst = "http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1964"
$("#resultAction").html("Error Code : " + rst + "<br/>" + " for more details see the follwing link: " + errDetail.link(errDetail));
}
}
}
function onSuccessResult(response) {
response = eval('(' + response + ')')
if (response.UserId == -1 || response.UserId == -207) {
$("#resultData").html("Invalid username or password");
}
else if (response.UserId == -231) {
$("#resultData").html("You must have at least one account");
}
else if (response == null || response == "" || response.UserId < 0) {
$("#resultData").html("Error while login.Please try later");
}
else {
$("#resultData").html("SuccessResult ... UserId is :" + response.UserId);
}
}
function onErrorResult(result) {
alert('Service call faild : ' + result.status + ' ' + result.statusText);
}
$("#btnLogin").click(function () {
$.getJSON(urlStr + "/Login?username=" + $("#txtusername").val() + "&password=" + $("#txtpassword").val() + "&callback=?" , onSuccessResult);
});
$("#btnAction").click(function () {
$.getJSON(urlStr + "/NewOrder?AccountId=" + $("#txtAccountId").val() + "&Symbol=" + $("#txtSymbol").val() + "&BuySell=" + $("#txtBuySell").val() + "&lots=" + $("#txtlots").val() + "&Note=" + $("#txtNote").val() + "&callback=?", onSuccessResultOrder);
});
});
</script>
<body>
<table border="1px">
<tbody>
<tr>
<td>
Username: <input type="text" id="txtusername" value=""/>
password: <input type="text" id="txtpassword" value=""/>
<button id="btnLogin"> Login </button>
</td>
</tr>
<tr>
<td>AccountId : <input type="text" id="txtAccountId" value ="" /> </td>
<td>Symbol: <input type="text" id="txtSymbol" value ="" /> </td>
<td>BuySell: <input type="text" id="txtBuySell" value ="" /></td>
</tr>
<tr>
<td>lots:<input type="text" id="txtlots" value ="" /></td>
<td>Note :<input type="text" id="txtNote" value ="" /></td>
<td><button id="btnAction"> NewOrder </button></td>
</tr>
</tbody>
</table>
<div id="resultData"> </div>
<div id="resultAction"> </div>
<div style="display:none" id="progress">Loading ... </div>
</body>
</html>

 

 


See Also


VertexFX WCF Service Index

(2 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Hybrid Solutions