コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="cache"></param>
 /// <param name="isCollateralised"></param>
 /// <param name="collateralCurrency"></param>
 /// <param name="fixingCalendar"></param>
 /// <param name="paymentCalendar"></param>
 /// <param name="isPayer"></param>
 /// <param name="commodityForwardFpML"></param>
 /// <param name="nameSpace"></param>
 public CommodityForwardPricer(ILogger logger, ICoreCache cache, bool isCollateralised,
                               string collateralCurrency, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                               bool isPayer, CommodityForward commodityForwardFpML, String nameSpace)
 {
     IsCollateralised   = isCollateralised;
     CollateralCurrency = collateralCurrency;
     OrderedPartyNames  = new List <string>();
     Multiplier         = 1.0m;
     ValueDate          = commodityForwardFpML.valueDate;
     FixedLeg           = commodityForwardFpML.fixedLeg;
     BullionPhysicalLeg = commodityForwardFpML.Item;
     if (commodityForwardFpML.commonPricingSpecified)
     {
         CommonPricing = commodityForwardFpML.commonPricing;
     }
     AddCashFlows(logger, cache, fixingCalendar, paymentCalendar, commodityForwardFpML, isPayer, nameSpace);
     BasePartyPayingFixed = !isPayer;
     RiskMaturityDate     = TerminationDate;
     NumberOfDays         = (DayCounterHelper.Parse(DayCountFraction.Value)).DayCount(EffectiveDate, TerminationDate);
     //Set the product type.
     ProductType       = ProductTypeSimpleEnum.FRA;
     PaymentCurrencies = new List <string> {
         Notional.currency.Value
     };
     //Set the default discount curve name.
     DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(CollateralCurrency, !IsCollateralised);
     ForecastCurveName = CurveNameHelpers.GetForecastCurveName(commodityForwardFpML.floatingRateIndex, commodityForwardFpML.indexTenor);
 }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="cache"></param>
 /// <param name="isCollateralised"></param>
 /// <param name="collateralCurrency"></param>
 /// <param name="fixingCalendar"></param>
 /// <param name="paymentCalendar"></param>
 /// <param name="commodityForwardFpML"></param>
 /// <param name="baseParty"></param>
 /// <param name="nameSpace"></param>
 public CommodityForwardPricer(ILogger logger, ICoreCache cache, bool isCollateralised,
                               string collateralCurrency, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                               CommodityForward commodityForwardFpML, String baseParty, String nameSpace)
     : this(logger, cache, isCollateralised, collateralCurrency, fixingCalendar, paymentCalendar,
            !IsBasePartyBuyer(baseParty, commodityForwardFpML), commodityForwardFpML, nameSpace)
 {
 }
コード例 #3
0
        private void AddCashFlows(ILogger logger, ICoreCache cache,
                                  IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                                  CommodityForward commodityForwardFpML, bool isBuyer, String nameSpace)
        {
            EffectiveDate   = fraFpML.adjustedEffectiveDate.Value;
            TerminationDate = fraFpML.adjustedTerminationDate;
            if (paymentCalendar == null)
            {
                paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fraFpML.paymentDate.dateAdjustments.businessCenters, nameSpace);
            }
            if (fixingCalendar == null)
            {
                fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fraFpML.fixingDateOffset.businessCenters, nameSpace);
            }
            DateTime unadjustedPaymentDate = fraFpML.paymentDate.unadjustedDate.Value;
            var      notional = MoneyHelper.GetAmount(fraFpML.notional.amount, fraFpML.notional.currency);

            PaymentDate = paymentCalendar.Roll(unadjustedPaymentDate, BusinessDayConventionHelper.Parse(fraFpML.paymentDate.dateAdjustments.businessDayConvention.ToString()));
            DateTime adjustedFixingDate = GetResetDate(logger, cache, fixingCalendar, fraFpML, nameSpace);
            var      interval           = fraFpML.indexTenor[0];
            var      floatingInterest   = new PriceableFloatingRateCoupon(fraFpML.id + "FloatingCoupon_1"
                                                                          , isBuyer
                                                                          , EffectiveDate
                                                                          , TerminationDate
                                                                          , adjustedFixingDate
                                                                          , fraFpML.dayCountFraction
                                                                          , 0.0m
                                                                          , FixedRate
                                                                          , null
                                                                          , isBuyer ? MoneyHelper.Neg(notional) : notional
                                                                          , PaymentDate
                                                                          , new ForecastRateIndex {
                floatingRateIndex = fraFpML.floatingRateIndex, indexTenor = interval
            }
                                                                          , null
                                                                          , null
                                                                          , fraFpML.fraDiscounting
                                                                          , paymentCalendar
                                                                          , fixingCalendar)
            {
                ForecastRateInterpolation = ForecastRateInterpolation
            };

            // Combine two cashflows into one leg
            //
            FloatingCoupon = floatingInterest;//fraFpML.fraDiscounting,
        }
コード例 #4
0
        /// <summary>
        /// Gets the reset date.
        /// </summary>
        /// <param name="logger"> </param>
        /// <param name="cache"> </param>
        /// <param name="fixingCalendar"> </param>
        /// <param name="commodityForwardFpML">The fraFpML.</param>
        /// <param name="nameSpace"></param>
        /// <returns></returns>
        private static DateTime GetResetDate(ILogger logger, ICoreCache cache,
                                             IBusinessCalendar fixingCalendar,
                                             CommodityForward commodityForwardFpML, String nameSpace)
        {
            var      effectiveDateId = fraFpML.adjustedEffectiveDate.id;
            var      fixingdateRef   = fraFpML.fixingDateOffset.dateRelativeTo.href;
            DateTime resetDate       = fraFpML.adjustedEffectiveDate.Value;

            if (fixingCalendar == null)
            {
                fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fraFpML.fixingDateOffset.businessCenters, nameSpace);
            }
            if (fixingdateRef == effectiveDateId)
            {
                resetDate = AdjustedDateHelper.ToAdjustedDate(fixingCalendar, fraFpML.adjustedEffectiveDate.Value, fraFpML.fixingDateOffset);
            }
            logger.LogInfo("Reset date set.");
            return(resetDate);
        }
コード例 #5
0
 private static bool IsBasePartyBuyer(string baseParty, CommodityForward commodityForwardFpML)
 {
     return(baseParty == commodityForwardFpML.pa.href);
 }