mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2026-02-01 09:04:18 +01:00
Merge pull request #62 from savagesmc/add_etf_fund_lists
Add interfaces to obtain mutual fund and ETF tickers.
This commit is contained in:
@@ -12,3 +12,4 @@ Contributors
|
||||
|
||||
* Dmitry Budaev <condemil@gmail.com>
|
||||
* Bharat Kalluri
|
||||
* Stephen Clark <steveclarkcode@gmail.com>
|
||||
|
||||
34
tests/fixtures/list_etf_tickers.yaml
vendored
Normal file
34
tests/fixtures/list_etf_tickers.yaml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
User-Agent: [python-requests/2.18.4]
|
||||
method: GET
|
||||
uri: https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
UEsDBBQAAAAIAEgBU0zqbCjObwAAAI4AAAAVABwAc3VwcG9ydGVkX3RpY2tlcnMuY3N2VVQJAANI
|
||||
aopaSGqKWnV4CwABBAAAAAAEAAAAACvJTM5OLdJJrUjOSMxLT9VJLC5OLQmpLEjVKSjKTE51Li0q
|
||||
Ss1LrtQpLkksKnFJLEnVSc1LAdG8XI6OLkE6fpHBrgqOQc6OOq4hbjqhwS465vpGhvpGBoYGOkb6
|
||||
hmYglgUvVwQWhYb6UHVQBlAZAFBLAQIeAxQAAAAIAEgBU0zqbCjObwAAAI4AAAAVABgAAAAAAAEA
|
||||
AAD/gQAAAABzdXBwb3J0ZWRfdGlja2Vycy5jc3ZVVAUAA0hqilp1eAsAAQQAAAAABAAAAABQSwUG
|
||||
AAAAAAEAAQBbAAAAvgAAAAAA
|
||||
headers:
|
||||
Accept-Ranges: [bytes]
|
||||
Age: ['820']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['2709436']
|
||||
Content-Type: [application/zip]
|
||||
Date: ['Sun, 08 Oct 2017 10:17:38 GMT']
|
||||
ETag: ['"aa6b2d0623735374b5c471305911fbac"']
|
||||
Last-Modified: ['Sat, 07 Oct 2017 23:28:33 GMT']
|
||||
Server: [AmazonS3]
|
||||
Via: [1.1 5d4ff22febf83d261f03aa068f5bdc04.cloudfront.net (CloudFront)]
|
||||
X-Amz-Cf-Id: [Eo3QEjB2WELpsXJhXHqylxkoU2G3DVFXCa6Ka7d0sDhOh2JG3HA08w==]
|
||||
X-Cache: [Hit from cloudfront]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
||||
34
tests/fixtures/list_fund_tickers.yaml
vendored
Normal file
34
tests/fixtures/list_fund_tickers.yaml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept: ['*/*']
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Connection: [keep-alive]
|
||||
User-Agent: [python-requests/2.18.4]
|
||||
method: GET
|
||||
uri: https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
UEsDBBQAAAAIAHQBU0zNiK0mbQAAAJ0AAAAVABwAc3VwcG9ydGVkX3RpY2tlcnMuY3N2VVQJAAOb
|
||||
aopam2qKWnV4CwABBAAAAAAEAAAAACvJTM5OLdJJrUjOSMxLT9VJLC5OLQmpLEjVKSjKTE51Li0q
|
||||
Ss1LrtQpLkksKnFJLEnVSc1LAdG8XI5AEKHj5+sWGKzjW1pSmpij4Faal6ITGuyiY65vbKhvZGBg
|
||||
rmOkb2gGZBlagDU4OZOiAQBQSwECHgMUAAAACAB0AVNMzYitJm0AAACdAAAAFQAYAAAAAAABAAAA
|
||||
/4EAAAAAc3VwcG9ydGVkX3RpY2tlcnMuY3N2VVQFAAObaopadXgLAAEEAAAAAAQAAAAAUEsFBgAA
|
||||
AAABAAEAWwAAALwAAAAAAA==
|
||||
headers:
|
||||
Accept-Ranges: [bytes]
|
||||
Age: ['820']
|
||||
Connection: [keep-alive]
|
||||
Content-Length: ['2709436']
|
||||
Content-Type: [application/zip]
|
||||
Date: ['Sun, 08 Oct 2017 10:17:38 GMT']
|
||||
ETag: ['"aa6b2d0623735374b5c471305911fbac"']
|
||||
Last-Modified: ['Sat, 07 Oct 2017 23:28:33 GMT']
|
||||
Server: [AmazonS3]
|
||||
Via: [1.1 5d4ff22febf83d261f03aa068f5bdc04.cloudfront.net (CloudFront)]
|
||||
X-Amz-Cf-Id: [Eo3QEjB2WELpsXJhXHqylxkoU2G3DVFXCa6Ka7d0sDhOh2JG3HA08w==]
|
||||
X-Cache: [Hit from cloudfront]
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
||||
@@ -95,6 +95,17 @@ class TestTickerPrices(TestCase):
|
||||
assert len(tickers) > 1
|
||||
assert all(ticker['assetType'] == 'Stock' for ticker in tickers)
|
||||
|
||||
@vcr.use_cassette('tests/fixtures/list_fund_tickers.yaml')
|
||||
def test_list_fund_tickers(self):
|
||||
tickers = self._client.list_fund_tickers()
|
||||
assert len(tickers) > 1
|
||||
assert all(ticker['assetType'] == 'Mutual Fund' for ticker in tickers)
|
||||
|
||||
@vcr.use_cassette('tests/fixtures/list_etf_tickers.yaml')
|
||||
def test_list_etf_tickers(self):
|
||||
tickers = self._client.list_etf_tickers()
|
||||
assert len(tickers) > 1
|
||||
assert all(ticker['assetType'] == 'ETF' for ticker in tickers)
|
||||
|
||||
# tiingo/news
|
||||
class TestNews(TestCase):
|
||||
|
||||
@@ -76,11 +76,11 @@ class TiingoClient(RestClient):
|
||||
|
||||
# TICKER PRICE ENDPOINTS
|
||||
# https://api.tiingo.com/docs/tiingo/daily
|
||||
def list_stock_tickers(self):
|
||||
"""Return a list of dicts of metadata tickers for all supported Stocks
|
||||
as well as metadata about each ticker. This includes supported
|
||||
date range, the exchange the ticker is traded on, and the currency
|
||||
the stock is traded on.
|
||||
def list_tickers(self, assetType):
|
||||
"""Return a list of dicts of metadata tickers for all supported tickers
|
||||
of the specified asset type, as well as metadata about each ticker.
|
||||
This includes supported date range, the exchange the ticker is traded
|
||||
on, and the currency the stock is traded on.
|
||||
Tickers for unrelated products are omitted.
|
||||
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
||||
"""
|
||||
@@ -91,7 +91,16 @@ class TiingoClient(RestClient):
|
||||
reader = csv.DictReader(raw_csv)
|
||||
|
||||
return [row for row in reader
|
||||
if row.get('assetType') == 'Stock']
|
||||
if row.get('assetType') == assetType]
|
||||
|
||||
def list_stock_tickers(self):
|
||||
return self.list_tickers('Stock')
|
||||
|
||||
def list_etf_tickers(self):
|
||||
return self.list_tickers('ETF')
|
||||
|
||||
def list_fund_tickers(self):
|
||||
return self.list_tickers('Mutual Fund')
|
||||
|
||||
def get_ticker_metadata(self, ticker, fmt='json'):
|
||||
"""Return metadata for 1 ticker
|
||||
|
||||
Reference in New Issue
Block a user