/// <summary> /// Parses the assetIdentifiers. /// </summary> /// <param name="assetIdentifiers"></param> /// <param name="values"></param> /// <param name="adjustments"></param> /// <returns></returns> public static FxRateSet ParseToFxRateSet(string[] assetIdentifiers, decimal[] values, decimal[] adjustments) { if (assetIdentifiers.Length != values.Length) { throw new ArgumentOutOfRangeException(nameof(values), "the rates do not match the number of assets"); } if (adjustments != null && assetIdentifiers.Length != adjustments.Length) { throw new ArgumentOutOfRangeException(nameof(values), "the rates do not match the number of assets"); } var quotedAssetSetFactory = new QuotedAssetSetFactory(); const string rateQuotationType = PriceableCommoditySpot.RateQuotationType; int index = 0; foreach (string assetIdentifier in assetIdentifiers) { var bav = new BasicAssetValuation { objectReference = new AnyAssetReference { href = assetIdentifier } }; var addOn = adjustments?[index] ?? 0.0m; var bqs = new List <BasicQuotation> { BasicQuotationHelper.Create(values[index] + addOn, rateQuotationType, "DecimalRate") }; bav.quote = bqs.ToArray(); quotedAssetSetFactory.AddAssetAndQuotes(Parse(assetIdentifier), bav); index++; } return(quotedAssetSetFactory.CreateFxRateSet()); }
/// <summary> /// Creates the specified assets in a quoted asset set. /// </summary> /// <param name="assetIdentifiers">The asset identifiers.</param> /// <param name="values">The adjusted rates.</param> /// <param name="measureTypes">The measure types. Currently supports MarketQuote and Volatility.</param> /// <param name="priceQuoteUnits">The price quote units. Currently supports Rates and LogNormalVolatility.</param> /// <param name="includeMarketQuoteValues">An include flag. If false, then the market quotes are set as null.</param> /// <returns></returns> public static FxRateSet ParseToFxRateSet(string[] assetIdentifiers, Decimal[] values, String[] measureTypes, String[] priceQuoteUnits, bool includeMarketQuoteValues) { if (assetIdentifiers.Length != values.Length && assetIdentifiers.Length != priceQuoteUnits.Length && assetIdentifiers.Length != measureTypes.Length) { throw new ArgumentOutOfRangeException(nameof(values), "the rates do not match the number of assets"); } var quotedAssetSetFactory = new QuotedAssetSetFactory(); foreach (string assetIdentifier in assetIdentifiers.Distinct()) { int index = 0; var bav = new BasicAssetValuation { objectReference = new AnyAssetReference { href = assetIdentifier } }; var bqs = new List <BasicQuotation>(); foreach (string ids in assetIdentifiers) { index++; if (ids != assetIdentifier) { continue; } BasicQuotation bq; if (measureTypes[index - 1] == AssetMeasureEnum.MarketQuote.ToString() && !includeMarketQuoteValues) { bq = BasicQuotationHelper.Create(measureTypes[index - 1], priceQuoteUnits[index - 1]); bqs.Add(bq); } else { bq = BasicQuotationHelper.Create(values[index - 1], measureTypes[index - 1], priceQuoteUnits[index - 1]); bqs.Add(bq); } } bav.quote = bqs.ToArray(); quotedAssetSetFactory.AddAssetAndQuotes(Parse(assetIdentifier), bav); } return(quotedAssetSetFactory.CreateFxRateSet()); }