solveRate method

Future<double> solveRate({
  1. required Convention dayCount,
})

Solves for an unknown interest rate, returning the result expressed as a decimal.

An UnsolvableException is thrown when the unknown cannot be determined.

dayCount convention for determining time intervals between cash flows

Implementation

Future<double> solveRate({
  required Convention dayCount,
}) async {
  if (_profile == null && !_isBespokeProfile) {
    _buildProfile();
  }
  _profile = _profile!.copyWith(dayCount: dayCount);
  _profile = assignFactors(_profile!);

  final interest = SolveRoot.solve(
    callback: SolveNfv(profile: _profile!),
  );

  _profile = _profile!.copyWith(
    cashFlows: amortiseInterest(
      _profile!.cashFlows,
      interest,
      _precision,
    ),
  );

  return interest;
}