Skip to content

Commit

Permalink
Make this more robust
Browse files Browse the repository at this point in the history
Because bond type does not return currency. See also alvarobartt/investpy#572
  • Loading branch information
ymyke committed May 23, 2022
1 parent dfb418a commit eb514cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tessa/investing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@

def get_currency_from_dataframe(df: pd.DataFrame) -> str:
"""Get currency from investpy dataframe."""
currencies = list(df["Currency"].unique())
try:
currencies = list(df["Currency"].unique())
except KeyError:
return "UNKNOWN"
if len(currencies) > 1:
raise ValueError(f"Expected only one currency, got {currencies}.")
return currencies[0]
Expand Down

0 comments on commit eb514cf

Please sign in to comment.