public bool Check(Trade trade) { Boolean result = true; var entity = Env.Current.StaticData.GetPartyById(trade.EntityId).Code; if (entity.Equals("SMF") && trade.Product.ProcessingType.Equals("FX") && trade.Product.UnderlierInfo.Equals("FX:USD:IDR")) { trade.SetProperty("OverridePB", "CGMI_PB_FI"); } return result; }
public override bool ExcludeFromMatching(Trade otTrade, DateTime dt, bool isExternalTrade) { if (isExternalTrade) { if (otTrade.Status.Equals(stateDeleted)) { otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } } var maturity = otTrade.Product.RiskMaturity; var maturity2 = otTrade.Product.ContractMaturity; if (!maturity2.IsNull && maturity2 < maturity) maturity = maturity2; if (!maturity.IsNull && maturity <= new SimpleDate(dt)) { otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } return false; }
public bool Check(Trade trade, StringBuilder msg) { var bond = trade.Product as Bond; //Is this a Sell of a EUR BOND trade.RemoveProperty(PropName); if (trade.Quantity < 0 && bond != null && bond.Currency.Equals("EUR")) { //Need to notify user to check Funding if (MessageBox.Show("Please check funding for this Bond " + bond.Description + " " + bond.Isin, "Check EUR Funding", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return false; } trade.SetProperty(PropName, "true"); } return true; }
public override bool ExcludeFromMatching(Trade otTrade, DateTime dt, bool isExternalTrade) { if (isExternalTrade) { if (otTrade.Product is GenericProduct) { var desc = ((GenericProduct)otTrade.Product).ProductDescription; if (desc.Equals(TypeUnknown)) { otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); return true; } } if (otTrade.Quantity == 0) { otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } } if (otTrade.Product is FX) { if (((FX)otTrade.Product).PrimaryAmount < Utilities.Epsilon) otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } var maturity = otTrade.Product.RiskMaturity; var maturity2 = otTrade.Product.ContractMaturity; if (!maturity2.IsNull && maturity2 < maturity) maturity = maturity2; if (!maturity.IsNull && maturity <= new SimpleDate(dt)) { otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } return false; }
//Init Trade Date SettleDateS Strategy CounterParty .... internal static bool InitTrade(Trade trade, TradeInfo info, FilterData filterData, StringBuilder sb) { Trade existingTrade = null; if (info.HoldingID != null) { if (filterData.ExistingTransIds != null && filterData.ExistingTransIds.Count > 0) { if (filterData.ExistingTransIds.Contains(info.HoldingID)) existingTrade = Env.Current.Trade.GetTradeByProperty(SymmetryTranId, info.HoldingID); } else existingTrade = Env.Current.Trade.GetTradeByProperty(SymmetryTranId, info.HoldingID); } if (existingTrade != null) { if (filterData.OnlyNewTrades) return false; trade.Id = existingTrade.Id; trade.Status = existingTrade.Status; trade.Action = UpdateAction; trade.Version = existingTrade.Version; trade.Product = existingTrade.Product; trade.InputUserId = existingTrade.InputUserId; trade.InputTime = existingTrade.InputTime; if (existingTrade.BackToBackBookId != 0) { trade.BackToBackBookId = existingTrade.BackToBackBookId; trade.SetProperty(Trade.BackToBackInternalTradeId, existingTrade.GetProperty(Trade.BackToBackInternalTradeId)); } } else { trade.Id = 0; // _id--; trade.Status = "New"; trade.Action = "Create"; } if (info.HoldingID != null) trade.SetProperty(SymmetryTranId, info.HoldingID); if (info.TradeID != null && !info.TradeID.Equals("0")) trade.SetProperty(MurexTradeId, info.TradeID); // set parties: entity, book, counterparty // need to book trade under block entity var s1 = ManagedAccountCode + ":" + info.Strategy; var s2 = MasterFundCode + ":" + info.Strategy; var s3 = info.Strategy; var p1 = ManagedAccountCode; var p2 = MasterFundCode; var p3 = BlockEntityCode; var entity1 = SetAndLoadParty(trade, p1, Party.Entity); var entity2 = SetAndLoadParty(trade, p2, Party.Entity); var entity3 = SetAndLoadParty(trade, p3, Party.Entity + ":" + Party.Block); // must be block entity var book1 = SetAndLoadParty(trade, s1, Party.Book, entity1.Id); var book2 = SetAndLoadParty(trade, s2, Party.Book, entity2.Id); var book3 = SetAndLoadParty(trade, s3, Party.Book, entity3.Id, true); // book trade under book3 SetUpAllocaitonGrid(AllocName, entity3.Id, entity1.Id, info.ReportDate.AddYears(-2), 1); if (info.Portfolio != null) { SetBookPortfolio(book1, info.Portfolio); SetBookPortfolio(book2, info.Portfolio); SetBookPortfolio(book3, info.Portfolio); } // set counterParty var counterparty = Env.Current.StaticData.GetPartyByProperty(Party.CounterParty, PartyDisplay, info.Counterparty); if (counterparty == null) { if (!info.Counterparty.Equals(TradeInfo.DefaultParty)) Logger.Warn(FormatReadFileMessage("CounterParty does not exist by display name, will create or load one by code", info.Counterparty, info.HoldingID, info.TradeID, false)); SetAndLoadParty(trade, info.Counterparty, Party.CounterParty); } else { trade.PartyId = counterparty.Id; trade.InitialPartyId = counterparty.Id; } var tradeDate = (info.Otc != null && !info.Otc.TradeDate.IsNull) ? info.Otc.TradeDate : info.ReportDate; trade.TradeTime = new DateTime(tradeDate.Year, tradeDate.Month, tradeDate.Day); trade.SettlementDate = info.ReportDate; trade.Price = info.Price; if (!double.IsNaN(info.Quantity)) trade.Quantity = info.Quantity; else trade.Quantity = info.Nominal1; trade.SettleCurrency = info.Currency1; trade.Source = Source; trade.SourceReference = info.HoldingID; trade.SetProperty(SourceSys, info.FileSource); if (info.TradeID != null && !info.TradeID.Equals("0")) trade.SetProperty(info.FileSource + "TradeId", info.TradeID); //Set Clearer and PrimeBroker if (info.PrimeBroker != null) { var clearer = Env.Current.StaticData.GetPartyByCode(info.PrimeBroker); if (clearer == null) { //Should create SSI Automatically ?? SetAndLoadParty(trade, info.PrimeBroker, Party.Clearer + ":" + Party.PrimeBroker); } else { trade.ClearerId = clearer.Id; trade.PrimeBrokerId = clearer.Id; } } /* else if (info.Account != null) { var clearer = Env.Current.StaticData.GetPartyByCode(info.Account); if (clearer == null) { //Should create SSI Automatically ?? SetAndLoadParty(trade, info.Account, Party.Clearer); } else trade.ClearerId = clearer.Id; }*/ return true; }
public bool ExcludeFromMatching(Trade otTrade, DateTime dt, bool isExternalTrade) { if (isExternalTrade) { if (!(otTrade.Product is FX)) { if (Math.Abs(otTrade.Quantity - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } else { var fx = otTrade.Product as FX; if (Math.Abs(fx.PrimaryAmount - 0) < 0.5) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } if (otTrade.Product is SymmetryProduct) { if (((SymmetryProduct)otTrade.Product).MaturityDate <= new SimpleDate(dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "Matured"); return true; } } else { var maturity = otTrade.Product.RiskMaturity; if (!maturity.IsNull && maturity <= new SimpleDate(dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "Matured"); return true; } } return false; } //When running the Reconciliation we need to exclude terminated Trade //based on Termination Trade Date. //Exclude as well Trades maturing Today if (!otTrade.Product.IsMultiplyTraded) { var maturity = otTrade.Product.RiskMaturity; if (!maturity.IsNull && maturity <= new SimpleDate(dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "Matured"); return true; } if (ProductHelper.IsTerminated(otTrade.Product, dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "Terminated"); return true; } if (otTrade.Product is OtcOption) { var mat = otTrade.Product.ContractMaturity; if (!mat.IsNull && mat <= new SimpleDate(dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "Matured"); return true; } } } if (!(otTrade.Product.IsMultiplyTraded)) { if (otTrade.Product is FXOption) { var fxoption = otTrade.Product as FXOption; var optionInfo = fxoption.OptionInfo; if (optionInfo != null && optionInfo is DigitalInfo) { if ((optionInfo as DigitalInfo).SettlementAmount == 0) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } return false; } if (fxoption.PrimaryAmount == 0) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } if (!(otTrade.Product is FxFva) && fxoption.QuotingAmount == 0) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } /* if (otTrade.Product is NDF) { var fx = otTrade.Product as NDF; if (fx.Primary == "USD") { if (Math.Abs(fx.QuotingAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } else if (fx.Quoting == "USD") { if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } else { if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon && Math.Abs(fx.QuotingAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } } else if (otTrade.Product is FX) { var fx = otTrade.Product as FX; if (fx.Primary == "USD") { if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } else if (fx.Quoting == "USD") { if (Math.Abs(fx.QuotingAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } else { if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon && Math.Abs(fx.QuotingAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } } */ if (otTrade.Product is FX) { var fx = otTrade.Product as FX; if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } if (otTrade.Product is Repo) { if (otTrade.SettlementDate > new SimpleDate(dt)) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ForwardPosition"); return true; } } if (otTrade.Product is FRA) { if (Math.Abs(otTrade.Quantity - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } if (otTrade.Product is Swap) { if (Math.Abs(otTrade.Quantity - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } if (otTrade.Product is Swaption) { if (Math.Abs(otTrade.Quantity - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } } } else if (Math.Abs(otTrade.Quantity - 0) < Utilities.Epsilon) { otTrade.SetProperty(Reconciled, "true"); otTrade.SetProperty(ImportRef, "ZeroPosition"); return true; } return false; }
public Trade FromString(string[] items, IDictionary<string, int> headers, IList<Exception> exceps, Market market, CultureInfo info, SimpleDate asOfDate) { var symInfo = new SymmetryInfo(items, headers, info); //Ignore Currency if (symInfo.SecurityType.ToLower() == "currency") return null; //if (symInfo.Maturity <= asOfDate) return null; //if (symInfo.SecurityType.ToLower() != "spot-forward") { if (Math.Abs(symInfo.CurrentDayPosition - 0) < Utilities.Epsilon) return null; } var trade = new Trade(); //Build Security Product product = null; try { product = GetProduct(symInfo); } catch (Exception x) { Logger.Error(x.Message); exceps.Add( new Exception("No Product retrieved for Security Code:" + symInfo.SecurityType + "/" + symInfo.Security)); } var pr = new SymmetryProduct(); if (product != null) { trade.PriceType = QuotationType.Price; if (product.QuoteName != null) trade.PriceType = product.QuoteName.QuoteType; if (product is FX) { var fx = product as FX; double dd = symInfo.CurrentDayPosition; if (symInfo.Currency == "USD") { if (fx.Primary == "USD") { fx.PrimaryAmount = dd; if (dd > 0) trade.Quantity = 1; else trade.Quantity = -1; } else if (fx.Quoting == "USD") { fx.PrimaryAmount = dd; if (dd < 0) trade.Quantity = 1; else trade.Quantity = -1; } } else { if (symInfo.Currency == fx.Quoting) { fx.QuotingAmount = dd; if (dd < 0) trade.Quantity = 1; else trade.Quantity = -1; } else if (symInfo.Currency == fx.Primary) { fx.PrimaryAmount = dd; trade.Quantity = dd; } } fx.PrimarySettleDate = symInfo.Maturity; fx.QuotingSettleDate = symInfo.Maturity; trade.SettlementDate = symInfo.Maturity; pr = null; } else if (product is FXOption) { trade.SetProperty(DPEDescription, symInfo.Security); pr = null; } else if (product is VolSwap) pr = null; else if (product.IsMultiplyTraded) pr = null; } if (pr != null) { pr.DetailQuantity = symInfo.CurrentDayPosition; pr.DetailCurrCode = symInfo.Currency; pr.Security = string.IsNullOrEmpty(symInfo.Security) ? symInfo.Currency + "|" + symInfo.SecurityType + "|" + symInfo.Maturity : symInfo.Security; pr.SecurityType = symInfo.SecurityType; pr.MaturityDate = symInfo.Maturity; if (pr.Security == null) pr.Security = "Unknown"; if (symInfo.SecurityType != null && symInfo.SecurityType.ToLowerInvariant().Equals("swaptions")) { var desc = pr.Security.Split(' '); for (int i = 0; i < desc.Length; i++) { if (desc[i] == "PAY" || desc[i] == "REC") { var strikes = desc[i + 1]; pr.Strike = Convert.ToDouble(strikes, CultureInfo.InvariantCulture) / 100; break; } } } if (pr.Generator != null) trade.SetProperty("Generator", pr.Generator); } trade.Product = product; if (pr != null) trade.Product = pr; trade.SettleCurrency = symInfo.Currency; if (!(trade.Product is FX)) { trade.Quantity = symInfo.CurrentDayPosition; if (trade.Product is Mbs) { trade.Quantity /= ((Mbs)trade.Product).GetPrincipalFactorAsOf(asOfDate, asOfDate); } else if (trade.Product is Bond) { trade.Quantity /= ((Bond)trade.Product).Nominal; } else if (trade.Product is VolSwap) { trade.Quantity /= 100; } } trade.SetProperty(ImportRef, symInfo.Security); //trade.SettleAmount = Convert.ToDouble(items[DetailLocalCost]); //Retrieve Book var ss = symInfo.MicroStrategy; string bookCode; if (Utilities.IsNullOrEmpty(ss)) { var traderName = Env.Current.StaticData.GetAlias(new Alias { EntityId = 0, AliasType = PortfolioAliasType, Source = Source, SourceReference = symInfo.Trader }); if (traderName != null) bookCode = EntityPrefix + ":" + traderName.Name + ":" + "Default"; else bookCode = EntityPrefix + ":Default"; } else { bookCode = EntityPrefix + ":" + ss; } var book = Env.Current.StaticData.GetPartyByCode(bookCode); if (book != null) { trade.BookId = book.Id; } return trade; }
internal static string GetGeneratorName(Trade trade) { var gname = trade.GetProperty(TradeImportHelper.GeneratorProp); if (!string.IsNullOrEmpty(gname)) return gname; var template = trade.GetProperty(TradeImportHelper.TemplateProp); if (template != null) { var prod = trade.Product; string aliasSource = null; if (prod is MTMCurrencySwap || prod is CurrencySwap) aliasSource = SwapInfo.AliasSourceCcy; else if (prod is FRA) aliasSource = SwapInfo.AliasSourceFra; else if (prod is Swap) aliasSource = SwapInfo.AliasSourceIrs; else if (prod is Swaption) aliasSource = SwaptionInfo.AliasSourceSwpt; if (aliasSource != null) { //if (aliasSource.Equals(SwapInfo.AliasSourceIrs) || aliasSource.Equals(SwaptionInfo.AliasSourceSwpt)) { // use ot template -> generator mapping var alias = new Alias { AliasType = "Template", EntityId = 0, Source = aliasSource, SourceReference = template }; alias = Env.Current.StaticData.GetAlias(alias); if (alias != null) { trade.SetProperty("Generator", alias.Name); return alias.Name; } } /* else { // use generator <- ot template mapping var aliases = Env.Current.StaticData.GetAliasesByName(new Alias { AliasType = "Template", EntityId = 0, Source = aliasSource, Name = template }); if (aliases != null && aliases.Count > 0) { var alias = aliases[0]; trade.SetProperty("Generator", alias.SourceReference); return alias.SourceReference; } }*/ } } return null; }
protected void SetMatchingFlag(Trade otTrade, Trade externalTrade) { otTrade.SetProperty(ImportRef, externalTrade.GetProperty("ImportRef")); otTrade.SetProperty(Reconciled, "true"); externalTrade.SetProperty(Reconciled, "true"); }
public bool Reconcile(Trade otTrade, Trade externalTrade, Market market, bool fullMatch, DateTime reconcileDate, IList<Exception> exceps) { string unmatchReason = string.Empty; var s = otTrade.GetProperty(ImportRef); var s2 = externalTrade.GetProperty(ImportRef); if (s != null && s2 != null) { if (s.Equals(s2)) return true; } s = otTrade.GetProperty(Reconciled); if (s != null && s.ToLowerInvariant().Equals("true")) return false; s2 = externalTrade.GetProperty(Reconciled); if (s2 != null && s2.ToLowerInvariant().Equals("true")) return false; if (externalTrade.BookId != otTrade.BookId) return false; /* if (externalTrade.BookId != 0) { if (otTrade.BookId != externalTrade.BookId) { if (fullMatch) return false; else { var book1 = Env.Current.StaticData.GetPartyById(otTrade.BookId); var book2 = Env.Current.StaticData.GetPartyById(externalTrade.BookId); if (book1 != null && book2 != null) { var port1 = book1.GetProperty(TradeImportHelper.BookProp2); var port2 = book2.GetProperty(TradeImportHelper.BookProp2); if (port1 != null && port2 != null && !port1.Equals(port2)) { return false; } } unmatchReason += "Book "; } } } else { return false; }*/ #region symmetryProduct var ifsproduct = externalTrade.Product as SymmetryProduct; if (ifsproduct != null) { if (ifsproduct.SecurityType.ToLowerInvariant() == "currency swaps") { if (otTrade.Product is MTMCurrencySwap) { //Check Generator var generator = GetGeneratorName(otTrade); if (generator == null) return false; if (!ifsproduct.Security.StartsWith(generator)) return false; if (!ifsproduct.Generator.Equals(generator.Trim())) return false; if (otTrade.Product.ContractMaturity != ifsproduct.ContractMaturity) { var sd = otTrade.Product.ContractMaturity; var sw = otTrade.Product as MTMCurrencySwap; var paymentP = CalendarHelper.Get(sw.PayLeg.PaymentMarketPlaces); if (!sd.IsBusinessDay(paymentP)) { sd = sd.NextBusinessDay(paymentP); if (sd != ifsproduct.ContractMaturity) return false; } else return false; } if (externalTrade.Product.Currency == "USD") { //The Nominal may be in the other currency var swap = otTrade.Product as MTMCurrencySwap; if (swap.PayLeg.NotionalCurrency == "USD") { if (Math.Abs(externalTrade.Quantity - swap.ReceiveLeg.Notional) < Utilities.Epsilon) { if (fullMatch) SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "RecLegNotional "; } else { if (Math.Abs(externalTrade.Quantity - swap.PayLeg.Notional) < Utilities.Epsilon) { if (fullMatch) SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "PayLegNotional "; } } if (externalTrade.Product.Currency == otTrade.SettleCurrency) { if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) > Utilities.Epsilon) { if (fullMatch) return false; else unmatchReason += "Notional "; } } else { if (Math.Abs(externalTrade.Quantity - otTrade.SettleAmount) > Utilities.Epsilon) { if (fullMatch) return false; else unmatchReason += "Notional "; } } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } if (otTrade.Product is CurrencySwap) { //Check Generator var generator = GetGeneratorName(otTrade); if (generator == null) return false; if (!ifsproduct.Security.StartsWith(generator)) return false; if (!ifsproduct.Generator.Equals(generator.Trim())) return false; if (otTrade.Product.ContractMaturity != ifsproduct.ContractMaturity) { var sd = otTrade.Product.ContractMaturity; var sw = otTrade.Product as CurrencySwap; var paymentP = CalendarHelper.Get(sw.PayLeg.PaymentMarketPlaces); if (!sd.IsBusinessDay(paymentP)) { sd = sd.NextBusinessDay(paymentP); if (sd != ifsproduct.ContractMaturity) return false; } else return false; } //The Nominal may be in the other currency var swap = otTrade.Product as CurrencySwap; if (Math.Abs(externalTrade.Quantity - swap.ReceiveLeg.Notional) < Utilities.Epsilon) { if (fullMatch) SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "RecLegNotional "; if (Math.Abs(externalTrade.Quantity - swap.PayLeg.Notional) < Utilities.Epsilon) { if (fullMatch) SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "PayLegNotional "; if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } } return false; } if (ifsproduct.SecurityType.ToLowerInvariant() == "interest rate swaps") { if (otTrade.Product is Swap) { var ccy = otTrade.Product.Currency; if (otTrade.Product is NDS) { ccy = (otTrade.Product as NDS).NonDeliverableCurrency; } if (ccy != ifsproduct.Currency) return false; var generator = GetGeneratorName(otTrade); if (generator == null) return false; var isBasisSwap = generator.ToLower().Contains("basis"); if (!ifsproduct.Security.StartsWith(generator)) return false; if (!ifsproduct.Generator.Equals(generator.Trim())) return false; if (otTrade.Product.ContractMaturity != ifsproduct.ContractMaturity) { var sd = otTrade.Product.ContractMaturity; var sw = otTrade.Product as Swap; var paymentP = CalendarHelper.Get(sw.PayLeg.PaymentMarketPlaces); if (!sd.IsBusinessDay(paymentP)) { sd = sd.NextBusinessDay(paymentP); if (sd != ifsproduct.ContractMaturity) return false; } else return false; } // for basis swap, we don't have the side infomation, so can only compare the abs value var notionalDiff = isBasisSwap ? Math.Abs(externalTrade.Quantity) - Math.Abs(otTrade.Quantity) : externalTrade.Quantity - otTrade.Quantity; if (Math.Abs(notionalDiff) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "Notional "; } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } return false; } if (ifsproduct.SecurityType.ToLowerInvariant() == "swaptions") { if (otTrade.Product is Swaption) { var ccy = otTrade.Product.Currency; var swaption = otTrade.Product as Swaption; if (ccy != ifsproduct.Currency) return false; if (otTrade.Product.ContractMaturity != ifsproduct.ContractMaturity) return false; //Check Generator var generator = GetGeneratorName(otTrade); if (generator == null) return false; if (!ifsproduct.Security.StartsWith(generator)) return false; if (!ifsproduct.Generator.Equals(generator.Trim())) return false; if (Math.Abs(ifsproduct.Strike - swaption.OptionStrike) > Utilities.Epsilon) return false; if (swaption.OptionType == OptionType.Put) { // PAY if (!ifsproduct.Security.Contains("PAY")) return false; } else if (swaption.OptionType == OptionType.Call) { //REC if (!ifsproduct.Security.Contains("REC")) return false; } if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "Notional "; } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } return false; } if (ifsproduct.SecurityType.ToLowerInvariant() == "fras") { if (otTrade.Product is FRA) { var ccy = otTrade.Product.Currency; if (ccy != ifsproduct.Currency) return false; var fra = otTrade.Product as FRA; if (fra.StartDate != ifsproduct.ContractMaturity) return false; //Check Generator var generator = GetGeneratorName(otTrade); if (generator == null) return false; if (!ifsproduct.Security.StartsWith(generator)) return false; if (!ifsproduct.Generator.Equals(generator.Trim())) return false; if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) > Utilities.Epsilon) { if (fullMatch) return false; else unmatchReason += "Notional "; } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } return false; } return false; } #endregion symemtryProduct #region fx var fxifs = externalTrade.Product as FX; if (fxifs != null) { if (otTrade.Product is FX) { if (otTrade.SettlementDate != externalTrade.SettlementDate) return false; var fx = otTrade.Product as FX; if (!fx.CurrencyPair.Equals(fxifs.CurrencyPair)) return false; if (Math.Abs(fxifs.PrimaryAmount - 0) > Utilities.Epsilon) { if (Math.Abs(fx.PrimaryAmount - fxifs.PrimaryAmount) < 1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "PrimaryAmount "; } else if (Math.Abs(fxifs.QuotingAmount - 0) > Utilities.Epsilon) { if (Math.Abs(fx.QuotingAmount - fxifs.QuotingAmount) < 1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "QuotingAmount "; } else { if (Math.Abs(fxifs.QuotingAmount - 0) < Utilities.Epsilon && Math.Abs(fxifs.PrimaryAmount - 0) < Utilities.Epsilon) { if (Math.Abs(fx.PrimaryAmount - 0) < Utilities.Epsilon || Math.Abs(fx.QuotingAmount - 0) < Utilities.Epsilon) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "PrimaryAmount QuotingAmount "; } } if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } return false; } return false; } #endregion fx #region listed var fut = externalTrade.Product as Future; if (fut != null) { if (otTrade.Product is Future) { var otfut = otTrade.Product as Future; if (otfut.Id != fut.Id) return false; if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) < 1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "Quantity "; if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } } return false; } var equ = externalTrade.Product as Equity; if (equ != null) { if (otTrade.Product is Equity) { var otfut = otTrade.Product as Equity; if (otfut.Id != equ.Id) return false; if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) < 1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "Quantity "; if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } } return false; } var bond = externalTrade.Product as Bond; if (bond != null) { if (otTrade.Product is Mbs) { var otfut = otTrade.Product as Mbs; if (otfut.Id != bond.Id) return false; //double dd = otfut.GetPrincipalFactorAsOf(new SimpleDate(reconcileDate), // new SimpleDate(reconcileDate)); //if (Math.Abs(externalTrade.Quantity - otTrade.Quantity * dd) < 1) if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) < 0.1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "Quantity "; if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } return false; } if (otTrade.Product is Bond) { var otfut = otTrade.Product as Bond; if (otfut.Id != bond.Id) return false; //if (Math.Abs(externalTrade.Quantity - otTrade.Quantity * otTrade.Product.Nominal) < 1) if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) < 0.1) { SetMatchingFlag(otTrade, externalTrade); return true; } unmatchReason += "Quantity "; if (!fullMatch) { otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } } return false; } #endregion listed #region fxOption var extfxoption = externalTrade.Product as FXOption; if (extfxoption != null) { var fxoption = otTrade.Product as FXOption; if (fxoption == null) return false; var extDpeDesc = externalTrade.GetProperty(DPEDescription); var dpeDesc = otTrade.GetProperty(DPEDescription); bool descMatched = false; if (extDpeDesc != null && dpeDesc != null && extDpeDesc.Trim().Equals(dpeDesc.Trim())) descMatched = true; var oinfo = fxoption.OptionInfo; if (fxoption is FxFva) { if (!(extfxoption is FxFva)) return false; var fva = fxoption as FxFva; var extFva = extfxoption as FxFva; if (!descMatched) { if (!extfxoption.CurrencyPair.Equals(fxoption.CurrencyPair)) return false; if (extfxoption.IsBuy != fxoption.IsBuy) return false; if (fva.FvaExpiryDate != extFva.FvaExpiryDate) return false; } if (Math.Abs(fva.PrimaryAmount - extFva.PrimaryAmount) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "PrimaryAmount "; } } else { if (descMatched) { if (Math.Abs(extfxoption.PrimaryAmount - fxoption.PrimaryAmount) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "PrimaryAmount "; } } else { if (extfxoption.ExerciseType != fxoption.ExerciseType) { if (fxoption.ExerciseType == OptionExerciseType.Digital && extfxoption.ExerciseType == OptionExerciseType.European) { // tolerate this diff, external is booked as vanilla for digital } else return false; } if (!extfxoption.CurrencyPair.Equals(fxoption.CurrencyPair)) return false; if (extfxoption.IsBuy != fxoption.IsBuy) return false; if (extfxoption.ExpiryDate != fxoption.ExpiryDate) return false; if (fxoption.ExerciseType == OptionExerciseType.Digital || fxoption.ExerciseType == OptionExerciseType.European || fxoption.ExerciseType == OptionExerciseType.Barrier) { if (extfxoption.OptionType != fxoption.OptionType) return false; if (Math.Abs(extfxoption.PrimaryAmount - fxoption.PrimaryAmount) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "PrimaryAmount "; } //if (Math.Abs(extfxoption.QuotingAmount - fxoption.QuotingAmount) > Utilities.Epsilon) //{ // if (fullMatch) return false; // unmatchReason += "QuotingAmount "; //} if (Math.Abs(extfxoption.OptionStrike - fxoption.OptionStrike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "Strike "; } if (fxoption.ExerciseType == OptionExerciseType.Barrier) { var binfo1 = fxoption.OptionInfo as BarrierInfo; var binfo2 = extfxoption.OptionInfo as BarrierInfo; if (Math.Abs(binfo1.BarrierStrike - binfo2.BarrierStrike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "UpperBarrier "; } if (Math.Abs(binfo1.LowerBarrierStrike - binfo2.LowerBarrierStrike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "LowerBarrier "; } } } else if (fxoption.ExerciseType == OptionExerciseType.Touch) { var binfo1 = fxoption.OptionInfo as DigitalInfo; var binfo2 = extfxoption.OptionInfo as DigitalInfo; if (Math.Abs(binfo1.BarrierStrike - binfo2.BarrierStrike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "UpperBarrier "; } if (Math.Abs(binfo1.LowerBarrierStrike - binfo2.LowerBarrierStrike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "LowerBarrier "; } if (Math.Abs(extfxoption.PrimaryAmount - fxoption.PrimaryAmount) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "PrimaryAmount "; } } } } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } #endregion fxOption #region volswap var extvolswap = externalTrade.Product as VolSwap; if (extvolswap != null) { var volswap = otTrade.Product as VolSwap; if (volswap == null) return false; if (volswap.ContractMaturity != extvolswap.ContractMaturity) return false; if (volswap.UnderlierId != extvolswap.UnderlierId) return false; if (volswap.PaymentCurrency != extvolswap.PaymentCurrency) return false; if (Math.Abs(externalTrade.Quantity - otTrade.Quantity) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "Notional "; } if (Math.Abs(volswap.Strike - extvolswap.Strike) > Utilities.Epsilon) { if (fullMatch) return false; unmatchReason += "Strike "; } if (fullMatch) SetMatchingFlag(otTrade, externalTrade); else otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } #endregion volswap return false; }
protected Trade FromString(MurexInfo info, IList<Exception> exceps) { var trade = new Trade(); trade.TradingDay = info.TradeDate; trade.Description = info.SecurityType; trade.Status = info.Status; trade.Accrual = info.AccruedInterest; if (info.Strategy != null) { var strategy = info.Strategy; if (info.Strategy.Equals(TradeInfo.DefaultStrategy) && info.Portfolio != null) { strategy = info.Portfolio + ":" + info.Strategy; } var book = Env.Current.StaticData.GetPartyByCode(EntityPrefix + ":" + strategy); if (book != null) trade.BookId = book.Id; } if (info.Counterparty != null || info.CounterpartyCode != null) { var party = Env.Current.StaticData.GetPartyByProperty(Party.CounterParty, TradeImportHelper.PartyDisplay, info.Counterparty) ?? Env.Current.StaticData.GetPartyByProperty(Party.CounterParty, TradeImportHelper.PartyMlpCode, info.CounterpartyCode); if (party != null) trade.InitialPartyId = party.Id; } if (info.PBAccount != null) { trade.SetProperty(MurexInfo.AccountProp, info.PBAccount); var pbname = Alias.PartyFromAlias(0, "Murex", info.PBAccount); if (pbname != null) { var pb = Env.Current.StaticData.GetPartyByCode(pbname); if (pb != null) trade.PrimeBrokerId = pb.Id; } //} } if (info.ClearingHouse != null) { var ccp = Env.Current.StaticData.GetPartyByCode(info.ClearingHouse + TradeInfo.ClearingHouseTag); if (ccp == null) { var ccpName = Alias.PartyFromAlias(0, "Murex", info.ClearingHouse); if (ccpName != null) { ccp = Env.Current.StaticData.GetPartyByCode(ccpName); } } if (ccp != null) trade.CcpId = ccp.Id; } if (info.TradeId != null && !info.TradeId.Equals("0") && info.IsOtc) trade.SetProperty(TradeImportHelper.MurexTradeId, info.TradeId); if (info.IsListedOption) trade.Product = info.GetProduct(GetContracts(true), Logger); else if (info.IsFuture) trade.Product = info.GetProduct(GetContracts(false), Logger); else trade.Product = info.GetProduct(null, Logger); if (trade.Product is MurexProduct) { trade.SetProperty(TradeImportHelper.GeneratorProp, ((MurexProduct)trade.Product).Generator); } if (!double.IsNaN(info.UpFrontAmount)) trade.SettleAmount = info.UpFrontAmount; if (info.SecurityType.Equals(FxInfo.SpotForward) && trade.Product is FX) { var fx = trade.Product as FX; if (info.BuySell.Equals("S")) { if (fx.Primary == info.QuotingCcy) { trade.Quantity = fx.PrimaryAmount; trade.SettleAmount = -fx.QuotingAmount; } else { trade.Quantity = -fx.PrimaryAmount; trade.SettleAmount = fx.QuotingAmount; } } else { if (fx.Primary == info.QuotingCcy) { trade.Quantity = -fx.PrimaryAmount; trade.SettleAmount = fx.QuotingAmount; } else { trade.Quantity = fx.PrimaryAmount; trade.SettleAmount = -fx.QuotingAmount; } } } else { if (!info.IsOtc) { trade.Quantity = info.Nominal1; if (trade.Product is Bond) { var bond = trade.Product as Bond; trade.Quantity = info.Nominal1 / bond.Nominal; } } else { trade.Quantity = info.BuySell.Equals("B") ? 1 : -1; trade.SetProperty(TradeImportHelper.GeneratorProp, info.Instrument); } } var price = Math.Abs(info.Price); if (trade.Product is Future) { trade.PriceType = ((Future)trade.Product).Contract.Quotation; } else if (trade.Product is Bond) { trade.PriceType = ((Bond)trade.Product).QuotationType; } if (trade.PriceType != QuotationType.None && Utilities.IsPercentageQuotation(trade.PriceType)) price /= 100; trade.Price = price; return trade; }
public override bool Reconcile(Trade otTrade, Trade externalTrade, Market market, bool fullMatch, DateTime reconciliationDate, IList<Exception> exceps) { var ref1 = otTrade.GetProperty(ReconcileTaskExecutor.Reconciled); if (ref1 != null && ref1.ToLowerInvariant().Equals("true")) return false; var ref2 = externalTrade.GetProperty(ReconcileTaskExecutor.Reconciled); if (ref2 != null && ref2.ToLowerInvariant().Equals("true")) return false; if (!(otTrade.Product.GetType() == externalTrade.Product.GetType())) return false; if (otTrade.PrimeBrokerId != externalTrade.PrimeBrokerId && otTrade.ClearerId != externalTrade.ClearerId) return false; if (externalTrade.BookId != otTrade.BookId) return false; if (externalTrade.PartyId != otTrade.PartyId) return false; if (Math.Abs(otTrade.Price - externalTrade.Price) > Utilities.Epsilon) return false; var fut1 = otTrade.Product as Future; var fut2 = externalTrade.Product as Future; if (fut1 != null && fut2 != null) { var ticker1 = fut1.Ticker; var ticker2 = fut2.Ticker; if (!string.IsNullOrEmpty(ticker1) && !string.IsNullOrEmpty(ticker2)) { if (!ticker1.Equals(ticker2)) return false; } } if ((otTrade.Quantity > 0 && externalTrade.Quantity < 0) || (otTrade.Quantity < 0 && externalTrade.Quantity > 0)) return false; var tradedate1 = new SimpleDate(otTrade.TradeTime); var tradedate2 = new SimpleDate(externalTrade.TradeTime); if (tradedate1 != tradedate2 && otTrade.TradingDay != tradedate2) return false; if (fullMatch) { if (Math.Abs(otTrade.Quantity - externalTrade.Quantity) > Utilities.Epsilon) return false; if (!CompareFees(otTrade, externalTrade)) return false; } otTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); externalTrade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); return true; }
public IList<Trade> Import(Market market, Feed feed, StringBuilder sb, FilterData filterData) { var infos = filterData.Data ?? TradeImportHelper.ReadData(FilterInfo, filterData, sb); var trades = new List<Trade>(); var dict = new Dictionary<TradeInfo, Trade>(); if (filterData.Progress != null) filterData.Progress.AnalysisInit(infos.Count, "Building Products"); int count = 0; foreach (var info in infos) { if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>(); count++; if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, ""); if (FilterInfo(info)) continue; if (filterData.Currencies != null && filterData.Currencies.Count > 0 && !filterData.Currencies.Contains(info.Currency1)) continue; if (info.Otc == null || !(info.Otc is SwaptionInfo) || info.Otc.IsEmpty()) { sb.Append(TradeImportHelper.FormatErrorMessage("Swaption info not found or not complete", info.HoldingID, info.TradeID, info.Instrument)); continue; } var alias = Env.Current.StaticData.GetAlias(new Alias { AliasType = "Template", EntityId = 0, Source = SwaptionInfo.AliasSourceSwpt, SourceReference = info.Instrument }); if (alias != null) { var sinfo = info.Otc as SwapInfo; sinfo.Generator = Env.Current.StaticData.GetTemplate(Template.Shared, "Swaption", alias.Name); if (sinfo.Generator == null) { sb.Append(TradeImportHelper.FormatErrorMessage("Generator Template for Swaption " + alias.Name + " not found", info.HoldingID, info.TradeID, info.Instrument)); continue; } } else { sb.Append(TradeImportHelper.FormatErrorMessage("Alias for Generator not found", info.HoldingID, info.TradeID, info.Instrument)); continue; } if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, ""); var trade = new Trade(); if (!TradeImportHelper.InitTrade(trade, info, filterData, sb)) continue; dict[info] = trade; } if (filterData.Progress != null) filterData.Progress.AnalysisDone(); if (filterData.Progress != null) filterData.Progress.AnalysisInit(infos.Count, "Building Products"); count = 0; foreach (var kvp in dict) { if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>(); count++; if (filterData.Progress != null && count % 5 == 0) filterData.Progress.AnalysisProgress(count, ""); var info = kvp.Key; var trade = kvp.Value; var swInfo = info.Otc as SwaptionInfo; try { var copy = trade.Id > 0 ? (Trade)trade.Clone() : null; if (swInfo.Generator != null) { var tradeType = trade.TradeType; swInfo.Generator.Apply(trade, new SimpleDate(swInfo.TradeDate), market); trade.TradeType = tradeType; } if (trade.Product == null) { sb.Append(TradeImportHelper.FormatErrorMessage("No product generated after applying Generator", info.HoldingID, info.TradeID, info.Instrument)); continue; } if (copy != null) { TradeImportHelper.CopyTrade(copy, trade); trade.MirrorBookId = copy.MirrorBookId; trade.MirrorTradeId = copy.MirrorTradeId; } TradeImportHelper.SetParties(trade, info); var swaption = (Swaption)trade.Product; trade.SettlementDate = swInfo.SettleDate; swaption.ExpiryDate = swInfo.OptionMaturity; swaption.ExerciseType= info.OptionStyle.Equals("E") ? OptionExerciseType.European : OptionExerciseType.American; swaption.ExerciseSettlement = swInfo.SettlementType; swaption.IsBuy = info.TradeAction.Equals("B"); swaption.InitialPremiumPayReceive = swaption.IsBuy ? PayReceive.Pay : PayReceive.Receive; swaption.InitialPremiumAmount = Math.Abs(swInfo.FeeAmount); swaption.InitialPremiumCurrency = swInfo.FeeCurrency; swaption.InitialPremiumDate = swInfo.SettleDate; if (swInfo.SettleDate >= swInfo.OptionMaturity) swaption.FirstPremium.IsForwardStart = true; var swap = swaption.Swap; // Assuming trade action tells direction of underlying swap (probably putcall) if (info.PutCall.Equals("C") && swap.ReceiveLeg.IsFixedRate) swap.SwitchLegs(); else if (info.PutCall.Equals("P") && !swap.ReceiveLeg.IsFixedRate) swap.SwitchLegs(); var fixedLeg = swap.PayLeg.IsFixedRate ? swap.PayLeg : swap.ReceiveLeg; var floatLeg = swap.PayLeg.IsFixedRate ? swap.ReceiveLeg : swap.PayLeg; InitLegs(swap.PayLeg, swap.ReceiveLeg, info); if (trade.CcpId != 0) { //Nothing to do let the EventScheduleHelper insert the StepIn } else { if (fixedLeg.StartDate < trade.GetTradingDay()) { fixedLeg.FirstFullCalculationPeriod = true; fixedLeg.FirstCalculationPeriodStart = fixedLeg.StartDate; floatLeg.FirstFullCalculationPeriod = true; floatLeg.FirstCalculationPeriodStart = floatLeg.StartDate; fixedLeg.StartDate = trade.GetTradingDay(); floatLeg.StartDate = fixedLeg.StartDate; } } if (swInfo.Generator != null) swInfo.Generator.Provider.FillTrade(trade, market); if (swInfo.Generator != null) trade.SetProperty("TemplateName", swInfo.Generator.Name); trade.SetProperty(TradeImportHelper.GeneratorProp, info.Instrument); //Add UpFront Fee /* if (Math.Abs(info.PremiumAmount) > Utilities.Epsilon) { var fee = new Fee { Date = swInfo.SettleDate, FeeType = FeeType.Upfront, PartyId = trade.PartyId, Currency = trade.Product.Currency, Amount = Math.Abs(info.PremiumAmount), PayReceive = info.PremiumAmount < 0 ? PayReceive.Pay : PayReceive.Receive }; if (trade.Fees == null) trade.Fees = new List<Fee>(); trade.Fees.Add(fee); }*/ trades.Add(trade); } catch (Exception x) { Logger.Error("Import Swaption", x); sb.Append(TradeImportHelper.FormatErrorMessage("Fill Trade " + x.Message + " " + x.StackTrace, info.HoldingID, info.TradeID, info.Instrument)); } } sb.Append("Imported " + trades.Count + " Swaptions\n"); if (filterData.Progress != null) filterData.Progress.AnalysisDone(); return trades; }
protected void SetImporterProperty(Trade trade) { trade.SetProperty("TradeSource", "SymmetryImporter"); }
public override bool Reconcile(Trade otTrade, Trade externalTrade, Market market, bool fullMatch, DateTime reconciliationDate, IList<Exception> exceps) { var date = new SimpleDate(reconciliationDate); var time = reconciliationDate; if (externalTrade.Status.Equals(MurexInfo.StateDead)) return false; string unmatchReason = string.Empty; bool sameRef = false; var otTid = otTrade.GetProperty(TradeImportHelper.MurexTradeId); var extTid = externalTrade.GetProperty(TradeImportHelper.MurexTradeId); externalTrade.SetProperty(ReconcileTaskExecutor.ImportRef, extTid); if (otTid != null && extTid != null) { if (!otTid.Equals(extTid, StringComparison.Ordinal)) return false; else sameRef = !fullMatch; // if not in fullMatch mode, turn on sameRef flag } if (otTrade.BookId != externalTrade.BookId) { if (fullMatch) return false; else { var book1 = Env.Current.StaticData.GetPartyById(otTrade.BookId); var book2 = Env.Current.StaticData.GetPartyById(externalTrade.BookId); if (book1 != null && book2 != null) { var port1 = book1.GetProperty(TradeImportHelper.BookProp2); var port2 = book2.GetProperty(TradeImportHelper.BookProp2); if (port1 != null && port2 != null && !port1.Equals(port2)) { return false; } } unmatchReason += "Book "; } } if (externalTrade.Product is MurexProduct) { var murex = externalTrade.Product as MurexProduct; var ot = otTrade.Product; var generator = SymmetryPositionReconciler.GetGeneratorName(otTrade); if (!CompareParties(otTrade, externalTrade, fullMatch, ref unmatchReason) && fullMatch) return false; if (!ot.ProcessingType.Equals(murex.ProductProcessingType)) { if ((ot.ProcessingType.Equals("Swap") && murex.ProductProcessingType.Equals("NDS")) || (ot.ProcessingType.Equals("NDS") && murex.ProductProcessingType.Equals("Swap"))) { if (fullMatch) return false; else unmatchReason += "Swap/NDS "; } else return false; } if (otTrade.TradingDay != externalTrade.TradingDay) { if (!sameRef) return false; else unmatchReason += "TradeDate "; } if (generator == null || murex.Generator == null || !generator.Equals(murex.Generator)) { if (!sameRef) return false; else if (!unmatchReason.Contains("Swap/NDS")) unmatchReason += "Template "; } #region swap if (ot is Swap) { // can be irs, currency swap or mtm currency swap var swap = ot as Swap; var payLeg = swap.PayLeg; var recLeg = swap.ReceiveLeg; Leg leg1, leg2; // 1 and 2 in import file if ((payLeg.IsFixedRate && !recLeg.IsFixedRate) || (!payLeg.IsFixedRate && recLeg.IsFixedRate)) { // fixed-float: leg1 is fixed, leg2 is float if (payLeg.IsFixedRate) { if (!externalTrade.BuySell.Equals(BuySell.Sell.ToString())) { if (!sameRef) return false; else unmatchReason += "Direction "; } leg1 = payLeg; leg2 = recLeg; } else { if (externalTrade.BuySell.Equals(BuySell.Sell.ToString())) { if (!sameRef) return false; else unmatchReason += "Direction "; } leg1 = recLeg; leg2 = payLeg; } if (!CompareLegs(leg1, leg2, murex, false, fullMatch, sameRef, ref unmatchReason, reconciliationDate) && fullMatch) return false; } else if (!payLeg.IsFixedRate && !recLeg.IsFixedRate) { // float-float: buy/sell = rec/pay is on leg1 if (externalTrade.Quantity > 0) { leg1 = recLeg; leg2 = payLeg; } else { leg1 = payLeg; leg2 = recLeg; } if (!CompareLegs(leg1, leg2, murex, true, fullMatch, sameRef, ref unmatchReason, reconciliationDate) && fullMatch) return false; } if (!CompareFees(otTrade, murex)) { if (fullMatch) return false; else unmatchReason += "UpfrontFee "; } } #endregion swap #region fra else if (ot is FRA) { var fra = ot as FRA; if (otTrade.BuySell != externalTrade.BuySell) { if (!sameRef) return false; else unmatchReason += "BuySell "; } if (fra.StartDate != murex.EffectiveDate) { if (!sameRef) return false; else unmatchReason += "StartDate "; } if (fra.EndDate != murex.EndDate) { if (!sameRef) return false; else unmatchReason += "EndDate "; } if (Math.Abs(fra.FixedRate - murex.FixedRate) > _rateTolerance) { if (fullMatch) return false; else unmatchReason += "FixedRate "; } if (Math.Abs(fra.CurrentNominal(date, time, false) - murex.Nominal1) > _qtyTolerance) { if (fullMatch) return false; else unmatchReason += "Nominal "; } if (!CompareFees(otTrade, murex)) { if (fullMatch) return false; else unmatchReason += "UpfrontFee "; } } #endregion fra #region swaption else if (ot is Swaption) { var spt = ot as Swaption; if (otTrade.SettlementDate != murex.EffectiveDate) { if (!sameRef) return false; else unmatchReason += "SettleDate "; } if (spt.ExpiryDate != murex.EndDate) { if (!sameRef) return false; else unmatchReason += "ExpiryDate "; } if (murex.ExerciseSettlement != ExerciseSettlement.None && spt.ExerciseSettlement != murex.ExerciseSettlement) { if (!sameRef) return false; else unmatchReason += "SettlementType "; } if (spt.ExerciseType != murex.ExerciseType) { if (!sameRef) return false; else unmatchReason += "ExerciseType "; } if (!otTrade.BuySell.Equals(externalTrade.BuySell)) { if (!sameRef) return false; else unmatchReason += "BuySell "; } { var premiumMatch = true; if (Math.Abs(spt.InitialPremiumAmount - Math.Abs(murex.UpFrontAmount)) > _qtyTolerance) premiumMatch = false; if ((spt.InitialPremiumCurrency != null && murex.UpFrontCcy == null) || (spt.InitialPremiumCurrency == null && murex.UpFrontCcy != null) || (spt.InitialPremiumCurrency != null && murex.UpFrontCcy != null && spt.InitialPremiumCurrency != murex.UpFrontCcy)) premiumMatch = false; if (spt.InitialPremiumDate != murex.UpFrontDate) premiumMatch = false; if (!premiumMatch) { if (fullMatch) return false; else unmatchReason += "Premium "; } } // call= payleg is fixed, put = recleg is fixed var payLeg = spt.Swap.PayLeg; var recLeg = spt.Swap.ReceiveLeg; double fixedRate; if (murex.CallPut == OptionType.Call) { if (!payLeg.IsFixedRate) { if (!sameRef) return false; else unmatchReason += "PutCall "; } fixedRate = payLeg.FixedRate; } else if (murex.CallPut == OptionType.Put) { if (!recLeg.IsFixedRate) { if (!sameRef) return false; else unmatchReason += "PutCall "; } fixedRate = recLeg.FixedRate; } else return false; if (Math.Abs(payLeg.CurrentNominal(date, time, false) - murex.Nominal1) > _qtyTolerance) { if (fullMatch) return false; else unmatchReason += "Nominal "; } if (Math.Abs(fixedRate - murex.FixedRate) > _rateTolerance) { if (fullMatch) return false; else unmatchReason += "FixedRate "; } if (payLeg.NotionalCurrency != murex.Currency1) { if (!sameRef) return false; else unmatchReason += "Currency "; } if (payLeg.StartDate != murex.SwapStartDate && payLeg.FirstCalculationPeriodStart != murex.SwapStartDate) { if (!sameRef) return false; else unmatchReason += "SwapStartDate "; } if (payLeg.EndDate != murex.SwapEndDate) { if (!sameRef) return false; else unmatchReason += "SwapEndDate "; } } #endregion swaption else { // do not support other type return false; } otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, extTid); if (!fullMatch && unmatchReason.Length > 0) otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } else if (externalTrade.Product is GenericProduct) { // no product found in ot return false; } else { if (externalTrade.Product.GetType() != otTrade.Product.GetType()) { if (IsLumpFxNdf() && otTrade.Product is FX && externalTrade.Product is FX) { // lump them together } else return false; } #region listed if (externalTrade.Product.IsMultiplyTraded) { if (otTrade.Product.Id != externalTrade.Product.Id) return false; { if (Math.Abs(otTrade.Quantity - externalTrade.Quantity) > _qtyTolerance) { if (fullMatch) return false; else unmatchReason += "Quantity "; } if (!ComparePrice(otTrade, externalTrade)) { if (fullMatch) return false; else unmatchReason += "Price "; } } } #endregion listed #region fx else if (otTrade.Product is FX) { var fx1 = otTrade.Product as FX; var fx2 = externalTrade.Product as FX; if (!otTrade.BuySell.Equals(externalTrade.BuySell)) return false; if (!fx1.Primary.Equals(fx2.Primary)) return false; if (!fx1.Quoting.Equals(fx2.Quoting)) return false; { if (Math.Abs(fx1.PrimaryAmount - fx2.PrimaryAmount) > _amountTolerance) { if (fullMatch) return false; else unmatchReason += "PrimaryAmount "; } if (Math.Abs(fx1.QuotingAmount - fx2.QuotingAmount) > _amountTolerance) { if (fullMatch) return false; else unmatchReason += "QuotingAmount "; } } if (!IsLumpFxNdf()) { if (otTrade.Product is NDF) { var ndf1 = fx1 as NDF; var ndf2 = fx2 as NDF; if (ndf1.FXFixingName != null && ndf1.FXFixingName != ndf2.FXFixingName) return false; if (ndf1.NonDeliverableCurrency != null && ndf1.NonDeliverableCurrency != ndf2.NonDeliverableCurrency) return false; if (!ndf1.FXFixingDate.IsNull && !ndf2.FXFixingDate.IsNull && ndf1.FXFixingDate != ndf2.FXFixingDate) return false; if (ndf1.FixingValue != 0 && ndf2.FixingValue != 0 && Math.Abs(ndf1.FixingValue - ndf2.FixingValue) > _priceTolerance) { if (fullMatch) return false; else unmatchReason += "FixingValue "; } } } } #endregion fx #region fxoption else if (otTrade.Product is FXOption) { if (!CompareParties(otTrade, externalTrade, fullMatch, ref unmatchReason) && fullMatch) return false; var fxo1 = otTrade.Product as FXOption; var fxo2 = externalTrade.Product as FXOption; if (fxo1.IsBuy != fxo2.IsBuy) { if (!sameRef) return false; else unmatchReason += "BuySell "; } if (fxo1.Primary != fxo2.Primary) { if (!sameRef) return false; else unmatchReason += "PrimaryCcy "; } if (fxo1.Quoting != fxo2.Quoting) { if (!sameRef) return false; else unmatchReason += "QuotingCcy "; } if (otTrade.TradingDay != externalTrade.TradingDay) { if (!sameRef) return false; else unmatchReason += "TradeDate "; } if (fxo1.OptionType != fxo2.OptionType) { if (!sameRef) return false; else unmatchReason += "PutCall "; } if (fxo1.ExerciseSettlement != fxo2.ExerciseSettlement) { if (!sameRef) return false; else unmatchReason += "SettlementType "; } if (fxo1.ExerciseType != fxo2.ExerciseType) { if (!sameRef) return false; else unmatchReason += "ExerciseType "; } if (fxo1.ExerciseSettlement == ExerciseSettlement.Cash && fxo1.SettleCurrency != fxo2.SettleCurrency) { if (!sameRef) return false; else unmatchReason += "SettleCurrency "; } if (fxo1.ExpiryDate != fxo2.ExpiryDate) { if (!sameRef) return false; else unmatchReason += "ExpiryDate "; } if (Math.Abs(fxo1.PrimaryAmount - fxo2.PrimaryAmount) > _amountTolerance) { if (fullMatch) return false; else unmatchReason += "PrimaryAmount "; } if (Math.Abs(fxo1.QuotingAmount - fxo2.QuotingAmount) > _amountTolerance) { if (fullMatch) return false; else unmatchReason += "QuotingAmount "; } if (Math.Abs(fxo1.OptionStrike - fxo2.OptionStrike) > _priceTolerance) { if (fullMatch) return false; else unmatchReason += "Strike "; } var premiumMatch = true; if (Math.Abs(fxo1.InitialPremiumAmount - fxo2.InitialPremiumAmount) > _amountTolerance) premiumMatch = false; if (fxo1.InitialPremiumCurrency != null && fxo2.InitialPremiumCurrency == null) premiumMatch = false; if (fxo1.InitialPremiumCurrency == null && fxo2.InitialPremiumCurrency != null) premiumMatch = false; if (fxo1.InitialPremiumCurrency != null && fxo2.InitialPremiumCurrency != null && fxo1.InitialPremiumCurrency != fxo2.InitialPremiumCurrency) premiumMatch = false; if (fxo1.InitialPremiumDate != fxo1.InitialPremiumDate) premiumMatch = false; if (!premiumMatch) { if (fullMatch) return false; else unmatchReason += "Premium "; } } #endregion fxoption otTrade.SetProperty(ReconcileTaskExecutor.ImportRef, extTid); if (!fullMatch && unmatchReason.Length > 0) otTrade.SetProperty(ReconcileTaskExecutor.UnmatchReason, unmatchReason); return true; } }
static public void SetParties(Trade trade, TradeInfo info) { if (info.HoldingID != null) trade.SetProperty(SymmetryTranId, info.HoldingID); if (info.TradeID != null && !info.TradeID.Equals("0")) trade.SetProperty(MurexTradeId, info.TradeID); var strategy = info.Strategy; var code = strategy; var entity = Env.Current.StaticData.GetPartyByCode(BlockEntityCode); if (entity == null) return; var book = Env.Current.StaticData.GetPartyByCode(code); if (book == null) { return; } trade.BookId = book.Id; if (!string.IsNullOrEmpty(info.Counterparty)) { var party = Env.Current.StaticData.GetPartyByProperty(Party.CounterParty, PartyDisplay, info.Counterparty) ?? Env.Current.StaticData.GetPartyByCode(info.Counterparty); if (party != null) { if (party.RoleList.Contains(Party.Entity)) { if (Party.GetEntity(trade.BookId).Id == party.Id) trade.TradeType = TradeType.Internal; } trade.PartyId = party.Id; trade.InitialPartyId = party.Id; } } if (!string.IsNullOrEmpty(info.PrimeBroker)) { var party = Env.Current.StaticData.GetPartyByCode(info.PrimeBroker) ?? Env.Current.StaticData.SaveAndLoadParty(new Party { Code = info.PrimeBroker, RoleList = new List<string> {Party.PrimeBroker, Party.Clearer,Party.Agent} }); trade.PrimeBrokerId = party.Id; trade.ClearerId = party.Id; } if (!string.IsNullOrEmpty(info.ClearingHouse)) { var party = Env.Current.StaticData.GetPartyByCode(info.ClearingHouse) ?? Env.Current.StaticData.SaveAndLoadParty(new Party { Code = info.ClearingHouse, Role = Party.Ccp }); if (!party.RoleList.Contains(Party.Ccp)) { var list = party.RoleList.ToList(); list.Add(Party.Ccp); party.RoleList = list; party.Action = UpdateAction; party = Env.Current.StaticData.SaveAndLoadParty(party); } trade.CcpId = party.Id; } }
public IList<Trade> Import(Market market, Feed feed, StringBuilder sb, FilterData filterData) { var infos = filterData.Data ?? TradeImportHelper.ReadData(FilterInfo, filterData, sb); var trades = new List<Trade>(); var dict = new Dictionary<TradeInfo, Trade>(); if (filterData.Progress != null) filterData.Progress.AnalysisInit(infos.Count, "Building Products"); int count = 0; foreach (var info in infos) { if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>(); count++; if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, ""); if (FilterInfo(info)) continue; if(filterData.Currencies !=null && filterData.Currencies.Count > 0 && !filterData.Currencies.Contains(info.Currency1)) continue; if (info.Otc == null || !(info.Otc is SwapInfo) || info.Otc.IsEmpty()) { sb.Append(TradeImportHelper.FormatErrorMessage("Swap info not found or not complete", info.HoldingID, info.TradeID, info.Instrument)); continue; } var prodCurrency = Env.Current.StaticData.GetCurrency(info.Currency1); string prodtype, aliasSource; if (info.SecurityType.Equals(SwapInfo.IRSwap)) { prodtype = prodCurrency.IsNonDeliverable ? "NDS" : "Swap"; aliasSource = SwapInfo.AliasSourceIrs; } else if (info.SecurityType.Equals(SwapInfo.CcySwap)) { prodtype = info.Instrument.Contains("MTM") ? "MTMCurrencySwap" : "CurrencySwap"; aliasSource = SwapInfo.AliasSourceCcy; } else { prodtype = "FRA"; aliasSource = SwapInfo.AliasSourceFra; } var alias = Env.Current.StaticData.GetAlias(new Alias { AliasType = "Template", EntityId = 0, Source = aliasSource, SourceReference = info.Instrument }); if (alias != null) { var swapInfo = info.Otc as SwapInfo; var template = Env.Current.StaticData.GetTemplate(Template.Shared, prodtype, alias.Name); if (template == null && prodtype == "Swap") { // some swap is booked as NDS prodtype = "NDS"; template = Env.Current.StaticData.GetTemplate(Template.Shared, prodtype, alias.Name); prodtype = "Swap/NDS"; } swapInfo.Generator = template; if (swapInfo.Generator == null) { sb.Append(TradeImportHelper.FormatErrorMessage("Generator template for " + prodtype + " " + alias.Name + " not found", info.HoldingID, info.TradeID, info.Instrument)); continue; } } else { sb.Append(TradeImportHelper.FormatErrorMessage("Alias for Generator not found", info.HoldingID, info.TradeID, info.Instrument)); continue; } if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, ""); var trade = new Trade(); if (FilterInfo(info)) continue; if (!TradeImportHelper.InitTrade(trade, info, filterData, sb)) continue; dict[info] = trade; } if (filterData.Progress != null) filterData.Progress.AnalysisDone(); if (filterData.Progress != null) filterData.Progress.AnalysisInit(infos.Count, "Building Products"); count = 0; foreach (var kvp in dict) { if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>(); count++; if (filterData.Progress != null && count%5==0) filterData.Progress.AnalysisProgress(count, ""); var info = kvp.Key; var trade = kvp.Value; var sinfo= info.Otc as SwapInfo; try { var copy = trade.Id > 0 ? (Trade)trade.Clone() : null; var tradeType = trade.TradeType; sinfo.Generator.Apply(trade, new SimpleDate(sinfo.TradeDate), market); trade.TradeType = tradeType; if (trade.Product == null) { sb.Append(TradeImportHelper.FormatErrorMessage("No product generated after applying Generator", info.HoldingID, info.TradeID, info.Instrument)); continue; } if (trade.Product == null) continue; if (copy != null) { TradeImportHelper.CopyTrade(copy, trade); trade.MirrorBookId = copy.MirrorBookId; trade.MirrorTradeId = copy.MirrorTradeId; } //if (sinfo.ClearingHouse != null) // info.ClearingHouse = sinfo.ClearingHouse; trade.SettlementDate = sinfo.SwapStartDate1; TradeImportHelper.SetParties(trade, info); if (info.SecurityType.Equals(SwapInfo.IRSwap)) { var swap = trade.Product as Swap; var payLeg = swap.PayLeg; var recLeg = swap.ReceiveLeg; Leg leg1 = payLeg, leg2 = recLeg; if (!payLeg.IsFixedRate && !recLeg.IsFixedRate) { // basis swap var r1 = payLeg.RateIndex; // leg1 index var r2 = recLeg.RateIndex; // leg2 index if (r1.Equals(r2)) { r1 = payLeg.RateIndexTenor.Count.ToString(); r2 = recLeg.RateIndexTenor.Count.ToString(); } var idx1 = sinfo.Generator.Name.IndexOf(r1); var idx2 = sinfo.Generator.Name.IndexOf(r2); if ((idx1 < idx2 && info.TradeAction.Equals("B")) || (idx1 > idx2 && (info.TradeAction.Equals("S")))) { swap.SwitchLegs(); } if (idx2 < idx1) { leg1 = recLeg; leg2 = payLeg; } InitLegs2(leg1, leg2, info); } else { if ((info.TradeAction.Equals("S") && !swap.PayLeg.IsFixedRate) || (info.TradeAction.Equals("B") && swap.PayLeg.IsFixedRate)) swap.SwitchLegs(); InitLegs(swap.PayLeg, swap.ReceiveLeg, info); } if (trade.CcpId != 0) { //Nothing to do let the EventScheduleHelper insert the StepIn } else { if (swap.PayLeg.StartDate < trade.GetTradingDay()) { swap.PayLeg.FirstFullCalculationPeriod = true; swap.PayLeg.FirstCalculationPeriodStart = sinfo.SwapStartDate1; swap.ReceiveLeg.FirstFullCalculationPeriod = true; swap.ReceiveLeg.FirstCalculationPeriodStart = sinfo.SwapStartDate1; swap.PayLeg.StartDate = trade.GetTradingDay(); swap.ReceiveLeg.StartDate = swap.PayLeg.StartDate; } } } else if (info.SecurityType.Equals(SwapInfo.CcySwap)) { var swap = trade.Product as CurrencySwap; var mtm = trade.Product as MTMCurrencySwap; Leg payLeg, recLeg, leg1, leg2; payLeg = swap != null ? swap.PayLeg : mtm.PayLeg; recLeg = swap != null ? swap.ReceiveLeg : mtm.ReceiveLeg; if (info.TradeAction.Equals("B") && recLeg.NotionalCurrency.Equals(info.Currency2) || (info.TradeAction.Equals("S") && recLeg.NotionalCurrency.Equals(info.Currency1))) { if (swap != null) swap.SwitchLegs(); else mtm.SwitchLegs(); } if (payLeg.NotionalCurrency.Equals(info.Currency1)) { leg1 = payLeg; leg2 = recLeg; } else { leg2 = payLeg; leg1 = recLeg; } InitLegs2(leg1, leg2, info); } else if (info.SecurityType.Equals(SwapInfo.Fras)) { var fra = trade.Product as FRA; InitFra(fra, info); } sinfo.Generator.Provider.FillTrade(trade, market); trade.SetProperty("TemplateName", sinfo.Generator.Name); trade.SetProperty(TradeImportHelper.GeneratorProp, info.Instrument); //Add UpFront Fee if (Math.Abs(sinfo.FeeAmount) > Utilities.Epsilon) { var fee = new Fee { Date = sinfo.FeeDate, FeeType = FeeType.Upfront, PartyId = trade.PartyId, Currency = sinfo.FeeCurrency, Amount = Math.Abs(sinfo.FeeAmount), PayReceive = sinfo.FeePayRecv.Equals("Pay") ? PayReceive.Pay : PayReceive.Receive // how about None?? }; if (trade.Fees == null) trade.Fees = new List<Fee>(); trade.Fees.Add(fee); } trades.Add(trade); } catch (Exception x) { Logger.Error("Import Swap/FRA/CurrencySwap/NDS", x); sb.Append(TradeImportHelper.FormatErrorMessage("Fill Trade " + x.Message + " " + x.StackTrace, info.HoldingID, info.TradeID, info.Instrument)); } } sb.Append("Imported " + trades.Count + " Swaps/Fras/CurrencySwap/NDS\n"); if (filterData.Progress != null) filterData.Progress.AnalysisDone(); return trades; }
public override bool ExcludeFromMatching(Trade trade, DateTime dt, bool isExternalTrade) { if (isExternalTrade) { if ((trade.Status != null && trade.Status.Equals(MurexInfo.StateDead))) { trade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); trade.SetProperty(ReconcileTaskExecutor.ImportRef, "Dead"); return true; } if (Math.Abs(trade.Quantity) < Utilities.Epsilon) { trade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); trade.SetProperty(ReconcileTaskExecutor.ImportRef, "ZeroQuantity"); return true; } if (trade.Description != null) { if (!(trade.Description.Equals(TradeInfo.Bonds) || trade.Description.Equals(TradeInfo.EquityFutures) || trade.Description.Equals(TradeInfo.LongFutures) || trade.Description.Equals(TradeInfo.ShortFutures) || trade.Description.Equals(TradeInfo.ComFutures) || trade.Description.Equals(TradeInfo.OtherFutures) || trade.Description.Equals(TradeInfo.IrfOption) || trade.Description.Equals(TradeInfo.EqOption) || trade.Description.Equals(SwapInfo.IRSwap) || trade.Description.Equals(SwapInfo.CcySwap) || trade.Description.Equals(MurexInfo.Fras) || trade.Description.Equals(SwaptionInfo.Swaption) || trade.Description.Equals(FxInfo.SpotForward) || trade.Description.Equals(FxoInfo.SimpleFXO))) { trade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); trade.SetProperty(ReconcileTaskExecutor.ImportRef, "TypeNotSupported"); return true; } } else { trade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); trade.SetProperty(ReconcileTaskExecutor.ImportRef, "TypeUnkonwn"); return true; } } var maturity = trade.Product.RiskMaturity; var maturity2 = trade.Product.ContractMaturity; if (!maturity2.IsNull && maturity2 < maturity) maturity = maturity2; if (!maturity.IsNull && maturity <= new SimpleDate(dt)) { trade.SetProperty(ReconcileTaskExecutor.Reconciled, "true"); trade.SetProperty(ReconcileTaskExecutor.ImportRef, "Matured"); return true; } return false; }