Skip to content

FittedBondCurve: unrecognized method gives "Boost assertion failed: px != 0" instead of an informative error #201

Description

@m-muecke

FittedBondCurve() doesn't currently validate curveparams$method. Any value other than the three exact strings "ExponentialSplinesFitting", "SimplePolynomialFitting", or "NelsonSiegelFitting" gives an unrelated error message. Having something like: Unknown fitting method 'NelsonSiegel ... would be great, similar to the existing throw std::range_error("Unknown method in AffineSwaption") in src/affine.cpp.

library(RQuantLib)

lengths <- c(2, 4, 6, 8, 10)
coupons <- c(0.02, 0.025, 0.03, 0.035, 0.04)
market_quotes <- rep(100, length(lengths))
date_params <- list(
  settlementDays = 0,
  period = "Annual",
  dayCounter = "ActualActual",
  businessDayConvention = "Unadjusted"
)

curve_params <- list(method = "NelsonSiegel", origDate = Sys.Date())
FittedBondCurve(curve_params, lengths, coupons, market_quotes, date_params)
#> Error in `fittedBondCurveEngine()`:
#> ! Boost assertion failed: px != 0

Created on 2026-07-23 with reprex v2.1.1

Activity

  1. eddelbuettel commented on Jul 23, 2026

    @eddelbuettel
    Owner

    Good idea, especially as dates are already checked. At a minimum we could rely on match.arg and just enumerate the options in the signature.

  2. eddelbuettel commented on Jul 26, 2026

    @eddelbuettel
    Owner

    Fixed in #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions