Create InterpolatedNodalCurve with discount factors (no calibration)

I want to create an InterpolatedNodalCurve programmatically. The Curve contains discount factors and doesn’t need to be calibrated. For testing purposes, I did it by importing CSV files, but now I need to do it programmatically.

The final InterpolatedNodalCurve object should look as follows:

InterpolatedNodalCurve {
				metadata = DefaultCurveMetadata {
					curveName = USD - Disc, xValueType = YearFraction, yValueType = DiscountFactor, info = {
						DayCount = Act / 360
					}, parameterMetadata = [LabelDateParameterMetadata {
						date = 2019 - 02 - 20, label = 0 D
					}, LabelDateParameterMetadata {
						date = 2019 - 03 - 20, label = 1 M
					}, ...
				}, xValues = [0.0, 0.07777777777777778, ...], yValues = [0.002571524, 0.001034099, ...], interpolator = Linear, extrapolatorLeft = Flat, extrapolatorRight = Flat

I have tried to look up the code that is used by RatesCurvesCsvLoader, but it seems to use internal methods or properties such as LoadedCurveNode. So I cannot just reuse this code.

For the xValues I only have dates (as in the example with the CSV files), so I need Strata to compute these based on the input dates.

I found an example here:
However, the USD_DSC_NODES in this example are FixedOvernightSwapCurveNode, but I would need a FxSingleCurveNode which does not exist.

Can someone point me to or show me example code where an InterpolatedNodalCurve using discount factors is constructed programmatically?

This is the basic way to create an instance:

CurveMetadata curveMetadata = Curves.discountFactors("USD-DSC", DayCounts.ACT_365F, paramMetadataList);
Curve curve = InterpolatedNodalCurve.builder()

thanks that already helps a lot.

just one more thing: when importing discount factors via CSV files, the xValues do not have to be supplied, because they are implicitly stored in the dates of the curve. I assume that the CSV loader automatically computes the xValues Based on the min and max dates in the CSV files.

One example: I have this line in the curve definition CSV file


the corresponding x value of the created InterpolatedNodalCurve object is 1.0138888888888888. As you see, it’s not exactly 1. It might be expected to be exactly 1, because the time difference between the Valuation Date (2019-02-20) and the other Date (2020-02-20) is exactly one year.

Hence, my question is, how does Strata compute the 1.0138 value? And how can I do it in my code?

Thanks, as always.

Use DayCounts.ACT_365F.yearFraction(startDate, endDate) to calculate the x-value. The difference to 1 might be due to the fact that most 1 year trades have an effective start date 2 days after the trade date, or it might be due to the specific day count that is right in your case. You’ll need someone at your end to validate your numbers and choice of day count, as we can’t really help with that.

thanks. the pointer to the function already helps.
the details, I have to work out on my own :slight_smile: