Skip to content

Portfolio currency conversion can construct NAN=X and break recordings #197

@jcoffi

Description

@jcoffi

Summary
Currency conversion within portfolio collection/performance attempts to fetch NAN=X on Yahoo, leading to 404s and blank Current Value/Return/Alpha fields in recorded CSVs.

Steps to reproduce

  1. Run: pytest -q tests/portfolio/test_portfolio_controller.py::test_collect_historical_data
  2. Run: pytest -q tests/portfolio/test_portfolio_controller.py::test_get_transactions_performance

Observed behavior

  • yfinance logs: HTTP Error 404: Quote not found for symbol: NAN=X
  • Resulting CSVs have blank Current Value/Return/Alpha where recordings expect values.

Expected behavior

  • Currency conversion is skipped or guarded when the portfolio has no explicit currency column, and no NAN=X symbol is constructed.

Context

  • The tests set portfolio._currency_column = None to avoid currency conversion.
  • Currency conversion logic constructs pairs from historical statistics currency vs transaction currency; when a currency is missing/NaN this results in NAN=X and a 404.

Environment

  • Branch: main (upstream)
  • Tests use recorded datasets in tests/datasets without external credentials

Potential approaches (for maintainers’ consideration)

  • Add guards to skip conversion when currency codes are missing/NaN or when _currency_column is falsy
  • Validate derived currency pair strings before requesting market data

Additional information

  • This was encountered while running the full suite; unrelated to feature work. Reporting for visibility and guidance on intended behavior when currency codes are absent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions