コード例 #1
0
 public static void CreateBook(string parent, string bookName, string strategy, string portfolio)
 {
     try
     {
         var exist = Env.Current.StaticData.GetPartyByCode(bookName);
         if (exist != null)
         {
             throw new Exception(String.Format("Book {0} already exists!", bookName));
         }
         else
         {
             var entity = Env.Current.StaticData.GetPartyByCode(parent);
             if (entity == null)
             {
                 throw new Exception("Cannot find entity" + entity);
             }
             var newStrategy = new Party { Code = bookName, Name = bookName, ParentId = entity.Id, Role = Party.Book, Description = "Legacy strategy" };
             newStrategy.SetProperty("Portfolio", portfolio);
             newStrategy.SetProperty("Strategy", strategy);
             Env.Current.StaticData.SaveParty(newStrategy);
             ScriptBase.Logger.InfoFormat("Created book {0} in pfolio {1}.", bookName, portfolio);
         }
     }
     catch (Exception ex)
     {
         ScriptBase.Logger.Error(ex);
     }
 }
コード例 #2
0
        internal static void SetBookPortfolio(Party book, string portfolio)
        {
            if (book.GetProperty(BookProp2) != null || portfolio == null) return;

            var temp = Env.Current.StaticData.GetDomain(BookPortfolio);
            var portfolios = temp != null ? temp.Values : null;
            book.SetProperty(BookProp2, portfolio);
            if (portfolios == null || !portfolios.Contains(portfolio))
                Logger.Warn("Trade Import book portfolio " + portfolio +" not recgonized");
            book.Action = UpdateAction;
            Env.Current.StaticData.SaveAndLoadParty(book);
            
        }
コード例 #3
0
        internal static Party LoadParty(PartyInfo info, StringBuilder sb)
        {
            var party = Env.Current.StaticData.GetPartyByCode(info.Code) ??
                        Env.Current.StaticData.GetPartyByProperty(Party.CounterParty, PartyMlpCode, info.Code);
            if (party == null)
            {
                party = new Party
                   {
                       Code = info.Code,
                       RoleList = info.RoleList,
                       Name = info.Name
                   };
                party.SetProperty(PartyCode2, info.Code2);
                party.SetProperty(PartyLabel, info.Label);
                party.SetProperty(PartyDisplay, info.Display);
                party.SetProperty(PartyMlpCode, info.Code);
                return party;
            }            

            
            {
                var display = party.GetProperty(PartyDisplay);
                var code2 = party.GetProperty(PartyCode2);
                var label = party.GetProperty(PartyLabel);
                var mlpCode = party.GetProperty(PartyMlpCode);
                var name = party.Name;
                var changed = false;
                if (info.Code != null && (mlpCode == null || !mlpCode.Equals(info.Code)))
                {
                    party.SetProperty(PartyMlpCode, info.Code);
                    changed = true;
                }
                if (info.Name != null && (name == null || !name.Equals(info.Name)))
                {
                    party.Name = info.Name;
                    changed = true;
                }
                if (info.Display != null && (display == null || !display.Equals(info.Display)))
                {
                    party.SetProperty(PartyDisplay, info.Display);
                    changed = true;
                }
                if (info.Code2 != null && (code2 == null || !code2.Equals(info.Code2)))
                {
                    party.SetProperty(PartyCode2, info.Code2);
                    changed = true;
                }
                if (info.Label != null && (label == null || !label.Equals(info.Label)))
                {
                    party.SetProperty(PartyLabel, info.Label);
                    changed = true;
                }
                foreach (var r in info.RoleList)
                {
                    if (!party.RoleList.Contains(r))
                    {
                        party.RoleList = info.RoleList;
                        changed = true;
                        break;
                    }
                }
                if (changed)
                {
                    party.Action = UpdateAction;
                    return party;
                }
                
            }
            return null;
        }
コード例 #4
0
 private void SetBookProperties(Party book)
 {
     foreach (var p in BookProperties)
     {
         book.SetProperty(p.Name, p.Value);
     }
 }