Skip to content

Commit

Permalink
gnc-fq-dump: Err msg if AlphaVantage API Key is needed but missing
Browse files Browse the repository at this point in the history
AlphaVantage API Key is needed for all currency quotes
and stock quotes with source 'alphavantage' or 'vanguard' or
multi sources that include 'alphavantage'
  • Loading branch information
goodvibes2 committed Jun 12, 2020
1 parent ec08fc1 commit 60da4bd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions libgnucash/quotes/gnc-fq-dump.in
Expand Up @@ -141,6 +141,25 @@ sub report {
}
}

sub chk_api_key {
my $exch = $_[0];
my $url = " https://wiki.gnucash.org/wiki/Online_Quotes#Source_Alphavantage.2C_US\n";
if (($exch eq "currency") || ($exch eq "alphavantage")
|| ($exch eq "vanguard")) {
die "ERROR: ALPHAVANTAGE_API_KEY *must* be set for currency quotes and \n" .
" stock quotes with source 'alphavantage' or 'vanguard'; see\n" . $url
unless (defined ($ENV{'ALPHAVANTAGE_API_KEY'}));
}
if (($exch eq "canada") || ($exch eq "nasdaq")
|| ($exch eq "nyse") || ($exch eq "usa")) {
printf("WARNING: Multiple Source '%s' will not be able to use alphavantage " .
"unless ALPHAVANTAGE_API_KEY is set; see\n%s", $exch, $url)
unless (defined ($ENV{'ALPHAVANTAGE_API_KEY'}));
}
}

############## end of functions - start mainline #########################

# Check for and load non-standard modules
check_modules ();

Expand All @@ -162,6 +181,7 @@ if ($ARGV[0] eq "-v") {
}

my $exchange = shift;
chk_api_key ($exchange);
if ($exchange eq "currency") {
my $from = shift;
while ($#ARGV >= 0) {
Expand Down

0 comments on commit 60da4bd

Please sign in to comment.