示例#1
0
        private static IdentifiedDate CreateIdentifiedDate(string id, DateTime value)
        {
            var identifiedDate = new IdentifiedDate {
                id = id, Value = value
            };

            return(identifiedDate);
        }
示例#2
0
        /// <summary>
        /// Converts to an identified date type.
        /// </summary>
        /// <param name="unadjustedDate"></param>
        /// <returns></returns>
        public static IdentifiedDate ToUnadjustedIdentifiedDate(DateTime unadjustedDate)
        {
            var result = new IdentifiedDate {
                Value = unadjustedDate, id = ItemsChoiceType.unadjustedDate.ToString()
            };

            return(result);
        }
        /// <summary>
        /// Create a grid from an array of names and complex array of data
        /// The data will contain strings and decimals
        /// </summary>
        /// <param name="pSettings">The settings object used to generate these SABR parameters</param>
        /// <param name="fields">The headers used to identify the SABR parameters</param>
        /// <param name="data">An array of SABR parameters and expiry/tenor pairs</param>
        /// <param name="valueDate">The valuation date</param>
        /// <param name="surfaceId">The id for this matrix</param>
        public SwaptionVolatilityMatrix(object[][] pSettings, string[] fields, object[][] data, DateTime valueDate, string surfaceId)
        {
            // Include a QuotedAssetSet to hold the Settings object used to generate this SABR parameters Matrix
            Settings = AssignSettings(pSettings);
            // Set the id for this matrix
            id = surfaceId;
            // Set the value date for this vol matrix
            baseDate = new IdentifiedDate {
                Value = valueDate
            };
            // Set the buildDate for this matrix
            buildDateTime = DateTime.Now;
            // Create the dataPoints structure. This will hold the matrix data
            dataPoints = new MultiDimensionalPricingData();
            var columns = fields.Length;
            var rows    = data.Length;

            dataPoints.point = new PricingStructurePoint[rows * IdentifierFieldCount];
            var point = 0;

            // Loop through the arrays to populate the underlying VolatilityMatrix
            for (var gRows = 0; gRows < rows; gRows++)
            {
                // Extract the expiry/tenor information for creating
                var expiry = PeriodHelper.Parse(data[gRows][0].ToString());
                var tenor  = PeriodHelper.Parse(data[gRows][1].ToString());
                for (var gCols = columns - IdentifierFieldCount; gCols < columns; gCols++)
                {
                    dataPoints.point[point] = new PricingStructurePoint {
                        coordinate = new PricingDataPointCoordinate[1]
                    };
                    // Set up the co-ordinate (Expiry/Term) for each point
                    dataPoints.point[point].coordinate[0] = new PricingDataPointCoordinate
                    {
                        expiration = new TimeDimension[1]
                    };
                    // Set the Expiry for the co-ordinate point
                    dataPoints.point[point].coordinate[0].expiration[0] = new TimeDimension
                    {
                        Items = new object[] { expiry }
                    };
                    // Set the Term for the co-ordinate point
                    dataPoints.point[point].coordinate[0].term    = new TimeDimension[1];
                    dataPoints.point[point].coordinate[0].term[0] = new TimeDimension {
                        Items = new object[] { tenor }
                    };
                    // Add the quotation characteristics for the point
                    // We will only record a value and the measure type
                    dataPoints.point[point].valueSpecified = true;
                    dataPoints.point[point].value          = Convert.ToDecimal(data[gRows][gCols]);
                    dataPoints.point[point].measureType    = new AssetMeasureType {
                        Value = fields[gCols]
                    };
                    point++;
                }
            }
        }
示例#4
0
        public static Payment Create(string identifier, bool pay, Money paymentAmount,
                                     DateTime adjustedPaymentDate, PaymentType paymentType,
                                     decimal discountFactor, Money presentValueAmount)
        {
            var payment = new Payment();
            var result  = new IdentifiedDate {
                Value = adjustedPaymentDate
            };

            payment.adjustedPaymentDate     = result;
            payment.discountFactor          = discountFactor;
            payment.discountFactorSpecified = true;
            payment.href = identifier;
            payment.payerPartyReference    = (pay) ? PartyOrAccountReferenceFactory.Create("CBA") : PartyOrAccountReferenceFactory.Create("");
            payment.paymentAmount          = paymentAmount;
            payment.paymentType            = paymentType;
            payment.presentValueAmount     = presentValueAmount;
            payment.receiverPartyReference = (pay) ? PartyOrAccountReferenceFactory.Create("") : PartyOrAccountReferenceFactory.Create("CBA");
            return(payment);
        }
示例#5
0
        public static Payment Create(string identifier, PartyOrAccountReference payerPartyReference,
                                     PartyOrAccountReference receiverPartyReference, Money paymentAmount,
                                     IdentifiedDate adjustedPaymentDate, SettlementInformation settlementInformation, PaymentType paymentType,
                                     decimal discountFactor, Money presentValueAmount)
        {
            var payment = new Payment
            {
                adjustedPaymentDate     = adjustedPaymentDate,
                discountFactor          = discountFactor,
                discountFactorSpecified = true,
                href = identifier,
                payerPartyReference    = payerPartyReference,
                paymentAmount          = paymentAmount,
                paymentType            = paymentType,
                presentValueAmount     = presentValueAmount,
                receiverPartyReference = receiverPartyReference,
                settlementInformation  = settlementInformation
            };

            return(payment);
        }
        /// <summary>
        /// Construct an FpML MultiDimensionalPricingData from the spreadsheet values
        /// </summary>
        /// <param name="headers">The columns to write</param>
        /// <param name="data">The values to store</param>
        /// <param name="settings">The settings used by this matrix</param>
        /// <param name="valueDate">The valuation date</param>
        /// <param name="surfaceId">The id of this surface</param>
        public CapFloorATMMatrix(string[] headers, object[][] data, object[][] settings, DateTime valueDate, string surfaceId)
            : this()
        {
            // Include a QuotedAssetSet to hold the Settings object used to generate this SABR parameters Matrix
            if (settings != null)
            {
                Settings = AssignSettings(settings);
            }
            id       = surfaceId;
            baseDate = new IdentifiedDate {
                Value = valueDate
            };
            var rows   = data.GetUpperBound(0) + 1;
            var points = new List <PricingStructurePoint>();
            int expiry = Find("Expiry", headers);
            int atm    = Find("ATM", headers);
            int type   = Find("Type", headers);
            int ppd    = Find("PPD", headers);

            for (int row = 0; row < rows; row++)
            {
                var point = new PricingStructurePoint();
                if (data[row][0] != null)
                {
                    // Populate each data point from the data array
                    for (var column = 0; column < headers.Length; column++)
                    {
                        object datum = data[row][column];
                        if (column == expiry)
                        {
                            // Add the coordinate value (the expiry)
                            var expiration = PeriodHelper.Parse(datum.ToString());
                            point.coordinate    = new PricingDataPointCoordinate[1];
                            point.coordinate[0] = new PricingDataPointCoordinate {
                                expiration = new TimeDimension[1]
                            };
                            point.coordinate[0].expiration[0] = new TimeDimension {
                                Items = new object[] { expiration }
                            };
                        }
                        else if (column == atm)
                        {
                            point.measureType = new AssetMeasureType {
                                Value = "ATM"
                            };
                            point.valueSpecified = true;
                            point.value          = Convert.ToDecimal(datum);
                        }
                        else if (column == ppd)
                        {
                            point.measureType = new AssetMeasureType {
                                Value = "PPD"
                            };
                            point.valueSpecified = true;
                            point.value          = Convert.ToDecimal(datum);
                        }
                        else if (column == type)
                        {
                            point.cashflowType = new CashflowType {
                                Value = datum.ToString()
                            };
                        }
                        else
                        {
                            throw new ArgumentException("Unknown column name: " + column);
                        }
                    }
                }
                points.Add(point);
            }
            dataPoints = new MultiDimensionalPricingData {
                point = points.ToArray()
            };
        }