예제 #1
0
        public static RateIndex Parse(string id,
                                      string instrumentId,
                                      string floatingRateIndex,
                                      string currency,
                                      string dayCountFraction,
                                      string paymentFrequency,
                                      string term)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency
                },
                dayCountFraction  = DayCountFractionHelper.Parse(dayCountFraction),
                floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex),
                id           = id,
                instrumentId = InstrumentIdArrayHelper.Parse(instrumentId)
            };
            Period frequency = null;

            if (paymentFrequency != null)
            {
                frequency = PeriodHelper.Parse(paymentFrequency);
            }
            rateIndex.paymentFrequency = frequency;
            Period period = null;

            if (term != null)
            {
                period = PeriodHelper.Parse(term);
            }
            rateIndex.term = period;
            return(rateIndex);
        }
예제 #2
0
 public PriceableStructuredRateCoupon
     (string uniqueId
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , Boolean adjustCalculationDatesIndicator
     , AdjustableDate paymentDate
     , Money notionalAmount
     , ResetRelativeToEnum resetRelativeTo
     , RelativeDateOffset fixingDateRelativeOffset
     , RateIndex underlyingRateIndex
     , RelativeDateOffset resetLagOffset
     , Decimal margin
     , Calculation calculation
     , ForecastRateIndex forecastRateIndex
     )
     : base
         (uniqueId
         , accrualStartDate
         , accrualEndDate
         , adjustCalculationDatesIndicator
         , paymentDate
         , notionalAmount
         , resetRelativeTo
         , fixingDateRelativeOffset
         , margin
         , calculation
         , forecastRateIndex
         )
 {
     UnderlyingRateIndex = underlyingRateIndex;
     ResetLagOffset      = resetLagOffset;
     PriceableCouponType = CouponType.StructuredRate;
     AnalyticsModel      = new StructuredRateCouponAnalytic();
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableCaplet"/> class.
        /// This is a special case for use with the factry for bootstrapping, as it
        /// uses no calendar logic. This is done by the factory.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="nodeStruct">A special class containing all salient data required.</param>
        /// <param name="properties">The properties set This includes strike information.</param>
        /// <param name="fixingCalendar">The fixing/expiry calendar></param>
        /// <param name="paymentCalendar">The paymentCalendar calendar.</param>
        /// <param name="notional">The notional. The default value is 1,000,000.00m.</param>
        /// <param name="marketQuotes">The market quotes, including the volatility and possibly the fixed rate as a decimal contained in a basic quotation.</param>
        public PriceableCaplet(DateTime baseDate, RateOptionNodeStruct nodeStruct, NamedValueSet properties, IBusinessCalendar fixingCalendar,
                               IBusinessCalendar paymentCalendar, Decimal notional, BasicAssetValuation marketQuotes)
            : base(baseDate, nodeStruct.ResetDateAdjustment, nodeStruct.SimpleRateOption, notional, 1000000.0m, nodeStruct.BusinessDayAdjustments, marketQuotes)
        {
            Id                    = nodeStruct.SimpleRateOption.id;
            IsCap                 = true;
            IsDiscounted          = false;
            RateOption            = nodeStruct.SimpleRateOption;
            ResetDateOffset       = nodeStruct.ResetDateAdjustment;
            SpotDateOffset        = nodeStruct.SpotDate;
            UnderlyingRateIndex   = nodeStruct.RateIndex;
            AdjustedStartDate     = GetSpotDate(baseDate, fixingCalendar, nodeStruct.SpotDate);
            AdjustedEffectiveDate = GetEffectiveDate(AdjustedStartDate, paymentCalendar, nodeStruct.SimpleRateOption.startTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);
            OptionsExpiryDate     = GetFixingDate(AdjustedEffectiveDate, fixingCalendar, nodeStruct.ResetDateAdjustment);
            MaturityDate          = GetEffectiveDate(AdjustedStartDate, paymentCalendar, nodeStruct.SimpleRateOption.endTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);
            PaymentDate           = MaturityDate;
            YearFraction          = GetYearFraction(RateOption.dayCountFraction.Value, AdjustedEffectiveDate, MaturityDate);
            TimeToExpiry          = GetTimeToExpiry(baseDate, OptionsExpiryDate);
            //Set the strike scalar. This must be after the number of expiry dates has been set.
            var quotes = new List <BasicQuotation>(marketQuotes.quote);

            //For the default cap the spot rate is used.
            SetQuote("ForwardRate", quotes);
            SetQuote("Strike", quotes);
            //decimal? strike = properties.GetValue<decimal>("Strike", false);
            //Strike = (decimal)strike;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableBasisSwap"/> class.
 /// </summary>
 /// <param name="baseDate">The base date.</param>
 /// <param name="nodeStruct">The nodeStruct.</param>
 /// <param name="fixingCalendar">The fixing Calendar</param>
 /// <param name="paymentCalendar">The payment Calendar.</param>
 /// <param name="spread">The spread.</param>
 public PriceableBasisSwap(DateTime baseDate, BasisSwapNodeStruct nodeStruct, IBusinessCalendar fixingCalendar,
                           IBusinessCalendar paymentCalendar, BasicQuotation spread)
     : base(baseDate, nodeStruct.MarginLeg, nodeStruct.SpotDate, nodeStruct.MarginLegCalculation, nodeStruct.MarginLegDateAdjustments,
            nodeStruct.MarginLegRateIndex, fixingCalendar, paymentCalendar, spread)
 {
     BaseLegRateIndex = nodeStruct.BaseLegRateIndex;
     MarketQuote      = GetSpread(spread);
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class.
 /// </summary>
 /// <param name="amount">The amount.</param>
 /// <param name="discountingType">The discounting type.</param>
 /// <param name="effectiveDate">The base date.</param>
 /// <param name="tenor">The maturity tenor.</param>
 /// <param name="fxdDayFraction">The fixed leg day fraction.</param>
 /// <param name="businessCenters">The payment business centers.</param>
 /// <param name="businessDayConvention">The payment business day convention.</param>
 /// <param name="fxdFrequency">The business day adjustments.</param>
 /// <param name="underlyingRateIndex">Index of the rate.</param>
 /// <param name="fixedRate">The fixed rate.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="currency">THe currency.</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="paymentCalendar">The paymentCalendar.</param>
 public PriceableSimpleIRSwap(string id, DateTime baseDate, string currency,
                              decimal amount, DiscountingTypeEnum?discountingType,
                              DateTime effectiveDate, string tenor, string fxdDayFraction,
                              string businessCenters, string businessDayConvention, string fxdFrequency,
                              RateIndex underlyingRateIndex, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
     : this(baseDate, SimpleIrsHelper.Parse(id, currency, fxdDayFraction, tenor, fxdFrequency, id), effectiveDate,
            CalculationFactory.CreateFixed(fixedRate.value, MoneyHelper.GetAmount(amount, currency),
                                           DayCountFractionHelper.Parse(fxdDayFraction), discountingType),
            BusinessDayAdjustmentsHelper.Create(businessDayConvention, businessCenters), underlyingRateIndex, fixingCalendar, paymentCalendar, fixedRate)
 {
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableSimpleFra"/> class.
 /// This is a special case for use with the factry for bootstrapping, as it
 /// uses no calendar logic. This is done by the factory.
 /// </summary>
 /// <param name="baseDate">The base date.</param>
 /// <param name="nodeStruct">A special class containing all salient data required.</param>
 /// <param name="fixingCalendar">The fixing calendar.</param>
 /// <param name="paymentCalendar">The payment calendar.></param>
 /// <param name="notional">The notional. The default value is 1.00m.</param>
 /// <param name="normalisedRate">Thhhe fixed rate as a decimal contained in a basic quotation.</param>
 public PriceableSimpleFra(DateTime baseDate, SimpleFraNodeStruct nodeStruct, IBusinessCalendar fixingCalendar,
                           IBusinessCalendar paymentCalendar, Decimal notional, BasicQuotation normalisedRate)
     : base(nodeStruct.SimpleFra.id, baseDate, notional, nodeStruct.BusinessDayAdjustments, normalisedRate)
 {
     SimpleFra           = nodeStruct.SimpleFra;
     FixingDateOffset    = nodeStruct.SpotDate;
     UnderlyingRateIndex = nodeStruct.RateIndex;
     SpotDate            = GetSpotDate(baseDate, fixingCalendar, nodeStruct.SpotDate);
     AdjustedStartDate   = GetEffectiveDate(SpotDate, paymentCalendar, nodeStruct.SimpleFra.startTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);//GetSpotDate();
     RiskMaturityDate    = GetEffectiveDate(SpotDate, paymentCalendar, nodeStruct.SimpleFra.endTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);
     YearFraction        = GetYearFraction(SimpleFra.dayCountFraction.Value, AdjustedStartDate, RiskMaturityDate);
     TimeToExpiry        = GetTimeToMaturity(baseDate, RiskMaturityDate);
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableRateIndex"/> class.
 /// </summary>
 /// <param name="baseDate"></param>
 /// <param name="amount">The amount.</param>
 /// <param name="rateIndex">Index of the rate.</param>
 /// <param name="businessDayAdjustments">The business day adjustments.</param>
 /// <param name="resetDateConvention">The reset date convention.</param>
 /// <param name="fixedRate">The fixed rate.</param>
 protected PriceableRateIndex(DateTime baseDate, Decimal amount, RateIndex rateIndex,
                              BusinessDayAdjustments businessDayAdjustments, RelativeDateOffset resetDateConvention,
                              BasicQuotation fixedRate)
     : base(rateIndex.id, baseDate, amount, businessDayAdjustments, fixedRate)
 {
     UnderlyingRateIndex = rateIndex;
     if (PeriodEnum.D != resetDateConvention.period)
     {
         throw new System.Exception("Only day units are supported!");
     }
     ResetDateConvention = resetDateConvention;
     Id = rateIndex.id;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableSpreadFra"/> class.
 /// </summary>
 /// <param name="baseDate">The base date.</param>
 /// <param name="nodeStruct">The nodeStruct.</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="underlyingRateIndex">The underlying rate index.</param>
 /// <param name="spread">The spread.</param>
 /// <param name="paymentCalendar">A paymentCalendar.</param>
 public PriceableSpreadFra(DateTime baseDate, SimpleFraNodeStruct nodeStruct, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                           RateIndex underlyingRateIndex, BasicQuotation spread)
     : base(baseDate, nodeStruct.BusinessDayAdjustments, spread)
 {
     Id                    = nodeStruct.SimpleFra.id;
     SimpleFra             = nodeStruct.SimpleFra;
     FixingDateOffset      = nodeStruct.SpotDate;
     UnderlyingRateIndex   = underlyingRateIndex;
     AdjustedStartDate     = GetSpotDate(baseDate, fixingCalendar, nodeStruct.SpotDate);
     AdjustedEffectiveDate = GetEffectiveDate(AdjustedStartDate, paymentCalendar, nodeStruct.SimpleFra.startTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);
     RiskMaturityDate      = GetEffectiveDate(AdjustedStartDate, paymentCalendar, nodeStruct.SimpleFra.endTerm, nodeStruct.BusinessDayAdjustments.businessDayConvention);
     YearFraction          = GetYearFractions()[0];
     TimeToExpiry          = GetTimeToMaturity(baseDate, RiskMaturityDate);
     SetSpread(spread);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleFra"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="nodeStruct"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="paymentCalendar"></param>
        /// <param name="fixedRate">The fixed rate.</param>
        public PriceableSimpleRevenueInflationSwap(DateTime baseDate, SimpleIRSwapNodeStruct nodeStruct,
                                                   IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
            : base(baseDate, nodeStruct.DateAdjustments, fixedRate)
        {
            Id = nodeStruct.SimpleIRSwap.id;
            SimpleInflationSwap = nodeStruct.SimpleIRSwap;
            SpotDateOffset      = nodeStruct.SpotDate;
            Calculation         = nodeStruct.Calculation;
            UnderlyingRateIndex = nodeStruct.UnderlyingRateIndex;
            AdjustedStartDate   = GetSpotDate(baseDate, fixingCalendar, SpotDateOffset);
            DayCounter          = DayCounterHelper.Parse(Calculation.dayCountFraction.Value);
            List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleInflationSwap.term, SimpleInflationSwap.paymentFrequency);

            AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, nodeStruct.DateAdjustments.businessDayConvention, paymentCalendar);
        }
예제 #10
0
        public static RateIndex Parse(string floatingRateIndex,
                                      string currency,
                                      string dayCountFraction)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency
                },
                dayCountFraction  = DayCountFractionHelper.Parse(dayCountFraction),
                floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex),
            };

            return(rateIndex);
        }
예제 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="simpleIRSwap">THe FpML swap.</param>
        /// <param name="spotDate">The spot date.</param>
        /// <param name="calculation">A calculation.</param>
        /// <param name="stringRollConvention">The roll convention.</param>
        /// <param name="businessDayAdjustments">The business day adjustments.</param>
        /// <param name="underlyingRateIndex">Index of the rate.</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="paymentCalendar">The paymentCalendar.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        public PriceableIRSwap(DateTime baseDate, SimpleIRSwap simpleIRSwap,
                               DateTime spotDate, Calculation calculation, String stringRollConvention,
                               BusinessDayAdjustments businessDayAdjustments, RateIndex underlyingRateIndex,
                               IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
            : base(baseDate, simpleIRSwap, spotDate, calculation, stringRollConvention,
                   businessDayAdjustments, underlyingRateIndex, fixingCalendar, paymentCalendar, fixedRate)
        {
            ModelIdentifier = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset";
            //The floating leg which is now non-zero.
            var unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, UnderlyingRateIndex.term);

            FloatingLegAdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, fixingCalendar);
            FloatingLegWeightings          = CreateWeightings(CDefaultWeightingValue, FloatingLegAdjustedPeriodDates.Count - 1);
            FloatingLegYearFractions       = GetFloatingLegYearFractions();
        }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class.
 /// </summary>
 /// <param name="cashlfowId">The stream id.</param>
 /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param>
 /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param>
 /// <param name="adjustCalculationDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param>
 /// <param name="accrualBusinessCenters">The accrual business centers.</param>
 /// <param name="underlyingRateIndex">Te underlying rate index can be Xibor or Swap.</param>
 /// <param name="resetLagOffset">This allows for non-standard lags to be used in convexity adjustment calculations.</param>
 /// <param name="margin">The margin.</param>
 /// <param name="observedRate">The observed Rate.</param>
 /// <param name="notionalAmount">The notional amount.</param>
 /// <param name="accrualDayCountfraction">Type of day Countfraction used for the acrual period.</param>
 /// <param name="paymentDate">The payment date.</param>
 /// <param name="accrualRollConvention">The accrual roll convention.</param>
 /// <param name="resetRelativeTo">reset relative to?</param>
 /// <param name="fixingDateRelativeOffset">The fixing date offset.</param>
 /// <param name="forecastRateIndex">The forecastrateindex.</param>
 /// <param name="discountingType">The swap discounting type.</param>
 /// <param name="discountRate">The discount rate.</param>
 /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null,
 /// <param name="underlyingRateIndex"></param>
 /// then it is assumed that there is no fradiscounting</param>
 public PriceableStructuredRateCoupon
 (
     string cashlfowId
     , DateTime accrualStartDate
     , DateTime accrualEndDate
     , Boolean adjustCalculationDatesIndicator
     , BusinessCenters accrualBusinessCenters
     , BusinessDayConventionEnum accrualRollConvention
     , DayCountFraction accrualDayCountfraction
     , ResetRelativeToEnum resetRelativeTo
     , RelativeDateOffset fixingDateRelativeOffset
     , RateIndex underlyingRateIndex
     , RelativeDateOffset resetLagOffset
     , Decimal margin
     , Decimal?observedRate
     , Money notionalAmount
     , AdjustableDate paymentDate
     , ForecastRateIndex forecastRateIndex
     , DiscountingTypeEnum?discountingType
     , Decimal?discountRate
     , FraDiscountingEnum?fraDiscounting)
     : base(
         cashlfowId
         , accrualStartDate
         , accrualEndDate
         , adjustCalculationDatesIndicator
         , accrualBusinessCenters
         , accrualRollConvention
         , accrualDayCountfraction
         , resetRelativeTo
         , fixingDateRelativeOffset
         , margin
         , observedRate
         , notionalAmount
         , paymentDate
         , forecastRateIndex
         , discountingType
         , discountRate
         , fraDiscounting
         )
 {
     UnderlyingRateIndex = underlyingRateIndex;
     ResetLagOffset      = resetLagOffset;
     PriceableCouponType = CouponType.StructuredRate;
     AnalyticsModel      = new StructuredRateCouponAnalytic();
 }
예제 #13
0
        public static RateIndex Parse(string floatingRateIndex,
                                      string currency,
                                      string dayCountFraction, string term)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency
                },
                dayCountFraction  = DayCountFractionHelper.Parse(dayCountFraction),
                floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex),
            };
            Period period = null;

            if (term != null)
            {
                period = PeriodHelper.Parse(term);
            }
            rateIndex.term = period;
            return(rateIndex);
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="identifier">The asset identifier.</param>
        /// <param name="adjustedDates">The dates.</param>
        /// <param name="notionalWeights">The notionals, weighted by the first notional.</param>
        /// <param name="calculation">A calculation.</param>
        /// <param name="businessDayAdjustments">The business day adjustments.</param>
        /// <param name="underlyingRateIndex">Index of the rate.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        public PriceableSimpleIRSwap(DateTime baseDate, string identifier, DateTime[] adjustedDates, Decimal[] notionalWeights,
                                     Calculation calculation, BusinessDayAdjustments businessDayAdjustments, RateIndex underlyingRateIndex,
                                     BasicQuotation fixedRate)
            : base(baseDate, businessDayAdjustments, calculation, fixedRate)
        {
            Id           = identifier;
            SimpleIRSwap = new SimpleIRSwap
            {
                dayCountFraction = calculation.dayCountFraction
            };
            UnderlyingRateIndex = underlyingRateIndex;
            RiskMaturityDate    = adjustedDates[adjustedDates.Length - 1];
            AdjustedPeriodDates = new List <DateTime>(adjustedDates);
            AdjustedStartDate   = AdjustedPeriodDates[0];
            Weightings          = notionalWeights;
            YearFractions       = GetYearFractions();
            ModelIdentifier     = DiscountingType == null ? "SimpleSwapAsset" : "SimpleDiscountSwapAsset";
            var timeToMaturity = Actual365.Instance.YearFraction(baseDate, RiskMaturityDate);

            EndDiscountFactor = (decimal)System.Math.Exp(-(double)fixedRate.value * timeToMaturity);
        }
예제 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="simpleIRSwap">THe FpML swap.</param>
        /// <param name="spotDate">The spot date.</param>
        /// <param name="calculation">A calculation.</param>
        /// <param name="stringRollConvention">The roll convention.</param>
        /// <param name="businessDayAdjustments">The business day adjustments.</param>
        /// <param name="underlyingRateIndex">Index of the rate.</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="paymentCalendar">The paymentCalendar.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        public PriceableSimpleIRSwap(DateTime baseDate, SimpleIRSwap simpleIRSwap,
                                     DateTime spotDate, Calculation calculation, String stringRollConvention,
                                     BusinessDayAdjustments businessDayAdjustments, RateIndex underlyingRateIndex,
                                     IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
            : base(baseDate, businessDayAdjustments, calculation, fixedRate)
        {
            Id                  = simpleIRSwap.id;
            SimpleIRSwap        = simpleIRSwap;
            UnderlyingRateIndex = underlyingRateIndex;
            AdjustedStartDate   = spotDate;
            List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, SimpleIRSwap.paymentFrequency);

            AdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, paymentCalendar);
            RiskMaturityDate    = AdjustedPeriodDates[AdjustedPeriodDates.Count - 1];
            Weightings          = CreateWeightings(CDefaultWeightingValue, AdjustedPeriodDates.Count - 1);
            YearFractions       = GetYearFractions();
            ModelIdentifier     = DiscountingType == null ? "SimpleSwapAsset" : "SimpleDiscountSwapAsset";
            var timeToMaturity = Actual365.Instance.YearFraction(baseDate, RiskMaturityDate);

            EndDiscountFactor = (decimal)System.Math.Exp(-(double)fixedRate.value * timeToMaturity);
        }
예제 #16
0
        public static RateIndex Create(string instrumentId,
                                       FloatingRateIndex floatingRateIndex,
                                       Currency currency,
                                       DayCountFraction dayCountFraction,
                                       Period paymentFrequency,
                                       Period term)
        {
            RateIndex rateIndex = new RateIndex();

            rateIndex.currency = new IdentifiedCurrency()
            {
                Value = currency.Value
            };
            rateIndex.dayCountFraction  = dayCountFraction;
            rateIndex.floatingRateIndex = floatingRateIndex;
            rateIndex.id               = instrumentId;
            rateIndex.instrumentId     = InstrumentIdArrayHelper.Parse(instrumentId);
            rateIndex.paymentFrequency = paymentFrequency;
            rateIndex.term             = term;

            return(rateIndex);
        }
예제 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="nodeStruct">The nodeStruct;</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="paymentCalendar">The paymentCalendar.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        public PriceableSimpleIRSwap(DateTime baseDate, SimpleIRSwapNodeStruct nodeStruct,
                                     IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
            : base(baseDate, nodeStruct.DateAdjustments, nodeStruct.Calculation, fixedRate)
        {
            Id = nodeStruct.SimpleIRSwap.id;
            FixingDateOffset    = nodeStruct.SpotDate;
            SimpleIRSwap        = nodeStruct.SimpleIRSwap;
            UnderlyingRateIndex = nodeStruct.UnderlyingRateIndex;
            //TODO: This needs to be modified to use backwards roll.
            AdjustedStartDate = GetSpotDate(baseDate, fixingCalendar, FixingDateOffset);
            List <DateTime> unadjustedDateSchedule = DateScheduler.GetUnadjustedDateSchedule(AdjustedStartDate, SimpleIRSwap.term, SimpleIRSwap.paymentFrequency);

            AdjustedPeriodDates =
                AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedDateSchedule, BusinessDayAdjustments.businessDayConvention, paymentCalendar);
            RiskMaturityDate = AdjustedPeriodDates[AdjustedPeriodDates.Count - 1];
            Weightings       = CreateWeightings(CDefaultWeightingValue, AdjustedPeriodDates.Count - 1);
            YearFractions    = GetYearFractions();
            ModelIdentifier  = DiscountingType == null ? "SimpleSwapAsset" : "SimpleDiscountSwapAsset";
            var timeToMaturity = Actual365.Instance.YearFraction(baseDate, RiskMaturityDate);

            EndDiscountFactor = (decimal)System.Math.Exp(-(double)fixedRate.value * timeToMaturity);
        }
예제 #18
0
        public static RateIndex Create(string instrumentId,
                                       FloatingRateIndex floatingRateIndex,
                                       Currency currency,
                                       DayCountFraction dayCountFraction,
                                       Period paymentFrequency,
                                       Period term)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency.Value
                },
                dayCountFraction  = dayCountFraction,
                floatingRateIndex = floatingRateIndex,
                id               = instrumentId,
                instrumentId     = InstrumentIdArrayHelper.Parse(instrumentId),
                paymentFrequency = paymentFrequency,
                term             = term
            };

            return(rateIndex);
        }
예제 #19
0
        public static RateIndex Parse(string instrumentId,
                                      string floatingRateIndex,
                                      string currency,
                                      string dayCountFraction,
                                      string paymentFrequency,
                                      string term)
        {
            var rateIndex = new RateIndex
            {
                currency = new IdentifiedCurrency {
                    Value = currency
                },
                dayCountFraction  = DayCountFractionHelper.Parse(dayCountFraction),
                floatingRateIndex = FloatingRateIndexHelper.Parse(floatingRateIndex),
                id               = instrumentId,
                instrumentId     = InstrumentIdArrayHelper.Parse(instrumentId),
                paymentFrequency = PeriodHelper.Parse(paymentFrequency),
                term             = PeriodHelper.Parse(term)
            };

            return(rateIndex);
        }
        /// <summary>
        /// Tests that par rates and ibor index are required for curves.
        /// </summary>
        public virtual void requirements()
        {
            FraCurveNode      node1x4   = CurveTestUtils.fraNode(1, "foo");
            FraCurveNode      node2x5   = CurveTestUtils.fraNode(2, "foo");
            IList <CurveNode> nodes     = ImmutableList.of(node1x4, node2x5);
            CurveGroupName    groupName = CurveGroupName.of("Curve Group");
            CurveName         curveName = CurveName.of("FRA Curve");
            ObservableSource  obsSource = ObservableSource.of("Vendor");

            InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(curveName).nodes(nodes).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();

            RateIndex ibor = IborIndices.USD_LIBOR_3M;
            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(groupName).addCurve(curveDefn, Currency.USD, ibor).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupName, groupDefn).build();

            RatesCurveGroupMarketDataFunction function = new RatesCurveGroupMarketDataFunction();
            RatesCurveGroupId      curveGroupId        = RatesCurveGroupId.of(groupName, obsSource);
            MarketDataRequirements requirements        = function.requirements(curveGroupId, marketDataConfig);

            assertThat(requirements.NonObservables).contains(RatesCurveInputsId.of(groupName, curveName, obsSource));
            assertThat(requirements.TimeSeries.contains(IndexQuoteId.of(ibor)));
        }
예제 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="fixedDates">The fixed side dates.</param>
        /// <param name="floatingDates">The floating side dates.</param>
        /// <param name="resetRates">An array of override reset dates.</param>
        /// <param name="fixedCalculation">The fixed side calculation.</param>
        /// <param name="businessDayAdjustments">The business day adjustments.</param>
        /// <param name="floatingCalculation">The floating leg calculation.</param>
        /// <param name="underlyingRateIndex">Index of the rate.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        /// <param name="floatingSpread">The floating leg spread.</param>
        public PriceableIRSwap(DateTime baseDate, List <DateTime> fixedDates,
                               List <DateTime> floatingDates, List <Decimal> resetRates,
                               Calculation fixedCalculation, BusinessDayAdjustments businessDayAdjustments,
                               Calculation floatingCalculation, RateIndex underlyingRateIndex,
                               BasicQuotation fixedRate, BasicQuotation floatingSpread)
            : base(baseDate, null, fixedDates.ToArray(), null, floatingCalculation,
                   businessDayAdjustments, underlyingRateIndex, fixedRate)
        {
            ModelIdentifier = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset";
            Id                = "Unidentified";
            ForwardRates      = resetRates?.ToArray();
            FloatingLegSpread = floatingSpread;
            FloatingLegAdjustedPeriodDates = floatingDates;
            //Exract the notional weights from the fixed calculation.
            var fixedNotionalSchedule = (Notional)fixedCalculation.Item;

            Weightings = CreateWeightingsFromNonNegativeNotionalSchedule(fixedNotionalSchedule.notionalStepSchedule, fixedDates);
            //Extract the floating weights from the floating calculation.
            var floatingNotionalSchedule = (Notional)Calculation.Item;

            FloatingLegWeightings    = CreateWeightingsFromNonNegativeNotionalSchedule(floatingNotionalSchedule.notionalStepSchedule, floatingDates);
            FloatingLegYearFractions = GetFloatingLegYearFractions();
        }
예제 #22
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Adds the definition of a curve to the curve group definition which is used to provide
        /// discount rates and forward rates.
        /// </summary>
        /// <param name="curveDefinition">  the definition of the forward curve </param>
        /// <param name="currency">  the currency for which the curve provides discount rates </param>
        /// <param name="index">  the index for which the curve provides forward rates </param>
        /// <param name="otherIndices">  the additional indices for which the curve provides forward rates </param>
        /// <returns> this builder </returns>
        public RatesCurveGroupDefinitionBuilder addCurve(CurveDefinition curveDefinition, Currency currency, RateIndex index, params RateIndex[] otherIndices)
        {
            ArgChecker.notNull(curveDefinition, "curveDefinition");
            ArgChecker.notNull(currency, "currency");
            ArgChecker.notNull(index, "index");

            RatesCurveGroupEntry entry = RatesCurveGroupEntry.builder().curveName(curveDefinition.Name).discountCurrencies(ImmutableSet.of(currency)).indices(indices(index, otherIndices)).build();

            return(merge(entry, curveDefinition));
        }
예제 #23
0
        /// <summary>
        /// Adds a curve to the curve group definition which is used to provide discount rates and forward rates.
        /// <para>
        /// A curve added with this method cannot be calibrated by the market data system as it does not include
        /// a curve definition. It is intended to be used with curves which are supplied by the user.
        ///
        /// </para>
        /// </summary>
        /// <param name="curveName">  the name of the curve </param>
        /// <param name="currency">  the currency for which the curve provides discount rates </param>
        /// <param name="index">  the index for which the curve provides forward rates </param>
        /// <param name="otherIndices">  the additional indices for which the curve provides forward rates </param>
        /// <returns> this builder </returns>
        public RatesCurveGroupDefinitionBuilder addCurve(CurveName curveName, Currency currency, RateIndex index, params RateIndex[] otherIndices)
        {
            RatesCurveGroupEntry entry = RatesCurveGroupEntry.builder().curveName(curveName).discountCurrencies(ImmutableSet.of(currency)).indices(indices(index, otherIndices)).build();

            return(mergeEntry(entry));
        }
예제 #24
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <returns></returns>
        public static Asset Parse(string instrumentId)
        {
            Asset underlyingAsset;
            var   properties = new PriceableAssetProperties(instrumentId);

            switch (properties.AssetType)
            {
            case AssetTypesEnum.ZeroRate:
            {
                var zeroRate = new Cash {
                    id = instrumentId
                };
                underlyingAsset = zeroRate;
                break;
            }

            case AssetTypesEnum.Xibor:
            case AssetTypesEnum.OIS:
            {
                var rateIndex = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = rateIndex;
                break;
            }

            case AssetTypesEnum.IRSwap:
            case AssetTypesEnum.ClearedIRSwap:
            case AssetTypesEnum.OISSwap:
            case AssetTypesEnum.XccySwap:
            case AssetTypesEnum.SimpleIRSwap:
            case AssetTypesEnum.XccyBasisSwap:
            case AssetTypesEnum.BasisSwap:
            case AssetTypesEnum.ResettableXccyBasisSwap:
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = simpleIRSwap;
                break;
            }

            case AssetTypesEnum.Deposit:
            case AssetTypesEnum.SpreadDeposit:
            case AssetTypesEnum.XccyDepo:
            case AssetTypesEnum.BankBill:
            case AssetTypesEnum.Repo:
            case AssetTypesEnum.RepoSpread:
            {
                var deposit = new Deposit {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = deposit;
                break;
            }

            case AssetTypesEnum.SimpleFra:
            case AssetTypesEnum.Fra:
            case AssetTypesEnum.BillFra:
            case AssetTypesEnum.SpreadFra:
            {
                var simpleFra = new SimpleFra {
                    id = instrumentId, startTerm = properties.TermTenor
                };
                if (properties.ForwardIndex == null)
                {
                    throw new ArgumentException("ForwardIndex must be set in the instrumentId " + instrumentId,
                                                nameof(instrumentId));
                }
                simpleFra.endTerm = simpleFra.startTerm.Sum(properties.ForwardIndex);
                underlyingAsset   = simpleFra;
                break;
            }

            case AssetTypesEnum.IRFloor:
            case AssetTypesEnum.IRCap:
            {
                var simpleIRCap = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = simpleIRCap;
                break;
            }

            case AssetTypesEnum.IRFutureOption:
            case AssetTypesEnum.IRFuture:
            {
                var future = new Future {
                    id = instrumentId
                };
                underlyingAsset = future;
                break;
            }

            case AssetTypesEnum.CommodityFuture:
            case AssetTypesEnum.CommodityFutureSpread:
            {
                var future = new Future {
                    id = instrumentId
                };
                underlyingAsset = future;
                break;
            }

            case AssetTypesEnum.CPIndex:
            {
                var rateIndex = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = rateIndex;
                break;
            }

            case AssetTypesEnum.SimpleCPISwap:
            case AssetTypesEnum.CPISwap:
            case AssetTypesEnum.ZCCPISwap:
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                underlyingAsset = simpleIRSwap;
                break;
            }

            case AssetTypesEnum.Equity:
            case AssetTypesEnum.EquityForward:
            {
                //  var tenor = results[2];
                var equityAsset = new EquityAsset {
                    id = instrumentId
                };
                underlyingAsset = equityAsset;
                break;
            }

            case AssetTypesEnum.FxSpot:
            case AssetTypesEnum.FxForward:
            {
                //  var tenor = results[2];
                var fxRateAsset = new FxRateAsset {
                    id = instrumentId
                };
                underlyingAsset = fxRateAsset;
                break;
            }

            case AssetTypesEnum.CommoditySpot:
            case AssetTypesEnum.CommodityForward:
            case AssetTypesEnum.CommodityAverageForward:
            case AssetTypesEnum.CommoditySpread:
            {
                var commodityAsset = new Commodity {
                    id = instrumentId
                };
                underlyingAsset = commodityAsset;
                break;
            }

            case AssetTypesEnum.Bond:
            case AssetTypesEnum.BondSpot:
            case AssetTypesEnum.BondForward:
            {
                var bond = new Bond {
                    id = instrumentId
                };
                underlyingAsset = bond;
                break;
            }

            default:
                throw new NotSupportedException($"Asset type {properties.AssetType} is not supported");
            }
            return(underlyingAsset);
        }
예제 #25
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <param name="value"></param>
        /// <param name="adjustment"></param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> Parse(string instrumentId, decimal value, decimal?adjustment)
        {
            const string rateQuotationType       = PriceableSimpleRateAsset.RateQuotationType;
            const string volatilityQuotationType = PriceableCapRateAsset.VolatilityQuotationType;
            Asset        underlyingAsset;
            decimal      additional = 0.0m;

            if (adjustment != null)
            {
                additional = (decimal)adjustment;
            }
            var listBasicQuotations = new List <BasicQuotation>();
            var properties          = new PriceableAssetProperties(instrumentId);

            switch (properties.AssetType)
            {
            //This is in place to handle volatility curves where the tenor is the expiry.
            case AssetTypesEnum.Period:
            {
                //There is no underlying asset.
                underlyingAsset = null;
                listBasicQuotations.Add(BasicQuotationHelper.Create(instrumentId, value, volatilityQuotationType, "LognormalVolatility"));
                break;
            }

            case AssetTypesEnum.ZeroRate:
            {
                underlyingAsset = new Cash {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Xibor:
            case AssetTypesEnum.OIS:
            {
                underlyingAsset = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.IRSwap:
            case AssetTypesEnum.ClearedIRSwap:
            case AssetTypesEnum.OISSwap:
            case AssetTypesEnum.XccySwap:
            case AssetTypesEnum.SimpleIRSwap:
            case AssetTypesEnum.XccyBasisSwap:
            case AssetTypesEnum.BasisSwap:
            case AssetTypesEnum.ResettableXccyBasisSwap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Caplet:
            case AssetTypesEnum.Floorlet:
            case AssetTypesEnum.BillCaplet:
            case AssetTypesEnum.BillFloorlet:
            {
                underlyingAsset = new SimpleFra
                {
                    id        = instrumentId,
                    startTerm = properties.TermTenor,
                    endTerm   = properties.TermTenor.Sum(properties.ForwardIndex)
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.Deposit:
            case AssetTypesEnum.SpreadDeposit:
            case AssetTypesEnum.XccyDepo:
            case AssetTypesEnum.BankBill:
            case AssetTypesEnum.Repo:
            case AssetTypesEnum.RepoSpread:
            {
                underlyingAsset = new Deposit {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.SimpleFra:
            case AssetTypesEnum.Fra:
            case AssetTypesEnum.BillFra:
            case AssetTypesEnum.SpreadFra:
            {
                underlyingAsset = new SimpleFra
                {
                    id        = instrumentId,
                    startTerm = properties.TermTenor,
                    endTerm   = properties.TermTenor.Sum(properties.ForwardIndex)      //TODO this restricts the perios to be the same!!!
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Swaption:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFloor:
            case AssetTypesEnum.IRCap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFutureOption:
            case AssetTypesEnum.IRCallFutureOption:
            case AssetTypesEnum.IRPutFutureOption:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFuture:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Volatility", "LognormalVolatility"));
                }
                break;
            }

            case AssetTypesEnum.CommodityFuture:
            case AssetTypesEnum.CommodityFutureSpread:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.CPIndex:
            {
                underlyingAsset = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.SimpleCPISwap:
            case AssetTypesEnum.CPISwap:
            case AssetTypesEnum.ZCCPISwap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.FxSpot:
            case AssetTypesEnum.FxForward:
            {
                underlyingAsset = new FxRateAsset {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "FxRate"));
                break;
            }

            case AssetTypesEnum.Equity:
            case AssetTypesEnum.EquityForward:
            {
                underlyingAsset = new EquityAsset {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            case AssetTypesEnum.CommoditySpot:
            case AssetTypesEnum.CommodityForward:
            case AssetTypesEnum.CommodityAverageForward:
            case AssetTypesEnum.CommoditySpread:
            {
                underlyingAsset = new Commodity {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            case AssetTypesEnum.Bond:
            case AssetTypesEnum.BondSpot:
            case AssetTypesEnum.BondForward:
            {
                underlyingAsset = new Bond {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));        //Changed from DirtyPrice.
                break;
            }

            case AssetTypesEnum.Lease:
            {
                underlyingAsset = new Lease {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            default:
                throw new NotSupportedException($"Asset type {properties.AssetType} is not supported");
            }
            var id = underlyingAsset?.id;

            if (underlyingAsset == null)
            {
                id = listBasicQuotations[0].id;
            }
            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, BasicAssetValuationHelper.Create(id, listBasicQuotations.ToArray())));
        }
예제 #26
0
        /// <summary>
        /// Parses the data.
        /// </summary>
        /// <param name="instrumentIds"></param>
        /// <returns></returns>
        public static QuotedAssetSet Parse(string[] instrumentIds)
        {
            var quotedAssetSetFactory = new QuotedAssetSetFactory();

            const string rateQuotationType = "MarketQuote";

            for (var i = 0; i < instrumentIds.Length; i++)
            {
                Asset underlyingAsset;

                var instrumentId = instrumentIds[i];
                var results      = instrumentIds[i].Split('-');
                var instrument   = results[1];

                var listBasicQuotations = new List <BasicQuotation>();

                const string priceUnitDecimalRate = "DecimalRate";

                switch (instrument)
                {
                case "ZeroRate":
                {
                    underlyingAsset = new Cash {
                        id = instrumentId
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "Xibor":
                case "OIS":
                {
                    var tenor = results[2];
                    underlyingAsset = new RateIndex {
                        id = instrumentId, term = Period.Parse(tenor)
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "IRSwap":
                case "XccySwap":
                case "SimpleIRSwap":
                {
                    underlyingAsset = new SimpleIRSwap {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "Deposit":
                case "XccyDepo":
                case "BankBill":
                {
                    underlyingAsset = new Deposit {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "SimpleFra":
                case "Fra":
                case "BillFra":
                {
                    var index = results[3];
                    var asset = new SimpleFra {
                        id = instrumentId, startTerm = Period.Parse(results[2])
                    };

                    asset.endTerm   = asset.startTerm.Sum(Period.Parse(index));
                    underlyingAsset = asset;
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "IRFuture":
                {
                    underlyingAsset = new Future {
                        id = instrumentId
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    listBasicQuotations.Add(BasicQuotationHelper.Create("Volatility", "LognormalVolatility"));
                    break;
                }

                case "CPIndex":
                {
                    var tenor = results[2];
                    underlyingAsset = new RateIndex {
                        id = instrumentId, term = Period.Parse(tenor)
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "SimpleCPISwap":
                case "CPISwap":
                case "ZCCPISwap":
                {
                    underlyingAsset = new SimpleIRSwap {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                default:
                    throw new NotSupportedException(string.Format("Asset type {0} is not supported", instrument));
                }

                quotedAssetSetFactory.AddAssetAndQuotes(underlyingAsset, Helpers.BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray()));
            }
            return(quotedAssetSetFactory.Create());
        }
예제 #27
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <param name="value"></param>
        /// <param name="adjustment"></param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> Parse(string instrumentId, decimal value, decimal adjustment)
        {
            const string rateQuotationType = "MarketQuote";
            Asset        underlyingAsset;
            var          results             = instrumentId.Split('-');
            var          instrument          = results[1];
            var          listBasicQuotations = new List <BasicQuotation>();

            switch (instrument)
            {
            case "ZeroRate":
            {
                var zeroRate = new Cash {
                    id = instrumentId
                };
                underlyingAsset = zeroRate;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case "Xibor":
            case "OIS":
            {
                var tenor     = results[2];
                var rateIndex = new RateIndex {
                    id = instrumentId, term = Period.Parse(tenor)
                };
                underlyingAsset = rateIndex;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "IRSwap":
            case "XccySwap":
            case "SimpleIRSwap":
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRSwap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "Deposit":
            case "XccyDepo":
            case "BankBill":
            {
                var deposit = new Deposit {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = deposit;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "SimpleFra":
            case "Fra":
            case "BillFra":
            case "SpreadFra":
            {
                var index = results[3];
                var asset = new SimpleFra {
                    id = instrumentId, startTerm = Period.Parse(results[2])
                };

                asset.endTerm   = asset.startTerm.Sum(Period.Parse(index));
                underlyingAsset = asset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "IRCap":
            {
                var simpleIRCap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRCap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, "Premium", "Amount"));
                break;
            }

            case "IRFuture":
            {
                var future = new Future {
                    id = instrumentId
                };

                underlyingAsset = future;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                listBasicQuotations.Add(BasicQuotationHelper.Create(adjustment, "Volatility", "LognormalVolatility"));
                break;
            }

            case "CommodityFuture":
            {
                var future = new Future {
                    id = instrumentId
                };

                underlyingAsset = future;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case "CPIndex":
            {
                var tenor     = results[2];
                var rateIndex = new RateIndex {
                    id = instrumentId, term = Period.Parse(tenor)
                };
                underlyingAsset = rateIndex;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "SimpleCPISwap":
            case "CPISwap":
            case "ZCCPISwap":
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRSwap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "FxSpot":
            case "FxForward":
            {
                //  var tenor = results[2];
                var fxRateAsset = new FxRateAsset {
                    id = instrumentId
                };
                underlyingAsset = fxRateAsset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "FxRate"));
                break;
            }

            case "CommoditySpot":
            case "CommodityForward":
            {
                var commodityAsset = new FxRateAsset {
                    id = instrumentId
                };
                underlyingAsset = commodityAsset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "Price"));
                break;
            }

            case "Bond":
            {
                var asset = new Bond {
                    id = instrumentId
                };
                underlyingAsset = asset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DirtyPrice"));
                break;
            }

            default:
                throw new NotSupportedException(string.Format("Asset type {0} is not supported", instrument));
            }

            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, Helpers.BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray())));
        }