/// <summary> /// Parses the data. /// </summary> /// <param name="instrumentIds"></param> /// <param name="values"></param> /// <returns></returns> public static QuotedAssetSet Parse(string[] instrumentIds, decimal[] values) { var quotedAssetSetFactory = new QuotedAssetSetFactory(); for (int i = 0; i < instrumentIds.Length; i++) { Pair <Asset, BasicAssetValuation> assetPair = Parse(instrumentIds[i], values[i], null); quotedAssetSetFactory.AddAssetAndQuotes(assetPair.First, assetPair.Second); } return(quotedAssetSetFactory.Create()); }
/// <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 QuotedAssetSet Parse(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.Create()); }
/// <summary> /// Parses the data. /// </summary> /// <param name="instrumentIds"></param> /// <returns></returns> public static QuotedAssetSet Parse(string[] instrumentIds) { var quotedAssetSetFactory = new QuotedAssetSetFactory(); const string rateQuotationType = "MarketQuote"; for (var i = 0; i < instrumentIds.Length; i++) { Asset underlyingAsset; var instrumentId = instrumentIds[i]; var results = instrumentIds[i].Split('-'); var instrument = results[1]; var listBasicQuotations = new List <BasicQuotation>(); const string priceUnitDecimalRate = "DecimalRate"; switch (instrument) { case "ZeroRate": { underlyingAsset = new Cash { id = instrumentId }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "Xibor": case "OIS": { var tenor = results[2]; underlyingAsset = new RateIndex { id = instrumentId, term = Period.Parse(tenor) }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "IRSwap": case "XccySwap": case "SimpleIRSwap": { underlyingAsset = new SimpleIRSwap { id = instrumentId, term = Period.Parse(results[2]) }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "Deposit": case "XccyDepo": case "BankBill": { underlyingAsset = new Deposit { id = instrumentId, term = Period.Parse(results[2]) }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "SimpleFra": case "Fra": case "BillFra": { var index = results[3]; var asset = new SimpleFra { id = instrumentId, startTerm = Period.Parse(results[2]) }; asset.endTerm = asset.startTerm.Sum(Period.Parse(index)); underlyingAsset = asset; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "IRFuture": { underlyingAsset = new Future { id = instrumentId }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); listBasicQuotations.Add(BasicQuotationHelper.Create("Volatility", "LognormalVolatility")); break; } case "CPIndex": { var tenor = results[2]; underlyingAsset = new RateIndex { id = instrumentId, term = Period.Parse(tenor) }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } case "SimpleCPISwap": case "CPISwap": case "ZCCPISwap": { underlyingAsset = new SimpleIRSwap { id = instrumentId, term = Period.Parse(results[2]) }; listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate)); break; } default: throw new NotSupportedException(string.Format("Asset type {0} is not supported", instrument)); } quotedAssetSetFactory.AddAssetAndQuotes(underlyingAsset, Helpers.BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray())); } return(quotedAssetSetFactory.Create()); }