getHistoricalFinancials method

  1. @override
Future<CompanyFinancials> getHistoricalFinancials(
  1. String ticker, {
  2. int years = 10,
  3. bool includeQuarterly = true,
  4. Set<FinancialMetric>? metrics,
})
override

Fetch historical financial data for a company.

Returns structured CompanyFinancials with up to years years of data. Set includeQuarterly to true to include Q1-Q4 data.

Implementation

@override
Future<CompanyFinancials> getHistoricalFinancials(
  String ticker, {
  int years = 10,
  bool includeQuarterly = true,
  Set<FinancialMetric>? metrics,
}) async {
  final cik = await getCik(ticker);
  if (cik == null) {
    throw Exception('Ticker $ticker not found.');
  }

  final facts = await getCompanyFacts(ticker);

  return _parser.parseCompanyFacts(
    ticker: ticker,
    cik: cik,
    facts: facts,
    options: FetchOptions(
      years: years,
      includeQuarterly: includeQuarterly,
      metricsToFetch: metrics,
    ),
  );
}