示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeterminsiticCurves"/> class with just a discounting curve.
 /// Additional rate forecast curves are added with <see cref="AddRateForecast(IFloatingRateSource)"/>, and
 /// FXC forecast sources are added with <see cref="AddFXForecast(IFXSource)"/>.
 /// </summary>
 /// <param name="discountCurve">The discount curve.</param>
 public DeterminsiticCurves(IDiscountingSource discountCurve)
 {
     numeraireCurrency  = discountCurve.GetCurrency();
     this.discountCurve = discountCurve;
     forecastCurves     = new Dictionary <MarketObservable, IFloatingRateSource>();
     fxCurves           = new Dictionary <MarketObservable, IFXSource>();
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeterministicCurves"/> class with just a discounting curve.
 /// Additional rate forecast curves are added with <see cref="AddRateForecast(IFloatingRateSource)"/>, and
 /// FXC forecast sources are added with <see cref="AddFXForecast(IFXSource)"/>.
 /// </summary>
 /// <param name="discountCurve">The discount curve.</param>
 public DeterministicCurves(IDiscountingSource discountCurve)
 {
     _numeraireCurrency = discountCurve.GetCurrency();
     _discountCurve     = discountCurve;
     _forecastCurves    = new Dictionary <string, IFloatingRateSource>();
     _fxCurves          = new Dictionary <string, IFXSource>();
 }
示例#3
0
        public static HullWhite1F CreateHWModelDemo([ExcelArgument(Description = "The constant rate of mean reversion.")] double meanReversion,
                                                    [ExcelArgument(Description = "The constant short rate volatility.  Note that this is a Gaussian vol and will in general be lower than the vol that would be used in Black.")] double flatVol,
                                                    [ExcelArgument(Description = "The curve to which zero coupon bond prices will be calibrated.")] IDiscountingSource baseCurve,
                                                    [ExcelArgument(Description = "The indices that should be forecast with this same cuve.  No spreads are added.")] FloatingIndex forecastIndices)
        {
            Date        anchorDate    = baseCurve.GetAnchorDate();
            double      flatCurveRate = -Math.Log(baseCurve.GetDF(anchorDate.AddTenor(Tenor.Years(1))));
            HullWhite1F model         = new HullWhite1F(baseCurve.GetCurrency(), meanReversion, flatVol, flatCurveRate, flatCurveRate, anchorDate);

            model.AddForecast(forecastIndices);
            return(model);
        }
示例#4
0
        private Dictionary <int, double[]> simulation; // stores the simulated spot rates at each required date

        /// <summary>
        /// Initializes a new instance of the <see cref="MultiHWAndFXToy"/> class.
        /// </summary>
        /// <param name="anchorDate">The anchor date.</param>
        /// <param name="numeraireCurve">The numeraire curve.</param>
        /// <param name="numeraireHWParams"></param>
        /// <param name="otherCcys">The other currencies that will be simulated.</param>
        /// <param name="otherCcySpots">The exchange rates at the anchor date.  Discounted from the spot values. Quoted in units of the numeraire currency per unit of the foreign currency.</param>
        /// <param name="otherCcyVols"></param>
        /// <param name="otherCcyCurves"></param>
        /// <param name="otherCcyHwParams"></param>
        /// <param name="correlations">The correlation matrix ordered by: numeraireRate, otherCcy1Rate, ..., otherCcyFX1, ...</param>
        /// <exception cref="System.ArgumentException">A rate simulator must be provided for the numeraire currency: " + numeraireCcy.ToString()</exception>
        public MultiHWAndFXToy(Date anchorDate, IDiscountingSource numeraireCurve,
                               List <FloatingIndex> numeraireCcyRequiredIndices, HWParams numeraireHWParams,
                               List <Currency> otherCcys, List <double> otherCcySpots, List <double> otherCcyVols,
                               List <IDiscountingSource> otherCcyCurves, List <List <FloatingIndex> > otherCcyRequiredIndices,
                               List <HWParams> otherCcyHwParams,
                               double[,] correlations)
        {
            this.anchorDate = anchorDate;
            numeraireCcy    = numeraireCurve.GetCurrency();

            List <HullWhite1F> rateSimulatorsList = new List <HullWhite1F>();

            ccySimMap = new Dictionary <Currency, HullWhite1F>();
            double rate = -Math.Log(numeraireCurve.GetDF(anchorDate.AddMonths(12)));

            numeraireSimulator = new HullWhite1F(numeraireCcy, numeraireHWParams.meanReversionSpeed,
                                                 numeraireHWParams.vol, rate, rate, anchorDate);
            foreach (FloatingIndex index in numeraireCcyRequiredIndices)
            {
                numeraireSimulator.AddForecast(index);
            }

            rateSimulatorsList.Add(numeraireSimulator);
            ccySimMap[numeraireCcy] = numeraireSimulator;
            for (int i = 0; i < otherCcys.Count; i++)
            {
                rate = -Math.Log(otherCcyCurves[i].GetDF(anchorDate.AddMonths(12)));
                HullWhite1F thisSim = new HullWhite1F(otherCcys[i], otherCcyHwParams[i].meanReversionSpeed,
                                                      otherCcyHwParams[i].vol, rate, rate, anchorDate);
                foreach (FloatingIndex index in otherCcyRequiredIndices[i])
                {
                    thisSim.AddForecast(index);
                }
                rateSimulatorsList.Add(thisSim);
                ccySimMap[otherCcys[i]] = thisSim;
            }

            currencyPairs     = otherCcys.Select(ccy => new CurrencyPair(ccy, numeraireCcy)).ToArray();
            spots             = otherCcySpots.ToArray();
            vols              = otherCcyVols.ToArray();
            this.correlations = Matrix.Identity(otherCcys.Count);
            normal            = new MultivariateNormalDistribution(Vector.Zeros(currencyPairs.Length), correlations);
            rateSimulators    = rateSimulatorsList.ToArray();
        }
示例#5
0
        /// <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;
        }
 /// <summary>
 /// Construct an FX source where the forwards are obtained from the discount factors on two basis curves.
 /// </summary>
 /// <param name="baseCurrency"></param>
 /// <param name="counterCurrency"></param>
 /// <param name="fxRateAtAnchorDate"></param>
 /// <param name="baseCurrencyFXBasisCurve"></param>
 /// <param name="counterCurrencyFXBasisCurve"></param>
 public FXForecastCurve(Currency baseCurrency, Currency counterCurrency, double fxRateAtAnchorDate, IDiscountingSource baseCurrencyFXBasisCurve,
                        IDiscountingSource counterCurrencyFXBasisCurve)
 {
     if (baseCurrencyFXBasisCurve.GetAnchorDate() != counterCurrencyFXBasisCurve.GetAnchorDate())
     {
         throw new ArgumentException("The two basis curves must have the same anchor dates.");
     }
     if (baseCurrency != baseCurrencyFXBasisCurve.GetCurrency())
     {
         throw new ArgumentException("The currency of the baseCurrencyFXBasisCurve must the base currency.");
     }
     if (counterCurrency != counterCurrencyFXBasisCurve.GetCurrency())
     {
         throw new ArgumentException("The currency of the counterCurrencyFXBasisCurve must the counter currency.");
     }
     this.baseCurrency                = baseCurrency;
     this.counterCurrency             = counterCurrency;
     this.fxRateAtAnchorDate          = fxRateAtAnchorDate;
     this.baseCurrencyFXBasisCurve    = baseCurrencyFXBasisCurve;
     this.counterCurrencyFXBasisCurve = counterCurrencyFXBasisCurve;
     currencyPair = new CurrencyPair(baseCurrency, counterCurrency);
 }
 /// <summary>
 /// Construct an FX source where the forwards are obtained from the discount factors on two basis curves.
 /// </summary>
 /// <param name="currencyPair"></param>
 /// <param name="fxRateAtAnchorDate"></param>
 /// <param name="baseCurrencyFXBasisCurve"></param>
 /// <param name="counterCurrencyFXBasisCurve"></param>
 public FXForecastCurve(CurrencyPair currencyPair, double fxRateAtAnchorDate,
                        IDiscountingSource baseCurrencyFXBasisCurve,
                        IDiscountingSource counterCurrencyFXBasisCurve)
 {
     _currencyPair = currencyPair ?? throw new ArgumentNullException(nameof(currencyPair));
     if (baseCurrencyFXBasisCurve.GetAnchorDate() != counterCurrencyFXBasisCurve.GetAnchorDate())
     {
         throw new ArgumentException("The two basis curves must have the same anchor dates.");
     }
     if (currencyPair.BaseCurrency != baseCurrencyFXBasisCurve.GetCurrency())
     {
         throw new ArgumentException("The currency of the baseCurrencyFXBasisCurve must the base currency.");
     }
     if (currencyPair.CounterCurrency != counterCurrencyFXBasisCurve.GetCurrency())
     {
         throw new ArgumentException(
                   "The currency of the counterCurrencyFXBasisCurve must the counter currency.");
     }
     _fxRateAtAnchorDate          = fxRateAtAnchorDate;
     _baseCurrencyFXBasisCurve    = baseCurrencyFXBasisCurve;
     _counterCurrencyFXBasisCurve = counterCurrencyFXBasisCurve;
 }
 public ZeroRatesCurveForStripping(Date anchorDate, IDiscountingSource underlyingCurve)
 {
     this.anchorDate      = anchorDate;
     this.underlyingCurve = underlyingCurve;
     ccy = underlyingCurve.GetCurrency();
 }
示例#9
0
 public override Currency GetNumeraireCurrency()
 {
     return(discountCurve.GetCurrency());
 }
 public Currency GetCurrency()
 {
     return(underlyingCurve.GetCurrency());
 }
 public override Currency GetNumeraireCurrency()
 {
     return(_valueCurrencyDiscount.GetCurrency());
 }