Posted by
James Thomas-6 on
Mar 04, 2005; 5:18am
URL: http://quantlib.414.s1.nabble.com/Shanghai-Stock-Bond-prices-tp3662p3663.html
Joseph,
I did something like this last year. The below script gets tickers from a
text file,
queries Bloomberg's website for details, and puts the results in a
spreadsheet.
Pretty straightforward - hope it helps.
Regards,
Matthew
#!/usr/bin/perl
use LWP::Simple;
use HTML::TokeParser;
use Spreadsheet::WriteExcel;
my $row = my $col = 0;
my $workbook = Spreadsheet::WriteExcel->new('c:\temp\stocks.xls');
my $worksheet = $workbook->addworksheet();
open (TXT,'c:\temp\stocks.txt') || die $!;
while (<TXT>) {
$stock = $_;
$stock =~ m{(.*[^\n])}i;
$trimmedStock = $1;
$page = '
http://quote.bloomberg.com/apps/quote?ticker=' .$trimmedStock;
$html = get($page);
$worksheet->write($row, $col, $trimmedStock);
$row++;
my $stream = HTML::TokeParser-> new (\$html);
while (my $token = $stream ->get_token()) {
if ($token->[0] eq 'T') {
if ($token->[1]
=~/^Price|Open|Volume|High|Low|^Earnings|Bid|Ask|Beta|P\/E|Shares|Cap|Dividend|Change|^Return|N\.A|^[-\d*]/){
$worksheet->write($row, $col, $token->[1]);
$row++;
}
}
}
$col++;
$row = 0;
}
>From: Joseph Wang <
[hidden email]>
>To:
[hidden email]
>Subject: [Quantlib-users] Shanghai Stock/Bond prices
>Date: Fri, 04 Mar 2005 01:04:44 -0600
>
>My project for next week is going to be to write a small perl script that
>queries the Shanghai stock/bond exchange
>website to download historical data on stock and bond prices. I was
>curious if anyone on the list either has already done something like this
>or else would find this useful.
>
>
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real users.
>Discover which products truly live up to the hype. Start reading now.
>
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click>_______________________________________________
>Quantlib-users mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-users