diff --git a/libgnucash/quotes/gnc-fq-dump.in b/libgnucash/quotes/gnc-fq-dump.in index 6c595a8356..6f11f8d82b 100755 --- a/libgnucash/quotes/gnc-fq-dump.in +++ b/libgnucash/quotes/gnc-fq-dump.in @@ -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 (); @@ -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) {