Chartsv26.10.18
Kits

Swaps kit

The accrual schedule of both legs, forward rates from a discount curve, present value, the par swap rate and the painters of the ladder, the net flows and the cumulative PV curve.

@unifin/chart-kit-swaps values a plain vanilla swap and paints the position: the accrual schedule of both legs, the forward rates the curve implies, the present value of each leg and the par rate.

import { flatCurve, netFlows, parSwapRate, swapNpvFromCurve, swapScheduleOf } from '@unifin/chart-kit-swaps';

const terms = {
  notional: 100_000_000,
  fixedRate: 0.05,
  startIso: '2026-10-06',
  tenorMonths: 60,
  stepMonths: 6,
  direction: 'pay-fixed' as const,
};

const curve = flatCurve(0.05);
const schedule = swapScheduleOf(terms, curve, '2026-10-06');   // both legs, projected from the curve
const npv = swapNpvFromCurve(terms, curve, '2026-10-06');      // fixed, floating and the net
const par = parSwapRate(terms, curve, '2026-10-06');           // the fixed rate that prices it at par
const flows = netFlows(schedule);                              // what is paid or received on each date

What the kit renders

FigureFunctionReads
Leg ladderlegPoints + paintSwapLadderone bar per payment, drawn from the zero line: a negative bar is a payment
Net flowsnetPoints + paintNetArrowsthe net of both legs per payment date, marked on the palette of the chart
Cumulative PVcumulativePvPoints + paintCumulativePvthe running present value of the net flows - the curve that shows when the position has paid for itself
ScheduleswapSchedule, swapPeriods, flowsTotalaccrual boundaries, the periods of both legs and the totals per leg

The kit signs every amount the same way (positive received, negative paid) and takes its day count conventions from the core, so a swap and a bond quote the same dates to the same accrual. Both ACT/365 and 30/360 are supported.

Live ladder, net flows and cumulative PV

Swaps kit - live panel
Theme
Swaps - legs, net flows and the cumulative present value
100M notional, 5y pay-fixed, semiannual - fixed leg -21.9M, floating leg 22.1M, net 0.3M, par rate 5.06% - 10 payment dates - zoom x1.00

Leg ladder, net flows and the cumulative PV curve

The S105 wave adds the gradient fills and the smooth dynamics: the ladder bars ramp from the tip to the zero line, the cumulative PV curve carries a ribbon down to the plot floor with a bright edge, and the busiest payment date of the net view is emphasised. The two rate sliders set the target while the figure follows a 200 ms ramp - data-swap-phase marks the running frames, ?frozen=1 pins a deterministic capture, reduced motion lands at once, and the zoom indicator keeps the wheel and drag readouts honest (data-swap-scale).

The swaps panel with the gradient fills

Where it appears

The swap view of the Yields workspace draws these painters: the leg ladder of the schedule, the net arrows of the payment dates and the cumulative PV curve next to the curve builders of the same kit.

See also

On this page