App-Chart
view release on metacpan or search on metacpan
misc/t-yahoo.pl view on Meta::CPAN
$gmtoff = 3600;
my @t = gmtime($t);
print join(',',@t),"\n";
print "GMT ",strftime('%H:%M:%S %d %m %Y',@t),"\n";
$ENV{TZ} = $tz;
@t = localtime($t);
print "local ",strftime('%H:%M:%S %d %m %Y',@t),"\n";
@t = gmtime($t - $gmtoff);
print "GMT off ",strftime('%H:%M:%S %d %m %Y',@t),"\n";
# 2024-06-17
# 1718593328 - 2*86400 == 1718420528
# 1718593328 + 2*86400 == 1718766128
# https://query2.finance.yahoo.com/v8/finance/chart/TSCO.L?formatted=true&lang=en-US®ion=US&period1=1718420528&period2=1718766128&interval=1d&events=div%7Csplit&corsDomain=finance.yahoo.com
# "open":[43.04999923706055,42.63999938964844,42.77000045776367],
# "low":[42.540000915527344,42.40999984741211,42.61000061035156],
# "close":[42.540000915527344,42.79999923706055,42.7400016784668],
# "volume":[7993163,11623663,6440310],
# "high":[43.13999938964844,43.06999969482422,42.88999938964844]}],
# "adjclose":[{"adjclose":[42.540000915527344,42.79999923706055,42.7400016784668]}]b
foreach my $t (1718582400,1718668800,1718755200) {
$ENV{TZ} = "Australia/Sydney";
@t = localtime($t);
print "stamp ",strftime('%H:%M:%S %d %m %Y',@t),"\n";
}
$t = Time::Local::timegm_modern (0,0,0, 16, 9-1, 2020);
$t = Time::Local::timegm_modern (0,0,0, 21, 6-1, 2024); # 6 Mar 2024
print $t - 6*86400,"\n";
print $t + 6*86400,"\n";
@t = gmtime($t - $gmtoff);
print "is GM ",strftime('%H:%M:%S %d %m %Y',@t),"\n";
exit 0;
# 'BHP.AX','2024-06-17','43.05','43.14','42.54','42.54','7993163'
# TSCO.L split 15 February 2021 in the ratio 15:19
# 229.07650756835938 / 149.2069549560547
# 19/15.
# 275.3731994628906 / 193.92584228515625
}
{
# exchanges_data() download
$App::Chart::option{'verbose'} = 2;
my $h = App::Chart::Yahoo::exchanges_data ();
print Dumper(\$h);
exit 0;
}
{
# exchanges_parse() from file
#
my $filename = $ENV{'HOME'}.'/chart/samples/yahoo/exchanges.html';
$filename = $ENV{'HOME'}.'/chart/samples/yahoo/SLN2310.html';
$filename = $ENV{'HOME'}.'/chart/samples/yahoo/exchanges-data-providers-yahoo-finance-sln2310.html';
my $decoded_content = File::Slurp::read_file ($filename, {binmode => ':utf8'});
my $h = App::Chart::Yahoo::exchanges_parse ($decoded_content);
print Dumper(\$h);
exit 0;
}
{
# v8 download size
# https://query2.finance.yahoo.com/v8/finance/chart/TSCO.L?period1=1701140528&period2=1718766128&interval=1d&events=div%7Csplit
# &corsDomain=finance.yahoo.com
exit 0;
}
{
# json v8 with flonum values rounding
# https://query2.finance.yahoo.com/v8/finance/chart/IBM?formatted=true&lang=en-US®ion=US&period1=1504028419&period2=1504428419&interval=1d&events=div%7Csplit&corsDomain=finance.yahoo.com
# https://forums.yahoo.net/t5/Yahoo-Finance-help/Is-Yahoo-Finance-API-broken/td-p/250503/page/14
# https://forums.yahoo.net/t5/Yahoo-Finance-help/Is-Yahoo-Finance-API-broken/td-p/250503/page/23
# {"chart":
# {"result":
# [{"meta":
# {"currency":"AUD",
# "symbol":"NAB.AX",
# "exchangeName":"ASX",
# "instrumentType":"EQUITY",
# "firstTradeDate":570398400,
# "gmtoffset":36000,
# "timezone":"AEST",
# "exchangeTimezoneName":"Australia/Sydney",
# "currentTradingPeriod":
# {"pre":{"timezone":"AEST",
# "end":1504828800,
# "start":1504818000,
# "gmtoffset":36000},
# "regular":{"timezone":"AEST",
# "end":1504850400,
# "start":1504828800,
# "gmtoffset":36000},
# "post":{"timezone":"AEST",
# "end":1504851120,
# "start":1504850400,
# "gmtoffset":36000}},
# "dataGranularity":"1d",
# "validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},
# "timestamp":[1504483200,1504569600,1504656000,1504742400,1504845136],
# "indicators":
# {"quote":
# [{"high":[30.385000228881836,30.399999618530273,30.209999084472656,30.3799991607666,30.170000076293945],
# "low":[30.15999984741211,30.100000381469727,29.950000762939453,30.0,29.829999923706055],
# "close":[30.260000228881836,30.350000381469727,30.149999618530273,30.170000076293945,29.885000228881836],
# "open":[30.270000457763672,30.290000915527344,30.059999465942383,30.299999237060547,30.170000076293945],
# "volume":[2059508,2240849,4332445,3451099,2144174]}],
# "unadjclose":[{"unadjclose":[30.260000228881836,30.350000381469727,30.149999618530273,30.170000076293945,29.885000228881836]}],
# "adjclose":[{"adjclose":[30.260000228881836,30.350000381469727,30.149999618530273,30.170000076293945,29.885000228881836]}]}}],
# "error":null}}
( run in 0.544 second using v1.01-cache-2.11-cpan-39bf76dae61 )