Add columns param to get_ticker_price, including tests

This commit is contained in:
Koen werklaptop
2024-10-23 21:27:02 +02:00
parent 80b40c5be5
commit 6b53725dca
5 changed files with 109 additions and 4 deletions

View File

@@ -219,7 +219,7 @@ class TiingoClient(RestClient):
return prices
def get_ticker_price(
self, ticker, startDate=None, endDate=None, fmt="json", frequency="daily"
self, ticker, startDate=None, endDate=None, columns=None, fmt="json", frequency="daily"
):
"""By default, return latest EOD Composite Price for a stock ticker.
On average, each feed contains 3 data sources.
@@ -231,6 +231,7 @@ class TiingoClient(RestClient):
ticker (string): Unique identifier for stock ticker
startDate (string): Start of ticker range in YYYY-MM-DD format
endDate (string): End of ticker range in YYYY-MM-DD format
columns (string): Comma separated parameter specifying which columns to retrieve (to include volume)
fmt (string): 'csv' or 'json'
frequency (string): Resample frequency
"""
@@ -244,6 +245,8 @@ class TiingoClient(RestClient):
params["startDate"] = startDate
if endDate:
params["endDate"] = endDate
if columns:
params["columns"] = columns
# TODO: evaluate whether to stream CSV to cache on disk, or
# load as array in memory, or just pass plain text
@@ -279,7 +282,7 @@ class TiingoClient(RestClient):
tickers (string/list): One or more unique identifiers for a stock ticker.
startDate (string): Start of ticker range in YYYY-MM-DD format.
endDate (string): End of ticker range in YYYY-MM-DD format.
columns (string): Comma seperated parameter specifying which columns to retrieve (to include volume)
columns (string): Comma separated parameter specifying which columns to retrieve (to include volume)
metric_name (string): Optional parameter specifying metric to be returned for each
ticker. In the event of a single ticker, this is optional and if not specified
all of the available data will be returned. In the event of a list of tickers,