QuantConnect / QuantConnect/Lean

Fundamentals: AccessionNumber default period is OneMonth, so HasValue is always false (and no 12M slot for 10-K accessions)

Open
#9,777 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
21.7k
Forks
5.3k
Avg merge
2d 22h
Merged PRs (30d)
34

Description

Expected Behavior

EarningReports.AccessionNumber / FinancialStatements.AccessionNumber should report HasValue == true (and Value should resolve without falling back) whenever Morningstar supplies an EDGAR accession number for the filing, the same way the sibling filing-metadata fields FileDate, FormType, PeriodType and PeriodEndingDate do.

Actual Behavior

Both generated AccessionNumber classes use DefaultPeriod => "OneMonth":

  • Common/Data/Fundamental/Generated/EarningReportsAccessionNumber.cs:34
  • Common/Data/Fundamental/Generated/FinancialStatementsAccessionNumber.cs:34

while every other filing-metadata field in the same classes defaults to ThreeMonths (EarningReportsFileDate.cs:34, EarningReportsFormType.cs:34, EarningReportsPeriodType.cs:34, FinancialStatementsFileDate.cs:34, FinancialStatementsPeriodEndingDate.cs:34).

Morningstar never populates the 1M slot of the accession number, so:

  • HasValue (which only checks EarningReports_AccessionNumber_OneMonth, line 69) is false on every row;
  • Value (line 74) misses the default and only returns a result through the MultiPeriodField.Value fallback (first populated period);
  • the ThreeMonths slot carries the accession number on the large majority of rows (and Value does resolve to it through the fallback, so Value and HasValue disagree on every populated row).

A related gap: the two AccessionNumber fields have only 1M/2M/3M/6M/9M periods, while FileDate, FormType, PeriodType and PeriodEndingDate also have a TwelveMonths period, so the accession number of an annual report (10-K) is never exposed even though its file date and period end are.

Measured with History<Fundamental> over 2005-01-01..2024-01-01 in a cloud backtest (LEAN v2.5.0.0.18057):

ticker rows AccessionNumber.HasValue AccessionNumber.Value non-empty AccessionNumber.ThreeMonths non-empty FormType.HasValue
AAPL 4781 0 4781 4781 4781
XOM 4781 0 3690 3690 3690
IBM 4781 0 n/a 4703 4703

Users who guard on has_value (the documented idiom for multi-period fields) conclude the accession number is missing from the dataset.

Potential Solution

The generator that emits Common/Data/Fundamental/Generated/* should pick ThreeMonths as the default period for the two AccessionNumber fields, matching the other filing-metadata fields (or, more generally, derive the default from the periods the data dictionary actually populates). Alternatively HasValue could be defined as HasValues() for fields whose default period is never populated.

Reproduction

class AccessionProbe(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024, 1, 2)
        self.set_end_date(2024, 1, 3)
        self.add_equity("SPY", Resolution.DAILY)

    def on_data(self, data):
        sym = Symbol.create("AAPL", SecurityType.EQUITY, Market.USA)
        rows = list(self.history[Fundamental](sym, datetime(2005, 1, 1), datetime(2024, 1, 1)))
        self.log(f"has_value={sum(r.earning_reports.accession_number.has_value for r in rows)} "
                 f"three_months={sum(bool(r.earning_reports.accession_number.three_months) for r in rows)} rows={len(rows)}")

Output: has_value=0 three_months=4781 rows=4781.

Support reference: Intercom conversation 215475820156709.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Common/Data/Fundamental/Generated/EarningReportsAccessionNumber.cs and FinancialStatementsAccessionNumber.cs, comparing them with the sibling filing-metadata classes named in the issue. Then locate the generator that emits these files and inspect how periods and the default period are selected. Done means populated accession numbers report HasValue consistently, and annual-report accession numbers are exposed through TwelveMonths; verify with the provided History reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.