mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-17 11:54:19 +01:00
reverted to prior indexing method
This commit is contained in:
@@ -55,10 +55,11 @@ class TestTiingoWithPython(TestCase):
|
|||||||
self.assertTrue(isinstance(prices, pd.Series))
|
self.assertTrue(isinstance(prices, pd.Series))
|
||||||
assert len(prices.index) == 10
|
assert len(prices.index) == 10
|
||||||
|
|
||||||
def test_column_error(self):
|
def test_metric_name_column_error(self):
|
||||||
with self.assertRaises(APIColumnNameError):
|
with self.assertRaises(APIColumnNameError):
|
||||||
self._client.get_dataframe(['GOOGL', 'AAPL'], startDate='2018-01-05',
|
self._client.get_dataframe(['GOOGL', 'AAPL'], startDate='2018-01-05',
|
||||||
endDate='2018-01-19', metric_name='xopen', frequency='weekly')
|
endDate='2018-01-19', metric_name='xopen', frequency='weekly')
|
||||||
|
|
||||||
@vcr.use_cassette('tests/fixtures/ticker_price_pandas_single.yaml')
|
@vcr.use_cassette('tests/fixtures/ticker_price_pandas_single.yaml')
|
||||||
def test_pandas_edge_case(self):
|
def test_pandas_edge_case(self):
|
||||||
"""Test single price/date being returned as a frame"""
|
"""Test single price/date being returned as a frame"""
|
||||||
|
|||||||
@@ -166,16 +166,6 @@ class TiingoClient(RestClient):
|
|||||||
else:
|
else:
|
||||||
return response.content.decode("utf-8")
|
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,
|
def get_dataframe(self, tickers,
|
||||||
startDate=None, endDate=None, metric_name=None, frequency='daily'):
|
startDate=None, endDate=None, metric_name=None, frequency='daily'):
|
||||||
|
|
||||||
@@ -186,6 +176,7 @@ class TiingoClient(RestClient):
|
|||||||
|
|
||||||
Supported tickers + Available Day Ranges are here:
|
Supported tickers + Available Day Ranges are here:
|
||||||
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
||||||
|
or from the TiingoClient.list_tickers() method.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tickers (string/list): One or more unique identifiers for a stock ticker.
|
tickers (string/list): One or more unique identifiers for a stock ticker.
|
||||||
@@ -221,6 +212,7 @@ class TiingoClient(RestClient):
|
|||||||
df = pd.DataFrame(response.json())
|
df = pd.DataFrame(response.json())
|
||||||
if metric_name is not None:
|
if metric_name is not None:
|
||||||
prices = df[metric_name]
|
prices = df[metric_name]
|
||||||
|
prices.index = df['date']
|
||||||
else:
|
else:
|
||||||
prices = df
|
prices = df
|
||||||
prices.index = df['date']
|
prices.index = df['date']
|
||||||
|
|||||||
Reference in New Issue
Block a user