r ();
use Carp;
use Finance::Quote::UserAgent;
use HTTP::Request::Common;
use Encode;
use JSON qw( decode_json );
use vars qw/@ISA @EXPORT @EXPORT_OK @EXPORT_TAGS
$TIMEOUT @MODULES %MODUL
w/
AlphaVantage
CurrencyFreaks
ECB
FinanceAPI
Fixer
OpenExchange
YahooJSON
/;
@MODULES = qw/
AEX
ASEGR
ASX
AlphaVantage
BSEIndia
BorsaItaliana
reto
TMX
Tradegate
TreasuryDirect
TSP
TwelveData
Union
XETRA
YahooJSON
YahooWeb
ZA
/;
@ISA = qw/Exporter/;
@EXPORT = ();
@EXPORT_OK = qw/asx currency_lookup
urrencyRates/YahooJSON.pm
package Finance::Quote::CurrencyRates::FinanceAPI;
use strict;
use warnings;
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use JSON;
our $VERSION =
($this, $ua, $from, $to) = @_;
my $json_data;
my $rate;
# Set headers. API key is sent as a header.
my @ua_headers = (
'Accept' => 'application/json',
'X-API-KEY' => $this->{API_KEY},
$json_data = JSON::decode_json $body;
### JSON: $json_data
if ( !$json_data || !$json_data->{'chart'}->{'result'}->[0]->{'meta'}->{'regularMarketPrice'} ) {
return;
}
$rate =
$json_
ucash.org/>
#
# Changes:
# Rewritten for issue #516: 2025-10-21, Bruce Schuck
# Parses JSON retrieved from
# https://internal.api.union-investment.de/beta/web/funddata/fundsearch?segme
{DEBUG};
use if DEBUG, 'Smart::Comments', '###';
use JSON qw(decode_json);
our $VERSION = '1.67_01'; # TRIAL VERSION
# This url retrieve a JSON data structure containing data for all funds
our $UNI
==========
# The unionfunds routine gets quotes of UNION funds (Union Invest)
# The URL returns a JSON data structure containing a table containing
# quote data for all funds
#
# This subroutine was w
gs;
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use Encode;
use JSON qw( decode_json );
use LWP::UserAgent;
use Web::Scraper;
use String::Util qw(trim);
our $VERSION = '1.67
/instruments/$symbol";
my $reply = $ua->get($url);
# JSON inside script id="__NEXT_DATA__" type="application/json" crossorigin="">
my $widget = scraper {
process '
ult->script: $result->{script}
my $json = encode_utf8($result->{script});
my $json_data;
eval {$json_data = JSON::decode_json($json)};
if ($@) {
$info{ $sy
';
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Cookies;
use JSON qw(decode_json);
use Text::Template;
our $VERSION = '1.67_01'; # TRIAL VERSION
$MSTARUK_MAIN_URL =
next;
}
$webdoc = $response->content;
### [<now>] 2nd Webdoc: $webdoc
my $json;
eval {$json = decode_json $webdoc};
if ($@) {
# serious error, report it and give up
ecode JSON";
next;
}
### [<now>] JSON: $json
# Find date, currency and price all in one table row
my ($date, $time);
my $currency = $json->{'currency'};
my $price = $json->{'na
renamed to yahooJSON
# since it gets a lot of quotes besides Indian
#
# The code has been modified by Abhijit K to
# retrieve stock information from Yahoo Finance through json calls
#
# Th
t, Fifth Floor, Boston, MA
# 02110-1301, USA
package Finance::Quote::YahooJSON;
use strict;
use JSON qw( decode_json );
use vars qw($VERSION $YIND_URL_HEAD $YIND_URL_TAIL);
use HTTP::Request::Co
YahooJSON';
our @LABELS = qw/name last date isodate volume currency method exchange type
div_yield eps pe year_range open high low close/;
our $METHODHASH = {subroutine => \&yahoo_json,
a;
use strict;
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use JSON qw( decode_json );
use HTTP::Request::Common;
use Text::Template;
use DateTime::Format::Strptime qw( strp
errormsg' } = $desc;
next;
}
my $quote;
eval {$quote = JSON::decode_json $body};
if ($@) {
$info{ $symbol, 'success' } = 0;
$info{
ol, 'success' } = 0;
$info{ $symbol, 'errormsg' } = "TwevleData return and unexpected json result";
next;
}
$info{ $symbol, 'success' } = 1;
$info{ $sy
sh.org/>
use strict;
use warnings;
package Finance::Quote::ASX;
use LWP::UserAgent;
use JSON qw/decode_json/;
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use vars qw/$ASX_
uotes
# which prevented the previous HTML screen scraping from working, but exposed
# a number of JSON data sources, two of which are used here.
# The primary source returns data elements for almost a
) {
$status = 0;
$error = "Cannot parse content from ASX server '$url'. Expected a top level JSON element named data.";
### ASX.pm Error: $error
return $status, $error;
}
# Map the Finance::
#!/usr/bin/perl -w
# This module is based on the Finance::Quote::yahooJSON module
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Gene
# 02110-1301, USA
package Finance::Quote::IEXCloud;
require 5.005;
use strict;
use JSON qw( decode_json );
use HTTP::Request::Common;
use Text::Template;
use DateTime::Format::Strptime qw( strp
errormsg' } = $desc;
next;
}
my $quote;
eval {$quote = JSON::decode_json $body};
if ($@) {
$info{ $symbol, 'success' } = 0;
$info{
use strict;
use warnings;
package Finance::Quote::Consorsbank;
use LWP::UserAgent;
use JSON qw( decode_json );
use Date::Parse qw(str2time);
use POSIX qw(strftime);
use Encode qw(encode_utf8);
use
$info{ $symbol, 'success' } = 0;
$info{ $symbol, 'errormsg' } = '';
my $get_json = sub {
my $query = shift;
my $response = $ua->get($query);
tent-type') =~ m|application/json|i) {
$info{ $symbol, 'errormsg' } = "Invalid content-type from Consorsbank server for $symbol. Expected: application/json, received: " . $response->h
2110-1301, USA
package Finance::Quote::Fool;
use strict;
use HTTP::Request::Common;
use JSON qw( decode_json );
use Text::Template;
use Encode qw(decode);
use constant DEBUG => $ENV{DEBUG};
use if
D}?timeFrame=OneWeek&precision=Day&apikey=6cbf5f34-ba40-4108-a1ab-d951c608955e');
# Fool returns JSON with a Currency stanza
# '1' -> USD
my %currencies_by_id = (
'1' => 'USD',
);
our $DISPLAY
t;
my @stocks = @_;
my (%info, $symbol, $url, $reply, $code, $desc, $body);
my ($json_data, $instrumentID, $exchange, $tree );
my %mnames = (jan => 1, feb => 2, mar => 3, apr => 4
constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use LWP::UserAgent;
use JSON qw( decode_json );
use String::Util qw(trim);
use Scalar::Util qw(looks_like_number);
our $VERSION = '1.
s/snap.json?select=ValorId,PortalSegment,ProductLine&where=PortalSegment=EQ|BO|FU|EP|IN&pagesize=2&match=' . $symbol;
my $reply = $ua->get($url);
my $search = JSON::decode_json $reply
mbol not found" unless defined $valorid;
$url = 'https://www.six-group.com/fqs/ref.json?select=DividendEntitlementFlag,FirstTradingDate,LastTradingDate,ISIN,IssuerNameFull,IssuerNameSho
t;
use HTTP::Request::Common;
use HTTP::CookieJar::LWP ();
use HTML::TreeBuilder;
use Encode;
use JSON;
our $VERSION = '1.65_01'; # TRIAL VERSION
use vars qw($BLOOMBERG_URL);
$BLOOMBERG_URL = 'http
nt);
my $json = encode_utf8 (($tree->look_down(_tag=>'script', 'id'=>'__NEXT_DATA__')->content_list())[0]);
my $json_decoded = decode_json $json;
my $json_quote = $json_decoded->{'pr
{'quote'};
my $desc = $json_quote->{'longName'};
my $price = $json_quote->{'price'};
my $curr = $json_quote->{'issuedCurrency'};
my $date = $json_quote->{'lastUpdate'};
L $FUNDLIB_MAIN_URL);
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::TableExtract;
use JSON;
use warnings;
use Time::Piece;
our $VERSION = '1.59_01'; #TRIAL VERSION
# URLs of where to ob
racefully - add later##
return unless ($reply->is_success);
my $json = JSON->new;
my $data = decode_json($reply->decoded_content);
# If the fund is not found, "PriceAsOfDateStr
USA
#
# $Id: $
package Finance::Quote::GoldMoney;
require 5.005;
use HTTP::Request::Common;
use JSON;
use strict;
use warnings;
our $VERSION = '1.67_01'; # TRIAL VERSION
sub methods {
return
returned (note: this module only works for 'gold' and 'silver')";
}
}
# get the JSON of the prices. Currently getting sell price,
if ( $_want_gold or $_want_silver or $_want_plat
my $json = from_json($html_string);
$table_gold = $json->{spotPrices}[0];
$table_silver = $json->{spotPrices}[1];
$table_platinum = $json->{spotPrice
package Finance::Quote::Oslobors;
use strict;
use JSON qw( decode_json );
use HTTP::Request::Common;
our $VERSION = '1.65'; # VERSION
use vars qw( $OSLOBORS_COMPONENTS_URL );
$OSLOBORS_COMPONENTS_
= 0;
$funds{$symbol, "errormsg"} = "HTTP request failed";
} else {
$data = JSON::decode_json($reply->content)->{"rows"}[0]{"values"};
$quoter->store_date(\%funds, $symbol, { is
nings;
use Encode qw(encode_utf8);
use HTML::TreeBuilder;
use HTTP::Request::Common;
use JSON qw( decode_json );
use Date::Parse qw(str2time);
use POSIX qw(strftime);
use constant DEBUG => $ENV{DEBU
}
sub onvista {
my $quoter = shift;
my @stocks = @_;
my (%info, $tree, $url, $reply, $json, $json_decoded);
my $ua = $quoter->user_agent();
foreach my $stock (@stocks) {
$url = $O
body)) {
$tree->eof;
unless ( $json = encode_utf8 (($tree->look_down(_tag => 'script', id => '__NEXT_DATA__', type => 'application/json')->content_list())[0]) ) {
$info{ $st
#!/usr/bin/perl -w
# This module is based on the Finance::Quote::yahooJSON module
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Gene
lose as returned in the JSON.
# Bruce Schuck (bschuck at asgard hyphen systems dot com)
package Finance::Quote::AlphaVantage;
use strict;
use JSON qw( decode_json );
use HTTP::Request::C
ort
my $ALPHAVANTAGE_URL =
'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&datatype=json';
my %currencies_by_suffix = (
# Country City/Exchange Name
'.US'
nceAPI;
use strict;
use warnings;
use Encode qw(decode);
use HTTP::Request::Common;
use JSON qw( decode_json );
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments', '###';
our $VERS
# Set headers. API key is sent as a header.
my @ua_headers = (
'Accept' => 'application/json',
'X-API-KEY' => $token,
);
foreach my $stock (@stocks) {
if ( !defined $token ) {
eval {$quote = JSON::decode_json $body};
if ($@) {
$info{ $stock, 'success' } = 0;
$info{ $stock, 'errormsg' } = $@;
next;
}
### [<now>] JSON quote: $quote
e strict;
use warnings;
use constant DEBUG => $ENV{DEBUG};
use if DEBUG, 'Smart::Comments';
use JSON;
our $VERSION = '1.67_01'; # TRIAL VERSION
sub parameters {
return ('API_KEY');
}
sub new
{
l = 'https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE';
my $try_cnt = 0;
my $json_data;
my $rate;
do {
$try_cnt += 1;
my $reply = $ua->get($url
. '&from_curren
$json_data = JSON::decode_json $body;
if ( !$json_data || $json_data->{'Error Message'} ) {
return;
}
### JSON: $json_data
sleep (20) if (($try_cnt < 5) && ($json_data-