FinanceModels.ShortRate API Reference

Exported API

Simulation and Monte Carlo

FinanceModels.simulateFunction
simulate(model::AbstractStochasticModel;
         n_scenarios=1000, timestep=1/12, horizon=30.0,
         rng=Random.default_rng())

Generate n_scenarios interest-rate paths. Each path is returned as a RatePath (an AbstractYieldModel) so it plugs directly into present_value, discount, etc.

Discretisation schemes:

  • Vasicek / Hull-White: the exact Gaussian transition density, so the simulated short rate has no discretisation bias at any timestep.
  • Cox-Ingersoll-Ross: full truncation (Lord, Koekkoek & Van Dijk, 2010) — an auxiliary process may go negative while the observed rate is max(x, 0). Weak bias vanishes as timestep → 0, but is material for coarse steps when the Feller condition is strongly violated.

In all cases the cumulative discount integral $∫₀ᵗ r(s)\,ds$ is accumulated with the trapezoidal rule between grid points, so pathwise discount factors (and hence pv_mc) retain an integration error that grows with timestep even when the short-rate transition itself is exact.

source
FinanceModels.pv_mcFunction
pv_mc(model, contract;
      n_scenarios=1000, timestep=1/12, horizon=nothing,
      rng=Random.default_rng())

Estimate the expected present value of contract under the stochastic model by averaging present_value across simulated scenarios.

Note

pv_mc is designed for fixed-cashflow instruments where each RatePath scenario provides the discount factors. For floating-rate instruments whose cashflows depend on the rate path, project cashflows per scenario using Projection instead.

The horizon should cover the contract's maturity. The default (maturity + 1) ensures this.

source
FinanceModels.short_rateFunction
short_rate(path::RatePath, t)

The instantaneous short rate r(t) for a simulated scenario.

RatePath stores the cumulative integral ∫₀ᵗ r(s) ds as a LinearInterpolation. The short rate is the derivative of this cumulative integral.

Because the cumulative integral is built from trapezoidal steps, the returned rate is piecewise-constant within each timestep — an approximation to the continuous short-rate process, not the exact value.

source

Unexported API

FinanceModels.ShortRate.CoxIngersollRossType
CoxIngersollRoss(a, b, σ, initial)

Cox-Ingersoll-Ross (1985) mean-reverting short-rate model:

dr = a(b - r) dt + σ √r dW

Arguments

  • a: speed of mean reversion
  • b: long-term mean rate (continuous compounding). Can be passed as a Real or Continuous(b).
  • σ: volatility
  • initial: initial short rate r₀ (a Rate object or Real)
Feller condition

The condition 2ab > σ² is required for the variance process to stay strictly positive. When violated, the short rate can reach zero; simulation uses the full truncation scheme (Lord, Koekkoek & Van Dijk, 2010), which lets an auxiliary process go negative while the observed rate is floored at zero. Discretisation bias grows with σ²/(2ab) — use a finer timestep when the Feller condition is strongly violated.

source
FinanceModels.ShortRate.HullWhiteType
HullWhite(a, σ, curve)

Hull-White (1990) one-factor model:

dr = (θ(t) - a r) dt + σ dW

where θ(t) is calibrated to fit the initial term structure curve.

Arguments

  • a: speed of mean reversion
  • σ: volatility
  • curve: an existing yield model providing the initial term structure
source
FinanceModels.ShortRate.VasicekType
Vasicek(a, b, σ, initial)

Vasicek (1977) mean-reverting short-rate model:

dr = a(b - r) dt + σ dW

Arguments

  • a: speed of mean reversion
  • b: long-term mean rate (continuous compounding). Can be passed as a Real or Continuous(b).
  • σ: volatility
  • initial: initial short rate r₀ (a Rate object or Real)
Note

The Vasicek model allows negative rates. For very negative rates or long horizons, discount factors may exceed 1.

source

Please open an issue if you encounter any issues or confusion with the package.