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 |
|
Yes |
FromDate |
|
No |
ToDate |
|
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:
Otherwise an expliciterror codeis returned. Type: JSON object as List (of Position) |
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>GetOpenPositions_stmt</title><script src="http://code.jquery.com/jquery-latest.js"></script></head><script >$(document).ready(function () {var urlStr = "http://webtrader.hybridsolutions.com/publicweb/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].IDposRows += "<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