public AutoCall(ICouponDecomposable underlying, DateTime[] callDates, Coupon[] redemptionCoupons, IFixingFunction[] triggers) { Contract.ForAll(redemptionCoupons, c => c.Financing.Equals(underlying.Financing)); Underlying = underlying; Financing = underlying.Financing; CallDates = callDates; redemptions = callDates.ZipToDictionary(redemptionCoupons); this.triggers = callDates.ZipToDictionary(triggers); }
private IProduct BuildCombination(ParseTreeNode leftNode, ParseTreeNode rightNode, string op, object[,] bag) { ICouponDecomposable left = BuildProduct(leftNode, bag) as ICouponDecomposable; ICouponDecomposable right = BuildProduct(rightNode, bag) as ICouponDecomposable; switch (op) { case "+": return(DecomposableLinearCombination.Create(new[] { 1.0, 1.0 }, new[] { left, right })); case "-": return(DecomposableLinearCombination.Create(new[] { 1.0, -1.0 }, new[] { left, right })); default: throw new Exception("BUG should never get there !"); } }
private IProduct BuilAutoCall(ICouponDecomposable underlying, object[,] bag) { var parameters = bag.ProcessLabelledMatrix("AutocallDate", DateAndDurationConverter.ConvertDate, o => o.ToString(), o => o); var redemptionScripts = parameters.GetColFromLabel("Redemption", o => o.ToString()); var currencies = parameters.GetColFromLabel("RedemptionCurrency", o => Currency.Parse(o.ToString())); var payDates = parameters.GetColFromLabel("RedemptionDate", DateAndDurationConverter.ConvertDate); PaymentInfo[] payInfos = payDates.ZipWith(currencies, (d, c) => new PaymentInfo(c, d)); IFixingFunction[] redemptionPayoffs = DslPayoffFactory.Build("AutocallDate", parameters, redemptionScripts); var redemptionCoupons = redemptionPayoffs.ZipWith(payInfos, (payoff, payInfo) => new Coupon(payInfo, payoff)); var triggerScripts = parameters.GetColFromLabel("AutocallTrigger", o => o.ToString()); var triggers = DslPayoffFactory.Build("AutocallDate", parameters, triggerScripts); return(new AutoCall(underlying, parameters.RowLabels, redemptionCoupons, triggers)); }
public static DecomposableLinearCombination Create(double[] weights, ICouponDecomposable[] decomposables) { Debug.Assert(weights.Length == decomposables.Length); var weightsList = new List <double>(); var decompList = new List <ICouponDecomposable>(); for (int i = 0; i < weights.Length; i++) { double weight = weights[i]; ICouponDecomposable decomp = decomposables[i]; var lc = decomp as DecomposableLinearCombination; if (lc != null) { decompList.AddRange(lc.decomposables); weightsList.AddRange(lc.weights.Map(w => w * weight)); } else { decompList.Add(decomp); weightsList.Add(weight); } } return(new DecomposableLinearCombination(weightsList.ToArray(), decompList.ToArray())); }
public DateTime[] Visit(ICouponDecomposable couponDecomposable) { return(couponDecomposable.Decomposition().Aggregate(new DateTime[0], (allEventDates, cpn) => allEventDates.Union(cpn.Accept(this)).ToArray())); }
public IFixing[] Visit(ICouponDecomposable couponDecomposable) { var fixings = EnumerableUtils.Merge(couponDecomposable.Decomposition().Map(Visit)); return(fixings.OrderBy(f => f.Date).ToArray()); }
public PaymentInfo[] Visit(ICouponDecomposable couponDecomposable) { return(couponDecomposable.Decomposition().Aggregate(new PaymentInfo[0], (allPayments, cpn) => allPayments.Union(cpn.Accept(this)).ToArray())); }
public IProductPathFlow Visit(ICouponDecomposable couponDecomposable) { var couponFlows = BuildCouponPathFlow(couponDecomposable.Decomposition()); return(new CouponArrayPathFlow(couponFlows)); }