Syntax
Public Function ClosePosition(AccountID As Long, TicketID As Integer, Amount As Double, Price As Double, RefAskPrice As Double,RefBidPrice As Double, Comm As Double, Optional UserDefinedDate As String = "") As String
Description
The ClosePosition operation is used to close the position that belongs to the given account number.
Request Parameters
Name |
Description |
Required |
AccountID |
- Account number to close the position for.
- Type : Long
- Default : None
- Constraints : Must be valid account Id and accessible by logged in dealer
|
Yes
|
TicketID |
- The position number to be closed
- Type : Integer
- Default : None
|
Yes |
Amount |
- The position amount to be closed
- Type : Double
- Default : None
|
Yes |
Price |
- At price value to close position on it
- Type : Double
- Default : None
|
Yes |
RefAskPrice |
- Ask price value for the Reference Symbol
- Type : Double
- Default : None
|
Yes |
RefBidPrice |
- Bid Price value for the reference Symbol
- Type : Double
- Default : none
|
Yes |
Comm
|
- The commission value that wants to use when closing the position
- Type : Double
- Default : None
|
Yes |
UserDefinedDate |
- Trade close time
- Type : String
- Default : “” Which is mean now
- Must be in format (“DD:MM:yyyy HH:mm:ss”)
|
No |
Response Elements
Name |
Description |
Result |
The operation returns the closed ticket number in case success , otherwise an explicit error code is returned
|
Sample
<!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>ClosePosition</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) {
rst += "The position has been closed successfully!: </br>" ;
rst += "Ticket ID:" + result ;
$("#resultAction").html(rst);
}
else {
var rst = "https://support.hybridsolutions.com//index.php?/Knowledgebase/Article/View/1964"
$("#resultAction").html("Error Code : " + result + "<br/>" + " for more details see the follwing link: " + rst);
}
}
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 + "/BackofficeLogin?username=" + $("#txtusername").val() + "&password=" + $("#txtpassword").val() + "&callback=?" , onSuccessResult);
});
$("#btnAction").click(function () {
$.getJSON(urlStr + "/ClosePosition?AccountID=" + $("#txtAccountID").val() + "&TicketID=" + $("#txtTicketID").val() + "&Amount=" + $("#txtAmount").val() + "&Price=" + $("#txtPrice").val() + "&RefAskPrice=" + $("#txtRefAskPrice").val() + "&RefBidPrice=" + $("#txtRefBidPrice").val() + "&Comm=" + $("#txtComm").val() + "&UserDefinedDate=" + $("#txtDefinedDate").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>TicketID : <input type="text" id="txtTicketID" value ="" /> </td>
<td>Amount : <input type="text" id="txtAmount" value ="" /></td>
<td>Price :<input type="text" id="txtPrice" value ="" /></td>
</tr>
<tr>
<td>RefAskPrice :<input type="text" id="txtRefAskPrice" value ="" /></td>
<td>RefBidPrice :<input type="text" id="txtRefBidPrice" value ="" /></td>
<td>Comm :<input type="text" id="txtComm" value ="" /></td>
<td>UserDefinedDate :<input type="text" id="txtDefinedDate" value ="" /></td>
</tr>
<tr>
<td><button id="btnAction"> Close Position</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 Backoffice WCF Service Index
|