diff options
Diffstat (limited to 'api.h')
-rw-r--r-- | api.h | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -9,6 +9,7 @@ #ifndef API_H #define API_H +#define SYMBOL_MAX_LENGTH 32 #define EMPTY (-999) #include <stddef.h> @@ -17,8 +18,8 @@ #include "string-tick.h" typedef struct info { - char* name; // Name of security (ex. Apple Inc.) - char* symbol; // Symbol of security (ex. AAPL) + char name[SYMBOL_MAX_LENGTH]; // Name of security (ex. Apple Inc.) + char symbol[SYMBOL_MAX_LENGTH]; // Symbol of security (ex. AAPL) double price; // Current price of security in USD (ex. 174.54) double change_1d, change_7d, change_30d; // Percent change in the past x days (ex. -7.49) double div_yield; // Percent dividend yield (ex. 1.46) @@ -36,7 +37,7 @@ Info* api_info_init(void); * writefunction for cURL HTTP GET/POST * stolen from a nice man on stackoverflow */ -size_t api_string_writefunc(void* ptr, size_t size, size_t nmemb, String* hString); +size_t api_string_writefunc(void* ptr, size_t size, size_t nmemb, String* pString); /** * If post_field is not NULL, performs a HTTP POST with the given parameters. Otherwise, performs a HTTP GET. Response @@ -57,55 +58,55 @@ String* api_curl_data(const char* url, const char* post_field); * 1. IEX -- NASDAQ/NYSE/NYSEARCA * 2. Morningstar -- MUTF/OTCMKTS * 3. Coinmarketcap -- CRYPTO - * @param ticker_name_string security symbol or name to get prices of + * @param symbol security symbol or name to get prices of * @return price data or NULL if invalid symbol */ -double* api_get_current_price(const char* ticker_name_string); +double* api_get_current_price(const char* symbol); /** * Returns current and yesterday's price of a stock with data from IEX. * Tested for NASDAQ, NYSE, and NYSEARCA listed stocks/ETFs. - * @param ticker_name_string symbol + * @param symbol symbol * @return price data as defined by api_get_current_price or NULL if invalid symbol */ -double* iex_get_price(const char* ticker_name_string); +double* iex_get_price(const char* symbol); /** * Returns current and yesterday's price of a mutual fund with data from Morningstar * Tested for MUTF and OTCMKTS listed securities. - * @param ticker_name_string symbol + * @param symbol symbol * @return price data as defined by api_get_current_price or NULL if invalid symbol */ -double* morningstar_get_price(const char* ticker_name_string); +double* morningstar_get_price(const char* symbol); /** * Returns current and yesterday's price of a cryptocurrency with data from Coinmarketcap. * All cryptocurrencies listed on Coinmarketcap will work. - * @param ticker_name_string symbol + * @param symbol symbol * @return price data as defined by api_get_current_price or NULL if invalid symbol */ -double* coinmarketcap_get_price(const char* ticker_name_string); +double* coinmarketcap_get_price(const char* symbol); /** * Returns an array of doubles containing the close price each day in the past 5 years - * @param ticker_name_string symbol + * @param symbol symbol * @return double array of close prices */ -double* api_get_hist_5y(const char* ticker_name_string); +double* api_get_hist_5y(const char* symbol); /** * Returns an array of doubles containing the close price each day in the past 5 years - * @param ticker_name_string symbol of stock or etf + * @param symbol symbol of stock or etf * @return double array of close prices */ -double* iex_get_hist_5y(const char* ticker_name_string); +double* iex_get_hist_5y(const char* symbol); /** * Returns an array of doubles containing the close price each day in the past 5 years - * @param ticker_name_string symbol of mutf/otcmkts + * @param symbol symbol of mutf/otcmkts * @return double array of close prices */ -double* morningstar_get_hist_5y(const char* ticker_name_string); +double* morningstar_get_hist_5y(const char* symbol); /** * Prints the top three news articles by popularity pertaining to the given string, ticker_name_string. Spaces and |