Example #1
0
        public string[] GetKeyTenors()
        {
            return(MarketInstruments != null
                                ? MarketInstruments.Select(x => x.Instrument.Tenor).Select(x => x.ToString()).ToArray()
                                : KeyTenors);

            //KeyPoints.Select(x => new Term(x.Item1 - ReferenceDate, Period.Day)).Select(x => x.ToString()).ToArray();
        }
Example #2
0
        public IYieldCurve BumpKeyRate(int index, double resetRate)
        {
            if (index < 0 || index > KeyPoints.Count() - 1)
            {
                throw new IndexOutOfRangeException("YieldCurve");
            }


            if (MarketInstruments == null)
            {
                //var offset = MarketInstruments == null ? 0 : KeyPoints.Length - MarketInstruments.Length;
                //var additionalBumpIndex = (index == 0 && offset > 0) ? 0 : Int32.MaxValue;
                return(new YieldCurve(
                           Name,
                           ReferenceDate,
                           KeyPoints.Select((x, i) => i == index ? Tuple.Create(x.Item1, resetRate) : x).ToArray(),
                           Bda,
                           DayCount,
                           Calendar,
                           Currency,
                           Compound,
                           Interpolation,
                           Trait,
                           BaseMarket,
                           CalibrateMktUpdateCondition,
                           Spread
                           ));
            }
            else
            {
                return(new YieldCurve(
                           Name,
                           ReferenceDate,
                           MarketInstruments.Select((x, i) => i == index ? new MarketInstrument(x.Instrument.Bump(resetRate), resetRate, x.CalibMethod) : x as MarketInstrument).ToArray(),
                           Bda,
                           DayCount,
                           Calendar,
                           Currency,
                           Compound,
                           Interpolation,
                           Trait,
                           BaseMarket,
                           CalibrateMktUpdateCondition,
                           null
                           )
                {
                    Spread = Spread
                });
            }
        }
Example #3
0
 public IYieldCurve Shift(int bp)
 {
     if (MarketInstruments == null)
     {
         return(new YieldCurve(
                    Name,
                    ReferenceDate,
                    KeyPoints.Select(x => Tuple.Create(x.Item1, x.Item2 + bp * 0.0001)).ToArray(),
                    Bda,
                    DayCount,
                    Calendar,
                    Currency,
                    Compound,
                    Interpolation,
                    Trait,
                    BaseMarket,
                    CalibrateMktUpdateCondition,
                    Spread
                    ));
     }
     else
     {
         return(new YieldCurve(
                    Name,
                    ReferenceDate,
                    MarketInstruments.Select(x => new MarketInstrument(x.Instrument.Bump(bp), x.TargetValue + bp * 0.0001, x.CalibMethod)).ToArray(),
                    Bda,
                    DayCount,
                    Calendar,
                    Currency,
                    Compound,
                    Interpolation,
                    Trait,
                    BaseMarket,
                    CalibrateMktUpdateCondition,
                    null
                    )
         {
             Spread = Spread
         });
     }
 }