[feature] Add news onlyWithTickers parameter

This commit is contained in:
Cameron Yick
2019-09-01 21:11:43 -04:00
parent d22b56d9b5
commit 98ad58a0ef
2 changed files with 6 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ interactions:
Content-Type: [application/json] Content-Type: [application/json]
User-Agent: [tiingo-python-client 0.11.0] User-Agent: [tiingo-python-client 0.11.0]
method: GET method: GET
uri: https://api.tiingo.com/tiingo/news?limit=1&offset=0&sortBy=publishedDate&tickers=aapl&tickers=googl&source=cnbc.com,altcointoday.com&tags=Technology&tags=Bitcoin&startDate=2016-01-01&endDate=2017-08-31 uri: https://api.tiingo.com/tiingo/news?limit=1&offset=0&sortBy=publishedDate&tickers=aapl&tickers=googl&source=cnbc.com,altcointoday.com&tags=Technology&tags=Bitcoin&startDate=2016-01-01&endDate=2017-08-31&onlyWithTickers=False
response: response:
body: {string: '[{ body: {string: '[{
"publishedDate": "2016-01-11T23:13:00Z", "publishedDate": "2016-01-11T23:13:00Z",

View File

@@ -278,6 +278,7 @@ class TiingoClient(RestClient):
# tiingo/news # tiingo/news
def get_news(self, tickers=[], tags=[], sources=[], startDate=None, def get_news(self, tickers=[], tags=[], sources=[], startDate=None,
endDate=None, limit=100, offset=0, sortBy="publishedDate", endDate=None, limit=100, offset=0, sortBy="publishedDate",
onlyWithTickers=False,
fmt='json'): fmt='json'):
"""Return list of news articles matching given search terms """Return list of news articles matching given search terms
https://api.tiingo.com/docs/tiingo/news https://api.tiingo.com/docs/tiingo/news
@@ -291,7 +292,8 @@ class TiingoClient(RestClient):
startDate, endDate [date]: Boundaries of news search window startDate, endDate [date]: Boundaries of news search window
limit (int): Max results returned. Default 100, max 1000 limit (int): Max results returned. Default 100, max 1000
offset (int): Search results offset, used for paginating offset (int): Search results offset, used for paginating
sortBy (string): "publishedDate" OR (#TODO: UPDATE THIS) sortBy (string): "publishedDate" OR "crawlDate", descending
onlyWithTickers (bool): If true, only links with tagged tickers will return.
""" """
url = "tiingo/news" url = "tiingo/news"
params = { params = {
@@ -302,7 +304,8 @@ class TiingoClient(RestClient):
'source': (",").join(sources), 'source': (",").join(sources),
'tags': tags, 'tags': tags,
'startDate': startDate, 'startDate': startDate,
'endDate': endDate 'endDate': endDate,
'onlyWithTickers': onlyWithTickers
} }
response = self._request('GET', url, params=params) response = self._request('GET', url, params=params)
data = response.json() data = response.json()