public static PriceQuoteUnits Copy(PriceQuoteUnits quoteUnits) { return(new PriceQuoteUnits { Value = quoteUnits.Value }); }
public static BasicQuotation Create(AssetMeasureType measureType, PriceQuoteUnits priceUnits, string sideAsString) { ParseQuotationSideEnum(sideAsString, out var sideSpecified, out var side); return(new BasicQuotation { valueSpecified = false, measureType = measureType, quoteUnits = priceUnits, sideSpecified = sideSpecified, side = side }); }
/// <summary> /// Initializes a new instance of the <see cref="VolatilitySurfaceIdentifier"/> class. /// </summary> /// <param name="surfaceId">The surface id.</param> public VolatilitySurfaceIdentifier(string surfaceId) : base(surfaceId) { var volCurveId = surfaceId.Split('-'); Instrument = volCurveId[volCurveId.Length - 2]; UnderlyingAssetReference = new AssetReference { href = Instrument }; StrikeQuoteUnits = new PriceQuoteUnits { Value = PriceQuoteProp.Absolute }; //DecimalRate }
/// <summary> /// A helper to extract properties from a namedvalueset.. /// </summary> /// <param name="propertyCollection">The collection of properties.</param> public static PriceQuoteUnits ExtractStrikeQuoteUnits(NamedValueSet propertyCollection) { var priceQuoteUnits = new PriceQuoteUnits { Value = "Absolute" }; var dictionaryKeys = propertyCollection.ToDictionary(); if (dictionaryKeys.ContainsKey("StrikeQuoteUnits")) { var result = propertyCollection.Get("StrikeQuoteUnits").AsValue <string>(); priceQuoteUnits.Value = result; } return(priceQuoteUnits); }
/// <summary> /// A helper to extract properties from a namedvalueset.. /// </summary> /// <param name="propertyCollection">The collection of properties.</param> public static PriceQuoteUnits ExtractQuoteUnits(NamedValueSet propertyCollection) { PriceQuoteUnits priceQuoteUnits = null; var dictionaryKeys = propertyCollection.ToDictionary(); if (dictionaryKeys.ContainsKey("QuoteUnits")) { var result = propertyCollection.Get("QuoteUnits").AsValue <string>(); priceQuoteUnits = new PriceQuoteUnits { Value = result }; } return(priceQuoteUnits); }
/// <summary> /// Initializes a new instance of the <see cref="VolatilitySurfaceIdentifier"/> class. /// </summary> /// <param name="pricingStructureType"></param> /// <param name="curveName"></param> /// <param name="baseDate"></param> /// <param name="algorithm"></param> public VolatilitySurfaceIdentifier(PricingStructureTypeEnum pricingStructureType, string curveName, DateTime baseDate, string algorithm) : base(pricingStructureType, curveName, baseDate, algorithm) { var volCurveId = CurveName.Split('-'); Currency = CurrencyHelper.Parse(volCurveId[0]); Instrument = volCurveId[volCurveId.Length - 2]; UnderlyingAssetReference = new AssetReference { href = Instrument }; StrikeQuoteUnits = new PriceQuoteUnits { Value = PriceQuoteProp.Absolute }; //DecimalRate }
///<summary> /// A swaption ppd grid. ///</summary> ///<param name="rows"></param> ///<param name="cols"></param> ///<param name="data"></param> public SwaptionPPDGrid(string[] rows, string[] cols, object[][] data) : this() { measureType = new AssetMeasureType { Value = "PPD" }; quoteUnits = new PriceQuoteUnits { Value = "points" }; // build the co-ordinate tree.. data[row][column] // row = expiry, column = tenor var points = new List <PricingStructurePoint>(); for (int row = 0; row < rows.Length; row++) { for (int col = 0; col < cols.Length; col++) { if (data[row][col] != null) { var currentPoint = new PricingStructurePoint { coordinate = new PricingDataPointCoordinate[1] }; // Set up the coordinate for this point currentPoint.coordinate[0] = new PricingDataPointCoordinate { expiration = new TimeDimension[1] }; // The row - Expiry currentPoint.coordinate[0].expiration[0] = new TimeDimension { Items = new object[] { PeriodHelper.Parse(rows[row]) } }; // The column - Tenor currentPoint.coordinate[0].term = new TimeDimension[1]; currentPoint.coordinate[0].term[0] = new TimeDimension { Items = new object[] { PeriodHelper.Parse(cols[col]) } }; // The data value currentPoint.valueSpecified = true; currentPoint.value = Convert.ToDecimal(data[row][col]); points.Add(currentPoint); } } } point = points.ToArray(); }
/// <summary> /// Generate an array of PricingStructurePoint from a set of input arrays /// The array can then be added to the Matrix /// </summary> /// <param name="expiry">Expiry values to use</param> /// <param name="strike">Strike values to use</param> /// <param name="volatility">An array of volatility values</param> /// <param name="strikeQuoteUnits">The strike quote units.</param> /// <param name="underlyingAssetReference">The underlying asset.</param> /// <returns></returns> private PricingStructurePoint[] ProcessRawSurface(String[] expiry, Double[] strike, double[,] volatility, PriceQuoteUnits strikeQuoteUnits, AssetReference underlyingAssetReference) { var expiryLength = expiry.Length; var strikeLength = strike.Length; var pointIndex = 0; var points = new PricingStructurePoint[expiryLength * strikeLength]; for (var expiryIndex = 0; expiryIndex < expiryLength; expiryIndex++) { // extract the current expiry var expiryKeyPart = expiry[expiryIndex]; for (var strikeIndex = 0; strikeIndex < strikeLength; strikeIndex++) { // Extract the strike to use in the helper key var strikeKeyPart = strike[strikeIndex]; // extract the current tenor (term) of null if there are no tenors // Extract the row,column indexed volatility var vol = (decimal)volatility[expiryIndex, strikeIndex]; var key = new ExpiryTenorStrikeKey(expiryKeyPart, strikeKeyPart); _matrixIndexHelper.Add(key, pointIndex); // Add the value to the points array (dataPoints entry in the matrix) var coordinates = new PricingDataPointCoordinate[1]; coordinates[0] = PricingDataPointCoordinateFactory.Create(expiry[expiryIndex], null, (Decimal)strike[strikeIndex]); var pt = new PricingStructurePoint { value = vol, valueSpecified = true, coordinate = coordinates, underlyingAssetReference = underlyingAssetReference, quoteUnits = strikeQuoteUnits }; points[pointIndex++] = pt; } } return(points); }
private static PricingStructurePoint[] ProcessRawSurface(string[] expiries, string[] tenors, decimal[] strikes, decimal[,] volatility, PriceQuoteUnits strikeQuoteUnits, AssetReference underlyingAssetReference) { var expiryLength = expiries.Length; var strikeLength = strikes.Length; var tenorLength = tenors.Length; var points = new List <PricingStructurePoint>(); for (var expiryIndex = 0; expiryIndex < expiryLength; expiryIndex++) { for (var strikeIndex = 0; strikeIndex < strikeLength; strikeIndex++) { for (var tenorIndex = 0; tenorIndex < tenorLength; tenorIndex++) { // Extract the row,column indexed volatility var vol = volatility[expiryIndex + tenorIndex * expiryLength, strikeIndex]; // Add the value to the points array (dataPoints entry in the matrix) var coordinates = new PricingDataPointCoordinate[1]; coordinates[0] = PricingDataPointCoordinateFactory.Create(expiries[expiryIndex], tenors[tenorIndex], strikes[strikeIndex]); var point = new PricingStructurePoint { value = vol, valueSpecified = true, coordinate = coordinates, underlyingAssetReference = underlyingAssetReference, quoteUnits = strikeQuoteUnits }; points.Add(point); } } } return(points.ToArray()); }