Beispiel #1
0
        public static void BuildBothTrades(ILogger logger, ICoreCache targetClient, string nameSpace, FpML.V5r3.Confirmation.Trade tradeVersion, FpML.V5r3.Confirmation.Party[] party)
        {
            var extraProps = new NamedValueSet();
            var party1     = party[0].partyId[0].Value;
            var party2     = party[1].partyId[0].Value;

            extraProps.Set(TradeProp.Party1, party1);
            extraProps.Set(TradeProp.Party2, party2);
            extraProps.Set(TradeProp.TradeDate, tradeVersion.tradeHeader.tradeDate.Value);
            extraProps.Set(TradeProp.TradingBookName, "Test");
            FpML.V5r3.Confirmation.TradeId tradeId;
            if (tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[1] is FpML.V5r3.Confirmation.VersionedTradeId tempId)
            {
                tradeId = tempId.tradeId;
                extraProps.Set(TradeProp.TradeId, tradeId.Value);
            }
            else
            {
                tradeId = tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[1] as FpML.V5r3.Confirmation.TradeId ??
                          new FpML.V5r3.Confirmation.TradeId {
                    Value = "temp001"
                };
                extraProps.Set(TradeProp.TradeId, tradeId.Value);
            }
            //tradeId = (TradeId)tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[0];
            extraProps.Set(TradeProp.TradeState, "Pricing");
            //extraProps.Set("TradeType", "Deposit");
            extraProps.Set(TradeProp.TradeSource, "FPMLSamples");
            extraProps.Set(TradeProp.BaseParty, TradeProp.Party1);        //party1
            extraProps.Set(TradeProp.CounterPartyName, TradeProp.Party2); //party2
            extraProps.Set(TradeProp.AsAtDate, DateTime.Today);
            var product   = tradeVersion.Item;
            var tradeType = TradeTypeHelper(product);

            extraProps.Set(TradeProp.TradeType, tradeType);
            extraProps.Set(TradeProp.ProductType, tradeType);//TODO this should be a product type...
            //Get the required currencies
            //1. need to convert to Reporting namespace, where the functionality exists.
            var xml            = XmlSerializerHelper.SerializeToString(tradeVersion);
            var newxml         = xml.Replace("FpML-5/confirmation", "FpML-5/reporting");
            var reportingTrade = XmlSerializerHelper.DeserializeFromString <Trade>(newxml);
            var currencies     = reportingTrade.Item.GetRequiredCurrencies().ToArray();
            var curveNames     = reportingTrade.Item.GetRequiredPricingStructures().ToArray();

            extraProps.Set(TradeProp.RequiredCurrencies, currencies);
            extraProps.Set(TradeProp.RequiredPricingStructures, curveNames);
            string   idSuffix = $"{tradeType}.{tradeId.Value}";
            ItemInfo itemInfo = MakeConfirmationTradeProps("Trade", idSuffix, extraProps, nameSpace);

            logger.LogDebug("  {0} ...", idSuffix);
            targetClient.SaveObject(tradeVersion, itemInfo.ItemName, itemInfo.ItemProps, false, TimeSpan.MaxValue);
            ItemInfo itemInfo2 = MakeReportingTradeProps("Trade", idSuffix, extraProps, nameSpace);

            logger.LogDebug("  {0} ...", idSuffix);
            targetClient.SaveObject(reportingTrade, itemInfo2.ItemName, itemInfo2.ItemProps, false, TimeSpan.MaxValue);
        }
Beispiel #2
0
        public static void LoadPricingStructures(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading pricing structures...");
            Assembly     assembly = Assembly.GetExecutingAssembly();
            const string prefix   = "FpML.V5r10.ConfigData.PricingStructures";
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException("Missing Pricing Structures");
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                var    market     = XmlSerializerHelper.DeserializeFromString <Market>(file.Value);
                string nvs        = ResourceHelper.GetResource(assembly, file.Key.Replace(".xml", ".nvs"));
                var    extraProps = new NamedValueSet(nvs);
                string idSuffix   =
                    $"{extraProps.GetValue<string>(CurveProp.Market)}.{extraProps.GetValue<string>(CurveProp.PricingStructureType)}.{extraProps.GetValue<string>(CurveProp.CurveName)}";
                ItemInfo itemInfo = MakePricingStructureConfigProps("PricingStructures", idSuffix, extraProps, nameSpace);
                logger.LogDebug("  {0} ...", idSuffix);
                targetClient.SaveObject(market, itemInfo.ItemName, itemInfo.ItemProps, false, TimeSpan.MaxValue);
            } // foreach file
            logger.LogDebug("Loaded {0} pricing structures.", chosenFiles.Count);
        }
        public static void LoadProviderRules(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading market data provider rules...");
            const string itemType = "MarketData.ProviderRules";
            int          count    = 0;
            Assembly     assembly = Assembly.GetExecutingAssembly();
            const string prefix   = "FpML.V5r10.ConfigData.ProviderRuleSets";
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException("Missing  market data provider rules!");
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                var           ruleSet    = XmlSerializerHelper.DeserializeFromString <ProviderRuleSet>(file.Value);
                MDSProviderId providerId = ruleSet.provider;
                logger.LogDebug("  Loading {0} ...", providerId);
                var itemProps = new NamedValueSet();
                itemProps.Set(EnvironmentProp.DataGroup, "Orion.V5r10.Configuration." + itemType);
                itemProps.Set(EnvironmentProp.SourceSystem, "Orion");
                itemProps.Set(EnvironmentProp.Function, FunctionProp.Configuration.ToString());
                itemProps.Set(EnvironmentProp.Type, itemType);
                itemProps.Set(EnvironmentProp.Schema, "V5r10.Reporting");
                itemProps.Set(EnvironmentProp.NameSpace, nameSpace);
                string itemName = String.Format(nameSpace + ".Configuration.{0}.{1}", itemType, providerId);
                targetClient.SaveObject(ruleSet, itemName, itemProps, false, TimeSpan.MaxValue);
                count++;
            }
            logger.LogDebug("Loaded {0} market data provider rule sets", count);
        }
Beispiel #4
0
        public static void LoadTrades2(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading trades...");
            var schemaSet = FpMLViewHelpers.GetSchemaSet();
            var results   = TestHelper.LoadAndReturnConfirmationExamples(
                schemaSet, FpMLViewHelpers.AutoDetectType,
                new CustomXmlTransformer(FpMLViewHelpers.GetIncomingConversionMap()),
                new CustomXmlTransformer(FpMLViewHelpers.GetOutgoingConversionMap()),
                false, false, false);

            foreach (var document in results)
            {
                var extraProps = new NamedValueSet();
                extraProps.Set(TradeProp.TradingBookName, "Test");
                extraProps.Set(TradeProp.TradeState, "Confirmed");
                //extraProps.Set("TradeType", "Deposit");
                extraProps.Set(TradeProp.TradeSource, "FPMLSamples");
                extraProps.Set(TradeProp.AsAtDate, DateTime.Today);
                extraProps.Set("Namespace", "Confirmation");
                ItemInfo itemInfo = MakeTradeProps(document.GetType().ToString(), null, extraProps, nameSpace);
                logger.LogDebug("  {0} ...", itemInfo.ItemName);
                targetClient.SaveObject(document, itemInfo.ItemName, itemInfo.ItemProps, false, TimeSpan.MaxValue);
            } // foreach file
            //as TradeConfirmed
            logger.LogDebug("Loaded {0} trades.", results.Count());
        }
        //public static string GetExpectedResults(string resourceFileName)
        //{
        //    Assembly assembly = Assembly.GetExecutingAssembly();
        //    return ResourceHelper.GetResource(assembly, ResourcePath + ".ExpectedResults." + resourceFileName);
        //}

        private static void LoadFiles <T>(
            ILogger logger,
            ICoreCache client,
            Assembly assembly,
            string filenamePrefix) where T : class
        {
            logger.LogDebug("Loading {0} files...", typeof(T).Name);
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, ResourcePath + "." + filenamePrefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException($"No {typeof(T).Name} files found!");
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                var    curve     = XmlSerializerHelper.DeserializeFromString <T>(file.Value);
                string nvs       = ResourceHelper.GetResource(assembly, file.Key.Replace(".xml", ".nvs"));
                var    itemProps = new NamedValueSet(nvs);
                // strip assembly prefix
                string itemName = file.Key.Substring(ResourcePath.Length + 1);
                // strip file extension
                itemName = itemName.Substring(0, itemName.Length - 4);
                logger.LogDebug("  {0} ...", itemName);
                client.SaveObject(curve, itemName, itemProps, TimeSpan.MaxValue);
            } // foreach file
            logger.LogDebug("Loaded {0} {1} files...", chosenFiles.Count, typeof(T).Name);
        }
Beispiel #6
0
        public static void Load(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading trade import rules...");
            // generate import rules
            var rules = new List <TradeImportRule>
            {
                MakeTradeImportRule(
                    "TradeImporter",
                    false,                    // rule enabled
                    "13142,14859,126636,1637" // Barclays, Woolworths, Fix bill line, nab swaps
                    )
            };

            // build rules

            // save Import rules
            foreach (TradeImportRule rule in rules)
            {
                logger.LogDebug("  Loading {0} ...", rule.RuleName);
                rule.NameSpace = nameSpace;
                TimeSpan lifetime = rule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
                targetClient.SaveObject(rule, lifetime);
            }

            logger.LogDebug("Loaded {0} trade import rules.", rules.Count);
        }
Beispiel #7
0
        public static void LoadTradeData(ILogger logger, ICoreCache client, string nameSpace)
        {
            Assembly     assembly = Assembly.GetExecutingAssembly();
            const string prefix   = "FpML.V5r10.ConfigData.Config.Trade";

            logger.LogDebug("Loading {0} files...", typeof(Trade).Name);
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException($"No {typeof(Trade).Name} files found!");
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                var    curve     = XmlSerializerHelper.DeserializeFromString <Document>(file.Value);
                string nvs       = ResourceHelper.GetResource(assembly, file.Key.Replace(".xml", ".nvs"));
                var    itemProps = new NamedValueSet(nvs);
                // strip assempbly prefix
                string itemName = file.Key.Substring(ResourcePath.Length + 1);
                // strip file extension
                itemProps.Set(EnvironmentProp.NameSpace, nameSpace);
                itemProps.Set(EnvironmentProp.Function, FunctionProp.Trade.ToString());
                itemName = nameSpace + itemName.Substring(19, itemName.Length - 23);
                logger.LogDebug("  {0} ...", itemName);
                client.SaveObject(curve, itemName, itemProps, TimeSpan.MaxValue);
            } // foreach file
            logger.LogDebug("Loaded {0} {1} files...", chosenFiles.Count, typeof(Bond).Name);
        }
        public static void Load(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            //logger.LogDebug("Deleting service host rules...");
            //targetClient.Proxy.DeleteObjects<HostConfigRule>(Expr.ALL);

            logger.LogDebug("Loading service host rules...");
            // generate rules
            var rules = new List <HostConfigRule>();

            AddRuleSet(EnvId.Dev_Development, "sydwadqds01", "Release", rules);
            AddRuleSet(EnvId.Sit_SystemTest, "sydwadqds01", "Release", rules);
            AddRuleSet(EnvId.Stg_StagingLive, "sydwadbrl01", "Release", rules);
            //AddRuleSet(EnvId.PRD_Production, "unknown", "Release", rules);

            // unit test rules
            AddRuleSetUnitTest("Debug", rules);
            AddRuleSetUnitTest("Release", rules);

            // specific developer rules
            AddRuleSetSydwCndb12S("Debug", rules);
            AddRuleSetSydwCndb12S("Release", rules);

            AddRuleSetSydw7Jxjz1S("Debug", rules);
            AddRuleSetSydw7Jxjz1S("Release", rules);

            // save rules
            foreach (HostConfigRule rule in rules)
            {
                rule.NameSpace = nameSpace;
                TimeSpan lifetime = rule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
                targetClient.SaveObject(rule, lifetime);
            }
            logger.LogDebug("Loaded service host rules.");
        }
        public static void LoadInstrumentsConfig(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            string xml      = GetXml("Orion.V5r3.Configuration.Config.Instruments.xml");
            var    assetSet = XmlSerializerHelper.DeserializeFromString <AssetSetConfiguration>(xml);

            foreach (Instrument instrument in assetSet.Instruments)
            {
                string id = instrument.Currency.Value;
                if (instrument.AssetType == "Lease")
                {
                    var assetId = id + '-' + instrument.AssetType;
                    if (instrument.ExtraItem != null)
                    {
                        id = id + "." + instrument.ExtraItem;
                    }
                    ItemInfo itemInfo =
                        StandardConfigProps("Instrument", instrument.AssetType + '.' + id, nameSpace); //id
                    itemInfo.ItemProps.Set(CurveProp.Currency1, instrument.Currency.Value);
                    itemInfo.ItemProps.Set("AssetType", instrument.AssetType);
                    itemInfo.ItemProps.Set("AssetId", assetId);
                    itemInfo.ItemProps.Set("Schema", "FpML.V5r3");
                    if (instrument.ExtraItem != null)
                    {
                        itemInfo.ItemProps.Set("ExtraItem", instrument.ExtraItem);
                    }
                    targetClient.SaveObject(instrument, itemInfo.ItemName, itemInfo.ItemProps);
                }
            }
            logger.LogDebug("Loaded instrument configs.");
        }
Beispiel #10
0
        public string CreateFraValuationReport(ICoreCache cache, string nameSpace, string id, string baseParty, Fra fra, Market market, AssetValuation assetValuation, NamedValueSet properties)
        {
            ValuationReport valuationReport = ValuationReportGenerator.Generate(id, baseParty, fra, market, assetValuation);

            cache.SaveObject(valuationReport, nameSpace + "." + id, properties);
            return(id);
        }
        /// <summary>
        /// Publishes the curve and properties
        /// </summary>
        /// <param name="market"></param>
        /// <param name="uniqueIdentifier"></param>
        /// <param name="curveProperties"></param>
        /// <param name="publishPropertiesRange"></param>
        public void Publish(Market market, string uniqueIdentifier, NamedValueSet curveProperties, object[][] publishPropertiesRange)
        {
            NamedValueSet publishProperties = publishPropertiesRange.ToNamedValueSet();
            TimeSpan      lifetime          = GetLifetime(publishProperties);

            Cache.SaveObject(market, NameSpace + "." + uniqueIdentifier, curveProperties, lifetime);
        }
Beispiel #12
0
        public string CreateTradeValuationReport(ICoreCache cache, string nameSpace, string id, string party1, string party2, bool isParty1Base, Trade trade, Market market, AssetValuation assetValuation, NamedValueSet properties)
        {
            ValuationReport valuationReport = ValuationReportGenerator.Generate(id, party1, party2, isParty1Base, trade, market, assetValuation);

            cache.SaveObject(valuationReport, nameSpace + "." + id, properties);
            return(id);
        }
Beispiel #13
0
        public static void LoadFixedIncomeData(ILogger logger, ICoreCache client)
        {
            Assembly     assembly = Assembly.GetExecutingAssembly();
            const string prefix   = "Orion.Configuration.Config.FixedIncome";

            logger.LogDebug("Loading {0} files...", typeof(Bond).Name);
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException(String.Format("No {0} files found!", typeof(Bond).Name));
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                var    curve     = XmlSerializerHelper.DeserializeFromString <Bond>(file.Value);
                string nvs       = ResourceHelper.GetResource(assembly, file.Key.Replace(".xml", ".nvs"));
                var    itemProps = new NamedValueSet(nvs);
                // strip assempbly prefix
                string itemName = file.Key.Substring(ResourcePath.Length + 1);
                // strip file extension
                itemName = "Orion.ReferenceData." + itemName.Substring(19, itemName.Length - 23);
                logger.LogDebug("  {0} ...", itemName);
                client.SaveObject(curve, itemName, itemProps, TimeSpan.MaxValue);
            } // foreach file
            logger.LogDebug("Loaded {0} {1} files...", chosenFiles.Count(), typeof(Bond).Name);
        }
Beispiel #14
0
        public string LoadFromFile(ICoreCache cache, string filename)
        {
            var valuationReport =
                XmlSerializerHelper.DeserializeFromFile <ValuationReport>(typeof(Document), filename);

            cache.SaveObject(valuationReport, "someId", null);
            return("Valuation successfully loaded.");
        }
        /// <summary>
        /// Publishes the curve and properties
        /// </summary>
        /// <param name="market"></param>
        /// <param name="uniqueIdentifier"></param>
        /// <param name="curveProperties"></param>
        /// <param name="publishPropertiesRange"></param>
        public void Publish(Market market, string uniqueIdentifier, NamedValueSet curveProperties, object[][] publishPropertiesRange)
        {
            NamedValueSet publishProperties = publishPropertiesRange.ToNamedValueSet();
            TimeSpan      lifetime          = GetLifetime(publishProperties);

            Cache.SaveObject(market, NameSpace + "." + uniqueIdentifier, curveProperties, lifetime);
            Global.LoggerRef.Target.LogInfo("Published '{0}'.", uniqueIdentifier);
        }
Beispiel #16
0
        public string CacheFraTrade(ILogger logger, ICoreCache cache, string fraId, FraInputRange fraInputRange)
        {
            var fra   = ProductFactory.GetFpMLFra(fraInputRange);
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            cache.SaveObject(trade, fraId, null);
            return(fraId);
        }
        private static void BuildTrade(ILogger logger, ICoreCache targetClient, string nameSpace, Trade tradeVersion, Party[] party)
        {
            var extraProps = new NamedValueSet();
            var party1     = party[0].Items?[0] as PartyId;
            var party2     = party[1].Items?[0] as PartyId;

            if (party1 != null)
            {
                extraProps.Set(TradeProp.Party1, party1.Value);
            }
            if (party2 != null)
            {
                extraProps.Set(TradeProp.Party2, party2.Value);
            }
            //if (party2 != null) extraProps.Set(TradeProp.CounterPartyId, party2.Value); //Redundant
            //if (party1 != null) extraProps.Set(TradeProp.OriginatingPartyId, party1.Value); //Redundant
            extraProps.Set(TradeProp.TradeDate, tradeVersion.tradeHeader.tradeDate.Value);
            extraProps.Set(TradeProp.TradingBookName, "Test");
            TradeId tradeId;

            if (tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[1] is VersionedTradeId tempId)
            {
                tradeId = tempId.tradeId;
                extraProps.Set(TradeProp.TradeId, tradeId.Value);
            }
            else
            {
                tradeId = tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[1] as TradeId ??
                          new TradeId {
                    Value = "temp001"
                };
                extraProps.Set(TradeProp.TradeId, tradeId.Value);
            }
            //tradeId = (TradeId)tradeVersion.tradeHeader.partyTradeIdentifier[0].Items[0];
            extraProps.Set(TradeProp.TradeState, "Pricing");
            //extraProps.Set("TradeType", "Deposit");
            extraProps.Set(TradeProp.TradeSource, "FPMLSamples");
            extraProps.Set(TradeProp.BaseParty, TradeProp.Party1);        //party1
            extraProps.Set(TradeProp.CounterPartyName, TradeProp.Party2); //party2
            extraProps.Set(TradeProp.AsAtDate, DateTime.Today);
            var product   = tradeVersion.Item;
            var tradeType = TradeTypeHelper(product);

            extraProps.Set(TradeProp.TradeType, tradeType);
            extraProps.Set(TradeProp.ProductType, tradeType);//TODO this should be a product type...
            //Get the required currencies
            var currencies = tradeVersion.Item.GetRequiredCurrencies().ToArray();
            var curveNames = tradeVersion.Item.GetRequiredPricingStructures().ToArray();

            extraProps.Set(TradeProp.RequiredCurrencies, currencies);
            extraProps.Set(TradeProp.RequiredPricingStructures, curveNames);
            string   idSuffix  = $"{tradeType}.{tradeId.Value}";
            ItemInfo itemInfo2 = MakeReportingTradeProps("Trade", idSuffix, extraProps, nameSpace);

            logger.LogDebug("  {0} ...", idSuffix);
            targetClient.SaveObject(tradeVersion, itemInfo2.ItemName, itemInfo2.ItemProps, false, TimeSpan.MaxValue);
        }
        public static void LoadBoundaryRider(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            string   xml = GetXml("Orion.V5r3.Configuration.Config.BoundaryRiderMappingVals.xml");
            var      boundaryRiderMappings = XmlSerializerHelper.DeserializeFromString <BoundaryRiderMappings>(xml);
            ItemInfo itemInfo = StandardConfigProps("BoundaryRiderMappingVals", null, nameSpace);

            targetClient.SaveObject(boundaryRiderMappings, itemInfo.ItemName, itemInfo.ItemProps);
            logger.LogDebug("Loaded BoundaryRider mappings.");
        }
        public static void LoadGwml(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            string xml = GetXml("Orion.Configuration.Config.GwmlEnumMaps.xml");

            var      enumMaps = XmlSerializerHelper.DeserializeFromString <EnumMaps>(xml);
            ItemInfo itemInfo = StandardConfigProps("GwmlEnumMaps", null, nameSpace);

            targetClient.SaveObject(enumMaps, itemInfo.ItemName, itemInfo.ItemProps);
            logger.LogDebug("Loaded GWML enum maps.");
        }
Beispiel #20
0
        private static void HandleSpecificRequest <R, W>(ILogger logger, ICoreCache cache, string requestItemName)
            where R : RequestBase
            where W : WorkstepBase <RequestBase, HandlerResponse>, IRequestHandler <RequestBase, HandlerResponse>, new()
        {
            R request = cache.LoadObject <R>(requestItemName);

            if (request == null)
            {
                throw new ApplicationException(String.Format("Request not found (type={0},name='{1}')", typeof(R).Name, requestItemName));
            }

            // publish 'initial' status
            HandlerResponse response = new HandlerResponse()
            {
                RequestId    = request.RequestId,
                RequesterId  = request.RequesterId,
                Status       = RequestStatusEnum.Commencing,
                CommenceTime = DateTimeOffset.Now.ToString("o")
            };

            cache.SaveObject <HandlerResponse>(response);
            try
            {
                using (IRequestHandler <RequestBase, HandlerResponse> handler = new W() as IRequestHandler <RequestBase, HandlerResponse>)
                {
                    handler.InitialiseRequest(logger, cache);
                    handler.ProcessRequest(request, response);
                }
            }
            catch (OperationCanceledException cancelExcp)
            {
                response.Status       = RequestStatusEnum.Cancelled;
                response.CancelReason = cancelExcp.Message;
            }
            catch (Exception outerExcp)
            {
                response.Status      = RequestStatusEnum.Faulted;
                response.FaultDetail = new ExceptionDetail(outerExcp);
                logger.Log(outerExcp);
            }
            // publish 'completed' status
            cache.SaveObject <HandlerResponse>(response);
        }
Beispiel #21
0
 public static void DispatchToWorker(ICoreCache cache, RequestBase request, string workerHostComputer, string workerHostInstance)
 {
     cache.SaveObject(new AssignedWorkflowRequest(request)
     {
         RequestDataType    = request.GetType().FullName,
         RequestItemName    = request.NetworkKey,
         WorkerHostComputer = workerHostComputer,
         WorkerHostInstance = workerHostInstance
     });
 }
Beispiel #22
0
 public static void TransferToWorker(ICoreCache cache, UnassignedWorkflowRequest request, string workerHostComputer, string workerHostInstance)
 {
     cache.SaveObject(new AssignedWorkflowRequest(request)
     {
         RequestDataType    = request.RequestDataType,
         RequestItemName    = request.RequestItemName,
         WorkerHostComputer = workerHostComputer,
         WorkerHostInstance = workerHostInstance
     });
 }
Beispiel #23
0
        public static void LoadNewHolidayDates(ILogger logger, ICoreCache targetClient)
        {
            Assembly     assembly = Assembly.GetExecutingAssembly();
            const string prefix   = "Orion.Configuration.Config.HolidayDates";
            Dictionary <string, string> chosenFiles = ResourceHelper.GetResources(assembly, prefix, "xml");

            if (chosenFiles.Count == 0)
            {
                throw new InvalidOperationException("Missing Date Rules");
            }

            foreach (KeyValuePair <string, string> file in chosenFiles)
            {
                // load daterules from file
                var calendarYears      = XmlSerializerHelper.DeserializeFromString <LocationCalendarYears>(file.Value);
                var businessCenterList = new Dictionary <string, BusinessCenterCalendar>();

                foreach (LocationCalendarYear locationCalendarYear in calendarYears.LocationCalendarYear)
                {
                    BusinessCenterCalendar result;
                    var contains = businessCenterList.TryGetValue(locationCalendarYear.BusinessCenter, out result);
                    if (!contains)
                    {
                        var bc = new BusinessCenterCalendar
                        {
                            BusinessCenter = locationCalendarYear.BusinessCenter,
                            Location       = locationCalendarYear.RDMLocation,
                            LocationName   = locationCalendarYear.LocationName,
                            Holidays       = locationCalendarYear.Holidays
                        };
                        businessCenterList.Add(bc.BusinessCenter, bc);
                    }
                    else
                    {
                        if (locationCalendarYear.Holidays != null)// && result.Holidays != null)
                        {
                            var holidays = new List <DateRule>();
                            if (result.Holidays != null)
                            {
                                holidays = new List <DateRule>(result.Holidays);
                            }
                            holidays.AddRange(locationCalendarYear.Holidays);//Test if null
                            result.Holidays = holidays.ToArray();
                        }
                    }
                }
                foreach (var center in businessCenterList)
                {
                    ItemInfo itemInfo = BusinessCenterHolidayConfigProps(center.Value);
                    targetClient.SaveObject(center.Value, itemInfo.ItemName, itemInfo.ItemProps);
                    logger.LogDebug("Loaded business center holiday dates: {0}", itemInfo.ItemName);
                }
            }
            logger.LogDebug("Loaded business center holiday dates.");
        }
Beispiel #24
0
        public string CreateSwapValuationReport(ICoreCache cache, string nameSpace, string valuationId, string baseParty,
                                                string tradeId, DateTime tradeDate,
                                                Swap swap, Market market, AssetValuation assetValuation)
        {
            ValuationReport valuationReport = ValuationReportGenerator.Generate(valuationId, baseParty,
                                                                                tradeId, tradeDate,
                                                                                swap, market, assetValuation);

            cache.SaveObject(valuationReport, nameSpace + "." + valuationId, null);
            return(valuationId);
        }
Beispiel #25
0
        public static void Load(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            logger.LogDebug("Loading alert rules...");

            // defaults
            // - check constraint: time of day is between 2am and 11pm 7 days a week
            IExpression defaultCheckConstraint = Expr.BoolAND(
                Expr.IsGEQ(Expr.DayOfWeek(Expr.FuncToday()), Expr.Const(DayOfWeek.Monday)),
                Expr.IsLEQ(Expr.DayOfWeek(Expr.FuncToday()), Expr.Const(DayOfWeek.Friday)),
                Expr.IsGEQ(Expr.FuncTimeOfDay(), Expr.Const(new TimeSpan(4, 30, 0))),
                Expr.IsLEQ(Expr.FuncTimeOfDay(), Expr.Const(new TimeSpan(20, 30, 0))));
            // - monitor period: every minute
            TimeSpan defaultMonitorPeriod = TimeSpan.FromMinutes(1);
            // - publish period: hourly
            TimeSpan defaultPublishPeriod = TimeSpan.FromHours(1);

            // build rules
            var alertRules = new List <AlertRule>();

            alertRules.AddRange(CreateDevRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
            alertRules.AddRange(CreateSitRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
            alertRules.AddRange(CreateStgRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));
            alertRules.AddRange(CreateLegacyRules(defaultCheckConstraint, defaultMonitorPeriod, defaultPublishPeriod));

            // save Import rules
            foreach (AlertRule rule in alertRules)
            {
                logger.LogDebug("  Loading {0}.{1}.{2} ({3})...", rule.EnvName, rule.Instance, rule.RuleName, rule.Disabled ? "Disabled" : "Enabled");
                rule.NameSpace = nameSpace;
                TimeSpan lifetime = rule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
                targetClient.SaveObject(rule, lifetime);
            }
            logger.LogDebug("Loaded {0} alert rules.", alertRules.Count);

            // load from embedded xml
            //const string Prefix = "Orion.Configuration.AlertRules";
            //Dictionary<string, string> chosenFiles = ResourceHelper.GetResources(assembly, Prefix, "xml");
            //if (chosenFiles.Count == 0)
            //    throw new InvalidOperationException("Missing alert rules!");

            //foreach (KeyValuePair<string, string> file in chosenFiles)
            //{
            //    AlertRule rule = XmlSerializerHelper.DeserializeFromString<AlertRule>(file.Value);
            //    logger.LogDebug("  Loading {0} ({1})...",
            //        file.Key,
            //        rule.Disabled ? "Disabled" : "Enabled");
            //    TimeSpan lifetime = rule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
            //    LoadConfigDataHelper.AsyncSaveObject<AlertRule>(
            //        rule, rule.UniqueKeyNetwork, rule.Properties, lifetime, false, targetClient, completions);
            //}
            //logger.LogDebug("Loaded {0} alert rules.", chosenFiles.Count);
        }
Beispiel #26
0
        public string CreateValuation(
            ILogger logger, ICoreCache cache,
            String nameSpace,
            IBusinessCalendar fixingCalendar,
            IBusinessCalendar paymentCalendar,
            List <StringObjectRangeItem> valuationSet,
            ValuationRange valuationRange,
            TradeRange tradeRange,
            CapFloorLegParametersRange_Old legParametersRange,
            List <InputCashflowRangeItem> legDetailedCashflowsListArray,
            List <InputPrincipalExchangeCashflowRangeItem> legPrincipleExchangeCashflowListArray,
            List <AdditionalPaymentRangeItem> legAdditionalPaymentListArray,
            List <PartyIdRangeItem> partyIdList,                     //optional
            List <OtherPartyPaymentRangeItem> otherPartyPaymentList, //optional
            List <FeePaymentRangeItem> feePaymentList                //optional
            )
        {
            Pair <ValuationResultRange, CapFloor> fpML = GetPriceAndGeneratedFpML(logger, cache, nameSpace, fixingCalendar, paymentCalendar, valuationRange, tradeRange,
                                                                                  legParametersRange, legDetailedCashflowsListArray, legPrincipleExchangeCashflowListArray,
                                                                                  legAdditionalPaymentListArray, feePaymentList);
            CapFloor capFloor = fpML.Second;
            string   valuationReportAndProductId = tradeRange.Id ?? Guid.NewGuid().ToString();

            capFloor.id = valuationReportAndProductId;
            AssetValuation assetValuation = InterestRateProduct.CreateAssetValuationFromValuationSet(valuationSet);
            //Valuation valuation = new Valuation();
            //  TODO: add Trade Id & Trade data into valuation. (Trade.Id & Trade.TradeHeader.TradeDate)
            //
            string baseParty    = valuationRange.BaseParty;
            var    uniqueCurves = new List <IRateCurve>();

            foreach (string curveName in new[] { legParametersRange.ForecastCurve, legParametersRange.DiscountCurve })
            {
                if (!String.IsNullOrEmpty(curveName))
                {
                    var curve = CurveLoader.LoadInterestRateCurve(logger, cache, nameSpace, curveName);
                    if (!uniqueCurves.Contains(curve))
                    {
                        uniqueCurves.Add(curve);
                    }
                }
            }
            Market          fpMLMarket      = InterestRateProduct.CreateFpMLMarketFromCurves(uniqueCurves);
            ValuationReport valuationReport = ValuationReportGenerator.Generate(valuationReportAndProductId, baseParty, valuationReportAndProductId, tradeRange.TradeDate, capFloor, fpMLMarket, assetValuation);

            cache.SaveObject(valuationReport, valuationReportAndProductId, null);
            InterestRateProduct.ReplacePartiesInValuationReport(valuationReport, partyIdList);
            InterestRateProduct.AddOtherPartyPayments(valuationReport, otherPartyPaymentList);
            return(valuationReportAndProductId);
        }
Beispiel #27
0
        public string CacheFraTradeWithProperties(ILogger logger, ICoreCache cache, FraInputRange fraInputRange, NamedValueSet properties)
        {
            var fra   = ProductFactory.GetFpMLFra(fraInputRange);
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            //Get the id.
            ProductIdentifier = new FpML.V5r10.Reporting.Identifiers.TradeIdentifier(properties);
            var fraId = ProductIdentifier.UniqueIdentifier;

            //Cache the trade.
            cache.SaveObject(trade, fraId, properties);
            return(fraId);
        }
Beispiel #28
0
        public static void DispatchToManager(ICoreCache cache, RequestBase request)
        {
            string requestItemName = request.NetworkKey;

            if (cache.Proxy.LoadItem(requestItemName) == null)
            {
                throw new ArgumentException($"The '{request.GetType().Name}' named '{requestItemName}' does not exist");
            }
            cache.SaveObject(new UnassignedWorkflowRequest(request)
            {
                RequestDataType = request.GetType().FullName,
                RequestItemName = requestItemName
            });
        }
        public static void LoadStressDefinitions(ILogger logger, ICoreCache targetClient, string nameSpace)
        {
            // generate stress definitions
            // - ZeroStress: the curve definition with the market quotes adjusted by zero
            // - ParallelUp/Dn: the curve definition with the market quotes adjusted by +/- 100bp
            // - PercentUp/Dn: the curve definition with the market quotes adjusted by +/- 1, 5, and 10%
            logger.LogDebug("Loading stress definitions...");
            var stressRules = new List <StressRule>();

            {
                //IExpression excludedCurveFilter =
                //    Expr.BoolOR(
                //        Expr.IsEQU(CurveProp.PricingStructureType, "RateBasisCurve"),
                //        Expr.IsEQU(CurveProp.PricingStructureType, "RateSpreadCurve"));
                //IExpression anyOtherCurveFilter =
                //    Expr.BoolAND(
                //        Expr.IsNEQ(CurveProp.PricingStructureType, "RateBasisCurve"),
                //        Expr.IsNEQ(CurveProp.PricingStructureType, "RateSpreadCurve"));

                // build rules
                stressRules.Add(MakeStressRule("ZeroStress", "1", 1, Expr.ALL, NoAdjustment()));
                stressRules.Add(MakeStressRule(StressConst.ParallelUp001, "1", 1, Expr.ALL, ParallelUp(0.0001M)));
                stressRules.Add(MakeStressRule(StressConst.ParallelDn001, "1", 1, Expr.ALL, ParallelDn(0.0001M)));
                stressRules.Add(MakeStressRule(StressConst.ParallelUp050, "1", 1, Expr.ALL, ParallelUp(0.0050M)));
                stressRules.Add(MakeStressRule(StressConst.ParallelDn050, "1", 1, Expr.ALL, ParallelDn(0.0050M)));
                stressRules.Add(MakeStressRule(StressConst.ParallelUp100, "1", 1, Expr.ALL, ParallelUp(0.0100M)));
                stressRules.Add(MakeStressRule(StressConst.ParallelDn100, "1", 1, Expr.ALL, ParallelDn(0.0100M)));

                stressRules.Add(MakeStressRule(StressConst.PercentUp01, "1", 1, Expr.ALL, PercentUp(0.01M)));
                stressRules.Add(MakeStressRule(StressConst.PercentDn01, "1", 1, Expr.ALL, PercentDn(0.01M)));
                stressRules.Add(MakeStressRule(StressConst.PercentUp05, "1", 1, Expr.ALL, PercentUp(0.05M)));
                stressRules.Add(MakeStressRule(StressConst.PercentDn05, "1", 1, Expr.ALL, PercentDn(0.05M)));
                stressRules.Add(MakeStressRule(StressConst.PercentUp10, "1", 1, Expr.ALL, PercentUp(0.10M)));
                stressRules.Add(MakeStressRule(StressConst.PercentDn10, "1", 1, Expr.ALL, PercentDn(0.10M)));
            }

            // save stress rules
            foreach (StressRule stressRule in stressRules)
            {
                const string itemType = "StressDefinition";
                string       idSuffix = stressRule.StressId + "." + stressRule.RuleId;
                logger.LogDebug("  Loading {0} ...", idSuffix);
                Pair <string, NamedValueSet> itemInfo = LoadConfigDataHelper.StandardConfigProps(null, itemType, idSuffix, nameSpace);
                TimeSpan lifetime = stressRule.Disabled ? TimeSpan.FromDays(30) : TimeSpan.MaxValue;
                targetClient.SaveObject(stressRule, itemInfo.First, itemInfo.Second, false, lifetime);
            }

            logger.LogDebug("Loaded {0} stress definitions", stressRules.Count);
        }
Beispiel #30
0
        public static void SaveDocument(ILogger logger, ICoreCache targetClient, object fpMLProduct)
        {
            var extraProps = new NamedValueSet();

            extraProps.Set(TradeProp.TradingBookName, "Test");
            extraProps.Set(TradeProp.TradeState, "Confirmed");
            //extraProps.Set("TradeType", "Deposit");
            extraProps.Set(TradeProp.TradeSource, "FPMLSamples");
            extraProps.Set(TradeProp.AsAtDate, DateTime.Today);
            extraProps.Set("Namespace", "Confirmation");
            ItemInfo itemInfo = MakeTradeProps(fpMLProduct.GetType().ToString(), null, extraProps);

            logger.LogDebug("  {0} ...", itemInfo.ItemName);
            targetClient.SaveObject(fpMLProduct, itemInfo.ItemName, itemInfo.ItemProps, false, TimeSpan.MaxValue);
        }