URL Used : http://finance.yahoo.com/q/hp?s=IBM&a=00&b=2&c=2004&d=04&e=8&f=2005&g=d&z=66&y=66
* s - ticker symbol( MSFT - Microsoft, IBM etc)
* a - start month
* b - start day
* c - start year
* d - end month
* e - end day
* f - end year
* g - resolution (e.g. 'd' is daily, 'w' is weekly, 'm' is monthly)
* y is the offset (cursor) from the start date
* z is the number of results to return starting at the cursor (66
maximum, apparently)
Here is the Job:
static void StockMarket_Analysis(Args _args)
{
System.Net.WebClient web = new System.Net.WebClient();
TextBuffer txtBuffer = new TextBuffer();
str result;
container recordContainer, fieldContainer;
str stockContent;
int i;
FileName nameOfTheFile;
str tmpContent;
str urlQuery = @"http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=00&b=2&c=2007&d=04&e=8&f=2008&g=d&ignore=.csv";
CCHTMLString htmlString;
CCHTMLString formHTML(Container hmtlContainer, int tmp = 0)
{
CCHTMLString html;
int h;
str start_td_th;
str end_td_th;
str value;
;
if (tmp == 1)
{
start_td_th = @"
end_td_th = @'
}
else
{
start_td_th = @"
end_td_th = @'
}
html += '
for (h = 1; h <= conlen(hmtlContainer); h++)
{
if (h == 6 && isInteger(conpeek(hmtlContainer, h)))
value = int2str(conpeek(hmtlContainer, h));
else
value = conpeek(hmtlContainer, h);
html += start_td_th + value + end_td_th;
}
html += '
return html;
}
;
result = web.DownloadString(urlQuery);
result = strreplace(result,"\r", "");
recordContainer = str2con(result,'\n');
htmlString += @'html>body>
for (i = 1; i <= conlen(recordContainer); i++)
{
tmpContent = conpeek(recordContainer, i);
fieldContainer = str2con(tmpContent,',');
if (i == 1)
stockContent += formHtml(fieldContainer, 1);
else
stockContent += formHtml(fieldContainer);
}
htmlString += stockContent + '
txtBuffer.setText(htmlString);
nameOfTheFile = winApi::getTempPath() + 'StockMarket.html';
txtBuffer.toFile(nameOfTheFile);
infolog.urlLookup(nameOfTheFile);
}
No comments:
Post a Comment