/// <summary> /// Maps from a list of asset pairs to a quoted asset set. /// </summary> /// <param name="assetPairs"></param> /// <returns></returns> internal static QuotedAssetSet MapFromAssetPairs(ICollection <Pair <Asset, BasicAssetValuation> > assetPairs) { var quotedAssetSet = new QuotedAssetSet(); var assets = new Asset[assetPairs.Count]; var basicAssetValuations = new BasicAssetValuation[assetPairs.Count]; var types = new List <ItemsChoiceType19>(); var index = 0; foreach (var pair in assetPairs) { assets[index] = pair.First; basicAssetValuations[index] = pair.Second; var properties = new PriceableAssetProperties(assets[index].id); var assetTypeFpML = AssetTypeConvertor.ParseEnumStringToFpML(properties.AssetType.ToString()); types.Add(assetTypeFpML); index++; } quotedAssetSet.assetQuote = basicAssetValuations; var instrumentSet = new InstrumentSet { Items = assets.ToArray(), ItemsElementName = types.ToArray() }; quotedAssetSet.instrumentSet = instrumentSet; return(quotedAssetSet); }
/// <summary> /// Creates a quoted asset set without the asset type specified. /// </summary> /// <param name="assetType">The asset Type to remove.</param> /// <param name="assetSet">The original assetSet</param> /// <returns></returns> public static QuotedAssetSet RemoveAssetsFromQuotedAssetSet(AssetTypesEnum assetType, QuotedAssetSet assetSet) { var assets = new List <Asset>(); var quotes = new List <BasicAssetValuation>(); var types = new List <ItemsChoiceType19>(); var index = 0; foreach (var asset in assetSet.instrumentSet.Items) { var tempAssetType = new PriceableAssetProperties(asset.id).AssetType; if (tempAssetType != assetType) { assets.Add(asset); quotes.Add(assetSet.assetQuote[index]); if (assetSet.instrumentSet.ItemsElementName != null) { types.Add(assetSet.instrumentSet.ItemsElementName[index]); } else { var assetTypeFpML = AssetTypeConvertor.ParseEnumStringToFpML(tempAssetType.ToString()); types.Add(assetTypeFpML); } } index++; } var instrumentSet = new InstrumentSet { Items = assets.ToArray(), ItemsElementName = types.ToArray() }; return(new QuotedAssetSet { instrumentSet = instrumentSet, assetQuote = quotes.ToArray() }); }