Knowledgebase:
GetChartData
Posted by Mohammad Rahhal, Last modified by Rawan Al Hourani on 30 August 2017 01:46 PM

Syntax 

GetChartData (Symbol As String, PeriodID As Long, AfterDate As String)

Description

The GetChartData operation is used to return a JSON object as a list (of type ChartCandle) which contains a given symbol
historical data based on the specified period identifier and date.

Request Parameters

Name Description  Required
Symbol
  • The intended symbol ID/Name.
  • Type: String.
  • Default: None.
  • Constraints: Must be a valid Symbol and accessible by logged in client.
Yes
PeriodID
  • Period ID can be one of the chart Periods.
  • Type: Long.
  • Default: None.
  • Constraints: Must be valid Period ID.
Yes
AfterDate
  • Starting date for the specified period.
  • Type: String.
  • Default:01/01/1900.
  • Constraints: Must be in DD/MM/YYYY format.
No

Response Elements

Name Description 
Result

This operation returns a given Symbol chart data upon success.

The following are the ChartCandle's Data members:

  • SymID: Candle symbol ID.
  • OpenPrice: Candle open price.
  • HighPrice: Candle high price.
  • LowPrice: Candle low price.
  • ClosePrice: Candle close price. 
  • CandleDate: Candle open date. 
  • CandleSym: Symbol name.

Type: JSON Object as a list (of type ChartCandle),

Otherwise an explicit error code is returned.

 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>GetChartData</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 + "/GetChartData?Symbol=" + $("#txtSymbol").val() + "&PeriodID=" + $("#txtPeriodID").val() + "&AfterDate=" + $("#txtAfterDate").val() + "&callback=?" , onSuccessResultOrder);
function onSuccessResultOrder(dataResult) {
dataResult = eval('(' + dataResult + ')');
var posRows ="<table><caption>Chart Data </caption><thead><tr ><th>Symbol ID</span></th><th>Open Price</th><th>High Price</th><th>low price</th>"
+ "<th>CLose Price</th><th>Volum</th>"
+ "<th >Symbolname</th></thead><tbody>";
for (var i = 0; i < dataResult.length; i++) {
posRows += "<tr>"
posRows += "<td>" + dataResult[i].SymID + "</td>";
posRows += "<td>" + dataResult[i].OpenPrice + "</td>";
posRows += "<td>" + dataResult[i].HighPrice + "</td>";
posRows += "<td>" + dataResult[i].LowPrice + "</td>";
posRows += "<td>" + dataResult[i].ClosePrice + "</td>";
posRows += "<td>" + dataResult[i].Volume + "</td>";
posRows += "<td>" + dataResult[i].CandleSym + "</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>Symbol : <input type="text" id="txtSymbol" value ="" /> </td>
<td>Period Id: <input type="text" id="txtPeriodID" value ="" /> </td>
<td>After Date: <input type="text" id="txtAfterDate" value ="" /> </td>
<td><button id="btnAction"> GetChartData </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