Skip to content

Commit c2e5f4f

Browse files
authored
Merge branch 'main' into fix-float-precision
2 parents 542b86f + 4cca791 commit c2e5f4f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

financetoolkit/portfolio/portfolio_controller.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,19 @@ def collect_historical_data(
830830
self._currency_column # type: ignore
831831
].items():
832832
data_currency = self._historical_statistics.loc["Currency", ticker]
833-
if self._historical_statistics.loc["Currency", ticker] != currency:
833+
834+
# Skip when either currency code is missing or NaN,
835+
# otherwise a bogus symbol like "NAN=X" gets sent to
836+
# Yahoo Finance and triggers a 404.
837+
if (
838+
not currency
839+
or not data_currency
840+
or pd.isna(currency)
841+
or pd.isna(data_currency)
842+
):
843+
continue
844+
845+
if data_currency != currency:
834846
currency_conversions[ticker] = (
835847
f"{currency}{data_currency}=X".upper()
836848
)

0 commit comments

Comments
 (0)