mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-18 04:14:20 +01:00
Add method for listing available tickers
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -67,3 +67,6 @@ target/
|
|||||||
# Remove Project Components from tracking
|
# Remove Project Components from tracking
|
||||||
travis_pypi_setup.py
|
travis_pypi_setup.py
|
||||||
|
|
||||||
|
# Mac
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ class TestTickerPrices(TestCase):
|
|||||||
assert self._ticker_metadata_response.get('ticker') == "GOOGL"
|
assert self._ticker_metadata_response.get('ticker') == "GOOGL"
|
||||||
assert self._ticker_metadata_response.get("name")
|
assert self._ticker_metadata_response.get("name")
|
||||||
|
|
||||||
def test_list_tickers(self):
|
def test_list_stock_tickers(self):
|
||||||
"""Update this test when the method is added."""
|
"""Update this test when the method is added."""
|
||||||
with self.assertRaises(NotImplementedError):
|
tickers = self._client.list_stock_tickers()
|
||||||
response = self._client.list_tickers()
|
assert len(tickers) > 1
|
||||||
assert not response
|
assert all(ticker['assetType'] == 'Stock' for ticker in tickers)
|
||||||
|
|
||||||
|
|
||||||
# tiingo/news
|
# tiingo/news
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
|
import csv
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from tiingo.restclient import RestClient
|
from tiingo.restclient import RestClient
|
||||||
|
|
||||||
@@ -35,11 +37,24 @@ class TiingoClient(RestClient):
|
|||||||
|
|
||||||
# TICKER PRICE ENDPOINTS
|
# TICKER PRICE ENDPOINTS
|
||||||
# https://api.tiingo.com/docs/tiingo/daily
|
# https://api.tiingo.com/docs/tiingo/daily
|
||||||
def list_tickers(self):
|
def list_stock_tickers(self):
|
||||||
"""Return a list of all supported tickers.
|
"""Return a list of dicts of metadata tickers for all supported Stocks
|
||||||
|
as well as metadata about each ticker.
|
||||||
|
Tickers for unrelated products are omitted.
|
||||||
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
resource_package = __name__
|
||||||
|
listing_path = "/".join(('data', 'supported_tickers.csv'))
|
||||||
|
listing_file = pkg_resources.resource_stream(resource_package,
|
||||||
|
listing_path)
|
||||||
|
tickers = []
|
||||||
|
reader = csv.DictReader(listing_file)
|
||||||
|
for row in reader:
|
||||||
|
tickers = [row for row in reader
|
||||||
|
if row.get('assetType') == 'Stock']
|
||||||
|
|
||||||
|
return [ticker for
|
||||||
|
ticker in tickers if ticker.get('assetType') == 'Stock']
|
||||||
|
|
||||||
def get_ticker_metadata(self, ticker):
|
def get_ticker_metadata(self, ticker):
|
||||||
"""Return metadata for 1 ticker
|
"""Return metadata for 1 ticker
|
||||||
|
|||||||
54264
tiingo/data/supported_tickers.csv
Normal file
54264
tiingo/data/supported_tickers.csv
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user