ob_start("ob_gzhandler");
?>
匯控各上市地股價換算港元
匯控各上市地股價換算港元
// Get All price , in Form of CSV , from yahoo
$url = 'http://download.finance.yahoo.com/d/quotes.csv?f=sd1t1l1c1&e=.cvs&s=0005.HK,HBC1.F,HSBA.L,HBC,USDHKD=X,EURHKD=X,GBPHKD=X,EURUSD=X';
// $url = 'http://download.finance.yahoo.com/d/quotes.csv?f=sd1t1l1c1&e=.cvs&s=0005.HK,HBC1.F,HSA.L,HBC,USDHKD=X,EURHKD=X,GBPHKD=X';
$web_return = @file_get_contents($url);
$return= str_replace('"',"",$web_return);
$result=explode(",", $return);
$hsbc_hk = $result[3];
$hsbc_adr = $result[15];
$hsbc_paris = $result[7];
$hsbc_london = $result[11];
$usd_rate = $result[19];
$euro_rate = $result[23];
$gbp_rate = $result[27];
$euro_usd_rate = $result[31];
// Get HBC ADR Stock price - $hsbc_adr
// $url = "http://hk.finance.yahoo.com/q?s=hbc";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $hsbc_adr=$output[1][0];
// Get HSBC 0005.HK Stock price - $hsbc_hk
// $url = "http://hk.finance.yahoo.com/q?s=0005.hk";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $hsbc_hk=$output[1][0];
// Get HSBC from aastock
$url = "http://www.aastocks.com/tc/mobile/Quote.aspx?symbol=5";
$input = @file_get_contents($url);
$regexp = '!
(.*)!iU';
preg_match_all($regexp,$input,$output);
$hsbc_hk = $output[1][0];
// Get HSBC Paris (HBC1.F) stock price - hsbc_paris
// $url = "http://hk.finance.yahoo.com/q?s=HBC1.F";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $hsbc_london=$output[1][0]/100;
// Get USD-> HKD rate
// $url = "http://hk.finance.yahoo.com/q?s=USDHKD=X";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $usd_rate=$output[1][0];
// Get Euro -> HKD rate
// $url = "http://hk.finance.yahoo.com/q?s=EURHKD=X";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $euro_rate=$output[1][0];
// Get GBP -> HKD rate
// $url = "http://hk.finance.yahoo.com/q?s=GBPHKD=X";
// $input = @file_get_contents($url);
// $regexp = '!(.*)
!iU';
// preg_match_all($regexp,$input,$output);
// $gbp_rate=$output[1][0];
// ADR and ordinary share rate
$adr=5;
echo '| Exchange Market | Price | HKD |
';
echo 'HSBC (Hong Kong,0005) |  | '.number_format($hsbc_hk,2).' |
';
echo 'HSBC (Paris, HBC) | Euro $'.$hsbc_paris.' | '.number_format($hsbc_paris*$euro_rate,2).' |
';
echo 'HSBC (London, HSBA.L) | GBP $'.$hsbc_london.'
 | '.number_format($hsbc_london*$gbp_rate/100,2).' |
';
echo 'HBC (US ADR) | USD $'.$hsbc_adr.'
 | '.number_format($hsbc_adr*$usd_rate/$adr,2).' |
';
echo '
';
echo '
1 USD $= HKD $'.$usd_rate."";
echo '
7.85 : 弱方兌換保證
7.75 : 強方兌換保證';
echo "
";
echo '
1 Euro $= HKD $'.$euro_rate."";
echo "
";
echo '
1 GBP $= HKD $'.$gbp_rate."";
echo "
";
echo '
1 Euro $ = $USD'.$euro_usd_rate."";
echo "
";
?>
ADR = 5 ordinary shares
Reminder : 15 minutes delay
此為本人寫的小程式