App-Chart
view release on metacpan or search on metacpan
unused/YahooOld.pm view on Meta::CPAN
# s # symbol
# n # company name
# l1 # last price
# d1 # last trade date (in home exchange's timezone)
# t1 # last trade time (in yahoo server timezone)
# c1 # change
# p2 # percent change
# v # volume
# a2 # average daily volume
# b # bid
# b6 # bid size
# a # ask
# a5 # ask size
# k1 # "time - last" (ECN), with <b> and <i> markup
# c6 # change (ECN)
# m2 # day's range (ECN)
# b3 # bid (ECN)
# b2 # ask (ECN)
# p # previous close
# o # today's open
# m # day's range, eg. "1.23 - 4.56"
# w # 52-week range, eg. "1.23 - 4.56"
# e # earnings per share
# r # p/e ratio
# d # div per share
# q # ex div date, eg. "Mar 31" or "N/A"
# r1 # div pay date
# y # div yield
# j1 # market cap
# x # stock exchange
# c4 # currency, eg. "AUD"
# i # more info links, letters
# # c=chart, n=news, p=profile, r=research, i=insider,
# # m=message board (yahoo)
# k # 52-week high
#
# Don't know what the distinction between b,a and b3,b2 quotes are actually
# meant to be.
# - For the Australian Stock Exchange, b,a are "N/A", and b3,b2 is the
# SEATS best quote.
# - For US stocks b,a seem to be "N/A", and b3,b2 an ECN quote. The
# latter has been seen a long way away from from recent trades though,
# eg. in BRK-A.
#
# d1,t1 are a bit odd, the time is the yahoo server's zone, but the date
# seems to be always GMT. The zone for the time can be seen easily by
# looking at a quote from the various international XX.finance.yahoo.com.
# For the zone for the date however you need to be watching at midnight
# GMT, where it ticks over (at all the international XX.finance.yahoo.com).
# quote_parse_div_date ($str) returns an iso YYYY-MM-DD date string for a
# dividend $str coming from quote.csv data, or undef if none. There are
# several different formats,
# "Jan 7" # finance.yahoo.com
# " 5 Jan" # au.finance, uk.finance
# "24-Sep-04" # ABB.AX on finance.yahoo.com
# "24 Sep, 2004" # ABB.AX on au.finance
# "Sep 24, 2004" # ABB.AX on ca.finance
#
# An error is thrown for an unrecognised string, don't want some new form to
# end up with dividends silently forgotten.
#
sub quote_parse_div_date {
my ($str) = @_;
if (DEBUG) { print "quote_parse_div_date() '$str'\n"; }
if (! defined $str || $str eq 'N/A' || $str eq '') {
return undef; # no info
}
my ($ss,$mm,$hh,$day,$month,$year,$zone) = Date::Parse::strptime ($str);
$month++;
if ($year) {
$year += 1900;
if ($year < 2000) { # "04" returned as 1904, bump to 2004
$year += 100;
}
} else {
# year not given, try nearest
$year = App::Chart::Download::month_to_nearest_year ($month);
}
if (! Date::Calc::check_date ($year, $month, $day)) {
warn "Yahoo invalid dividend date '$str'";
}
return App::Chart::ymd_to_iso ($year, $month, $day);
}
#------------------------------------------------------------------------------
# Latest Quotes by CSV
# wget -S -O /dev/stdout 'http://download.finance.yahoo.com/d/quotes.csv?f=snc4b3b2d1t1oml1c1vqdx&e=.csv&s=GM'
#
# sub latest_download {
# my ($symbol_list) = @_;
# App::Chart::Download::status (__('Yahoo quotes'));
#
# # App::Chart::Download::verbose_message ("Yahoo crumb $crumb cookies\n"
# # . $jar->as_string);
#
# my $crumb_errors = 0;
# SYMBOL: foreach my $symbol (@$symbol_list) {
# my $tdate = daily_available_tdate ($symbol);
#
# App::Chart::Download::status(__('Yahoo quote'), $symbol);
#
# my $lo_timet = tdate_to_unix($tdate - 4);
# my $hi_timet = tdate_to_unix($tdate + 2);
#
# my $data = daily_cookie_data($symbol);
# if (! defined $data) {
# print "Yahoo $symbol does not exist\n";
# next SYMBOL;
# }
# my $crumb = URI::Escape::uri_escape($data->{'crumb'});
# my $jar = http_cookies_from_string($data->{'cookies'} // '');
#
# my $events = 'history';
# my $url = "http://query1.finance.yahoo.com/v7/finance/download/"
# . URI::Escape::uri_escape($symbol)
# . "?period1=$lo_timet&period2=$hi_timet&interval=1d&events=$events&crumb=$crumb";
( run in 2.794 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )