def get_fundamentals(inputSymbols, info=None): """Takes any number of stock tickers and returns fundamental information about the stock such as what sector it is in, a description of the company, dividend yield, and market cap. :param inputSymbols: May be a single stock ticker or a list of stock tickers. :type inputSymbols: str or list :param info: Will filter the results to have a list of the values that correspond to key that matches info. :type info: Optional[str] :returns: If info parameter is left as None then the list will contain a dictionary of key/value pairs for each ticker. \ Otherwise, it will be a list of strings where the strings are the values of the key that corresponds to info. """ symbols = helper.inputs_to_set(inputSymbols) url = urls.fundamentals() payload = {'symbols': ','.join(symbols)} data = helper.request_get(url, 'results', payload) if (data == None or data == [None]): return data for count, item in enumerate(data): if item is None: print(helper.error_ticker_does_not_exist(symbols[count])) data = [item for item in data if item is not None] return (helper.filter(data, info))
def get_fundamentals(inputSymbols, info=None): """Takes any number of stock tickers and returns fundamental information about the stock such as what sector it is in, a description of the company, dividend yield, and market cap. :param inputSymbols: May be a single stock ticker or a list of stock tickers. :type inputSymbols: str or list :param info: Will filter the results to have a list of the values that correspond to key that matches info. :type info: Optional[str] :returns: [list] If info parameter is left as None then the list will contain a dictionary of key/value pairs for each ticker. \ Otherwise, it will be a list of strings where the strings are the values of the key that corresponds to info. :Dictionary Keys: * open * high * low * volume * average_volume_2_weeks * average_volume * high_52_weeks * dividend_yield * float * low_52_weeks * market_cap * pb_ratio * pe_ratio * shares_outstanding * description * instrument * ceo * headquarters_city * headquarters_state * sector * industry * num_employees * year_founded * symbol """ symbols = helper.inputs_to_set(inputSymbols) url = urls.fundamentals() payload = {'symbols': ','.join(symbols)} data = helper.request_get(url, 'results', payload) if (data == None or data == [None]): return data for count, item in enumerate(data): if item is None: print(helper.error_ticker_does_not_exist(symbols[count]), file=helper.get_output()) else: item['symbol'] = symbols[count] data = [item for item in data if item is not None] return (helper.filter(data, info))