Knowledgebase:
GetOpenPositions_stmt
Posted by Mohammad Rahhal, Last modified by Angham Al-Banawien on 18 July 2018 11:56 AM

Syntax 

GetOpenPositions_stmt(AccountId As Long,FromDate As String ,ToDate As String )

Description

The GetOpenPositions_stmt operation is used to return a list of positions which contains a given account open positions between a given starting date and ending date.

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
FromDate
  • Starting date for account open positions query.
  • Type: String.
  • Default: 01/01/1970
  • Constraints: Must be in DD/MM/YYYY format.
No
ToDate
  • Ending date for account open positions query.
  • Type: String.
  • Default: System date.
  • Constraints: Must be in DD/MM/YYYY format.
No


Response Elements

Name Description 
Result

This operation returns a given account open positions upon success as List(of type position). The following are the Position's Data members:

  • ClosePrice: Close position price.
  • ProfitLoss: Profit or loss value.
  • PositionValue: Position value.
  • Commission: Commission value.
  • Interest: Position Interest value.
  • OpenPrice: Position open price.
  • ManagedTKTID: Manage Order number.
  • CurrentPrice: Current Price.
  • Symbol: Symbol ID.
  • SL: Stop loss value.
  • TP: Take profit value.
  • SymbolName: Symbol name.
  • BuySell:
       1: Which means Buy type.
      -1: Which means Sell type.
  • RefPrice: Reference symbol price.
  • Note: Position note.
  • delItems: Deliver Items.
  • ID: Ticket ID.
  • Time: Position opened time.
  • Amount: Position amount.
  • IsFreezed: Detected if the open position is freezed or not

Otherwise an explicit error code is returned.

Type: JSON object as List (of Position)

 
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>GetOpenPositions_stmt</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"); });
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);
}
}
$("#resultAction").ajaxError(function (result) { $(this).html('An error occured'); });
function onErrorResult(result) {
alert('Service call failed : ' + result.status + ' ' + result.statusText);
}
$("#btnLogin").click(function () {
$.getJSON(urlStr + "/Login?username=" + $("#txtusername").val() + "&password=" + $("#txtpassword").val() + "&callback=?" , onSuccessResult);
});
$("#btnAction").click(function () {
$.getJSON(urlStr + "/GetOpenPositions_stmt?AccountId=" + $("#txtAccountId").val() + "&FromDate=" + $("#txtFromDate").val() + "&ToDate=" + $("#txtToDate").val() + "&callback=?" , onSuccessResultOrder);
function onSuccessResultOrder(dataResult) {
dataResult = eval(dataResult);
var posRows = "<span><b>Note: </b> All close prices for open positions are at the report issue date</span></br>"
posRows += "<table><caption>Open Positions</caption><thead><tr ><th>Ticket</span></th><th>Date/Time</th><th>Type</th><th>Amount</th>"
+ "<th>Symbol</th><th>Open Price</th><th>Close Price</th><th>S/L</th><th>T/P</th><th>Comm</th>"
+ "<th >Intrest</th><th>P/L</th></tr></thead><tbody>";
for (var i = 0; i < dataResult.length; i++) {
posRows += "<tr>" + dataResult[i].ID
posRows += "<td>" + dataResult[i].ID + "</td>";
posRows += "<td>" + dataResult[i].Time + "</td>";
posRows += "<td>" + (dataResult[i].BuySell == -1 ? "Sell" : "Buy") + "</td>";
posRows += "<td>" + parseFloat(dataResult[i].Amount) + "</td>";
posRows += "<td>" + dataResult[i].SymbolName + "</td>";
posRows += "<td>" + parseFloat(dataResult[i].OpenPrice) + "</td>";
posRows += "<td>" + parseFloat(dataResult[i].ClosePrice) + "</td>";
posRows += "<td>" + dataResult[i].SL + "</td>";
posRows += "<td>" + dataResult[i].TP + "</td>";
posRows += "<td>" + dataResult[i].Commission + "</td>";
posRows += "<td>" + dataResult[i].Interest + "</td>";
posRows += "<td>" + dataResult[i].ProfitLoss + "</td>";
posRows += "</tr>";
}
posRows += "</tbody></table>";
$("#resultAction").html(posRows);
}
});
});
</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>FromDate: <input type="text" id="txtFromDate" value ="" /> </td>
<td>ToDate: <input type="text" id="txtToDate" value ="" /> </td>
<td><button id="btnAction"> GetOpenPositions_stmt </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

(0 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