Skip to content

annual_reports

Download and retrieves annual reports for the specified stock tickers.

Analysis

Bases: AnalysisInterface

Class for collecting and processing annual report data.

Source code in src/stocktracer/analysis/annual_reports.py
@beartype
class Analysis(AnalysisInterface):
    """Class for collecting and processing annual report data."""

    under_development = True

    def analyze(self) -> Optional[pd.DataFrame]:
        # By omitting the tags, we'll collect all tags for securities
        sec_filter = Sec.Filter(
            # tags=["EarningsPerShareDiluted"],
            years=1,  # Over the past 1 years
            last_report=self.options.final_report,
            only_annual=True,  # We only want the 10-K
        )

        # Create an SEC Data Source
        table = create_normalized_sec_table(sec_filter, self.options.tickers, False)

        return table.data

    # Reuse documentation from parent
    analyze.__doc__ = AnalysisInterface.analyze.__doc__

create_normalized_sec_table(sec_filter, tickers, normalize=True)

Create a normalized SEC table with all NA values removed.

Parameters:

Name Type Description Default
sec_filter Sec.Filter

filter to use for grabbing results

required
tickers list[str]

tickers to retrieve

required
normalize bool

Remove all columns that contain at least one NA value

True

Returns:

Type Description
Sec.Results.Table

Sec.Results.Table: An SEC table with normalized results

Source code in src/stocktracer/analysis/annual_reports.py
def create_normalized_sec_table(
    sec_filter: Sec.Filter, tickers: list[str], normalize: bool = True
) -> Sec.Results.Table:
    """Create a normalized SEC table with all NA values removed.

    Args:
        sec_filter (Sec.Filter): filter to use for grabbing results
        tickers (list[str]): tickers to retrieve
        normalize (bool): Remove all columns that contain at least one NA value

    Returns:
        Sec.Results.Table: An SEC table with normalized results
    """
    # prep for caching
    tickers.sort()
    results = Sec.filter_data(tickers=tickers, sec_filter=sec_filter)

    table = results.select()
    # If you prefer to see columns that are not universal across all stocks, comment this out
    if normalize:
        table.normalize()
    return table

Last update: July 3, 2023