mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-17 20:04:19 +01:00
Rewrite tickers function to use most current ticket data from tiingo website
This commit is contained in:
@@ -69,12 +69,15 @@ Now you can use ``TiingoClient`` to make your API calls. (Other parameters are a
|
||||
.. code-block:: python
|
||||
|
||||
# Get Ticker
|
||||
# See official docs for list of all supported tickers + date ranges
|
||||
ticker_metadata = client.get_ticker_metadata("GOOGL")
|
||||
|
||||
# Get latest prices, based on 3+ sources, as CSV or JSON, sampled weekly
|
||||
ticker_price = client.get_ticker_price("GOOGL", frequency="weekly")
|
||||
|
||||
# Check what tickers are available, as well as metadata about each ticker
|
||||
# including supported currency, exchange, and available start/end dates.
|
||||
tickers = client.get_stock_tickers()
|
||||
|
||||
# Get news articles about given tickers or search terms from given domains
|
||||
articles = client.get_news(tickers=['GOOGL', 'APPL'],
|
||||
tags=['Laptops'],
|
||||
@@ -82,6 +85,8 @@ Now you can use ``TiingoClient`` to make your API calls. (Other parameters are a
|
||||
startDate='2017-01-01',
|
||||
endDate='2017-08-31')
|
||||
|
||||
# Get ai
|
||||
|
||||
|
||||
Further Docs
|
||||
--------
|
||||
|
||||
@@ -43,6 +43,10 @@ Now you can use ``TiingoClient`` to make your API calls. (Other parameters are a
|
||||
# Get latest prices, based on 3+ sources, as CSV or JSON, sampled weekly
|
||||
ticker_price = client.get_ticker_price("GOOGL", frequency="weekly")
|
||||
|
||||
# Check what tickers are available, as well as metadata about each ticker
|
||||
# including supported currency, exchange, and available start/end dates.
|
||||
tickers = client.get_stock_tickers()
|
||||
|
||||
# Get news articles about given tickers. Requires Pro account.
|
||||
articles = client.get_news(tickers=['GOOGL', 'APPL'],
|
||||
tags=['Bitcoin'],
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import io
|
||||
import os
|
||||
import csv
|
||||
import pkg_resources
|
||||
import csv
|
||||
from StringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
from tiingo.restclient import RestClient
|
||||
import requests
|
||||
|
||||
VERSION = pkg_resources.get_distribution("tiingo").version
|
||||
|
||||
@@ -39,22 +43,20 @@ class TiingoClient(RestClient):
|
||||
# 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.
|
||||
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
|
||||
"""
|
||||
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']
|
||||
listing_file_url = "https://apimedia.tiingo.com/docs/tiingo/daily/supported_tickers.zip"
|
||||
response = requests.get(listing_file_url)
|
||||
zipdata = ZipFile(StringIO(response.content))
|
||||
raw_csv = StringIO(zipdata.read('supported_tickers.csv'))
|
||||
reader = csv.DictReader(raw_csv)
|
||||
|
||||
return [ticker for
|
||||
ticker in tickers if ticker.get('assetType') == 'Stock']
|
||||
return [row for row in reader
|
||||
if row.get('assetType') == 'Stock']
|
||||
|
||||
def get_ticker_metadata(self, ticker):
|
||||
"""Return metadata for 1 ticker
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user