reverted to prior indexing method

This commit is contained in:
Davis Thames
2018-06-10 14:13:28 -05:00
parent f7b3da50a7
commit a2b4d34ab1
2 changed files with 4 additions and 11 deletions

View File

@@ -55,10 +55,11 @@ class TestTiingoWithPython(TestCase):
self.assertTrue(isinstance(prices, pd.Series))
assert len(prices.index) == 10
def test_column_error(self):
def test_metric_name_column_error(self):
with self.assertRaises(APIColumnNameError):
self._client.get_dataframe(['GOOGL', 'AAPL'], startDate='2018-01-05',
endDate='2018-01-19', metric_name='xopen', frequency='weekly')
@vcr.use_cassette('tests/fixtures/ticker_price_pandas_single.yaml')
def test_pandas_edge_case(self):
"""Test single price/date being returned as a frame"""

View File

@@ -166,16 +166,6 @@ class TiingoClient(RestClient):
else:
return response.content.decode("utf-8")
def _build_url(self, stock, startDate, endDate, frequency):
url = "https://api.tiingo.com/tiingo/"
url += "daily/{}/prices?".format(stock)
if startDate is not None and endDate is None:
url += "&startDate={}".format(startDate)
if startDate is not None and endDate is not None:
url += "&startDate={}&endDate={}".format(startDate, endDate)
url += "&format=json&resampleFreq={}&token={}".format(frequency, self._api_key)
return url
def get_dataframe(self, tickers,
startDate=None, endDate=None, metric_name=None, frequency='daily'):
@@ -186,6 +176,7 @@ class TiingoClient(RestClient):
Supported tickers + Available Day Ranges are here:
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
or from the TiingoClient.list_tickers() method.
Args:
tickers (string/list): One or more unique identifiers for a stock ticker.
@@ -221,6 +212,7 @@ class TiingoClient(RestClient):
df = pd.DataFrame(response.json())
if metric_name is not None:
prices = df[metric_name]
prices.index = df['date']
else:
prices = df
prices.index = df['date']