cashflow method

  1. @override
Future<Cashflow> cashflow(
  1. SecurityIdentifier id, {
  2. String? currency,
  3. Freq mode = Freq.annual,
})
override

The cashflow method is used to get the cashflow statement for a given stock symbol. By default, the cashflow statement is returned in EUR. You can specify a different currency by passing the currency argument.

The mode argument is used to specify the mode of the cashflow statement. The id argument is used to specify the stock id. The currency argument is used to specify the currency.

// Get cashflow statement for Apple in EUR
final client = BavestRestClient(api_key);
final cashflow = client.cashflow(SecurityIdentifier(symbol: "AAPL"), currency: 'EUR', mode: FinancialsMode.annual);

Implementation

@override
Future<Cashflow> cashflow(SecurityIdentifier id,
    {String? currency, Freq mode = Freq.annual}) async {
  const url = '$_baseUrl/stock/financials';
  final freq = mode == Freq.annual ? "annual" : "quarterly";
  final params = {
    "statement": "cf",
    "currency": currency ?? "EUR",
    "freq": freq
  }..addAll(id.toJson());

  var response = await _post(url, params);
  if (_isSuccess(response)) {
    return Cashflow.fromJson(jsonDecode(response!.data));
  }

  throw Exception("could not retrieve cashflow");
}