Welcome to Tiingo Python’s documentation!

https://img.shields.io/pypi/v/tiingo.svg?maxAge=600 Documentation Status Updates Coverage Launch Binder

Contents:

Tiingo Python

https://img.shields.io/pypi/v/tiingo.svg?maxAge=600 Coverage Documentation Status Updates Launch Binder

Tiingo is a financial data platform that makes high quality financial tools available to all. Tiingo has a REST and Real-Time Data API, which this library helps you to access. Presently, the API includes support for the following endpoints:

  • Stock Market Ticker Closing Prices + Metadata. Data includes full distribution details and is validated using a proprietary EOD Price Engine.
  • Curated news from top financial news sources + blogs. Stories are tagged with topic tags and relevant stock tickers by Tiingo’s algorithms.

Usage

If you’d like to try this library before installing, click below to open a folder of online runnable examples.

Launch Binder

First, install the library from PyPi:

pip install tiingo

If you prefer to receive your results in pandas DataFrame or Series format, and you do not already have pandas installed, install it as an optional dependency:

pip install tiingo[pandas]

Next, initialize your client. It is recommended to use an environment variable to initialize your client for convenience.

from tiingo import TiingoClient
# Set TIINGO_API_KEY in your environment variables in your .bash_profile, OR
# pass a dictionary with 'api_key' as a key into the TiingoClient.

client = TiingoClient()

Alternately, you may use a dictionary to customize/authorize your client.

config = {}

# To reuse the same HTTP Session across API calls (and have better performance), include a session key.
config['session'] = True

# If you don't have your API key as an environment variable,
# pass it in via a configuration dictionary.
config['api_key'] = "MY_SECRET_API_KEY"

# Initialize
client = TiingoClient(config)

Now you can use TiingoClient to make your API calls. (Other parameters are available for each endpoint beyond what is used in the below examples, inspect the docstring for each function for details.).

# Get Ticker
ticker_metadata = client.get_ticker_metadata("GOOGL")

# Get latest prices, based on 3+ sources as JSON, sampled weekly
ticker_price = client.get_ticker_price("GOOGL", frequency="weekly")

# Get historical GOOGL prices from August 2017 as JSON, sampled daily
historical_prices = client.get_ticker_price("GOOGL",
                                            fmt='json',
                                            startDate='2017-08-01',
                                            endDate='2017-08-31',
                                            frequency='daily')

# Check what tickers are available, as well as metadata about each ticker
# including supported currency, exchange, and available start/end dates.
tickers = client.list_stock_tickers()

# Get news articles about given tickers or search terms from given domains
articles = client.get_news(tickers=['GOOGL', 'AAPL'],
                            tags=['Laptops'],
                            sources=['washingtonpost.com'],
                            startDate='2017-01-01',
                            endDate='2017-08-31')

# Get definitions for fields available in the fundamentals-api, ticker is
# optional
definitions = get_fundamentals_definitions('GOOGL')

# Get fundamentals which require daily-updated (like marketCap). A start-
# and end-date can be passed. If omited, will get all available data.
fundamentals_daily = CLIENT.get_fundamentals_daily('GOOGL',
                                        startDate='2020-01-01',
                                        endDate='2020-12-31')

# Get fundamentals based on quarterly statements. Accepts time-range like
# daily-fundamentals. asReported can be set to get the data exactly like
# it was reported to SEC. Set to False if you want to get data containing
# corrections
fundamentals_stmnts = CLIENT.get_fundamentals_statements('GOOGL',
                                                         startDate='2020-01-01',
                                                         endDate='2020-12-31',
                                                         asReported=True)

To receive results in pandas format, use the get_dataframe() method:

#Get a pd.DataFrame of the price history of a single symbol (default is daily):
ticker_history = client.get_dataframe("GOOGL")

#The method returns all of the available information on a symbol, such as open, high, low, close,
#adjusted close, etc.  This page in the tiingo api documentation lists the available information on each
#symbol: https://api.tiingo.com/docs/tiingo/daily#priceData.

#Frequencies and start and end dates can be specified similarly to the json method above.

#Get a pd.Series of only one column of the available response data by specifying one of the valid the
#'metric_name' parameters:
ticker_history = client.get_dataframe("GOOGL", metric_name='adjClose')

#Get a pd.DataFrame for a list of symbols for a specified metric_name (default is adjClose if no
#metric_name is specified):
ticker_history = client.get_dataframe(['GOOGL', 'AAPL'],
                                      frequency='weekly',
                                      metric_name='volume',
                                      startDate='2017-01-01',
                                      endDate='2018-05-31')

You can specify any of the end of day frequencies (daily, weekly, monthly, and annually) or any intraday frequency for both the get_ticker_price and get_dataframe methods. Weekly frequencies resample to the end of day on Friday, monthly frequencies resample to the last day of the month, and annually frequencies resample to the end of day on 12-31 of each year. The intraday frequencies are specified using an integer followed by “Min” or “Hour”, for example “30Min” or “1Hour”.

Further Docs

Features

  • Easy programmatic access to Tiingo API
  • Reuse requests session across API calls for better performance
  • On most methods, pass in fmt=”object” as a keyword to have your responses come back as NamedTuples, which should have a lower memory impact than regular Python dictionaries.

Roadmap:

  • Client-side validation of tickers
  • Data validation of returned responses
  • Case insensitivity for ticker names
  • More documentation / code examples

Feel free to file a PR that implements any of the above items.

Credits

  • Many thanks to Rishi Singh for creating Tiingo.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Installation

Stable release

To install Tiingo Python, run this command in your terminal:

$ pip install tiingo

This is the preferred method to install Tiingo Python, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for Tiingo Python can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/hydrosquall/tiingo-python

Or download the tarball:

$ curl  -OL https://github.com/hydrosquall-python/tiingo/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage

To use Tiingo Python in a project:

import tiingo

Next, initialize your client object. It is recommended to use an environment variable to initialize your client object for convenience.

from tiingo import TiingoClient
# Set TIINGO_API_KEY in your environment variables in your .bash_profile, OR
# pass a dictionary with 'api_key' as a key into the TiingoClient.

client = TiingoClient()

Alternately, you may use a dictionary to customize/authorize your client.

Now you can use TiingoClient to make your API calls. (Other parameters are available for each endpoint beyond what has been written below, see the Tiingo website for full details).

Further Docs

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/hydrosquall/tiingo-python/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

Tiingo Python could always use more documentation, whether as part of the official Tiingo Python docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/hydrosquall/tiingo-python/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up tiingo for local development.

  1. Fork the tiingo repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/tiingo-python.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv tiingo-python
    $ cd tiingo-python/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 tiingo tests
    $ python setup.py test or py.test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.7, 3.6, and 3.7. These will be checked for you when you open your PR via Github Action checks.

Release Procedure

See RELEASE.rst .

Tips

To run a subset of tests:

$ py.test tests.test_tiingo

To regenerate fixture remove it from tests/fixtures and run tests again:

$ rm tests/fixtures/NAME.yaml
$ py.test

In order for py.test to run, you will have had to create an environment variable containing a valid tiingo API key so that the test runner can make a valid api call. One way to do that is to:

$ export TIINGO_API_KEY='...insert api key here...'

However, now this api key will become embedded in the test fixture file that is created per the prior procedure. In order to remove this api key from the new test fixtures, run the following from the top level directory:

$ ./tools/api_key_tool.py

Credits

Development Lead

Contributors

History

0.15.0 (2021-XX - Unreleased)

0.14.0 (2021-03-06 - Unreleased)

  • Feature: Added 3 new methods for fundamentals-endpoint: definitions, daily and statements
  • [/news] Fix bug in get_news() when sources list is empty (#566)
  • Development: Run tests in Github Actions instead of Travis.org
  • Development: This is the last version of tiingo that will support Python 3.5 and below. (#601)

0.13.0 (2020-12-12)

  • Minor: Address Pandas Future Warning for sorting in pd.concat (#392)
  • Feature: Add option to request data in csv format in get_dataframe method potentially boosting speed up to 4-5x. (#523)
  • Minor: bumped library dependencies, in particular cryptography
  • Development: Dropped official support for Python 3.5, replaced with 3.7
  • Development: Publish library with Github Actions instead of Travis (#546)

0.12.0 (2019-10-20)

  • Feature: Added 3 new methods for crypo endpoints: top of book prices, historical, and metadata endpoints (@n1rna #340)
  • Feature: Permit list_tickers to support multiple asset types at once (@n1rna #346)

0.11.0 (2019-09-01)

  • [/news] Internally rename sources parameter to “source”, ensure lists are passed as comma separated values #325. Non-breaking external change.
  • [/news] Add new URL parameter for “onlyWithTickers” #327

0.10.x (2019-05-11)

  • Documentation: Added a “Peer Comparison Analysis” Jupyter Notebook under “/examples” (@i3creations #197)
  • Minor: Update error message to clarify multiple tickers only work with single metrics
  • Updated development dependencies

0.9.x (2019-01-30)

  • Documentation: Added runnable jupyter notebook sample under “/examples”
  • Minor: bumped various library dependencies

0.8.0 (2018-07-06)

  • Major: Add IEX Endpoint to retrieve data with intraday frequencies (@dcwtx #125)
  • Minor: update documentation for contributing/releasing new versions
  • Speed up Travis build process with pip cache

0.7.0 (2018-06-14)

  • Major: Provide functions for returning data as pandas Dataframes or Series (@dcwtx #112)
  • Minor documentation edits

0.6.0 (2018-04-30)

  • Fix bug in resample argument name (@dcwtx #82)
  • Add tool for removing API Keys from test fixtures (@dcwtx #107)
  • Remove official support for Python 3.3

0.5.0 (2018-03-11)

  • Updated examples in docs for getting historical prices
  • Add interfaces to obtain mutual fund and ETF tickers (@savagesmc #62)
  • Raise explicit error when API key is missing (#44)
  • Update development dependencies

0.4.0 (2017-10-22)

  • Make tests run in 1/10th the time with vcr.py (@condemil #32)
  • Add support for returning python objects instead of dictionaries (@BharatKalluri #33)

0.3.0 (2017-09-17)

  • Add support for listing all tickers + date ranges
  • Add support for interacting with the /news API
  • Improve logging of REST client errors

0.2.0 (2017-09-01)

  • Improve test coverage of tickers endpoint
  • Deprecate the Mutual Funds endpoint

0.1.0 (2017-08-24)

  • First release on PyPI.

Tiingo is a financial data platform that makes high quality financial tools available to all. They have a RESTful and Real-Time Data API. Presently, the API includes support for the following endpoints:

  • Stock Market Ticker Closing Prices + Metadata. Data includes full distribution details and is validated using a proprietary EOD Price Engine.
  • Curated news from top financial news sources + curated blogs. Stories are tagged by Tiingo’s algorithms.

If you’d like to try this library without installing anything, click the button below. Otherwise, continue reading.

Launch Binder

Indices and tables