diff options
author | Antony Kellermann | 2018-02-01 10:28:35 -0500 |
---|---|---|
committer | Antony Kellermann | 2018-02-01 10:28:35 -0500 |
commit | bcd38b71b37f70d4a3b979c00ecc4c755f8910eb (patch) | |
tree | bc39488854b1fb3fe4d52fee1261b173241bdbe6 /portfolio.c | |
parent | 4c91aba4ebcd072597b09b714e8670cca3636804 (diff) | |
download | aur-bcd38b71b37f70d4a3b979c00ecc4c755f8910eb.tar.gz |
Removed Alpha Vantage and consolidated API calls to one per symbol
Diffstat (limited to 'portfolio.c')
-rw-r--r-- | portfolio.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/portfolio.c b/portfolio.c index 487a1e828eb6..e1501293e3da 100644 --- a/portfolio.c +++ b/portfolio.c @@ -62,7 +62,7 @@ void portfolio_modify(char* ticker_name_string, double quantity_shares, double u free(end); fclose(fp); } else { - if (strlen(ticker_name_string) > 16 || (api_get_current_price(ticker_name_string) == -1 && strcmp("USD$", ticker_name_string) != 0)) { + if (strlen(ticker_name_string) > 16 || (api_get_current_price(ticker_name_string) == NULL && strcmp("USD$", ticker_name_string) != 0)) { printf("Invalid symbol.\n"); return; } @@ -143,10 +143,13 @@ double* portfolio_print_stock(char* ticker_name_string, FILE* fp) { free(a); a = NULL; } else { + double* ticker_data; double ticker_current_price_usd = 1, ticker_1d_price_usd, ticker_1d_percent_change = 0; if (strcmp(ticker_name_string, "USD$") != 0) { - ticker_current_price_usd = api_get_current_price(ticker_name_string); - ticker_1d_price_usd = api_get_1d_price(ticker_name_string); + ticker_data = api_get_current_price(ticker_name_string); + ticker_current_price_usd = ticker_data[0]; + ticker_1d_price_usd = ticker_data[1]; + free(ticker_data); a[2] = ((ticker_current_price_usd - ticker_1d_price_usd) * a[0]); ticker_1d_percent_change = 100 * (ticker_current_price_usd / ticker_1d_price_usd - 1); a[0] *= ticker_current_price_usd; |