diff --git a/README.md b/README.md index 985180e..9dd99aa 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ and load them, and extend their functionality. Finally, tessa makes sure to be nice to the sites being accessed and tries to **prevent users from being blocked by 429 rate limiting errors** by 1) caching results upon retrieval and 2) keeping track of request timestamps and waiting appropriate amounts of -time if necessary. +time if necessary. tessa also automatically waits and retries requests that fail with a +5xx error. [→ Check out the full documentation. 📖](https://ymyke.github.io/tessa/tessa.html) @@ -51,14 +52,14 @@ s3 = Symbol("bitcoin", source="coingecko") s3.price_graph() # show price graph ``` -- Search for a more crypto ticker on coingecko: +- Search for a crypto ticker on coingecko: ```python -res = search("GAME") # search and print search result summary +res = search("name") # search and print search result summary filtered = res.filter(source="coingecko") # filter results filtered.p() # print summary of filtered results -filtered.buckets[0].symbols # review the best bucket in the filtered results -s4 = filtered.buckets[0].symbols[2] # our symbol is the 3rd in that list +filtered.buckets[1].symbols # review the 2nd bucket in the filtered results +s4 = filtered.buckets[1].symbols[2] # our symbol is the 3rd in that list s4.price_history() # get entire history ``` @@ -81,9 +82,9 @@ sc_new.load_yaml("my_symbols.yaml") - Use a different currency preference: ```python -sc.find_one("game").price_latest() # will return price in USD +sc.find_one("ens").price_latest() # will return price in USD Symbol.currency_preference = "CHF" -sc.find_one("game").price_latest() # will return price in CHF +sc.find_one("ens").price_latest() # will return price in CHF ``` Note that `currency_preference` will only have an effect with sources that support it. diff --git a/pyproject.toml b/pyproject.toml index 06520e2..9a53c3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tessa" -version = "0.8.0" +version = "0.8.1" description = "Find financial assets and get their price history without worrying about different APIs or rate limiting." authors = ["ymyke"] license = "MIT" diff --git a/tessa/price/yahoo.py b/tessa/price/yahoo.py index 8707c7e..f4f9353 100644 --- a/tessa/price/yahoo.py +++ b/tessa/price/yahoo.py @@ -2,7 +2,7 @@ import pandas as pd import yfinance as yf -from .types import PriceHistory, SymbolNotFoundError +from .types import PriceHistory START_FROM = "2000-01-01" """Adjust this date if you need to get historical data further in the past. Note that @@ -18,11 +18,7 @@ def get_price_history( that ticker. """ ticker = yf.Ticker(query) - try: - df = ticker.history(start=START_FROM, raise_errors=True) - except Exception as exc: # pylint: disable=broad-except - if "No timezone found" in str(exc): - raise SymbolNotFoundError(source="yahoo", query=query) from exc + df = ticker.history(start=START_FROM, raise_errors=True) # Simplify dataframe: df = df.copy() diff --git a/tests/price/test_price_points.py b/tests/price/test_price_points.py index 73a2455..6ae1c06 100644 --- a/tests/price/test_price_points.py +++ b/tests/price/test_price_points.py @@ -62,7 +62,7 @@ def test_concrete_yahoo_price_point(): res = price_point("AAPL", "2018-01-11", "yahoo") assert isinstance(res, PricePoint) assert res.when == pd.Timestamp("2018-01-11 05:00:00+0000", tz="UTC") - assert round(res.price) == 42 + assert round(res.price) == 41 assert res.currency == "USD" diff --git a/tests/price/test_yahoo_api.py b/tests/price/test_yahoo_api.py index 5c58106..0ea7f94 100644 --- a/tests/price/test_yahoo_api.py +++ b/tests/price/test_yahoo_api.py @@ -4,7 +4,6 @@ import pytest from tessa.price import yahoo -from tessa.price.types import SymbolNotFoundError @pytest.mark.parametrize( @@ -28,6 +27,5 @@ def test_api_returns_reasonable_data(query: str, expected_currency: str): @pytest.mark.net def test_non_existing_query_raises(): - with pytest.raises(SymbolNotFoundError) as excinfo: + with pytest.raises(Exception): yahoo.get_price_history("thisshouldntexistreally") - assert "No symbol found" in str(excinfo.value)