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
- Concepts: values and functions, the evaluation context, conventions as data, and what is experimental.
- The rates guides: dates and calendars, curves, indexes and fixings, swaps, caps and floors and swaptions.
- Pricing a USD SOFR swap to match the market: the conventions that move a price, set in XML.
- The stateless design: rebuilding, memoizing and pricing scenarios in parallel.
- Coming from QuantLib-Python or QLNet: from QuantLib-Python, from QLNet.
- Beyond C#: the bindings for Python and for C, which any language that calls C can use, and the Excel add-in.