/// <summary> /// Gets the indices. /// </summary> /// <param name="index">The index.</param> /// <param name="requiredTimes">The required times.</param> /// <returns></returns> /// <exception cref="System.ArgumentException"> /// defaultTime must only be queried with a single date. /// or /// defaultRecovery must only be queried with a single date. /// or /// </exception> public override double[] GetIndices(MarketObservable index, List <Date> requiredTimes) { if (index == currencyPair) { var result = new double[requiredTimes.Count]; for (var i = 0; i < requiredTimes.Count; i++) { if (requiredTimes[i] <= anchorDate) { result[i] = fxSource.GetRate(requiredTimes[i]); } else { result[i] = simulation[requiredTimes[i]]; } } return(result); } if (index == defaultTime) { if (requiredTimes.Count > 1) { throw new ArgumentException("defaultTime must only be queried with a single date."); } return(new[] { simDefaultTime }); } if (index == defaultRecovery) { if (requiredTimes.Count > 1) { throw new ArgumentException("defaultRecovery must only be queried with a single date."); } return(new[] { simRecoveryRate }); } throw new ArgumentException(index + " is not simulated by this model."); }
/// <summary> /// Initializes a new instance of the <see cref="DeterministicCreditWithFXJump"/> class. /// </summary> /// <param name="survivalProbSource">A curve that provides survival probabilities. Usually a hazard curve.</param> /// <param name="otherCurrency">The other currency required in the simulation. The valuation currency will /// be inferred from the <paramref name="valueCurrencyDiscount"/>. This value needs to be explicitly set /// since <paramref name="fxSource"/> may provide multiple pairs.</param> /// <param name="fxSource">The source FX spot and forwards.</param> /// <param name="valueCurrencyDiscount">The value currency discount curve.</param> /// <param name="fxVol">The fx volatility.</param> /// <param name="relJumpSizeInDefault">The relative jump size in default. For example if the value currency is ZAR and the /// other currency is USD then the fx is modelled as ZAR per USD and in default the fx rate will change to: /// rate before default * (1 + relJumpSizeInDefault).</param> /// <param name="expectedRecoveryRate">The constant recovery rate that will be assumed to apply in default.</param> public DeterministicCreditWithFXJump(ISurvivalProbabilitySource survivalProbSource, Currency otherCurrency, IFXSource fxSource, IDiscountingSource valueCurrencyDiscount, double fxVol, double relJumpSizeInDefault, double expectedRecoveryRate) { this.survivalProbSource = survivalProbSource; valueCurrency = valueCurrencyDiscount.GetCurrency(); this.fxSource = fxSource; this.valueCurrencyDiscount = valueCurrencyDiscount; this.fxVol = fxVol; this.relJumpSizeInDefault = relJumpSizeInDefault; ReferenceEntity refEntity = survivalProbSource.GetReferenceEntity(); defaultTime = new DefaultTime(refEntity); defaultRecovery = new DefaultRecovery(refEntity); currencyPair = new CurrencyPair(otherCurrency, valueCurrency); anchorDate = valueCurrencyDiscount.GetAnchorDate(); spot = fxSource.GetRate(anchorDate); simRecoveryRate = expectedRecoveryRate; }
public static double GetFXRate([ExcelArgument(Description = "Name of FX curve")] IFXSource fxCurve, [ExcelArgument(Description = "Date on which FX rate is required.")] Date date) { return(fxCurve.GetRate(date)); }