private void SetProperties(NamedValueSet properties)
 {
     try
     {
         DataType     = "Trade";
         SourceSystem = PropertyHelper.ExtractSourceSystem(properties);
         var tradeId = properties.GetValue <string>(TradeProp.TradeId);
         Id               = tradeId;
         Domain           = SourceSystem + '.' + DataType;
         TradeDate        = properties.GetValue <DateTime>(TradeProp.TradeDate);
         TradeType        = EnumHelper.Parse <ItemChoiceType15>(properties.GetValue <string>(TradeProp.TradeType), true);
         ProductType      = ProductTypeSimpleScheme.ParseEnumString(properties.GetValue <string>(TradeProp.ProductType, false));
         Party1           = properties.GetValue <string>(TradeProp.Party1, false);
         Party2           = properties.GetValue <string>(TradeProp.Party2, false);
         BaseParty        = properties.GetValue <string>(TradeProp.BaseParty);
         CounterParty     = properties.GetValue <string>(TradeProp.CounterPartyId);
         UniqueIdentifier = BuildUniqueId(tradeId);
         if (properties.GetValue <string>(CurveProp.UniqueIdentifier) != null)
         {
             UniqueIdentifier = properties.GetValue <string>(CurveProp.UniqueIdentifier);
         }
         PropertyHelper.Update(Properties, CurveProp.UniqueIdentifier, UniqueIdentifier);
         PropertyHelper.Update(Properties, "Domain", Domain);
     }
     catch
     {
         throw new System.Exception("Invalid tradeid.");
     }
 }
Exemple #2
0
        private static void LoadFPMLTrades(
            ILogger logger,
            ICoreCache client,
            Assembly assembly,
            string sourceSystem)
        {
            logger.LogDebug("Loading FPML trades...");
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, ResourcePath + "." + sourceSystem, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException(String.Format("No trades found!"));
            }

            // load gwml-to-fpml mappings
            //EnumMaps enumMaps = client.LoadObject<EnumMaps>("Orion.Configuration.GwmlEnumMaps");
            //GwmlFpmlEnumMap gwmlFpmlEnumMap = new GwmlFpmlEnumMap(enumMaps);
            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                string fpmlText = file.Value;
                // convert gwml
                //var fpmlDoc = XmlSerializerHelper.DeserializeFromString<DataDocument>(fpmlText);
                var tradeConfirmed = XmlSerializerHelper.DeserializeFromString <RequestConfirmation>(fpmlText);
                var trade          = tradeConfirmed.trade;
                //Converter imp = new Converter(gwmlFpmlEnumMap);
                var tradeProps = new NamedValueSet();
                tradeProps.Set(TradeProp.AsAtDate, DateTime.Today);
                tradeProps.Set(TradeProp.TradeSource, sourceSystem);
                // Document fpmlDoc = imp.ToFpml(gwmlDoc, tradeProps);
                // get trade properties
                //Trade trade = (Trade)(((DataDocument)fpmlDoc).Items[0]);
                ProductTypeSimpleEnum productType = ProductTypeSimpleScheme.ParseEnumString(trade.Item.Items[0].ToString());//TODO fix this
                DateTime tradeDate = trade.tradeHeader.tradeDate.Value;
                // now we can set the actual item name correctly
                string fpmlTradeItemName = $"{sourceSystem}.Trade.{productType}.{trade.id}";
                //gwmlDocItemName = String.Format("{0}.GWML.{1}.{2}", sourceSystem, productType, trade.id);
                tradeProps.Set(TradeProp.TradeDate, tradeDate);
                tradeProps.Set(TradeProp.TradeId, trade.id);
                tradeProps.Set(TradeProp.ProductType, ProductTypeSimpleScheme.GetEnumString(productType));
                tradeProps.Set(TradeProp.TradeState, TradeState.Verified.ToString());
                client.SaveObject(trade, fpmlTradeItemName, tradeProps, false, TimeSpan.FromDays(30));
            } // foreach file
            logger.LogDebug("Loaded {0} FPML trades.", chosenFiles.Count);
        }
Exemple #3
0
        public static bool IsImplementedProductType(NamedValueSet tradeProps)
        {
            var productType = ProductTypeSimpleScheme.ParseEnumString(tradeProps.GetValue <string>(TradeProp.ProductType));

            return(IsImplementedProductType(productType));
        }