Example #1
0
 public static AccountGroup DecorateAccountGroup(ACCOUNT_GROUP ag, DEALER_GROUP dealerGroup)
 {
     var group = DecorateAccountGroup(ag);
     if (dealerGroup == null) return group;
     group.MessageQueue = dealerGroup.MessageQueue;
     group.SessionName = dealerGroup.SessionName;
     group.HedgingAccount = dealerGroup.HedgingAccount;
     group.SenderCompId = dealerGroup.SenderCompId;
     group.Markup = (AccountGroup.MarkupType)ag.MarkupType;
     group.DefaultMarkupPoints = (float)ag.DefaultMarkupPoints;
     group.Dealer = new DealerDescription { Code = dealerGroup.Dealer };
     return group;
 }
Example #2
0
 public static AccountGroup DecorateAccountGroup(ACCOUNT_GROUP ag)
 {
     var group = new AccountGroup
     {
         Code = ag.Code,
         BrokerLeverage = (float)ag.BrokerLeverage,
         DefaultVirtualDepo = ag.DefaultVirtualDepo ?? 0,
         IsReal = ag.IsReal,
         MarginCallPercentLevel = (float)ag.MarginCallPercentLevel,
         Name = ag.Name,
         StopoutPercentLevel = (float)ag.StopoutPercentLevel,
         Markup = (AccountGroup.MarkupType)ag.MarkupType,
         DefaultMarkupPoints = (float)ag.DefaultMarkupPoints
     };
     return group;
 }
Example #3
0
 /// <summary>
 /// Мапинг объекта "группа счетов" в объект Entity FW. Изменяется переданный объект.
 /// </summary>
 /// <param name="dest"></param>
 /// <param name="src"></param>
 public static void UndecorateAccountGroup(ACCOUNT_GROUP dest, AccountGroup src)
 {
     dest.Code = src.Code;
     dest.Name = src.Name;
     dest.IsReal = src.IsReal;
     dest.BrokerLeverage = (decimal)src.BrokerLeverage;
     dest.MarginCallPercentLevel = (decimal)src.MarginCallPercentLevel;
     dest.StopoutPercentLevel = (decimal)src.StopoutPercentLevel;
     dest.DefaultMarkupPoints = src.DefaultMarkupPoints;
     dest.DefaultVirtualDepo = src.DefaultVirtualDepo;
     dest.MarkupType = (int)src.Markup;
     dest.SwapFree = src.SwapFree;
 }
Example #4
0
 /// <summary>
 /// Мапинг объекта "группа счетов" в объект Entity FW. Возвращает новый объект ACCOUNT_GROUP
 /// </summary>
 /// <param name="src"></param>
 /// <returns></returns>
 public static ACCOUNT_GROUP UndecorateAccountGroup(AccountGroup src)
 {
     var result = new ACCOUNT_GROUP
         {
             Code = src.Code,
             Name = src.Name,
             IsReal = src.IsReal,
             BrokerLeverage = (decimal)src.BrokerLeverage,
             MarginCallPercentLevel = (decimal)src.MarginCallPercentLevel,
             StopoutPercentLevel = (decimal)src.StopoutPercentLevel,
             DefaultMarkupPoints = src.DefaultMarkupPoints,
             DefaultVirtualDepo = src.DefaultVirtualDepo,
             MarkupType = (int)src.Markup,
             SwapFree = src.SwapFree
         };
     return result;
 }
Example #5
0
        /// <summary>
        /// Внимание! Не тестировать по параметру isDemoAccount
        /// </summary>
        public override List <GetPositionList_Result> GetPositionListWrapped(int?countItemShow, int?accountId, int?isRealAccount, string symbol,
                                                                             int?status, int?side, DateTime?timeOpenFrom, DateTime?timeOpenTo, DateTime?timeExitFrom, DateTime?timeExitTo, out int totalItemCount)
        {
            var parameters =
                new[]
            {
                new Tuple <string, object>("accountId", accountId),
                new Tuple <string, object>("isRealAccount", isRealAccount),
                new Tuple <string, object>("symbol", symbol),
                new Tuple <string, object>("status", status),
                new Tuple <string, object>("side", side),
                new Tuple <string, object>("timeOpenFrom", timeOpenFrom),
                new Tuple <string, object>("timeOpenTo", timeOpenTo),
                new Tuple <string, object>("timeExitFrom", timeExitFrom),
                new Tuple <string, object>("timeExitTo", timeExitTo)
            };


            var position = new List <GetPositionList_Result>();

            #region Формируем списк всех сделок
            try
            {
                foreach (var pos in POSITION)
                {
                    position.Add(new GetPositionList_Result
                    {
                        AccountID    = pos.AccountID,
                        ID           = pos.ID,
                        IsClosed     = pos.State,
                        PriceEnter   = pos.PriceEnter,
                        PriceExit    = null,
                        ResultDepo   = null,
                        ResultPoints = null,
                        Side         = pos.Side,
                        Symbol       = pos.Symbol,
                        TimeEnter    = pos.TimeEnter,
                        TimeExit     = null
                    });
                }

                foreach (var closePos in POSITION_CLOSED)
                {
                    position.Add(new GetPositionList_Result
                    {
                        AccountID    = closePos.AccountID,
                        ID           = closePos.ID,
                        IsClosed     = 0,
                        PriceEnter   = closePos.PriceEnter,
                        PriceExit    = null,
                        ResultDepo   = null,
                        ResultPoints = null,
                        Side         = closePos.Side,
                        Symbol       = closePos.Symbol,
                        TimeEnter    = closePos.TimeEnter,
                        TimeExit     = null
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("GetPositionListWrapped(). Не удалось получить список сделок из тестовой БД.", ex);
                totalItemCount = -1;
                return(null);
            }

            #endregion

            #region Фильтруем сделки в соответствии с указанными фильтрами
            foreach (var param in parameters)
            {
                if (param.Item2 == null)
                {
                    continue;
                }
                switch (param.Item1)
                {
                case "accountId":
                    position = position.Where(x => x.AccountID == ((int?)param.Item2).Value).ToList();
                    break;

                case "isRealAccount":
                    var param1   = param;
                    var accGroup = ACCOUNT_GROUP.Where(x => x.IsReal == (((int?)param1.Item2).Value == 1));
                    var accId    = new List <int>();
                    foreach (var accountGroup in accGroup)
                    {
                        accId.AddRange(ACCOUNT.Where(x => x.AccountGroup == accountGroup.Code).Select(x => x.ID).ToList());
                    }
                    position = position.Where(x => accId.Contains(x.AccountID)).ToList();
                    break;

                case "symbol":
                    position = position.Where(x => x.Symbol == (string)param.Item2).ToList();
                    break;

                case "status":
                    position = position.Where(x => x.IsClosed == ((int?)param.Item2).Value).ToList();
                    break;

                case "side":
                    position = position.Where(x => x.Side == ((int?)param.Item2).Value).ToList();
                    break;

                case "timeOpenFrom":
                    position = position.Where(x => x.TimeEnter >= ((DateTime?)param.Item2).Value).ToList();
                    break;

                case "timeOpenTo":
                    position = position.Where(x => x.TimeEnter <= ((DateTime?)param.Item2).Value).ToList();
                    break;

                case "timeExitFrom":
                    position = position.Where(x => x.TimeExit >= ((DateTime?)param.Item2).Value).ToList();
                    break;

                case "timeExitTo":
                    position = position.Where(x => x.TimeExit >= ((DateTime?)param.Item2).Value).ToList();
                    break;
                }
            }

            if (countItemShow.HasValue)
            {
                position = position.Take(countItemShow.Value).ToList();
            }
            #endregion

            totalItemCount = position.Count;
            return(position);
        }