solveValue method

Future<double> solveValue({
  1. required Convention dayCount,
  2. required double interestRate,
})

Solves for an unknown value or values.

An UnsolvableException is thrown when the unknown cannot be determined.

dayCount convention for determining time intervals between cash flows

interestRate the annual effective interest rate expressed as a decimal e.g. 5.25% is 0.0525 as a decimal

Implementation

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

  var value = SolveRoot.solve(
    callback: SolveCashFlow(
      profile: _profile!,
      effectiveRate: interestRate,
    ),
  );
  value = gaussRound(value, _precision);

  _profile = _profile!.copyWith(
    cashFlows: updateUnknowns(
      cashFlows: _profile!.cashFlows,
      value: value,
      precision: _precision,
    ),
  );

  _profile = _profile!.copyWith(
    cashFlows: amortiseInterest(
      _profile!.cashFlows,
      interestRate,
      _precision,
    ),
  );
  return value;
}