Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct TTM Financial Data Retrieval Feature #2321

Merged
merged 1 commit into from
Mar 2, 2025
Merged

Conversation

JanMkl
Copy link

@JanMkl JanMkl commented Feb 23, 2025

This PR completes the earlier #1643 and moves the PR in to the dev branch.

  • Fetches the TTM values for cash flow and income statement from Yahoo.
  • Added tests test_ttm_income_statement and test_ttm_cash_flow.
  • Transferring commit to dev branch

This feature was also requested in #2287

Obsoletes PR #2320

@ValueRaider
Copy link
Collaborator

ValueRaider commented Feb 23, 2025

Discard the mostly-nan columns, more that one column doesn't make sense with TTM.

Then open question about the user interface. Separate function like you've done? New argument on existing fetchers, prepending TTM to table? @victoryg739 @amigobrewbrew

@JanMkl
Copy link
Author

JanMkl commented Feb 23, 2025

Just double checking what you mean by discarding NaN. The ttm_cash_flow returns only the TTM column as Yahoo only returns one column. You would like to see same for the ttm_income_stmt where yahoo currently returns the TTM with all the values and then preceding 4 quarters with only some values and mostly NaN?

Meaning that we should implement a special if block in the get_financials_time_series to check if it was called with trailing timescale then it should return only one column and skip the rest (different behaviour than yearly and quarterly time scales)?

@JanMkl
Copy link
Author

JanMkl commented Feb 24, 2025

@ValueRaider Added now in get_financials_time_series that it drops the NaN columns and only returns exactly one column. Is this what you meant by removing the most-nan columns?

@amigobrewbrew
Copy link

amigobrewbrew commented Feb 24, 2025

@JanMkl @ValueRaider I would do separate functions like in PR: ttm_cashflow and ttm_income_stmt with single column. I did a quick test seems to be good like this!

@ValueRaider
Copy link
Collaborator

Perfect. Finally can you git squash? #1084

@JanMkl
Copy link
Author

JanMkl commented Feb 26, 2025

@ValueRaider squashed into single commit.

@ValueRaider
Copy link
Collaborator

I almost forgot, can you update the web docs: https://github.com/ranaroussi/yfinance/blob/main/doc/source/reference/yfinance.financials.rst

Instructions in guide

- Fetches the TTM values for cash flow and income statement from Yahoo.
- Added tests test_ttm_income_statement and test_ttm_cash_flow.
- When trailing 12 months income statement is fetched Yahoo returns
  income statement for last 5 quarters out of which only the latest is
  fully populated. Rest have NaN values and can be ignored.
- get_financials_time_series when called with timescale trailing removes
  from data frame the extra columns.
- Added quarterly_income_stmt to financials documentation
- Added ttm_income_stmt to financials documentation
- Added quarterly_cashflow to financials documentation
- Added ttm_cashflow to financials documentation
@JanMkl
Copy link
Author

JanMkl commented Feb 27, 2025

@ValueRaider Added quarterly_income_stmt, ttm_income_stmt, quaterly_cashflow, ttm_cashflow to the docs. I added also the quarterly ones as those seemed to be missing from the docs although implemented.

Let me know if you still see need for further modifications.

@ValueRaider ValueRaider merged commit f28284a into ranaroussi:dev Mar 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants