Table of Contents

Getting started

nanoql is a .NET 10 library. Add its package to a project:

dotnet add package NanoQL

The conventions' XML format and QLNet's additions are in a second package, NanoQL.Extensions (conventions.md); a first price needs only the first.

A first swap

Price a five-year SOFR swap on a flat curve. The evaluation date goes in an EvaluationContext, the curve and the swap are values, and the engine is a static function of them:

var today = new Date(15, Month.October, 2026);
var context = new EvaluationContext { EvaluationDate = today };
var curve = new FlatForward(today, 0.036, new Actual365Fixed());

OvernightIndexedSwap swap = new MakeOIS(new Period(5, TimeUnit.Years), new Sofr(curve))
    .WithFixedRate(0.036)
    .WithNominal(10e6)
    .ToOvernightIndexedSwap(context);

OvernightIndexedSwapResults result = DiscountingSwapEngine.Calculate(swap, context, curve);

The results:

NPV Fair rate
7,041.24 3.6154%

MakeOIS takes QuantLib's defaults for every option it isn't given: here, SOFR's own calendar and day count, annual payments, and two settlement days. DiscountingSwapEngine.Calculate returns a results record, whose NPV, FairRate and each leg's LegNPV and LegBPS are read like any other property. The same inputs give the same results, on any thread.

Next