GetAccountSumm
Posted by Mohammad Rahhal, Last modified by Rawan Al Hourani on 31 December 2018 09:34 AM

Syntax 

GetAccountSumm(AccId As Long)

Description

The GetAccountSumm operation is used to return the account details as listed below in response elements.

Request Parameters

Name Description  Required
AccId
  • The intended account identifier.
  • Type: Long.
  • Default: None.
  • Constraints: Must be a valid account ID, and accessible by logged in client.
Yes

Response Elements

Name Description 
Result

This operation returns a given account Summary upon success.

The returned array will hold the following values for each account ordered as: 

  • TotalCommission.
  • Margin Requirement.
  • Net profit.
  • Total Deposit.
  • Total Credit.
  • Prev margin.
  • Total Interest. 

Otherwise check Error Codes.

Type: JSON Object as Array of String.

NOTE :     Balance  = TotalCommission + NetProfit + TotalDeposit+ PrevMargin + TotalInterest

                FloatingPL  = total PL for each position on the trade list ( To get PL  call GetOrderPL method) 

                Equity = Balance + FloatingPL  

                Free Margin = Equity -  Margin Requirement

               Margin level ---->  If margin Req (used Margin)  = 0 Then Margin level = 100% 

                                           Else Margin level = Math.Round(100 * Equity / MarginReq, 2).ToString() + "%"

               Net Credit --->  If Credit > Equity Then Net Credit = Credit  -  Equity 

                                       Else  Net Credit = 0 

               Net Equity --->  If Equity > Credit  Then Net Equity=  Equity - Credit   

                                       Else  Net Equity = 0

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>GetAccountSumm</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script>
$(document).ready(function () {
var urlStr = "http://173.249.35.43/webtrader/webservice.svc";
var PL = 0;
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 onSuccessResultt(dataResult) {
var result = eval(dataResult);
var rst = ""
if (result[0].ID > 0) {
PL = 0;
for (var i = 0; i < result.length; i++) {
$.getJSON(urlStr + "/GetOrderPL?AccountId=" + $("#txtAccountId").val() + "&PosID=" + result[i].ID + "&callback=?", onSuccessResulttt);
function onSuccessResulttt(dataResult) {
dataResult = eval('(' + dataResult + ')');
//$("#resultAction").html("Order PL : " + dataResult)
PL = PL + dataResult

$.getJSON(urlStr + "/GetAccountSumm?AccID=" + $("#txtAccountId").val() + "&callback=?", onSuccessResultttt);
function onSuccessResultttt(dataResult) {
dataResult = eval('(' + dataResult + ')');
var resData
var x = parseFloat(dataResult[0]) + parseFloat(dataResult[2]) + parseFloat(dataResult[3]) + parseFloat(dataResult[5]) ;
var Equity = x + PL;
var EffMargin = Equity + parseFloat(dataResult[1]);
resData = "" + "<br/>"
resData = resData + "TotalCommission:" + dataResult[0] + "<br/>"
resData = resData + "Margin Requirement:" + dataResult[1] + "<br/>"
resData = resData + "Net profit:" + dataResult[2] + "<br/>"
resData = resData + "Total Deposit:" + dataResult[3] + "<br/>"
resData = resData + "Total Credit:" + dataResult[4] + "<br/>"
resData = resData + "Prev margin:" + dataResult[5] + "<br/>"
resData = resData + "Total Interest:" + dataResult[6] + "<br/>"
resData = resData + "Balance: " + x + "<br/>"
resData = resData + "Equity: " + Equity + "<br/>"
resData = resData + "EffMargin: " + EffMargin + "<br/>"
$("#resultAction").html(resData);
//$("#resultData").html("Orders PLs : " + PL);

}
}
}

}
else {
PL = 0;
$.getJSON(urlStr + "/GetAccountSumm?AccID=" + $("#txtAccountId").val() + "&callback=?", onSuccessResultttt);
function onSuccessResultttt(dataResult) {
dataResult = eval('(' + dataResult + ')');
var resData
var x = parseFloat(dataResult[0]) + parseFloat(dataResult[2]) + parseFloat(dataResult[3]) + parseFloat(dataResult[5]) ;
var Equity = x + PL;
var EffMargin = Equity + parseFloat(dataResult[1]);
resData = "" + "<br/>"
resData = resData + "TotalCommission:" + dataResult[0] + "<br/>"
resData = resData + "Margin Requirement:" + dataResult[1] + "<br/>"
resData = resData + "Net profit:" + dataResult[2] + "<br/>"
resData = resData + "Total Deposit:" + dataResult[3] + "<br/>"
resData = resData + "Total Credit:" + dataResult[4] + "<br/>"
resData = resData + "Prev margin:" + dataResult[5] + "<br/>"
resData = resData + "Total Interest:" + dataResult[6] + "<br/>"
resData = resData + "Balance: " + x + "<br/>"
resData = resData + "Equity: " + Equity  + "<br/>"
resData = resData + "EffMargin: " + EffMargin  + "<br/>"
$("#resultAction").html(resData);
//$("#resultData").html("Orders PLs : " + PL);

}
$("#resultAction").html("Error Code : " + result[0].ID + "<br/>" );
}
}

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 + "/GetOpenPositions?AccountId=" + $("#txtAccountId").val() + "&callback=?", onSuccessResultt);
});
});
</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><button id="btnAction">GetAccountSumm </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

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