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

Pulling 10-K filings from XBRL for multiple years not just one year #100

Closed
david08-08 opened this issue Sep 2, 2024 · 6 comments
Closed
Labels
question Further information is requested

Comments

@david08-08
Copy link

I am trying to pull 10-K for multiple years but I keep getting an error in the output. Can someone please give me some guidance on how to put the code together for this task. Below is what I put together but I keep getting an error. Thank you.

if name == 'main':
output_path = Path('/Users/name/Documents/Apple_Financials_2013_2023.xlsx')

with output_path.open('wb') as f:
    with ExcelWriter(f, engine='xlsxwriter') as writer:
        for year in range(2013, 2023 + 1):
            try:
                # Retrieve the 10-K filing for the given year
                filings = Company("AAPL").get_filings(form="10-K")
                filing_for_year = next(filing for filing in filings if filing.filing_date.year == year)

                # Process the XBRL data for the filing
                xbrl = filing_for_year.xbrl()

                # Write the statements to the Excel workbook
                write_statements(xbrl, writer, year)

            except StopIteration:
                print(f"No 10-K filing found for year {year}")
            except Exception as e:
                print(f"Error processing year {year} for AAPL: {str(e)}")
@dgunning
Copy link
Owner

dgunning commented Sep 5, 2024

Can you post the error here? Thanks

@david08-08
Copy link
Author

david08-08 commented Sep 6, 2024 via email

@david08-08
Copy link
Author

Example usage:

if name == 'main':
output_path = Path('/Users/name/Documents/Apple_Financials_2013_2023.xlsx')

with output_path.open('wb') as f:
    with ExcelWriter(f, engine='xlsxwriter') as writer:
        for year in range(2013, 2023 + 1):
            try:
                # Retrieve the 10-K filing for the given year
                filings = Company("AAPL").get_filings(form="10-K")
                filing_for_year = next(filing for filing in filings if filing.filing_date.year == year)

                # Process the XBRL data for the filing
                xbrl = filing_for_year.xbrl()

                # Write the statements to the Excel workbook
                write_statements(xbrl, writer, year)

            except StopIteration:
                print(f"No 10-K filing found for year {year}")
            except Exception as e:
                print(f"Error processing year {year} for AAPL: {str(e)}")

@dgunning dgunning added the question Further information is requested label Sep 7, 2024
@dgunning
Copy link
Owner

This is implemented in the latest version

from edgar import *

company = Company("MSFT")
filings = company.get_filings(form="10-K").latest(9)

financials = MultiFinancials(filings)
financials.get_balance_sheet()
financials.get_cash_flow_statement()
financials.get_income_statement()

@dgunning
Copy link
Owner

dgunning commented Oct 6, 2024 via email

@unparadise
Copy link

Dgunning, thank you for your reply. I was able to figure out the problem myself. I opened another issue regarding some data missing from the return of the XBRL get_statement function.

@dgunning dgunning closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants