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 via Euler-Maruyama discretisation. Each path is returned as a RatePath (an AbstractYieldModel) so it plugs directly into present_value, discount, etc.

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 Euler-Maruyama 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 absorption at zero (full truncation scheme) in that case.

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.