private static void CreateStrikeRateVolCurve(string currency1, string indexTenor, string[] instruments, decimal[] marketvalues, decimal[] additionalforwards) { NamedValueSet properties = new NamedValueSet(); properties.Set("Instrument", "AUD-Xibor-" + indexTenor); properties.Set("PricingStructureType", "CapVolatilityCurve"); properties.Set("ReferenceCurveUniqueId", "Market." + Market + ".DiscountCurve.GBP-LIBOR-SENIOR"); properties.Set("ReferenceCurrency2CurveId", "Market." + Market + ".DiscountCurve.GBP-LIBOR-SENIOR"); properties.Set("Currency", currency1); properties.Set("IndexTenor", indexTenor); properties.Set("IndexName", "AUD-BBR-BBSW"); properties.Set("MarketName", Market); properties.Set("StrikeQuoteUnits", StrikeQuoteUnitsEnum.DecimalRate.ToString()); properties.Set("MeasureType", MeasureTypesEnum.Volatility.ToString()); properties.Set("QuoteUnits", QuoteUnitsEnum.LogNormalVolatility.ToString()); properties.Set("Algorithm", "Linear"); properties.Set("QuotationSide", QuotationSideEnum.Mid.ToString()); properties.Set("Timing", QuoteTimingEnum.Close.ToString()); properties.Set("ValuationDate", DateTime.Today); properties.Set("BusinessCenter", "Sydney"); properties.Set("Strike", 0.025m); properties.Set("BaseDate", DateTime.Today); var volCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, marketvalues, additionalforwards)); string name = volCurve.GetPricingStructureId().UniqueIdentifier; Market market = volCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
private static void CreateDiscountCurve(string currency1, string[] instruments, decimal[] values) { NamedValueSet properties = new NamedValueSet(); properties.Set("PricingStructureType", "DiscountCurve"); properties.Set("CreditInstrumentId", "LIBOR"); properties.Set("CreditSeniority", "SENIOR"); properties.Set("CurveName", currency1 + "-LIBOR-SENIOR"); properties.Set("Currency", currency1); properties.Set("MarketName", Market); properties.Set("BaseDate", DateTime.Today); var rateCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, values)); string name = rateCurve.GetPricingStructureId().UniqueIdentifier; Market market = rateCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
private static void CreateRateCurve(string currency1, string indexTenor, string[] instruments, decimal[] values) { NamedValueSet properties = new NamedValueSet(); properties.Set("CurveName", "AUD-BBR-BBSW-" + indexTenor); properties.Set("PricingStructureType", "RateCurve"); properties.Set("Currency", currency1); properties.Set("IndexTenor", indexTenor); properties.Set("IndexName", "AUD-BBR-BBSW"); properties.Set("MarketName", Market); properties.Set("BaseDate", DateTime.Today); var rateCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, values)); string name = rateCurve.GetPricingStructureId().UniqueIdentifier; Market market = rateCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
private static void CreateFxCurve(string currency1, string currency2, string[] instruments, decimal[] values) { NamedValueSet properties = new NamedValueSet(); properties.Set("CurveName", "FxCurve" + currency1 + "-" + currency2); properties.Set("PricingStructureType", "FxCurve"); properties.Set("Currency", currency1); properties.Set("Currency2", currency2); properties.Set("CurrencyPair", currency1 + "-" + currency2); properties.Set("QuoteBasis", "Currency2PerCurrency1"); properties.Set("MarketName", Market); properties.Set("BaseDate", DateTime.Today); var fxCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, values)); string name = fxCurve.GetPricingStructureId().UniqueIdentifier; Market market = fxCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
private static void CreateBondDiscountCurve(string currency1, string[] instruments, decimal[] values) { NamedValueSet properties = new NamedValueSet(); properties.Set("PricingStructureType", "BondDiscountCurve"); properties.Set("Currency", currency1); properties.Set("CreditInstrumentId", "WATC"); properties.Set("CreditSeniority", "SENIOR"); properties.Set("MarketName", Market1); properties.Set("Algorithm", "LinearZero"); properties.Set("MarketQuote", "YieldToMaturity"); properties.Set("BaseDate", new DateTime(2010, 3, 1)); var bondCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, values)); string name = bondCurve.GetPricingStructureId().UniqueIdentifier; Market market = bondCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
private static void CreateBondFinancingBasisCurve(string currency1, string[] instruments, decimal[] values) { NamedValueSet properties = new NamedValueSet(); properties.Set("PricingStructureType", "BondFinancingBasisCurve"); properties.Set("ReferenceBond", "Govt.WATC.Fixed.7.15/10/2019"); properties.Set("ReferenceCurveUniqueId", "Market." + Market + ".DiscountCurve.GBP-LIBOR-SENIOR"); properties.Set("CurveName", "AUD-GC-SECURED"); properties.Set("Currency", currency1); properties.Set("BondType", "AGB"); properties.Set("CreditSeniority", "SECURED"); properties.Set("CreditInstrumentId", "GC"); properties.Set("MarketName", Market); properties.Set("Algorithm", "LinearZero"); properties.Set("MarketQuote", "YieldToMaturity"); properties.Set("BaseDate", new DateTime(2010, 3, 1)); var bondCurve = CurveEngine.CreatePricingStructure(properties, ProcessValues(instruments, values)); string name = bondCurve.GetPricingStructureId().UniqueIdentifier; Market market = bondCurve.GetMarket(); CurveEngine.SaveCurve(market, name, properties, new TimeSpan(0, 1, 0)); }
public void ProcessItems() { int count = Interlocked.Decrement(ref _queuedCalls); // exit if there are more callbacks following us //if (count % 10000 == 0) _loggerRef.Target.LogDebug("ProcessItems: Queued calls remaining: {0}", count); if (count != 0) { return; } ICoreItem item = null; _queuedItems.Locked(queue => { if (queue.Count > 0) { item = queue.Dequeue(); } }); while (item != null) { var qas = item.Data as QuotedAssetSet; if (qas != null) { // 1. Get the property values that uniquely identify the curves to refresh. // This is the process for the workflow request. Alternatively, a direct build of the curve can occur. // var nameSpace = item.AppProps.GetValue <string>(EnvironmentProp.NameSpace); var market = item.AppProps.GetValue <string>(CurveProp.Market);//For real time use Market and not MarketAndDate var curveType = item.AppProps.GetValue <string>(CurveProp.PricingStructureType); var curveName = item.AppProps.GetValue <string>(CurveProp.CurveName); var configIdentifier = FunctionProp.Configuration + ".PricingStructures." + market + "." + curveType + "." + curveName; var identifier = FunctionProp.Market + "." + market + "." + curveType + "." + curveName; List <ICoreItem> items = null; // 2.Check if the dependent curves should be refreshed // if (chkBoxDependentCurves.Checked) { //Find all the QAS's where the ReferenceCurveName is equal to the curveType.curveName! var requestProperties = new NamedValueSet(); requestProperties.Set(EnvironmentProp.NameSpace, NameSpace); requestProperties.Set(CurveProp.Market, market); requestProperties.Set(EnvironmentProp.Function, FunctionProp.Configuration); requestProperties.Set(CurveProp.ReferenceCurveName, curveType + '.' + curveName); IExpression queryExpr = Expr.BoolAND(requestProperties); _loggerRef.Target.LogDebug("Dependent curve property request set at {0}", DateTime.Now.ToLongTimeString()); items = _cache.LoadItems <Market>(queryExpr); } // 3. If the build is a local build then use the curve engine. // if (!chkBoxWorkflow.Checked) { _loggerRef.Target.LogDebug("Request to build base curve {0} locally at : {1}", identifier, DateTime.Now.ToLongTimeString()); var curve = CurveEngine.RefreshPricingStructureFromConfiguration(_loggerRef.Target, _cache, nameSpace, configIdentifier, identifier, qas, DateTime.Now, DateTime.Now); _loggerRef.Target.LogDebug("Built the base curve {0} locally at : {1}", curve, DateTime.Now.ToLongTimeString()); if (items != null) { foreach (var dataItem in items) { var spreadCurve = dataItem.Data as Market; if (spreadCurve == null) { continue; } //var bootstrap = dataItem.AppProps.GetValue<bool>(CurveProp.BootStrap, false); //if (!bootstrap) { dataItem.AppProps.Set(CurveProp.BootStrap, true); } try { var curveId = spreadCurve.id; if (String.IsNullOrEmpty(curveId)) { curveId = spreadCurve.Items[0].id; //use yieldCurve.id, CurveGen 1.X compatible } dataItem.AppProps.Set(CurveProp.BaseDate, DateTime.Now); dataItem.AppProps.Set(CurveProp.BuildDateTime, DateTime.Now); var marketData = new Pair <PricingStructure, PricingStructureValuation>(spreadCurve.Items[0], spreadCurve.Items1[0]); var ps = PricingStructureFactory.Create(_loggerRef.Target, _cache, nameSpace, null, null, marketData, dataItem.AppProps); if (ps != null) { CurveEngine.SaveCurve(_cache, nameSpace, ps); } _loggerRef.Target.LogDebug("Built the spread curve {0} locally at : {1}", curveId, DateTime.Now.ToLongTimeString()); } catch (Exception e) { _loggerRef.Target.LogDebug(e.ToString()); } } } } else { // 4. Set the parameters for the work request. // var curveGenRequest = new OrdinaryCurveGenRequest { NameSpace = nameSpace, BaseDate = DateTime.Now, RequestId = Guid.NewGuid().ToString(), RequesterId = new UserIdentity { Name = _cache.ClientInfo.Name, DisplayName = _cache.ClientInfo.UserFullName //Name = _clientRef.Target.ClientInfo.Name, //DisplayName = _clientRef.Target.ClientInfo.UserFullName }, UseSavedMarketData = true, ForceGenerateEODCurves = true }; // 5. Set the base curve in the curve selection for the work request. // var curveSelector = new List <CurveSelection> { new CurveSelection { NameSpace = nameSpace, MarketName = market, CurveType = curveType, CurveName = curveName } }; // 6.Include all other dependent curvenames i.e. spread curves. // if (items != null) { curveSelector.AddRange(from childCurve in items let spreadCurveType = childCurve.AppProps.GetValue <string>( CurveProp.PricingStructureType) let spreadCurveName = childCurve.AppProps.GetValue <string>(CurveProp.CurveName) select new CurveSelection { NameSpace = nameSpace, MarketName = market, CurveType = spreadCurveType, CurveName = spreadCurveName }); } curveGenRequest.CurveSelector = curveSelector.ToArray(); // 7. Set the actual work request. // IWorkContext context = new WorkContext(_loggerRef.Target, _cache, "DEV"); //IWorkContext context = new WorkContext(_loggerRef.Target, _clientRef.Target, "DEV"); _loggerRef.Target.LogDebug("WorkContext set at {0}", DateTime.Now.ToLongTimeString()); using (var workflow = new WFGenerateOrdinaryCurve()) { workflow.Initialise(context); WorkflowOutput <HandlerResponse> output = workflow.Execute(curveGenRequest); WorkflowHelper.ThrowErrors(output.Errors); foreach (var error in output.Errors) { _loggerRef.Target.LogInfo("WorkFlow error: {0} at {1}", error.Message, DateTime.Now.ToLongTimeString()); } } _loggerRef.Target.LogDebug("WorkFlow executed at {0}", DateTime.Now.ToLongTimeString()); //item = null; //_queuedItems.Locked(queue => // { // if (queue.Count > 0) // item = queue.Dequeue(); // }); } } } }