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

[Bug] example notebook "financialStatements" broken (API call changed?) #6627

Closed
norandom opened this issue Aug 18, 2024 · 2 comments · Fixed by #6639
Closed

[Bug] example notebook "financialStatements" broken (API call changed?) #6627

norandom opened this issue Aug 18, 2024 · 2 comments · Fixed by #6639

Comments

@norandom
Copy link

Describe the bug

Creating a dict of tickers and company names fails due to a (deprecated?) API call:

Copy-pasta from cell from repo:

# List of other retail chains
tickers = ["COST", "BJ", "DLTR", "DG", "WMT", "BIG", "M", "KSS", "TJX"]

# Create a dictionary of tickers and company names.
names = {
    ticker: obb.equity.fundamental.overview(ticker, provider="fmp").results[0].name
    for ticker in tickers
}
# Create a column for each.
fcf_yield = pd.DataFrame()
for ticker in tickers:
    fcf_yield[names[ticker]] = (
        obb.equity.fundamental.metrics(ticker, provider="fmp", period="annual", limit=10)
        .to_df()
        .reset_index()
        .set_index("calendar_year")
        .sort_index(ascending=False)
        ["free_cash_flow_yield"]
    )
fcf_yield.transpose()

Source:
https://github.com/OpenBB-finance/OpenBB/blob/develop/examples/financialStatements.ipynb

Error trace:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[17], line 5
      2 tickers = ["COST", "BJ", "DLTR", "DG", "WMT", "BIG", "M", "KSS", "TJX"]
      4 # Create a dictionary of tickers and company names.
----> 5 names = {
      6     ticker: obb.equity.fundamental.overview(ticker, provider="fmp").results[0].name
      7     for ticker in tickers
      8 }
      9 # Create a column for each.
     10 fcf_yield = pd.DataFrame()

Cell In[17], line 6, in <dictcomp>(.0)
      2 tickers = ["COST", "BJ", "DLTR", "DG", "WMT", "BIG", "M", "KSS", "TJX"]
      4 # Create a dictionary of tickers and company names.
      5 names = {
----> 6     ticker: obb.equity.fundamental.overview(ticker, provider="fmp").results[0].name
      7     for ticker in tickers
      8 }
      9 # Create a column for each.
     10 fcf_yield = pd.DataFrame()

AttributeError: 'ROUTER_equity_fundamental' object has no attribute 'overview'

To Reproduce

Run all cells from the example notebook. At 1.2.2. Free Cash Flow Yield code steps out.

Screenshots

Screenshot 2024-08-18 at 13 04 39

Desktop (please complete the following information):

  • OS: Linux Debian Bookworm
  • Python version [e.g. 3.11, Anaconda]

Additional context

obb.equity.fundamental.overview was probably renamed, but I cannot find out to what since I just started running the samples and creating the API keys. Fascinating project. Want to learn more.

@norandom
Copy link
Author

Possible fix:

import pandas as pd

tickers = ["COST", "BJ", "DLTR", "DG", "WMT", "BIG", "M", "KSS", "TJX"]

# Initialize the DataFrame for FCF yield
fcf_yield = pd.DataFrame()

for ticker in tickers:
    try:
        metrics_df = obb.equity.fundamental.metrics(ticker, provider="fmp", period="annual", limit=10).to_df()
        fcf_yield[ticker] = (
            metrics_df
            .reset_index()
            .set_index("calendar_year")
            .sort_index(ascending=False)
            ["free_cash_flow_yield"]
        )
    except Exception as e:
        print(f"Error retrieving FCF yield for {ticker}: {str(e)}")

fcf_yield = fcf_yield.transpose()

# Display the results
print(fcf_yield)
Screenshot 2024-08-18 at 13 34 18

@deeleeramone
Copy link
Contributor

Thanks for the note, I'll review other examples as well to check for similar occurrences.

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 a pull request may close this issue.

2 participants