Manual 09 Positions, market data sets, copulas
Portfolios and multivariate
Positions: algebra of contracts
Contracts on the same underlying form a vector space over the real numbers. Adding, subtracting or scaling payoffs returns a FinancialMonteCarlo.Position: the payoffs with their weights, in the order they were added.
straddle = EuropeanOption(T, K) + EuropeanOption(T, K, false)
spread = EuropeanOption(T, 95.0) - EuropeanOption(T, 105.0)
position = 2.0 * straddle - spread / 2
pricer(model, underlying, rfCurve, mcConfig, position)- The same contract appears once and its weights add up. Two payoffs are the same contract when they have the same type and equal parameters, whatever their number types:
EuropeanOption(T, 100) + EuropeanOption(T, 100.0)is one leg of weight 2. - A leg whose weight is exactly zero is removed:
c - cis the empty position, and a netted leg no longer sets how far the paths are simulated. A weight that is a dual number with value zero is kept, since it can carry a derivative. - The weights are promoted to one type, so a position of payoffs of one type (spreads, butterflies, strips) is concretely typed and its price is inferred.
position[payoff]is the weight ofpayoff(zero if absent), and a position iterates aspayoff => weightpairs.FinancialMonteCarlo.Position(payoff => weight, ...)builds one directly, andsum(positions)adds several.
A position is priced on a single simulation, up to the largest maturity of its legs, path by path: its discounted payoff along each path is the weighted sum of those of its legs. So variance and confinter of a position are those of the position as a whole, with the correlation between its legs, and delta and rho bump and reprice it like a single payoff.
Market data sets and portfolios
To price contracts on several underlyings, give each underlying a name and link it with → (typed \to<TAB>):
- a
MarketDataSetmaps names to underlyings and to models:"ENI" → Underlying(S0, d)and"ENI" → model, or both at once,"ENI" → (model, Underlying(S0, d)); - a
FinancialMonteCarlo.Portfoliomaps names to positions:"ENI" → payoffor"ENI" → position.
Both can be combined with +; adding portfolios adds the positions on the same name.
market = ("ENI" → (model_eni, und_eni)) + ("AAPL" → (model_aapl, und_aapl))
portfolio = ("ENI" → straddle) + ("AAPL" → 3.0 * AsianFixedStrikeOption(T, K))
pricer(market, rfCurve, mcConfig, portfolio)
delta(market, rfCurve, mcConfig, portfolio, "ENI")Each underlying is simulated once. The models are simulated one after the other, in the order of the market data set, from one stream of random numbers seeded once, so the underlyings are independent (with SobolMC, which would give every model the same points, a portfolio on several models is an error). Names in the market data set that have no position are not simulated.
Positions on names that are missing from the market data set are not priced, i.e. they contribute zero to the price.
Multivariate models
A multivariate model is linked to the tuple of the names of its components, whose underlyings it simulates:
ρ = [1.0 0.3; 0.3 1.0]
market = ("ENI", "AAPL") → (GaussianCopulaNVariateProcess(ρ, model_eni, model_aapl), (und_eni, und_aapl))delta of a name bumps its underlying, so every model that uses it, alone or in a copula, moves.
A portfolio on such a market can contain
- basket payoffs (e.g.
EuropeanOptionND) on the whole basket:("ENI", "AAPL") → EuropeanOptionND(T, K); - single name payoffs on one of the components:
"ENI" → EuropeanOption(T, K), priced on the marginal of the joint simulation.
Names joined by _ ("ENI_AAPL") still work, with a deprecation warning, and become the tuple of the names.
See Portfolios in the API reference.