mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-17 11:54:19 +01:00
Update Tests and Documentation
This commit is contained in:
@@ -74,6 +74,7 @@ Features
|
|||||||
|
|
||||||
* Easy programmatic access to Tiingo API
|
* Easy programmatic access to Tiingo API
|
||||||
* Coming soon: client-side validation of tickers, to save your API calls!
|
* Coming soon: client-side validation of tickers, to save your API calls!
|
||||||
|
* Data validation of returned responses / case insensitivity
|
||||||
* Free software: MIT license
|
* Free software: MIT license
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""Tests for `tiingo` package."""
|
"""Tests for `tiingo` package."""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tiingo import TiingoClient
|
from tiingo import TiingoClient
|
||||||
|
|
||||||
|
|
||||||
@@ -22,13 +20,44 @@ def ticker_metadata_response():
|
|||||||
return t.get_ticker_metadata("GOOGL")
|
return t.get_ticker_metadata("GOOGL")
|
||||||
|
|
||||||
|
|
||||||
def test_ticker_price(ticker_price_response):
|
@pytest.fixture
|
||||||
"""Sample pytest test function with the pytest fixture as an argument."""
|
def fund_metadata_response():
|
||||||
assert len(ticker_price_response) == 1
|
"""Test /tiingo/<ticker> endpoint"""
|
||||||
assert ticker_price_response.get('adjClose')
|
t = TiingoClient()
|
||||||
|
return t.get_fund_metadata("vfinx")
|
||||||
|
|
||||||
|
|
||||||
def test_ticker_metadata(ticker_metadata_response):
|
@pytest.fixture
|
||||||
"""Refactor this with python data schemavalidation"""
|
def fund_metrics_response():
|
||||||
assert ticker_metadata_response.get('ticker') == "GOOGL"
|
"""Test /tiingo/<ticker> endpoint"""
|
||||||
assert ticker_metadata_response.get("name")
|
t = TiingoClient()
|
||||||
|
return t.get_fund_metrics("VFINX")
|
||||||
|
|
||||||
|
|
||||||
|
# PRICES ENDPOINTS
|
||||||
|
class TestTickerPrices(object):
|
||||||
|
def test_ticker_price(self, ticker_price_response):
|
||||||
|
"""Test the EOD Prices Endpoint"""
|
||||||
|
assert len(ticker_price_response) == 1
|
||||||
|
assert ticker_price_response[0].get('adjClose')
|
||||||
|
|
||||||
|
def test_ticker_metadata(self, ticker_metadata_response):
|
||||||
|
"""Refactor this with python data schemavalidation"""
|
||||||
|
assert ticker_metadata_response.get('ticker') == "GOOGL"
|
||||||
|
assert ticker_metadata_response.get("name")
|
||||||
|
|
||||||
|
|
||||||
|
# FUND ENDPOINTS
|
||||||
|
@pytest.mark.skip(reason="My API key doesn't have access to mutual funds API")
|
||||||
|
class TestMutualFunds(object):
|
||||||
|
|
||||||
|
def test_fund_metadata(self, fund_metadata_response):
|
||||||
|
"""Refactor this with python data schemavalidation"""
|
||||||
|
assert fund_metadata_response.get('ticker') == "vfinx"
|
||||||
|
assert fund_metadata_response.get("shareClass", startDate="2012-1-1",
|
||||||
|
endDate="2016-1-1")
|
||||||
|
|
||||||
|
def test_fund_metrics(self, fund_metrics_response):
|
||||||
|
"""Test Fund Level Metrics"""
|
||||||
|
assert len(fund_metrics_response) > 0
|
||||||
|
assert fund_metrics_response[0].get('managementFee')
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class TiingoClient(RestClient):
|
|||||||
api_key = self._config['api_key']
|
api_key = self._config['api_key']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
api_key = os.environ.get('TIINGO_API_KEY')
|
api_key = os.environ.get('TIINGO_API_KEY')
|
||||||
|
|
||||||
assert(api_key)
|
assert(api_key)
|
||||||
|
|
||||||
self._headers = {
|
self._headers = {
|
||||||
@@ -33,7 +32,7 @@ class TiingoClient(RestClient):
|
|||||||
|
|
||||||
# TICKER PRICE ENDPOINTS
|
# TICKER PRICE ENDPOINTS
|
||||||
# https://api.tiingo.com/docs/tiingo/daily
|
# https://api.tiingo.com/docs/tiingo/daily
|
||||||
def get_price_metadata(self, ticker):
|
def get_ticker_metadata(self, ticker):
|
||||||
"""Return metadata for 1 ticker.
|
"""Return metadata for 1 ticker.
|
||||||
"""
|
"""
|
||||||
url = "tiingo/daily/{}".format(ticker)
|
url = "tiingo/daily/{}".format(ticker)
|
||||||
@@ -56,7 +55,6 @@ class TiingoClient(RestClient):
|
|||||||
fmt (string): 'csv' or 'json'
|
fmt (string): 'csv' or 'json'
|
||||||
frequency (string): Resample frequency
|
frequency (string): Resample frequency
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = "tiingo/daily/{}/prices".format(ticker)
|
url = "tiingo/daily/{}/prices".format(ticker)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
Reference in New Issue
Block a user