v1.0.0 · Fixed Income · Stable

Quantitative finance library built for Java.

Quant4J is a Java library for quantitative finance — covering fixed income, derivatives, options, futures, swaps, credit, and risk analytics. The v1.0.0 release establishes the fixed income foundation: bond pricing, duration, yield inversion, and curve construction. Each subsequent release extends the library with new instrument types, all sharing the same consistent, interface-driven API.

BondPricing.java
// 6% bond, semi-annual coupons, 5-year maturity
Bond bond = new Bond(1000.0, 0.06, 5.0, Frequency.SEMI_ANNUALLY);

// Price at 7% YTM, discrete semi-annual compounding
CompoundingStrategy compounding = new DiscreteCompoundingStrategy(2);
BondPricer pricer = new YieldBondPricer(0.07, compounding);
double price = pricer.price(bond); // → 958.42

// Duration & DV01
BondDurationCalculator calc = new YieldBondDurationCalculator(0.07, compounding);
double dv01 = calc.dv01(bond, price); // → 0.4053
v1.0.0 — Fixed Income Core

A solid foundation for fixed income analytics.

Every operation is backed by a named interface. Swap any implementation without touching the rest of your code.

💵

Bond Pricing

Price bonds by discounting cash flows at a single YTM, or tenor-by-tenor from a full zero rate curve with linear interpolation.

BondPricer
🎯

Yield to Maturity

Invert the pricing formula numerically. Plug in Bisection, Newton-Raphson, or Secant — the solver is a strategy you supply.

BondYieldCalculator
📉

Duration & Risk

Macaulay duration, modified duration, and DV01 in one call. The Macaulay-to-modified conversion is delegated to the compounding strategy.

BondDurationCalculator
🧱

Curve Bootstrapping

Build a spot rate curve from par bonds or observed market prices. Bonds are processed in ascending maturity order; intermediate cash flows are discounted from the curve built so far.

BootstrappingStrategy

Compounding Conventions

Discrete (any frequency) and continuous compounding, each exposing discount factor, accumulation factor, present value, future value, and forward rate.

CompoundingStrategy

Rate Conversion

Convert between any discrete frequency and continuous compounding, or between two discrete frequencies, using the standard equated-accumulation-factor formula.

RateConverter
Code examples

Usage examples.

The following examples cover the main entry points of the library. Inline comments show the actual computed output.

Yield to Maturity inversion RootFindingBondYieldCalculator
// 6% bond, semi-annual coupons, 5-year maturity
Bond bond = new Bond(1000.0, 0.06, 5.0, Frequency.SEMI_ANNUALLY);

BondYieldCalculator ytm = new RootFindingBondYieldCalculator(
    new DiscreteCompoundingStrategy(2),
    new NewtonRaphsonSolver());

double yield = ytm.yieldToMaturity(bond, 958.42);
// → 0.0700 (7.00%)

// Any RootSolver works — Bisection and Secant are also available
BondYieldCalculator ytm2 = new RootFindingBondYieldCalculator(
    new DiscreteCompoundingStrategy(2),
    new BisectionSolver());
Zero curve pricing ZeroCouponBondRateBondPricer
// 6% bond, semi-annual coupons, 5-year maturity
Bond bond = new Bond(1000.0, 0.06, 5.0, Frequency.SEMI_ANNUALLY);

Map<Double, Double> curve = Map.of(
    0.5, 0.050,  1.0, 0.055,
    2.0, 0.060,  5.0, 0.065);

BondPricer pricer = new ZeroCouponBondRateBondPricer(
    curve,
    new LinearInterpolationStrategy(),
    new ContinuousCompoundingStrategy());

double price = pricer.price(bond);
// → 976.55 (each cash flow at its own interpolated spot rate)
Spot curve bootstrapping SpotRateCurveBootstrappingStrategy
BootstrappingStrategy boot = new SpotRateCurveBootstrappingStrategy(
    Map.of(0.5, 0.04),              // seed: 6-month spot rate
    new ContinuousCompoundingStrategy());

List<Bond> benchmarks = List.of(
    new Bond(1000, 0.04, 1.0, Frequency.SEMI_ANNUALLY),
    new Bond(1000, 0.05, 2.0, Frequency.SEMI_ANNUALLY),
    new Bond(1000, 0.055, 3.0, Frequency.SEMI_ANNUALLY));

NavigableMap<Double, Double> spotCurve =
    boot.bootstrapFromParBonds(benchmarks, new LinearInterpolationStrategy());
// → {0.5=0.04, 1.0=0.0396, 2.0=0.0497, 3.0=0.0548}
Rate conversion RateConverter
// Semi-annual 5% → continuous equivalent
double rc = RateConverter.discreteToContinuous(
    0.05, Frequency.SEMI_ANNUALLY);
// → 0.04938 (4.938%)

// Continuous → quarterly discrete
double rq = RateConverter.continuousToDiscrete(
    rc, Frequency.QUARTERLY);
// → 0.04969 (4.969%)

// Direct discrete-to-discrete (equated accumulation factors)
double rm = RateConverter.convertDiscreteRates(
    0.05, Frequency.SEMI_ANNUALLY, Frequency.MONTHLY);
// → 0.04949 (4.949%)
Design

Built for production codebases.

Three principles that apply to every module, present and future.

1

Interface First

Every operation is expressed as an interface. Swap any implementation — pricer, solver, compounding convention — without touching the rest of your code.

BondPricer BondYieldCalculator BondDurationCalculator CompoundingStrategy RootSolver InterpolationStrategy BootstrappingStrategy
2

Explicit Conventions

Compounding convention, coupon frequency, and interpolation method are always supplied by the caller. The library never infers them. What you pass is what you get.

DiscreteCompoundingStrategy(m) ContinuousCompoundingStrategy Frequency.SEMI_ANNUALLY LinearInterpolationStrategy
3

Immutable by Design

Bond is a Java record. All calculators hold only final fields. Every instance is safe for concurrent use with no synchronisation.

record Bond(...) final fields thread-safe
Zero dependencies

Pure Java. No third-party runtime dependencies.

Keep quantitative finance logic portable, auditable, and simple to embed. Quant4J integrates cleanly into services, batch jobs, trading tools, and risk applications without pulling a dependency graph behind it.

Roadmap

From fixed income to a full quant stack.

v1.0.0 ships the fixed income foundation. Every subsequent release adds a new instrument class, all sharing the same consistent interface-driven API.

Version Module Key additions Status
v1.0.0 Fixed Income Core Bond pricing, YTM, duration, DV01, curve bootstrapping, compounding, rate conversion, solvers ✓ Stable
v1.1.0 Market Conventions Day-count conventions (Act/Act, 30/360), business calendars, dirty/clean price, accrued interest, settlement lag Planned
v1.2.0 Money Market T-bills, certificates of deposit, commercial paper, repo, FRAs, OIS rates Planned
v2.0.0 Interest Rate Swaps IRS, OIS, basis swaps, multi-curve framework (OIS discounting + SOFR/LIBOR projection), swap curve bootstrapping Planned
v2.1.0 Interest Rate Options Caps, floors, swaptions — Black & Bachelier models, volatility surfaces, Greeks Planned
v3.0.0 Credit CDS pricing (ISDA model), credit curve bootstrapping, hazard rates, Z-spread, asset swap spread Planned
v3.1.0 Equity Derivatives European & American options, Black-Scholes-Merton, binomial tree, Monte Carlo, full Greeks, implied volatility Planned
v5.0.0 Risk Engine VaR (historical, parametric, Monte Carlo), CVaR, Greeks aggregation, scenario analysis, XVA Planned
Quick install

Add Quant4J to your project.

Java 21+. No runtime dependencies.

Maven

<dependency>
  <groupId>io.quant4j</groupId>
  <artifactId>quant4j</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

dependencies {
  implementation("io.quant4j:quant4j:1.0.0")
}