Ejemplo n.º 1
0
 virtual public bool FilterInfo(TradeInfo info)
 {
     return !(info.SecurityType.Equals(TradeInfo.OtherFutures) || info.SecurityType.Equals(TradeInfo.ComFutures)
         || info.SecurityType.Equals(TradeInfo.ShortFutures) || info.SecurityType.Equals(TradeInfo.LongFutures)
         || info.SecurityType.Equals(TradeInfo.EquityFutures) || info.SecurityType.Equals(TradeInfo.Future)
         || info.SecurityType.Equals(TradeInfo.DepositFut) || info.SecurityType.Equals(TradeInfo.BondFut)
         || info.SecurityType.Equals(TradeInfo.QuantoFut));
 }
Ejemplo n.º 2
0
        protected override string TryGetTicker(TradeInfo info, out string display)
        {
            display = string.Empty;
            if (info.Identifier1 == null) return null;
            var tickerSymbol = info.Identifier1.Length == 1 ? info.Identifier1 + " " : info.Identifier1;
            var contractMonth = info.Symbol.Substring(info.Symbol.Length - 2);
            char monthRt = contractMonth[0];        
            var isCall = info.PutCall.StartsWith("C");
            Month month = 0;
            try
            {
                month = DateHelper.FromImmRt(monthRt, isCall);
            }
            catch (Exception e)
            {
                Logger.Error("Error parsing Ticker " + info.Symbol);
                Logger.Error(e);
                month = (Month)info.Maturity.Month;
                
            }

            if (!char.IsDigit(contractMonth[1]))
            {
                var year = (info.Maturity.Year % 10).ToString();
                contractMonth = DateHelper.ToImm(month) + year;
            }
            else
            {
                contractMonth = contractMonth.Replace(monthRt, DateHelper.ToImm(month));            // from rt to bbg  
            }
            
            var ticker = tickerSymbol + contractMonth + info.PutCall + " " + info.Strike;
            display = tickerSymbol + " " + TradeImportHelper.FormatDate(info.Maturity) + " " + info.PutCall + info.Strike;
            if (info.SecurityType.Equals(TradeInfo.IrfOption))
            {
                ticker += " Comdty";
                display += " Comdty";
            }
            else if (info.SecurityType.Equals(TradeInfo.EqOption))
            {
                ticker += " Equity";
                display += " Equity";
            }
            else
            {
                ticker += " Comdty";
                display += " Comdty";
            }
            return ticker;
        }
Ejemplo n.º 3
0
        virtual protected Future FindFuture(Feed feed, TradeInfo info, IList<Contract> contracts, string ticker, out Contract contract)
        {
            contract = null;
            try
            {
                //First Find Contract;  
                var words = ticker.Split(' ');
                string symbol = ticker;
                if (words.Length == 2)
                    symbol = words[0];
                else if (words.Length == 3)
                    symbol = words[0] + " " + words[1];
                foreach (var c in contracts)
                {
                    if (ticker.StartsWith(c.TickerSymbol) && ticker.EndsWith(c.TickerSuffix))
                    {
                        contract = c;
                        break;
                    }
                }

                if (contract == null) return null;
                var fromDate = info.ReportDate.AddYears(1) > info.Maturity ? info.ReportDate : info.Maturity.AddMonths(-1);
                var exps = GetExpirations(feed, contract, fromDate);
                if (exps == null || exps.Count == 0) return null;
                foreach (var exp in exps)
                {
                    if (contract.GetFutureCode(exp).EndsWith(symbol)) 
                        return contract.CreateFuture(exp);
                }
                
                return null;
            }
            catch (Exception x)
            {
                Logger.Error("FindFuture " + ticker, x);
                return null;
            }
            
        }        
Ejemplo n.º 4
0
 protected override Future FindFuture(Feed feed, TradeInfo info, IList<Contract> contracts, string ticker, out Contract contract)
 {
     contract = null;
     var exceptions = new List<Exception>();
     var validContracts = new List<Contract>();
     foreach (var c in contracts)
     {
         if (ticker.StartsWith(c.TickerSymbol) && ticker.EndsWith(c.TickerSuffix))
         {
             validContracts.Add(c);
             contract = c;
         }
     }
     if (contract == null) return null;
     var fromDate = info.ReportDate.AddYears(1) > info.Maturity ? info.ReportDate : info.Maturity.AddMonths(-1);
     var exps = GetExpirations(feed, contract, fromDate);
     if (exps == null || exps.Count == 0) return null;
     //var monthdate = ParseMonthDate(ticker);
     var monthdate = info.Maturity;
     var fut = ImportHelper.FindFuture(true, null, contracts, ticker, null, null, monthdate,
                 info.Maturity, info.Strike, info.PutCall.Equals("P") ? OptionType.Put : OptionType.Call, info.Currency1, exceptions, null);
     if (info.SecurityType.Equals(TradeInfo.EqFutOption))
     {
         // This adjustment is only applied to future option from Imagine
         if (fut.ContractMonth.Year != monthdate.Year || fut.ContractMonth.Month != monthdate.Month)
         {
             if (fut.ContractMonth > monthdate)
                 fut = ImportHelper.FindFuture(true, null, contracts, ticker, null, null, monthdate,
                     info.Maturity.AddMonths(-1), info.Strike, info.PutCall.Equals("P") ? OptionType.Put : OptionType.Call, info.Currency1, exceptions, null);
             else if (fut.ContractMonth < monthdate)
                 fut = ImportHelper.FindFuture(true, null, contracts, ticker, null, null, monthdate,
                     info.Maturity.AddMonths(1), info.Strike, info.PutCall.Equals("P") ? OptionType.Put : OptionType.Call, info.Currency1, exceptions, null);
         }
         if (fut.ContractMonth.Year != monthdate.Year || fut.ContractMonth.Month != monthdate.Month) return null;
     }
     return fut;
 }
Ejemplo n.º 5
0
        internal static IList<TradeInfo> ReadData(FilterTrade filterTrade, FilterData filterData, StringBuilder sb)
        {
            var fileName= filterData.FolderName;

            if (!File.Exists(fileName))
            {
                if (sb != null) sb.Append("File " + fileName + " not found\n");
                return new List<TradeInfo>();
            }
            
            var list = new List<TradeInfo>();
            using (var stream = File.OpenRead(fileName))
            {
                using (var reader = new StreamReader(stream))
                {
                    string line;
                    var header = reader.ReadLine();
                    if (string.IsNullOrEmpty(header))
                    {
                        Logger.Error("[Error Read File] Empty Headers ... ");
                        return new List<TradeInfo>();
                    }
                    var headers = new Dictionary<string, int>();
                    using (var csvParser = new TextFieldParser(new StringReader(header)))
                    {
                        csvParser.SetDelimiters(new[] { "," });
                        var hss = csvParser.ReadFields();
                        int idx = 0;
                        foreach (var s in hss)
                        {
                            headers[s.Trim()] = idx++;
                        }
                    }
                    //var hss = header.Split(Separators, StringSplitOptions.None);
                    int skipped1 = 0, skipped2 = 0, skipped3 = 0, skipped4 = 0, skipped5 = 0;
                    var count = 0;
                    while ((line = reader.ReadLine()) != null)
                    {
                        count++;
                        //Parse Line here
                        if (string.IsNullOrEmpty(line)) break; //we are at end
                        var tinfo = new TradeInfo(line, headers);

                        // start filtering out bad entries
                        // 1. Symbol not found
                        // 2. Duplicated entries
                        // 3. Trade has expired
                        // 4. Quantity/Nominal is 0
                        // 5. Security type not support

                        var isblankedOut = tinfo.IsMurex && tinfo.SecurityType.Equals(FxInfo.SpotForward);  // murex spotforward info is blanked out
                        var isSymbolBlankedOut = isblankedOut || (tinfo.IsMurex && tinfo.SecurityType.Equals(SwapInfo.CcySwap));
                        if (tinfo.ReportDate.IsNull) tinfo.ReportDate = filterData.LiveDate;
                        if (!isSymbolBlankedOut && tinfo.Symbol == null)
                        {
                            var msg = FormatReadFileMessage("Product Symbol not found", tinfo.Instrument, tinfo.HoldingID, tinfo.TradeID);
                            Logger.Warn("Trade Import " + msg);
                            //sb.Append(msg);
                            skipped1++;
                            continue;
                        }
                        if (tinfo.IsMurex && tinfo.HoldingID != null)
                        {
                            // right now only Murex has id for each entry
                            if (filterData.ExistingIds.Contains(tinfo.HoldingID))
                            {
                                var msg = FormatReadFileMessage("Duplicated HoldingID found", tinfo.Instrument, tinfo.HoldingID, tinfo.TradeID);
                                //sb.Append(msg);
                                Logger.Warn("Trade Import " + msg);
                                skipped2++;
                                continue;
                            }
                            else
                                filterData.ExistingIds.Add(tinfo.HoldingID);
                        }
                        if (!tinfo.Maturity.IsNull && filterData.LiveDate > tinfo.Maturity)
                        {
                            if (tinfo.IsMurex || tinfo.Maturity.Month != filterData.LiveDate.Month)
                            {
                                var msg = FormatReadFileMessage("Trade has matured before live date", tinfo.Instrument, tinfo.HoldingID, tinfo.TradeID);
                                //sb.Append(msg);
                                Logger.Warn("Trade Import " + msg);
                                skipped3++;
                                continue;
                            }
                        }
                        if (tinfo.Nominal1 == 0 && tinfo.Nominal2 == 0)
                        {
                            var msg = FormatReadFileMessage("Trade's quantity/nominal is 0", tinfo.Instrument, tinfo.HoldingID, tinfo.TradeID);
                            //sb.Append(msg);
                            Logger.Warn("Trade Import " + msg);
                            skipped4++;
                            continue;
                        }
                        if (!tinfo.IsMurex && !SecurityTypeSupported(tinfo.SecurityType))
                        {
                            var msg = FormatReadFileMessage("Security type(" + (tinfo.SecurityType ?? string.Empty) + ") is not supported by the importer",
                                tinfo.Instrument, tinfo.HoldingID, tinfo.TradeID);
                            Logger.Warn("Trade Import " + msg);
                            skipped5++;
                            continue;
                        }
                        list.Add(tinfo);
                    }
                    var skipped = skipped1 + skipped2 + skipped3 + skipped4 + skipped5;
                    sb.Append(skipped + "/" + count + " entries are skipped at file loading\n");
                    if (skipped1 > 0) sb.Append("Skip symbol is null " + skipped1 + "\n");
                    if (skipped2 > 0) sb.Append("Skip duplicated entries " + skipped2 + "\n");
                    if (skipped3 > 0) sb.Append("Skip trade has expired " + skipped3 + "\n");
                    if (skipped4 > 0) sb.Append("Skip 0 quality/norminal " + skipped4 + "\n");
                    if (skipped5 > 0) sb.Append("Skip security type not identified " + skipped5 + "\n");
                }
            }
            filterData.Data = list;
            return list;
        }
Ejemplo n.º 6
0
        private void FillOptionInfo(TradeInfo info, FXOption fxo, OptionInfo optionInfo)
        {
            if (info.SecurityType.Equals(FxoInfo.SimpleFXO))
            {
                // european digital and european
                if (info.OptionStyle.Equals("D"))
                {
                    var dinfo = optionInfo as DigitalInfo;
                    if (dinfo == null)
                    {
                        dinfo = new DigitalInfo();
                        fxo.OptionInfo = dinfo;
                        dinfo.Option = fxo;
                    }
                    fxo.ExerciseType = OptionExerciseType.Digital;
                    dinfo.ExerciseType = OptionExerciseType.European;
                    dinfo.StartDate = info.Maturity;
                    dinfo.EndDate = info.Maturity;
                    if (fxo.OptionType == OptionType.Call)
                    {
                        dinfo.BarrierStrike = fxo.OptionStrike;
                        dinfo.BarrierType = OptionBarrierType.Touch;
                        dinfo.LowerBarrierStrike = 0;
                        dinfo.LowerBarrierType = OptionBarrierType.None;
                    }
                    else
                    {
                        dinfo.LowerBarrierStrike = fxo.OptionStrike;
                        dinfo.LowerBarrierType = OptionBarrierType.Touch;
                        dinfo.BarrierStrike = 0;
                        dinfo.BarrierType = OptionBarrierType.None;
                    }
                    // pay off, currency, and payout style: deferred or...
                }
                else
                    fxo.ExerciseType = OptionExerciseType.European;
                    // settle currency
            }
            /*
            else if (info.SecurityType.Equals(TradeInfo.BarrierFXO))
            {
                // barrier
                var binfo = optionInfo as BarrierInfo;
                if (binfo == null)
                {
                    binfo = new BarrierInfo();
                    fxo.OptionInfo = binfo;
                    binfo.Option = fxo;
                }
                binfo.ExerciseType = OptionExerciseType.European;
                // start/end date
                // barrier type and strike

            }
            else if (info.SecurityType.Equals(TradeInfo.TouchFXO))
            {
                // touch
                var tinfo = optionInfo as DigitalInfo;
                if (tinfo == null)
                {
                    tinfo = new DigitalInfo();
                    fxo.OptionInfo = tinfo;
                    tinfo.Option = fxo;
                }
                tinfo.ExerciseType = OptionExerciseType.American;
                // barrier strike and type
                // rebate amount
            }*/
        }
Ejemplo n.º 7
0
 public bool FilterInfo(TradeInfo info)
 {
     return !(info.SecurityType.Equals(FxInfo.SpotForward) || info.SecurityType.Equals(TradeInfo.CrossCurrency)
             || info.SecurityType.Equals(FxoInfo.SimpleFXO));
 }
Ejemplo n.º 8
0
 public bool FilterInfo(TradeInfo info)
 {
     return !info.SecurityType.Equals(TradeInfo.Stock);
 }
Ejemplo n.º 9
0
 protected override void SetSourceProperty(Future fut, TradeInfo info)
 {
     if (info.IsMurex)
     {
         var key = fut.Contract.TickerSymbol + " " + info.Maturity + " " + info.PutCall + info.Strike;
         if (string.IsNullOrEmpty(fut.GetProperty(TradeImportHelper.MurexMaturity)))
         {
             fut.SetProperty(TradeImportHelper.MurexMaturity, fut.Contract.TickerSymbol + " " + info.Maturity);
             Env.Current.Trade.SaveProduct(fut);
         }
     }
     else if (string.IsNullOrEmpty(fut.GetProperty(TradeImportHelper.ImagineMaturity)))
     {
         fut.SetProperty(TradeImportHelper.ImagineMaturity, info.Symbol);
         Env.Current.Trade.SaveProduct(fut);
     }
 }
Ejemplo n.º 10
0
  // fra
  void InitFra(FRA fra, TradeInfo tinfo)
  {
      var sinfo = tinfo.Otc as SwapInfo;
      if (sinfo == null) return;
      fra.IsPay = tinfo.TradeAction.Equals("B") ? true : false;
      fra.FixedRate = tinfo.Price / 100;
      fra.Notional = Math.Abs(tinfo.Nominal1);
      fra.StartDate = sinfo.SwapStartDate1;
      fra.EndDate = sinfo.SwapMaturity1;
 
  }
Ejemplo n.º 11
0
 override public bool FilterInfo(TradeInfo info)
 {
     return !(info.SecurityType.Equals(TradeInfo.IrfOption) || info.SecurityType.Equals(TradeInfo.EqOption)
             || info.SecurityType.Equals(TradeInfo.Option) || info.SecurityType.Equals(TradeInfo.EqFutOption));
 }
Ejemplo n.º 12
0
 static public void ApplyExercise(TradeInfo info, Trade trade,  SimpleDate exerciseDate, SimpleDate settleDate,double amount, Market market, StringBuilder sb)
 {
    
      var pevent = new ExerciseEvent(trade)
                      {
                          ExerciseTime = exerciseDate.ToDateTime(),
                          EffectiveDate = exerciseDate,
                          AmountCurrency = trade.SettleCurrency,
                          Amount = amount,
                          CashSettlementDate = settleDate
                      };
     pevent.ActivityTime = pevent.ExerciseTime;
     var handler = (ExerciseProductEventHandler)ProductEvent.Handler(pevent.EventType, trade.Product.ProcessingType);
     var newTrades = new List<Trade>();
     var modifiedTrades = new List<Trade>();
     handler.Process(pevent, market, trade, newTrades, modifiedTrades, new List<IProductEvent>());
     if (trade.Fees != null)
     {
         foreach (Fee f in trade.Fees)
         {
             if (f.Date == pevent.CashSettlementDate)
             {
                 f.InputAmount = amount;
             }
         }
     }
     trade.Status = "Exercised";
 }
Ejemplo n.º 13
0
 virtual protected string TryGetTicker2(TradeInfo info, out string display)
 {
     display = string.Empty;
     if (info.Identifier1 == null) return null;
     var monthdate = info.Symbol.Substring(info.Symbol.Length - 2);
     var tokens = info.Identifier1.Split(' ');
     if (tokens.Length < 2) return null;
     var tickerSymbol = tokens[0];
     var suffix = tokens[tokens.Length - 1];
     if (tickerSymbol.Length == 1) tickerSymbol += " ";
     display = tickerSymbol + " " + TradeImportHelper.FormatDate(info.Maturity) + " " + suffix;
     return tickerSymbol + monthdate + " " + suffix;
    
 }
Ejemplo n.º 14
0
 virtual protected string TryGetTicker(TradeInfo info, out string display)
 {
     display = string.Empty;
     if (info.Identifier1 == null) return null;
     var tickerSymbol = info.Identifier1.Length == 1 ? info.Identifier1 + " " : info.Identifier1;
     var ticker = tickerSymbol + info.Symbol.Substring(info.Symbol.Length-2);
     display = tickerSymbol + " " + TradeImportHelper.FormatDate(info.Maturity);
     // adding suffix here
     if (info.SecurityType.Equals(TradeInfo.EquityFutures))
     {
         ticker += " Index";
         display += " Index";
     }
     else if (info.SecurityType.Equals(TradeInfo.OtherFutures))
     {
         ticker += " Curncy";
         display += " Curncy";
     }
     else if (info.SecurityType.Equals(TradeInfo.LongFutures) || info.SecurityType.Equals(TradeInfo.ShortFutures))
     {
         ticker += " Comdty";
         display += " Comdty";
     }
     else
     {
         ticker += " Comdty";
         display += " Comdty";
     }
     return ticker;
 }
Ejemplo n.º 15
0
 static bool CreateBond(Trade trade, TradeInfo info, FilterData filterData, Market market, StringBuilder sb, TemplateProvider provider)
 {
     try
     {
         var bond = (Bond)info.Security;
         trade.Product = info.Security;
         // assuming file has all clean price
         trade.PriceType = QuotationType.CleanPrice;
         if (bond.IssueDate > trade.SettlementDate)
             trade.SettlementDate = bond.IssueDate;
         trade.Price /= 100;
         info.MarketPrice /= 100;
         
         trade.Quantity = info.Nominal1/bond.FaceValue;
         if (!double.IsNaN(info.Quantity))
         {
             if (trade.Quantity != info.Quantity)
                 sb.Append("Warning Bad Quantity for Trade" + " Symbol " + info.Symbol + "\n");
         }
         provider.FillTrade(trade, market);
         if (Double.IsNaN(trade.Accrual))
         {
             trade.Accrual = 0;
             sb.Append("Warning Bad Accrual for Trade" + " Symbol " + info.Symbol + "\n");
         }              
         return true;
     }            
     catch (Exception x)
     {
         Logger.Error("Import Bond", x);
         sb.Append(TradeImportHelper.FormatErrorMessage("Fill Trade " + x.Message, info.HoldingID, info.TradeID, info.Instrument));
         return false;
     }
 }
Ejemplo n.º 16
0
        void InitLegs(Leg payLeg, Leg recLeg, TradeInfo tinfo)
        {
            var swInfo = tinfo.Otc as SwaptionInfo;
            if (swInfo == null) return;
            payLeg.NotionalCurrency = tinfo.Currency1;
            recLeg.NotionalCurrency = tinfo.Currency1;
            payLeg.StartDate = swInfo.SwapStartDate1;
            payLeg.EndDate = swInfo.SwapMaturity1;
            recLeg.StartDate = swInfo.SwapStartDate1;
            recLeg.EndDate = swInfo.SwapMaturity1;
            payLeg.Notional = Math.Abs(tinfo.Nominal1);
            recLeg.Notional = Math.Abs(tinfo.Nominal1);

            var floatLeg = payLeg.IsFixedRate ? recLeg : payLeg;
            var fixedLeg = payLeg.IsFixedRate ? payLeg : recLeg;
            fixedLeg.FixedRate = swInfo.FixedRate / 100;
        }
Ejemplo n.º 17
0
 public bool FilterInfo(TradeInfo info)
 {
     return !info.SecurityType.Equals(SwaptionInfo.Swaption);
 }
Ejemplo n.º 18
0
        //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;
        }
Ejemplo n.º 19
0
        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;
            }
        }        
Ejemplo n.º 20
0
        // fixed-float: irswap
        void InitLegs(Leg payLeg, Leg recLeg, TradeInfo tinfo)
        {
            var sinfo = tinfo.Otc as SwapInfo;
            var floatLeg = payLeg.IsFixedRate ? recLeg : payLeg;
            var fixedLeg = payLeg.IsFixedRate ? payLeg : recLeg;
            if (sinfo == null) return;
            payLeg.NotionalCurrency = tinfo.Currency1;
            recLeg.NotionalCurrency = tinfo.Currency1;
            payLeg.StartDate = sinfo.SwapStartDate1;
            recLeg.StartDate = sinfo.SwapStartDate1;
            payLeg.EndDate = sinfo.SwapMaturity1;
            recLeg.EndDate = sinfo.SwapMaturity1;
            payLeg.Notional = Math.Abs(tinfo.Nominal1);
            recLeg.Notional = Math.Abs(tinfo.Nominal1);
            fixedLeg.FixedRate = tinfo.Price / 100;

            if (sinfo.Spread2 != 0)     // L2 is floating leg
                floatLeg.Spread = sinfo.Spread2 / 100;
            if (sinfo.FirstFixingRate != 0)
                floatLeg.FirstFixing = sinfo.FirstFixingRate / 100;
        }
Ejemplo n.º 21
0
 public bool FilterInfo(TradeInfo info)
 {
     return !(info.SecurityType.Equals(SwapInfo.IRSwap) || info.SecurityType.Equals(SwapInfo.Fras)
              || info.SecurityType.Equals(SwapInfo.CcySwap));
 }
Ejemplo n.º 22
0
 virtual protected void SetSourceProperty(Future fut, TradeInfo info)
 {
     if (info.IsMurex)
     {
         var key = fut.Contract.TickerSymbol + " " + info.Maturity;
         if (fut.GetProperty(TradeImportHelper.MurexMaturity) == null)
         {
             fut.SetProperty(TradeImportHelper.MurexMaturity, fut.Contract.TickerSymbol + " " + info.Maturity);
             Env.Current.Trade.SaveProduct(fut);
         }
     }
     else if (fut.GetProperty(TradeImportHelper.ImagineMaturity) == null)
     {
         fut.SetProperty(TradeImportHelper.ImagineMaturity, info.Symbol);
         Env.Current.Trade.SaveProduct(fut);
     }
     
 }
Ejemplo n.º 23
0
 // float-float: currency swap, basis swap
 void InitLegs2(Leg leg1, Leg leg2, TradeInfo tinfo)
 {
     var sinfo = tinfo.Otc as SwapInfo;
     if (sinfo == null) return;
     leg1.NotionalCurrency = tinfo.Currency1;
     leg2.NotionalCurrency = tinfo.Currency2;
     leg1.StartDate = sinfo.SwapStartDate1;
     leg2.StartDate = sinfo.SwapStartDate2;
     leg1.EndDate = sinfo.SwapMaturity1;
     leg2.EndDate = sinfo.SwapMaturity2;
     leg1.Notional = Math.Abs(tinfo.Nominal1);
     leg2.Notional = Math.Abs(tinfo.Nominal2);
     leg1.Spread = sinfo.Spread1 / 100;
     leg2.Spread = sinfo.Spread2 / 100;
     // ...
 }
Ejemplo n.º 24
0
        static bool CreateEquity(Trade trade, TradeInfo info, Market market, StringBuilder sb, TemplateProvider provider)
        {
            try
            {
                trade.Product = info.Security;
                trade.PriceType = trade.Product.QuoteName.QuoteType;
                // add ...

                provider.FillTrade(trade, market);
                
                return true;
            }
            catch (Exception x)
            {
                Logger.Error("Import Equity", x);
                sb.Append(TradeImportHelper.FormatErrorMessage("Fill Trade " + x.Message, info.HoldingID, info.TradeID, info.Instrument));
                return false;
            }
            
        }
Ejemplo n.º 25
0
 public bool FilterInfo(TradeInfo info)
 {
     return !info.SecurityType.Equals(TradeInfo.BondRepo);
 }
Ejemplo n.º 26
0
 protected override string TryGetTicker2(TradeInfo info, out string display)
 {
     display = string.Empty;
     if (info.Identifier1 == null) return null;
     var tokens = info.Identifier1.Split(' ');
     if (tokens.Length < 2) return null;
     //var tickerSymbol = tokens[0];
     var tickerSymbol = tokens.Length == 2 ? tokens[0] : tokens[0] + " " + tokens[1] + " ";
     if (tickerSymbol.Length == 1) tickerSymbol += " ";
     display = tickerSymbol + " " + TradeImportHelper.FormatDate(info.Maturity) + " " + 
         info.PutCall + info.Strike + " " + tokens[tokens.Length - 1];
     return tickerSymbol + DateHelper.ToImm(info.Maturity) + (info.Maturity.Year % 10)
                + info.PutCall + " " + info.Strike + " " + tokens[tokens.Length - 1];
 }