Ejemplo n.º 1
0
        public AutocallPathFlow(CouponPathFlow[] underlyingPathFlows,
                                CouponPathFlow[] redemptionPathFlows,
                                FixingFuncPathValue[] triggers,
                                int[] underlyingCallIndexes)
        {
            Contract.Requires(redemptionPathFlows.Length == triggers.Length);
            Contract.Requires(underlyingCallIndexes.Length == triggers.Length);

            this.underlyingPathFlows   = underlyingPathFlows;
            this.redemptionPathFlows   = redemptionPathFlows;
            this.triggers              = triggers;
            this.underlyingCallIndexes = underlyingCallIndexes;

            var underlyingFixings = underlyingPathFlows.Map(pf => pf.PayoffPathValues.FixingFunction.Fixings);
            var redemptionFixings = redemptionPathFlows.Map(pf => pf.PayoffPathValues.FixingFunction.Fixings);
            var triggerFixings    = triggers.Map(pf => pf.FixingFunction.Fixings);

            Fixings = EnumerableUtils.Merge(underlyingFixings)
                      .MergeWith(redemptionFixings)
                      .MergeWith(triggerFixings);

            var underlyingLabels = underlyingPathFlows.Map(pf => pf.CouponLabel);
            var redemptionLabels = redemptionPathFlows.Map(pf => pf.CouponLabel);

            labels = EnumerableUtils.Append(underlyingLabels, redemptionLabels);

            var underlyingPayments = underlyingLabels.Map(l => l.Payment);
            var redemptionPayments = redemptionLabels.Map(l => l.Payment);

            Payments = EnumerableUtils.Append(underlyingPayments, redemptionPayments);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets a list of involved <see cref="IZincElement"/> instances that are the children of
 /// this <see cref="IZincElement"/>.
 /// </summary>
 /// <returns>
 /// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> instance of
 /// <see cref="IZincElement"/> that are the childrens of this <see cref="IZincBox"/> instance.
 /// </returns>
 public override IEnumerable <IZincElement> Children()
 {
     return(EnumerableUtils.Append(new IEnumerable <IZincElement>[] {
         this.annotations,
         this.typeInstExpressions,
         base.Children()
     }));
 }
Ejemplo n.º 3
0
 public Coupon[] Decomposition()
 {
     Coupon[][] weightedCoupons = weights.ZipWith(decomposables, (w, d) =>
     {
         var coupons = d.Decomposition();
         return(coupons.Map(cpn => new Coupon(cpn.PaymentInfo, new WeightedFixingFunction(w, cpn.Payoff))));
     });
     return(EnumerableUtils.Append(weightedCoupons));
 }
Ejemplo n.º 4
0
        private static Exception[] CollectAggregate(Exception exception)
        {
            var aggregateExcept = exception as AggregateException;

            if (aggregateExcept != null)
            {
                var inners = aggregateExcept.InnerExceptions.Map(CollectAggregate);
                return(EnumerableUtils.Append(inners));
            }
            return(new[] { exception });
        }
        public BlackScholesEquityPathGenerator(BsEqtySimulatorStepDatas[] stepDatas, double forward)
        {
            initialFwd = forward;

            pathDates = stepDatas.Map(step => step.Step.Sup);
            vols      = stepDatas.Map(step => step.Vols);
            varDrifts = stepDatas.Map(step => step.VarDrifts);
            discounts = stepDatas.Map(step => step.Discounts);
            divs      = stepDatas.Map(step => step.Dividends);

            AllSimulatedDates = EnumerableUtils.Append(stepDatas.Map(data => data.Dates));
        }
Ejemplo n.º 6
0
        public LocalVolEquityPathGenerator(LocalVolSimulatorStepDatas[] stepDatas, double forward)
        {
            initialFwd   = forward;
            localVols    = stepDatas.Map(step => step.LocalVols);
            logDiscounts = stepDatas.Map(step => step.Discounts.Map(Math.Log));
            divs         = stepDatas.Map(step => step.Dividends);
            isDivDates   = stepDatas.Map(step => step.IsDivDates);

            dts = stepDatas.Map(step =>
            {
                var stepDates = step.Dates;
                var stepDts   = new double[stepDates.Length];
                double prev   = step.Step.Inf;
                for (int i = 0; i < stepDts.Length; i++)
                {
                    stepDts[i] = stepDates[i] - prev;
                    prev       = stepDates[i];
                }
                return(stepDts);
            });

            Dates             = stepDatas.Map(step => step.Step.Sup);
            AllSimulatedDates = EnumerableUtils.Append(stepDatas.Map(data => data.Dates));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets a list of involved <see cref="IZincElement"/> instances that are the children of
 /// this <see cref="IZincElement"/>.
 /// </summary>
 /// <returns>
 /// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> instance of
 /// <see cref="IZincElement"/> that are the childrens of this <see cref="IZincBox"/> instance.
 /// </returns>
 public override IEnumerable <IZincElement> Children()
 {
     return(EnumerableUtils.Append(this.NumericExpression2, base.Children()));
 }
Ejemplo n.º 8
0
		/// <summary>
		/// Gets a list of involved <see cref="IZincElement"/> instances that are the children of
		/// this <see cref="IZincElement"/>.
		/// </summary>
		/// <returns>
		/// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> instance of
		/// <see cref="IZincElement"/> that are the childrens of this <see cref="IZincBox"/> instance.
		/// </returns>
		public override IEnumerable<IZincElement> Children () {
			return EnumerableUtils.Append (this.TypeInstExpression, base.Children ());
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Gets a list of involved <see cref="IZincElement"/> instances that are the children of
 /// this <see cref="IZincElement"/>.
 /// </summary>
 /// <returns>
 /// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> instance of
 /// <see cref="IZincElement"/> that are the childrens of this <see cref="IZincBox"/> instance.
 /// </returns>
 public override IEnumerable <IZincElement> Children()
 {
     return(EnumerableUtils.Append <IZincElement> ((IZincElement)this.annotations, base.Children()));
 }