Knowledgebase:
GetHistory
Posted by Mohammad Rahhal, Last modified by Eyad Alhaj Hammad on 22 January 2017 03:49 PM

Syntax 

GetHistory(AccountId As Long, FromDate As String, ToDate As String, isPaging As Boolean, lastXdays As Integer)

Description

The GetHistory operation is used to return a list which contains a given account history of 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 transactions query.
  • Type: String.
  • Default: 01/01/1970
  • Constraints: Must be in DD/MM/YYYY format.
No
ToDate
  • Ending date for account transactions query.
  • Type: String.
  • Default: System date.
  • Constraints: Must be in DD/MM/YYYY format.
No
isPaging
  • Boolean value which indicates that you are calling GetHistory to get the remaining records.
  • This is useful if you are calling a large amount of data to split the returned data as 3000 rows for each response.
  • Type: Boolean.
  • Default: False.
  • Constraints: On First call it must be False and next calls true.
Conditionally if the first TicketID in the history list = -1200

lastXdays

  • The number of days you want to get history for, example: last 5 days.
  • Type: Integer.
  • Default: 0
  • Constraints: Interval calculated based on current system date.
No


Response Elements

Name Description 
History

This operation returns a given account history as list (of type history) upon success.

The following are the Histories' Data members:

  • Ticket: The transaction order number.
  • Type: Indicate the history type as the following table.
  • DB: Means Deposit. 
  • AJ: Means Adjustment.
  • CI: Means Credit In.
  • WD: Means Withdrawal.
  • CO: Means Credit Out.
  • SL: Means Sell Limit.
  • BL: Means Buy Limit.
  • BS: Means Buy Stop.
  • SS: Means Sell Stop.
  • L: Means Close.
  • DateTime: The date and time of the history.
  • SymbolID: Trading symbol Identifier. 
  • Amount: Trading amount of lots.
  • BuySell: Type of action.
    If the value equal -1, then the operation type is sell.
    If the value equal 1, then the operation type is buy.
  • OpenTime: trading open time.
  • OpenSL: Open Stop loss value. 
  • CloseTP: Close Take profit value. 
  • DpWdAj: The amount of money withdrawn, added or Adjusted.
  • Commission: Commission value.
  • Interest: Intrest Value.
  • ProfitLoss: Profit Loss.
  • SymbolName: Trading symbol Name.
  • RefPrice: Reference symbol price.
  • Note: The comment which added when takes the order.
  • OpenPrice: Order open price.

Otherwise an explicit error code is returned

Type: JSON object as List (of History).


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>GetHistory</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<script type="text/javascript" >
var hisTable;
$(document).ready(function () {
var urlStr = "http://5.10.64.199/vertexweb10/WebService.svc";
$.support.cors = true;
$.ajaxSetup({ cash: false });
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 () {
$.ajax({
type: 'GET',
url: urlStr + "/Login",
dataType: "jsonp",
data: { "username": $("#txtusername").val(), "password": $("#txtpassword").val() },
ProcessData: false,
success: onSuccessResult,
error: onErrorResult
});
});
$("#btnAction").click(function () {
$.ajax({
type: 'GET',
url: urlStr + "/GetHistory",
dataType: "jsonp",
data: { "AccountId": $("#txtAccountId").val(), "FromDate": $("#txtFromDate").val(), "ToDate": $("#txtToDate").val() },
success: function (history) {
history = eval('(' + history + ')');
var result;
if (history == undefined || history == null || history.length == 0) {
result = "No data found";
$("#resultAction").html(result);
}
else if (history[0].Ticket < 0 && history[0].Ticket > -1000) {
result = "No data found";
$("#resultAction").html(result);
}
else if (history[0].Ticket > 0) {
historyTableHeader();
for (var i = 0; i < history.length; i++) {
fillHistoryTable(history[i]);
}
hisTable += "</tbody></table>";
}
$("#resultData").html(hisTable);
},
error: onErrorResult
});
});
});
function historyTableHeader() {
hisTable = "";
hisTable = "<table border='1px'><thead><tr>";
hisTable += "<th>Ticket</th> <th>Date/Time</th><th >Type</th><th >Amount</th>";
hisTable += "<th>Symbol</th><th>Buy/Sell</th><th>Open Time</th><th>Open/SL</th>";
hisTable += "<th>Close/TP</th><th>Comm</th>";
hisTable += "<th>Intrest</th><th>P/L Desc</th></tr></thead><tbody>";
}
function fillHistoryTable(history) {
if (history.Type == 'DP' || history.Type == 'AJ' || history.Type == 'CI') {
hisTable += "<tr><td>" + history.Ticket + "</td>";
hisTable += "<td>" + history.DateTime + "</td>";
hisTable += "<td>" + (history.Type == "DP" ? "Deposit" : history.Type == "WD" ? "Withdrawal" : history.Type == "AJ" ? "Adjustment" : history.Type == "CI" ? "Credit In" : "Credit Out") + "</td>";
hisTable += "<td>" + history.DpWdAj + "</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td>";
hisTable += "<td>-</td></tr>";
}
else if (history.Type == 'WD' || history.Type == 'CO') {
hisTable += "<tr><td>" + history.Ticket + "</td>";
hisTable += "<td>" + history.DateTime + "</td>";
hisTable += "<td>" + (history.Type == "DP" ? "Deposit" : history.Type == "WD" ? "Withdrawal" : history.Type == "AJ" ? "Adjustment" : history.Type == "CI" ? "Credit In" : "Credit Out") + "</td>";
hisTable += "<td>" + history.DpWdAj; +"</td>";
hisTable += "</tr>";
}
else if (history.Type == 'BL' || history.Type == 'BS' || history.Type == 'SL' || history.Type == 'SS' || history.Type == 'SL/TP') {
hisTable += "<tr><td>" + history.Ticket + "</td>";
hisTable += "<td>" + history.DateTime + "</td>";
hisTable += "<td>" + (history.Type == "SL" ? "Sell Limit" : (history.Type == "BL" ? "Buy Limit" : (history.Type == "BS" ? "Buy Stop" : "Sell Stop"))) + "</td>";
hisTable += "<td>" + history.Amount + "</td>";
hisTable += "<td>" + (history.SymbolName != -208 ? history.SymbolName : "Nothing ") + "</td>";
hisTable += "<td>" + (history.BuySell == -1 ? "Sell" : (history.BuySell == 1 ? "Buy" : (history.BuySell == 2 ? "Buy" : "Sell"))) + "</td>";
hisTable += "<td>" + history.OpenTime + "</td>";
hisTable += "<td>" + history.OpenSL + "</td>";
hisTable += "<td>" + history.CloseTP + "</td>";
hisTable += "<td>" + history.Commission + "</td>";
hisTable += "<td>" + history.Interest + "</td>";
hisTable += "<td>" +
(history.ProfitLoss == -2 ?
"No Money"
: (history.ProfitLoss == -4 ?
"Hedging" :
(history.ProfitLoss == -3 ?
"CANCELLED" :
"Done"))) + "</td></tr>";
}
else {
hisTable += "<tr><td>" + history.Ticket + "</td>";
hisTable += "<td>" + history.DateTime + "</td>";
if (history.Type == "L")
{ hisTable += "<td>Close</td>"; }
else { hisTable += "<td>unknow</td>"; }
hisTable += "<td>" + history.Amount + "</td>";
hisTable += "<td>" + (history.SymbolName != -208 ? history.SymbolName : "unknow Symbol Name") + "</td>";
hisTable += "<td>" + (history.BuySell == -1 ? "Sell" : "Buy") + "</td>";
hisTable += "<td>" + history.OpenTime + "</td>";
hisTable += "<td>" + parseFloat(history.OpenSL) + "</td>";
hisTable += "<td>" + parseFloat(history.CloseTP) + "</td>";
hisTable += "<td>" + parseFloat(history.Commission) + "</td>";
hisTable += "<td>" + parseFloat(history.Interest) + "</td>";
//if (CommCalcType == 2) {
// hisTable += "<td>" + parseFloat(parseFloat(history.ProfitLoss) - parseFloat(history.Commission)) + "</td></tr>";
//}
//else {
hisTable += "<td>" + parseFloat(history.ProfitLoss) + "</td></tr>";
//}
}
}
</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 ="" /> FromDate : <input type="text" id="txtFromDate" value=""/> ToDate : <input type="text" id="txtToDate" value="" />
<button id="btnAction"> GetHistory </button>
</td>
</tr>
</tbody>
</table>
<div id="resultData"> </div>
<div id="resultAction"> </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