OpenBI Docs Buy

Quantitative finance

Valuation and risk with QuantLib: curves and markets as of a date, bonds, swaps, FX forwards, options, swaptions and CDS, portfolios valued row by row, value at risk, credit risk, counterparty exposure and XVA, initial margin, and Monte Carlo simulations.

Quant

public static class Quant

Quantitative finance in a step, with QuantLib 1.43: bonds, curves, options and FX forwards. Dates are dates; rates and volatilities are decimals (0.04 = 4 %).

var p = Quant.Bond(settle, new DateTime(2033, 5, 24), coupon: 0.03, yield: 0.035); // p.Clean, p.Modified, p.DV01 var o = Quant.Option("call", spot: 100, strike: 100, today, expiry, volatility: 0.2, rate: 0.05); 

Properties

static string Version { get; }
The QuantLib the bridge was built with ("1.43").

Methods

static CdsPrice Cds(DateTime asOf, CreditCurve credit, Curve discount, string? tenor = "5Y", DateTime? maturity = null, double coupon = 0.01, double notional = 10000000, string side = "buy", double? recovery = null)
A CDS on a name's default curve: side "buy" (protection) or "sell"; coupon its running spread (0.01: 100 bp); tenor ("5Y": the standard maturity from asOf) or maturity.
static BondPrice Bond(DateTime settle, DateTime maturity, double coupon, double yield, int frequency = 1, string dayCount = "Actual/Actual", double redemption = 100, DateTime? issue = null)
static BondPrice Bond(DateTime settle, DateTime maturity, double coupon, Curve curve, double spread = 0, int frequency = 1, string dayCount = "Actual/Actual", double redemption = 100, DateTime? issue = null)
A fixed-rate bond's price from its yield, compounded at its coupon frequency, per 100 of nominal.
static double BondYield(DateTime settle, DateTime maturity, double coupon, double cleanPrice, int frequency = 1, string dayCount = "Actual/Actual", double redemption = 100, DateTime? issue = null)
The yield of a fixed-rate bond's clean price (compounded at its coupon frequency).
static OptionPrice Option(string type, double spot, double strike, DateTime date, DateTime expiry, double volatility, double rate, double dividend = 0, string style = "european")
An option on a spot price (a stock, an index or a currency) under Black-Scholes-Merton: European (in closed form) or American (on a binomial tree). dividend: the dividend yield, or for a currency the foreign rate.
static double ImpliedVol(string type, double price, double spot, double strike, DateTime date, DateTime expiry, double rate, double dividend = 0)
The volatility a European option's price implies.
static double FxForward(double spot, DateTime date, DateTime maturity, double domesticRate, double foreignRate)
An FX forward from the spot and the two currencies' rates (continuous, Actual/365): spot × e^((domestic − foreign) × t).
static double FxForward(double spot, DateTime maturity, Curve domestic, Curve foreign)
An FX forward from the spot and the two currencies' curves: spot × foreign discount ÷ domestic discount.
static SwaptionPrice Swaption(DateTime asOf, Curve curve, DateTime exercise, DateTime maturity, double fixedRate, double notional = 1000000, bool payer = true, int frequency = 1, double meanReversion = 0.03, double volatility = 0.01)
A European swaption in the Hull-White model fitted to the curve (QuantLib, Jamshidian): the right to enter at exercise a swap to maturity, paying (payer) or receiving the fixed rate, both legs at the frequency, Actual/365.

Curve

public sealed class Curve

A yield curve as of a date, kept as its pillars: dates with their discount factors, interpolated log-linearly in between. QuantLib bootstraps it from a table of instruments, or you give the pillars yourself. Because the pillars are kept, a run kept with the curve gives the same numbers again.

Properties

string Source { get; }
Where it came from: its instruments, in words.
Table Points { get; }
Its pillars: Date, Discount, Zero rate.

Also: string Name { get; }, DateTime AsOf { get; }, IReadOnlyList<DateTime> Dates { get; }, IReadOnlyList<double> Discounts { get; }.

Methods

static Curve Bootstrap(string name, DateTime asOf, Table instruments, string kind = "Kind", string tenor = "Tenor", string rate = "Rate", int settlementDays = 2, string calendar = "TARGET")
Bootstrapped from a table of instruments (an OAX or SQL step's): a row each with its kind ("deposit", "swap" or "zero"), its tenor ("ON", "3M", "10Y") and its rate. Deposits are simple Actual/360, swaps fixed annual 30/360 against 6 months; zero rates (continuous, Actual/365) make the curve by themselves.
static Curve FromPillars(string name, DateTime asOf, IEnumerable<(DateTime Date, double Discount)> pillars, string source = "given as pillars")
A curve given as its pillars: dates and discount factors.
double Discount(DateTime date)
The discount factor at a date.
double Zero(DateTime date)
The zero rate to a date (continuous, Actual/365).
double Forward(DateTime from, DateTime to)
The forward rate between two dates (simple, Actual/360).

Also: string ToString().

Market

public sealed class Market

The market data a run uses, as of a date: curves, quotes and FX rates, frozen with it. A version kept with its market (market.json) is run again on the same numbers.

var market = Market.AsOf(today).Add(Curve.Bootstrap("NOK zero", today, rates)).Fx("EURNOK", 11.62); 

Properties

IReadOnlyCollection<CreditCurve> CreditCurves { get; }
Names' default curves (CreditCurve.Bootstrap), frozen with the market.

Also: DateTime Date { get; }, IReadOnlyCollection<Curve> Curves { get; }, IReadOnlyDictionary<string, double> Quotes { get; }, IReadOnlyDictionary<string, double> FxRates { get; }.

Methods

static Market AsOf(DateTime date)
A market as of a date.
Market Add(CreditCurve credit)
A name's default curve, kept with the market.
CreditCurve Credit(string name)
A name's default curve by its name.
Market Add(Curve curve)
A curve (by its name).
Market Quote(string name, double value, string? source = null)
A named price or rate (a bond's clean price, an index level, a volatility).
Market QuotesFrom(Table rows, string name, string value, string? source = null)
Quotes from a table: a name column and a value column (bond prices from 'Quotes').
Market Fx(string pair, double rate)
An FX rate: units of the second currency for one of the first ("EURNOK" 11.62).
double Fx(string pair)
An FX rate, either way round ("NOKEUR" is 1 / "EURNOK").
JsonObject ToJson()
The market as data (market.json): what a version keeps so that it runs again on the same numbers.
static Market FromJson(JsonObject j)
A market kept as data (a version's market.json).

Also: Curve Curve(string name), double Quote(string name), bool TryQuote(string name, out double value), string ToString().

Valuation

public static class Valuation

Portfolios valued on a market, row by row with QuantLib.

Methods

static double[] Change(Table rows, DateTime settle, JsonObject conventions, double shift)
The bonds held, a row per position with its name, maturity, coupon and nominal, and its quoted clean price where there is one. A bond with a quote is priced from it, the others from the curve; each row gains Market value, Clean price, Dirty price, Accrued, Yield, Mod. duration, DV01 and Priced from.
static IReadOnlyList<string> Explain(Table rows, string bond, double marketValue, double dv01, IReadOnlyDictionary<string, double> measures, IReadOnlyList<double>? change100)
A valuation's risk in words (Valued.Explain), from its rows; change100: each position's change at +100 bp.

Also: static Valued Bonds(Table holdings, Market market, string curve, DateTime? settle = null, string bond = "Bond", string maturity = "Maturity", string coupon = "Coupon", string nominal = "Nominal", string? price = "Price", int frequency = 1, string dayCount = "Actual/Actual").

Valued

public sealed class Valued

A valuation: positions valued as of a date on a market (frozen with it), their totals, the risk measures computed, and what the run had to decide (a bond with no quote priced from the curve). Results.Save keeps it with its market.

Properties

Table Rows { get; }
The positions, valued: a row each.
double DV01 { get; }
What one basis point more on every bond's yield does to the market value (negative): the sum of the positions' modified duration × dirty value × 0.0001.
IReadOnlyDictionary<string, double> Measures { get; }
Risk measures added (WithRisk): "VaR 99 %, 1 day" → 9.8 M.

Also: Market Market { get; }, DateTime Settle { get; }, double MarketValue { get; }, List<string> Notes { get; }.

Methods

IReadOnlyList<string> Explain()
What drives the risk, in words: the DV01 and the positions that make it, a rise of 100 bp (each bond priced again at its yield + 1 %), the largest position, the positions without a quote, the risk measures.
Valued WithRisk(string name, double value)
A risk measure kept with the valuation ("VaR 99 %, 1 day", Risk.ValueAtRisk(pnl, 0.99)).
JsonObject ToDisplay()
What the studio shows: the totals, the measures, the notes, the positions, the market.

Also: string ToString().

BondPrice

public sealed record BondPrice(
    double Clean,
    double Dirty,
    double Accrued,
    double Macaulay,
    double Modified,
    double Convexity,
    double DV01,
    double Yield)

A bond's price and risk, per 100 of nominal.

Properties

double Clean { get; init; }
The clean price (without the interest accrued).
double Dirty { get; init; }
The dirty price (with it): what is paid.
double Accrued { get; init; }
The interest accrued since the last coupon.
double Macaulay { get; init; }
The Macaulay duration, in years.
double Modified { get; init; }
The modified duration: the price's sensitivity to the yield.
double Convexity { get; init; }
The convexity.
double DV01 { get; init; }
What one basis point more of yield (or of the curve) does to the dirty price (negative).
double Yield { get; init; }
The yield, compounded at the coupon frequency.

OptionPrice

public sealed record OptionPrice(
    double Price,
    double Delta,
    double Gamma,
    double Vega,
    double Theta,
    double Rho)

An option's price and greeks: vega and rho per 1 (100 %) of volatility and rate, theta per year.

Properties

Its properties: double Price { get; init; }, double Delta { get; init; }, double Gamma { get; init; }, double Vega { get; init; }, double Theta { get; init; }, double Rho { get; init; }.

SwaptionPrice

public sealed record SwaptionPrice(
    double Value,
    double SwapValue,
    double ParRate)

A European swaption in the Hull-White model (QuantLib, Jamshidian): its value, the swap's value today, its par rate.

Properties

Its properties: double Value { get; init; }, double SwapValue { get; init; }, double ParRate { get; init; }.

FxForward

public sealed record FxForward(
    string Name,
    DateTime Maturity,
    double Notional,
    double Strike,
    bool Buy = true)

An FX forward: buys (or sells) Notional of the foreign currency at Strike (domestic per foreign) on Maturity.

Properties

Its properties: string Name { get; init; }, DateTime Maturity { get; init; }, double Notional { get; init; }, double Strike { get; init; }, bool Buy { get; init; }.

InterestRateSwap

public sealed record InterestRateSwap(
    string Name,
    DateTime Start,
    DateTime Maturity,
    double Notional,
    double FixedRate,
    bool PayFixed = true,
    int Frequency = 1)

An interest rate swap on a single curve, fixed against floating; both legs pay at the given frequency, with Actual/365. PayFixed: you pay the fixed rate (and gain when rates rise).

Properties

Its properties: string Name { get; init; }, DateTime Start { get; init; }, DateTime Maturity { get; init; }, double Notional { get; init; }, double FixedRate { get; init; }, bool PayFixed { get; init; }, int Frequency { get; init; }.

CdsPrice

public sealed record CdsPrice(
    double Npv,
    double FairSpread,
    double FairUpfront,
    double DefaultLeg,
    double CouponLeg,
    double RiskyPV01,
    double Hazard01,
    DateTime Maturity)

A CDS priced on a default curve (per notional, to the side that holds it).

Properties

double Npv { get; init; }
Its value to the side: positive when it is worth having.
double FairSpread { get; init; }
The running spread that makes it worth nothing.
double FairUpfront { get; init; }
The upfront (a fraction of notional) that makes it worth nothing at its coupon.
double DefaultLeg { get; init; }
The protection's value.
double CouponLeg { get; init; }
The coupons' value.
double RiskyPV01 { get; init; }
What one basis point of running spread is worth (the risky annuity × notional × 1 bp).
double Hazard01 { get; init; }
Its value's change for one basis point more hazard rate.
DateTime Maturity { get; init; }
Its maturity (a tenor's standard one: the 20th of March, June, September or December).

CreditCurve

public sealed class CreditCurve

A name's default curve, as of a date: survival probabilities at its pillars, with a flat hazard rate between them (QuantLib's piecewise default curve). Bootstrapped from its CDS par spreads, or from pillars kept with a run.

Properties

double Recovery { get; }
The share of a claim recovered on default (0.4: 40 %).
Table Points { get; }
Its pillars: Date, Survival, Default probability, and the hazard rate since the previous pillar.

Also: string Name { get; }, DateTime AsOf { get; }, string Source { get; }, IReadOnlyList<DateTime> Dates { get; }.

Methods

static CreditCurve Bootstrap(string name, DateTime asOf, Table quotes, Curve discount, double recovery = 0.4, string tenor = "Tenor", string spread = "Spread")
A default curve bootstrapped from CDS par spreads at their tenors (a table of Tenor and Spread: 5Y with 0.012 for 120 bp), a recovery rate and a discount curve, on the standard CDS terms: a payment each quarter on 20 March, 20 June, 20 September and 20 December, Actual/360.
static CreditCurve FromPillars(string name, DateTime asOf, IReadOnlyList<DateTime> dates, IReadOnlyList<double> survival, double recovery = 0.4, string? source = null)
A default curve from its pillars (dates and survival probabilities), as a run kept it.
double Survival(DateTime date)
The probability the name has not defaulted by the date.
double DefaultProbability(DateTime date)
The probability it defaults by the date (1 − survival).
double DefaultProbability(DateTime from, DateTime to)
The probability it defaults between two dates (as seen today: S(from) − S(to)).
double Hazard(DateTime from, DateTime to)
The average hazard rate between two dates (continuous, a year being 365 days).

Also: JsonObject ToJson(), static CreditCurve FromJson(JsonNode j), string ToString().

CreditRisk

public static class CreditRisk

Credit risk of a portfolio over a horizon: expected loss, and the loss distribution when names default together (a one-factor Gaussian copula: Vasicek's model, behind Basel's internal-ratings formula).

Methods

static double ExpectedLoss(Table exposures, string exposure = "Exposure", string pd = "PD", string lgd = "LGD")
Σ exposure × PD × LGD over the rows (exposure at default, probability of default over the horizon, loss given default).
static double VasicekQuantile(double pd, double correlation, double confidence)
The default probability given the economy at its quantile: Φ((Φ⁻¹(PD) + √ρ Φ⁻¹(q)) / √(1 − ρ)). With q = 0.999 it is the conditional PD of Basel's formula.
static double CapitalRequirement(double pd, double lgd, double correlation)
Basel's internal-ratings capital per unit of exposure (without the maturity adjustment): LGD × (the conditional PD at 99.9 % − PD).
static Distribution Losses(Table exposures, double correlation, int paths = 100000, ulong seed = 1, string exposure = "Exposure", string pd = "PD", string lgd = "LGD")
The portfolio's losses over the horizon, by simulation: each path draws the economy (one factor) and each name's own shock; a name defaults when √ρ Z + √(1 − ρ) ε falls below Φ⁻¹(PD), losing exposure × LGD. Percentile(99.9) is the 99.9 % loss; less the mean (the expected loss), the credit VaR.

Risk

public static class Risk

Value at risk and expected shortfall of a profit-and-loss history (losses negative); both as positive losses.

Methods

static double ValueAtRisk(IEnumerable<double> pnl, double confidence = 0.99)
Historical value at risk: the loss not exceeded with the confidence given (0.99: the 1 % worst day's loss).
static double ExpectedShortfall(IEnumerable<double> pnl, double confidence = 0.975)
Historical expected shortfall: the average loss beyond the value at risk at that confidence (0.975 by Basel).
static double ParametricVaR(double standardDeviation, double confidence = 0.99, double mean = 0)
Parametric (normal) value at risk of a P&L's standard deviation.

Xva

public static class Xva

Counterparty exposure and valuation adjustments: a netting set's trades valued along simulated paths (Hull-White one factor fitted to today's curve, simulated exactly with each path's own discounting; FX lognormal, drifting with the path's domestic rates), its expected exposure profiles, and CVA, DVA and FVA from them.

Methods

static ExposureSimulation Simulate(DateTime asOf, Curve discount, int paths = 5000, ulong seed = 1)
A netting set's exposure, simulated over its trades' lives.
static double Cva(ExposureResult exposure, CreditCurve counterparty, double? recovery = null)
CVA: what the counterparty's default is expected to cost, (1 − recovery) × Σ discounted EE × the default probability of each interval (the EE averaged over the interval). Exposure and default are taken as independent.
static double Dva(ExposureResult exposure, CreditCurve own, double? recovery = null)
DVA: the same for one's own default, on the negative exposure (what the counterparty is owed).
static double Fva(ExposureResult exposure, double fundingSpread, double? lendingSpread = null)
FVA: funding the positive exposure at a spread over the discount curve, less what the negative one saves (Σ spread × discounted EE × Δt).

ExposureSimulation

public sealed class ExposureSimulation

A netting set to simulate: the rates model, FX, its trades, the grid; Run gives its exposure.

Methods

ExposureSimulation Rates(double meanReversion, double volatility)
Hull-White's mean reversion and (normal) volatility of the short rate: 0.03 and 0.01 (100 bp a year) by default.
ExposureSimulation Fx(string pair, double spot, double volatility, Curve? foreign = null, double foreignRate = 0)
An exchange rate (domestic per foreign: EURNOK 11.62), its volatility, and the foreign curve (or a flat foreign rate).
ExposureSimulation Grid(int stepsPerYear)
Exposure dates a year (12: monthly); the trades' payment dates are always on the grid.
ExposureResult Run()
Simulates the netting set: its value along each path at each date of the grid.

Also: ExposureSimulation Add(InterestRateSwap swap), ExposureSimulation Add(FxForward forward).

ExposureResult

public sealed class ExposureResult

A netting set's simulated values: at each date, the expected exposure (EE: what the counterparty would owe, on average), the expected negative exposure (ENE: what one would owe it), the potential future exposure (PFE, 97.5 %), and their discounted values (what CVA, DVA and FVA integrate).

Properties

double[] Expected { get; }
EE: E[max(V, 0)] at each date.
double[] Negative { get; }
ENE: E[max(−V, 0)] at each date (a positive number).
double[] Potential { get; }
PFE: the 97.5th percentile of max(V, 0) at each date.
double[] Discounted { get; }
Discounted EE: E[D(0, t) max(V, 0)] (CVA's integrand).
double[] DiscountedError { get; }
The discounted EE's standard error (the simulation's).
double[] DiscountedNegative { get; }
Discounted ENE (DVA's integrand).
double[] Value { get; }
The netting set's value today, as the simulation sees it at each date: E[D(0, t) V(t)] (constant but for the trades paid).
double ExpectedPositiveExposure { get; }
EPE: the EE averaged over the netting set's life.
double EffectiveEpe { get; }
Basel's effective EPE: the EE made non-decreasing, averaged over the first year (or the life when shorter).
Table Profile { get; }
The profile: Date, Years, EE, ENE, PFE 97.5 %, and the discounted EE and ENE.

Also: DateTime AsOf { get; }, DateTime[] Dates { get; }, int Paths { get; }, int Trades { get; }.

Methods

ChartSpec Chart()
The profiles as a chart: EE, PFE and ENE by date.
IReadOnlyList<string> Explain(CreditCurve? counterparty = null, CreditCurve? own = null)
The exposure in words, and with credit curves the adjustments.

Also: string ToString().

Margin

public static class Margin

Initial margin for non-centrally cleared derivatives. Schedule IM is the standardised one of the BCBS-IOSCO framework (d499, Appendix A): a share of each trade's notional by asset class (and, for credit and interest rates, by the years left), netted by the net-to-gross ratio of the replacement costs: net = 0.4 × gross + 0.6 × NGR × gross.

Methods

static double ScheduleRate(string assetClass, double years)
The schedule's rate for an asset class and the years left (credit and interest rates: under 2, 2 to 5, over 5).
static ScheduleMargin Schedule(Table trades, double? netToGross = null, string assetClass = "Asset class", string notional = "Notional", string years = "Years", string? value = "Value")
Schedule IM of a netting set's trades (a row each: asset class, notional, years left, and its value when known). The net-to-gross ratio is the trades' net replacement cost over their gross one (max(Σ V, 0) / Σ max(V, 0)) when their values are given, else netToGross (1: no netting benefit).

ScheduleMargin

public sealed record ScheduleMargin(
    Table Trades,
    double Gross,
    double NetToGross,
    double Net)

A netting set's standardised initial margin (BCBS-IOSCO): each trade's, gross, the net-to-gross ratio, net.

Properties

Its properties: Table Trades { get; init; }, double Gross { get; init; }, double NetToGross { get; init; }, double Net { get; init; }.

MonteCarlo

public static class MonteCarlo

Monte Carlo, written in a step: what moves over time (prices, currencies, rates) and what is simply uncertain (demand, costs, a yield), simulated together many times; any value of them per path (a portfolio, a margin, an option's payoff) becomes a distribution: its mean, percentiles, the chance of a loss or of reaching a target, VaR and expected shortfall. The same seed gives the same numbers on any computer.

var sim = MonteCarlo.Simulate(paths: 10_000, seed: 7) .Asset("Brent", spot: 82, drift: 0.03, volatility: 0.35) .MeanReverting("Salmon", spot: 95, level: 90, speed: 1.5, volatility: 0.3) .Correlate("Brent", "Salmon", 0.3) .Triangular("Demand", 800, 1000, 1300) .Steps(52, years: 1) .Run(); var margin = sim.Value(p => p["Demand"] * (p["Salmon"] - 60)); 

Methods

static Simulation Simulate(int paths = 10000, ulong seed = 1)
A simulation of this many paths, from this seed.

Simulation

public sealed class Simulation

A simulation being written: its factors (what moves, what is uncertain), how they correlate, its time steps.

Methods

Simulation Asset(string name, double spot, double drift, double volatility)

A price that drifts and wanders (geometric Brownian motion): stocks, indices, currencies, commodities.

  • name: What it is ("Brent").
  • spot: Its value now.
  • drift: Its expected growth a year (continuous: 0.05).
  • volatility: Its volatility a year (0.2).
Simulation MeanReverting(string name, double spot, double level, double speed, double volatility)

A price pulled back towards a level (its logarithm mean-reverting): salmon, power, freight.

  • name: What it is ("Salmon").
  • spot: Its value now.
  • level: The level it returns to.
  • speed: How fast it returns (1.5: about half the way in 5½ months).
  • volatility: Its volatility a year (of its logarithm).
Simulation Rate(string name, double start, double level, double speed, double volatility)
A rate that reverts to a level (Vasicek): it may go below zero.
Simulation Normal(string name, double mean, double standardDeviation)
An uncertain number, drawn once per path: normal.
Simulation Lognormal(string name, double mean, double standardDeviation)
An uncertain positive number, drawn once per path: lognormal, of this mean and standard deviation.
Simulation Uniform(string name, double min, double max)
An uncertain number, drawn once per path, as likely anywhere between min and max.
Simulation Triangular(string name, double min, double mode, double max)
An uncertain number, drawn once per path: least, most likely and most (a three-point estimate).
Simulation Correlate(string a, string b, double rho)
How two factors move together (−1 … 1): two prices, or a price and an uncertain number (normal ones).
Simulation Steps(int steps, double years = 1)
The time grid: this many steps over this many years (252 over 1 by default: trading days).
Simulation Antithetic(bool on = true)
Antithetic paths: each path's mirror too (−z for z), for a smaller error with the same work.
Simulation Keep(bool paths = true)
Keep every path's every step (for path-dependent values: averages, maxima); kept by default when they fit.
SimulationResult Run()
Simulates: every factor on every path.

SimulationResult

public sealed class SimulationResult

What a simulation produced: each factor's value at the end of every path (and every step, when kept), and any value of them per path as a distribution.

Properties

Its properties: int Paths { get; }, int Steps { get; }, double Years { get; }, IReadOnlyList<string> Factors { get; }, ulong Seed { get; }.

Methods

double[] Final(string factor)
A factor's values at the end of every path (a one-off number: its draws).
double At(string factor, int path, int step)
A factor's value on a path at a step (0: the start; the factors that move, when paths are kept).
Distribution Value(Func<SimulationResult.PathView, double> value, string name = "Value")
Any value of the factors per path (a portfolio, a margin, a payoff): p["Brent"] is a factor's final value, p.Path("Brent") its whole path, p.Average("Brent") and p.Max("Brent") along it.
Distribution Distribution(string factor)
A factor's final values as a distribution.
Table Percentiles(string factor)
A factor's percentiles over time (5, 25, 50, 75, 95): Step, Time (years), P5 … P95.
ChartSpec Fan(string factor)
A factor's fan: its median and the 5–95 and 25–75 bands over time.

Also: string ToString().

SimulationResult.PathView

public readonly struct PathView

One path, as Value(…) sees it.

Properties

int Index { get; }
The path's number (0 …).

Indexers

double this[string factor] { get; }
A factor's value at the end of the path (a one-off number: its draw).

Methods

double[] Path(string factor)
A factor's whole path, step 0 to the end.
double Average(string factor)
A factor's average along the path (after its start): an Asian option's, a year's average price.

Also: double Max(string factor), double Min(string factor).

Distribution

public sealed class Distribution

The values a simulation gave, one per path: their mean (and its standard error), percentiles, the chance of any condition, value at risk and expected shortfall, and a histogram.

Constructors

Its constructors: Distribution(string name, IEnumerable<double> values).

Properties

double StandardError { get; }
The standard error of the mean (antithetic pairs counted as one draw each).
Table Summary { get; }
A row of its figures: Mean, Std. dev., P5, P50, P95, Min, Max.

Also: string Name { get; }, int Count { get; }, double Mean { get; }, double StandardDeviation { get; }, double Min { get; }, double Max { get; }.

Methods

double Percentile(double percent)
The value below which this percent of the paths fall (5: the 5th percentile).
double Probability(Func<double, bool> condition)
The share of paths where the condition holds.
double ValueAtRisk(double confidence = 0.95, bool fromZero = false)
Value at risk of a profit or a value, measured from its mean (or from zero, for a profit and loss: fromZero): the loss not exceeded with this confidence.
double ExpectedShortfall(double confidence = 0.975, bool fromZero = false)
Expected shortfall: the average loss beyond the value at risk (from the mean, or from zero).
Table Histogram(int bins = 30)
The values in bins: From, To, Paths, Share.
ChartSpec Chart(int bins = 30)
Its histogram as a chart.

Also: string ToString().

Last updated · OpenBI Studio 0.3.78