当前位置: 首页>>代码示例>>C#>>正文


C# Trade.SetProperty方法代码示例

本文整理汇总了C#中Trade.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Trade.SetProperty方法的具体用法?C# Trade.SetProperty怎么用?C# Trade.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trade的用法示例。


在下文中一共展示了Trade.SetProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Check

        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;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:12,代码来源:ScriptTestValidator3.cs

示例2: ExcludeFromMatching

 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;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:23,代码来源:ImagineTradeActivityRecon.cs

示例3: Check

 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;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:17,代码来源:TradeCheckFunding.cs

示例4: ExcludeFromMatching

 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;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:39,代码来源:ImaginePositionRecon.cs

示例5: InitTrade

        //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)
                {
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:TradeImportHelper.cs

示例6: ExcludeFromMatching

        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");
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:SymmetryPositionReconciler.cs

示例7: FromString

        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";
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:SymmetryPositionReconciler.cs

示例8: GetGeneratorName

        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;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:60,代码来源:SymmetryPositionReconciler.cs

示例9: SetMatchingFlag

 protected void SetMatchingFlag(Trade otTrade, Trade externalTrade)
 {
     otTrade.SetProperty(ImportRef, externalTrade.GetProperty("ImportRef"));
     otTrade.SetProperty(Reconciled, "true");
     externalTrade.SetProperty(Reconciled, "true");
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:6,代码来源:SymmetryPositionReconciler.cs

示例10: Reconcile


//.........这里部分代码省略.........
                            {
                                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;
开发者ID:heimanhon,项目名称:researchwork,代码行数:67,代码来源:SymmetryPositionReconciler.cs

示例11: FromString

        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
            {
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:MurexPosTradeRecon.cs

示例12: Reconcile

        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;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:43,代码来源:ImagineTradeActivityRecon.cs

示例13: Import


//.........这里部分代码省略.........
                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;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:SwaptionImporter.cs

示例14: SetImporterProperty

 protected void SetImporterProperty(Trade trade)
 {
     trade.SetProperty("TradeSource", "SymmetryImporter");
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:4,代码来源:SymmetryImportPanel.cs

示例15: Reconcile

        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)
                    {
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:MurexPosTradeRecon.cs


注:本文中的Trade.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。