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

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