public static object _CreateModelDeterministicCreditWithFXJump(string objectName, object[,] survivalProbSource, object[,] otherCurrency, object[,] fxSource, object[,] valueCurrencyDiscount, object[,] fxVol, object[,] relJumpSizeInDefault, object[,] expectedRecoveryRate) { try { ISurvivalProbabilitySource _survivalProbSource = XU.GetObject0D <ISurvivalProbabilitySource>(survivalProbSource, "survivalProbSource"); Currency _otherCurrency = XU.GetCurrency0D(otherCurrency, "otherCurrency"); IFXSource _fxSource = XU.GetObject0D <IFXSource>(fxSource, "fxSource"); IDiscountingSource _valueCurrencyDiscount = XU.GetObject0D <IDiscountingSource>(valueCurrencyDiscount, "valueCurrencyDiscount"); Double _fxVol = XU.GetDouble0D(fxVol, "fxVol"); Double _relJumpSizeInDefault = XU.GetDouble0D(relJumpSizeInDefault, "relJumpSizeInDefault"); Double _expectedRecoveryRate = XU.GetDouble0D(expectedRecoveryRate, "expectedRecoveryRate"); DeterministicCreditWithFXJump _result = XLCredit.CreateModelDeterministicCreditWithFXJump(_survivalProbSource, _otherCurrency, _fxSource, _valueCurrencyDiscount, _fxVol, _relJumpSizeInDefault, _expectedRecoveryRate); return(XU.AddObject(objectName, _result)); } catch (Exception e) { return(XU.Error0D(e)); } }
[JsonIgnore] private Dictionary <int, double> _simulation; // stores the simulated share prices at each required date /// <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="ccyPair">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 modeled 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, CurrencyPair ccyPair, IFXSource fxSource, IDiscountingSource valueCurrencyDiscount, double fxVol, double relJumpSizeInDefault, double expectedRecoveryRate) { _survivalProbSource = survivalProbSource; _fxSource = fxSource; _valueCurrencyDiscount = valueCurrencyDiscount; _fxVol = fxVol; _relJumpSizeInDefault = relJumpSizeInDefault; _simRecoveryRate = expectedRecoveryRate; _currencyPair = ccyPair; }
public static DeterministicCreditWithFXJump CreateModelDeterministicCreditWithFXJump( [QuantSAExcelArgument(Description = "A curve that provides survival probabilities. Usually a hazard curve.")] ISurvivalProbabilitySource survivalProbSource, [QuantSAExcelArgument(Description = "The other currency required in the simulation. The valuation currency will be inferred from the valueCurrencyDiscount. This value needs to be explicitly set since fxSource may provide multiple pairs.")] Currency otherCurrency, [QuantSAExcelArgument(Description = "The source FX spot and forwards.")] IFXSource fxSource, [QuantSAExcelArgument(Description = "The value currency discount curve.")] IDiscountingSource valueCurrencyDiscount, [QuantSAExcelArgument(Description = "The fx volatility.")] double fxVol, [QuantSAExcelArgument(Description = "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).")] double relJumpSizeInDefault, [QuantSAExcelArgument(Description = "The constant recovery rate that will be assumed to apply in default.")] double expectedRecoveryRate) { return(new DeterministicCreditWithFXJump(survivalProbSource, otherCurrency, fxSource, valueCurrencyDiscount, fxVol, relJumpSizeInDefault, expectedRecoveryRate)); }
public void AddFXForecast(IFXSource fxForecastCurve) { if (numeraireCurrency.GetHashCode() == Currency.ANY.GetHashCode()) { throw new ArgumentException("If the model provides multiple currencies then the discounting currency cannot be 'ANY'."); } if (!fxCurves.ContainsKey(fxForecastCurve.GetCurrencyPair())) { fxCurves.Add(fxForecastCurve.GetCurrencyPair(), fxForecastCurve); } else { throw new ArgumentException(fxForecastCurve.GetCurrencyPair().ToString() + " has already been added to the model."); } }
public static object _GetFXRate(object[,] fxCurve, object[,] date) { try { IFXSource _fxCurve = XU.GetObject0D <IFXSource>(fxCurve, "fxCurve"); Date _date = XU.GetDate0D(date, "date"); Double _result = XLFX.GetFXRate(_fxCurve, _date); return(XU.ConvertToObjects(_result)); } catch (Exception e) { return(XU.Error0D(e)); } }
public void AddFXForecast(IFXSource fxForecastCurve) { if (fxForecastCurve == null) { return; } if (!fxCurves.ContainsKey(fxForecastCurve.GetCurrencyPair().ToString())) { fxCurves.Add(fxForecastCurve.GetCurrencyPair().ToString(), fxForecastCurve); } else { throw new ArgumentException(fxForecastCurve.GetCurrencyPair() + " has already been added to the 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 DeterministicCreditWithFXJump CreateModelDeterministicCreditWithFXJump( [QuantSAExcelArgument(Description = "A curve that provides survival probabilities. Usually a hazard curve.")] SurvivalProbabilitySource survivalProbSource, [QuantSAExcelArgument(Description = "The currency pair to be simulated. It should have the value currency as its counter currency.")] CurrencyPair currencyPair, [QuantSAExcelArgument(Description = "The source FX spot and forwards.")] IFXSource fxSource, [QuantSAExcelArgument(Description = "The value currency discount curve.")] IDiscountingSource valueCurrencyDiscount, [QuantSAExcelArgument(Description = "The FX volatility.")] double fxVol, [QuantSAExcelArgument(Description = "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).")] double relJumpSizeInDefault, [QuantSAExcelArgument(Description = "The constant recovery rate that will be assumed to apply in default.")] double expectedRecoveryRate) { return(new DeterministicCreditWithFXJump(survivalProbSource, currencyPair, fxSource, valueCurrencyDiscount, fxVol, relJumpSizeInDefault, 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)); }