def get_historical_quotes(self, stock, interval, span, bounds=Bounds.REGULAR): """Fetch historical data for stock Note: valid interval/span configs interval = 5minute | 10minute + span = day, week interval = day + span = year interval = week TODO: NEEDS TESTS Args: stock (str): stock ticker interval (str): resolution of data span (str): length of data bounds (:enum:`Bounds`, optional): 'extended' or 'regular' trading hours Returns: (:obj:`dict`) values returned from `historicals` endpoint """ if type(stock) is str: stock = [stock] if isinstance(bounds, str): # recast to Enum bounds = Bounds(bounds) historicals = endpoints.historicals( ) + "/?symbols=" + ','.join(stock).upper( ) + "&interval=" + interval + "&span=" + span + "&bounds=" + bounds.name.lower( ) res = self.session.get(historicals, timeout=15) return res.json()['results'][0]
def get_historical_quotes(self, stock, interval, span, bounds='regular'): """Fetch historical data for stock Note: valid interval/span configs interval = 5minute | 10minute + span = day, week interval = day + span = year interval = week TODO: NEEDS TESTS Args: stock (str): stock ticker interval (str): resolution of data span (str): length of data bounds (:enum:`Bounds`, optional): 'extended' or 'regular' trading hours Returns: (:obj:`dict`) values returned from `historicals` endpoint """ if type(stock) is str: stock = [stock] if isinstance(bounds, str): # recast to Enum bounds = Bounds(bounds) params = { 'symbols': ','.join(stock).upper(), 'interval': interval, 'span': span, 'bounds': 'regular' } res = self.session.get(endpoints.historicals(), params=params, timeout=15) return res.json()