private static WorkflowOutput <HandlerResponse> RunStressGenerator(NamedValueSet properties)
        {
            var          wfGenerateStressCurve = new WFGenerateStressedCurve();
            IWorkContext context = new WorkContext(Engine.Logger, Engine.Cache, "UnitTest");

            wfGenerateStressCurve.Initialise(context);
            var request = new StressedCurveGenRequest
            {
                RequestId   = Guid.NewGuid().ToString(),
                RequesterId = new UserIdentity
                {
                    Name        = Engine.Cache.ClientInfo.Name,
                    DisplayName = "Unit Test Agent"
                },
                BaseDate      = properties.GetValue <DateTime>("BaseDate", true),
                CurveSelector = new[] { new CurveSelection
                                        {
                                            NameSpace  = properties.GetString("NameSpace", true),
                                            CurveName  = properties.GetString("CurveName", true),
                                            CurveType  = properties.GetString("PricingStructureType", true),
                                            MarketName = properties.GetString("MarketName", true)
                                        } }
            };

            return(wfGenerateStressCurve.Execute(request));
        }
        private static HandlerResponse ExecuteCurveStressing(IEnumerable <string> marketNames, IEnumerable <string> curveTypes, IEnumerable <string> curveNames)
        {
            // create list of base curve ids to stress
            var curveSelectors = new List <CurveSelection>();

            // hack make sure QR_LIVE AUD reference curve is stressed first
            {
                curveSelectors.Add(new CurveSelection
                {
                    MarketName = CurveConst.QR_LIVE,
                    CurveType  = "RateCurve",
                    CurveName  = "AUD-BBR-BBSW-3M"
                });
            }
            curveSelectors.AddRange(from marketName in marketNames
                                    from curveType in curveTypes
                                    from curveName in curveNames
                                    let baseCurveUniqueId = String.Format(UTE.NameSpace + ".Market.{0}.{1}.{2}", marketName, curveType, curveName)
                                                            let curveItem = Engine.Cache.LoadItem <Market>(baseCurveUniqueId)
                                                                            where curveItem != null
                                                                            select new CurveSelection
            {
                MarketName = marketName, CurveType = curveType, CurveName = curveName
            });
            // create and execute workflow
            var request = new StressedCurveGenRequest
            {
                RequestId   = Guid.NewGuid().ToString(),
                RequesterId = new UserIdentity
                {
                    Name        = Engine.Cache.ClientInfo.Name,
                    DisplayName = "Unit Test Agent"
                },
                BaseDate      = TestBaseDate,
                CurveSelector = curveSelectors.ToArray()
            };
            // build list of curve unique ids required
            var baseCurveUniqueIds = curveSelectors.Select(curveSelector => String.Format(UTE.NameSpace + ".Market.{0}.{1}.{2}", curveSelector.MarketName, curveSelector.CurveType, curveSelector.CurveName)).ToList();

            AssertNotModified <Market>(baseCurveUniqueIds);
            HandlerResponse result;
            IWorkContext    context = new WorkContext(UTE.Logger, Engine.Cache, "UnitTest");

            using (var workflow = new WFGenerateStressedCurve())
            {
                workflow.Initialise(context);
                WorkflowOutput <HandlerResponse> output = workflow.Execute(request);
                WorkflowHelper.ThrowErrors(output.Errors);
                result = output.Result;
            }
            AssertNotModified <Market>(baseCurveUniqueIds);
            return(result);
        }
Exemple #3
0
        private void BaseCurveCallback(ICoreItem baseCurveItem)
        {
            try
            {
                // check for server shutdown
                if (GetState() != BasicServerState.Running)
                {
                    return;
                }

                // base curve changed
                DateTime dtNow = DateTime.Now;
                //Market baseCurve = (Market)baseCurveItem.Data;
                var curveType  = baseCurveItem.AppProps.GetValue <string>(CurveProp.PricingStructureType, true);
                var curveName  = baseCurveItem.AppProps.GetValue <string>(CurveProp.CurveName, true);
                var marketName = baseCurveItem.AppProps.GetValue <string>(CurveProp.Market, true);
                //var marketDate = baseCurveItem.AppProps.GetValue<DateTime?>(CurveProp.MarketDate, null);
                var      nameSpace       = baseCurveItem.AppProps.GetValue <string>(EnvironmentProp.NameSpace, true);
                DateTime curveBaseDate   = baseCurveItem.AppProps.GetValue(CurveProp.BaseDate, dtNow.Date);
                var      curveGenRequest = new StressedCurveGenRequest
                {
                    RequestId   = Guid.NewGuid().ToString(),
                    RequesterId = new UserIdentity
                    {
                        Name        = IntClient.Target.ClientInfo.Name,
                        DisplayName = "Stress Curve Generation Server"
                    },
                    BaseDate      = curveBaseDate,
                    CurveSelector = new[] { new CurveSelection
                                            {
                                                NameSpace  = nameSpace,
                                                MarketName = marketName,
                                                MarketDate = null,//marketDate,
                                                CurveType  = curveType,
                                                CurveName  = curveName
                                            } }
                };
                IWorkContext context = new WorkContext(Logger, IntClient.Target, "DEV");
                using (var workflow = new WFGenerateStressedCurve())
                {
                    workflow.Initialise(context);
                    WorkflowOutput <HandlerResponse> output = workflow.Execute(curveGenRequest);
                    WorkflowHelper.ThrowErrors(output.Errors);
                }
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
        }