示例#1
0
        private void AddStatisticAccount(RatingAccount ratingAccount, AccountDayStatistic statistic, AccountRole accType, List <Trader> traders, List <SignalProvider> providers, List <Manager> s)
        {
            if (statistic.MaxOpenOrders <= 0)
            {
                return;
            }

            switch (accType)
            {
            case AccountRole.Trading:
                traders.Add(new Trader
                {
                    AccountId        = ratingAccount.AccountId,
                    Age              = ratingAccount.Age,
                    Country          = ratingAccount.Country,
                    AccountNickname  = ratingAccount.Nickname,
                    Login            = ratingAccount.Login,
                    LoseOrders       = statistic.ClosedLoseTradesTotal,
                    MaxDailyDrowdown = (float)statistic.MaxDailyDrowdown,
                    Profit           = (float)statistic.ClosedProfitInPointsTotal,
                    ProfitLastDay    = (float)statistic.ClosedProfitInPointsPerDay,
                    ProfitOrders     = statistic.ClosedProfitTradesTotal,
                    Volatility       = (float)statistic.VolatilityPerDay,
                    Avatar           = ratingAccount.Avatar,
                    Rating           = ratingAccount.Rating,
                    ClientNickname   = ratingAccount.ClientNickname,
                    Currency         = ratingAccount.Currency,
                    Chart            = statisticRepository.GetDecimatedChart(ratingAccount.AccountId, Constants.PointsCountInSmallChart,
                                                                             StatisticRepository.StatisticType.ProfitInPointsTotal),
                    AccountsNumber = ratingAccount.AccountsNumber,
                });
                break;

            case AccountRole.SignalProvider:
                var subscribers = signalService.GetProviderSubscribers(ratingAccount.AccountId);
                if (!subscribers.IsSuccess)
                {
                    throw new Exception(subscribers.Error);
                }
                providers.Add(new SignalProvider
                {
                    AccountId        = ratingAccount.AccountId,
                    Age              = ratingAccount.Age,
                    Country          = ratingAccount.Country,
                    AccountNickname  = ratingAccount.Nickname,
                    Login            = ratingAccount.Login,
                    Profit           = (float)statistic.ClosedProfitInPointsTotal,
                    ProfitLastDay    = (float)statistic.ClosedProfitInPointsPerDay,
                    Subscribers      = subscribers.Result.Length,
                    LoseOrders       = statistic.ClosedLoseTradesTotal,
                    MaxDailyDrowdown = (float)statistic.MaxDailyDrowdown,
                    ProfitOrders     = statistic.ClosedProfitTradesTotal,
                    Volatility       = (float)statistic.VolatilityPerDay,
                    Avatar           = ratingAccount.Avatar,
                    Rating           = ratingAccount.Rating,
                    ClientNickname   = ratingAccount.ClientNickname,
                    Currency         = ratingAccount.Currency,
                    Chart            = statisticRepository.GetDecimatedChart(ratingAccount.AccountId, Constants.PointsCountInSmallChart,
                                                                             StatisticRepository.StatisticType.ProfitInPointsTotal),
                    AccountsNumber = ratingAccount.AccountsNumber,
                });
                break;

            case AccountRole.Master:
                var investorsCount = Service.GetIvestorsCount(ratingAccount.AccountId);
                if (!investorsCount.IsSuccess)
                {
                    throw new Exception(investorsCount.Error);
                }
                s.Add(new Manager
                {
                    AccountId        = ratingAccount.AccountId,
                    Age              = ratingAccount.Age,
                    Country          = ratingAccount.Country,
                    AccountNickname  = ratingAccount.Nickname,
                    Login            = ratingAccount.Login,
                    Profit           = (float)statistic.ClosedProfitInPercentsTotal,
                    ProfitLastDay    = (float)statistic.ClosedProfitInPercentsPerDay,
                    Investors        = investorsCount.Result,
                    LoseOrders       = statistic.ClosedLoseTradesTotal,
                    MaxDailyDrowdown = (float)statistic.MaxDailyDrowdown,
                    ProfitOrders     = statistic.ClosedProfitTradesTotal,
                    Volatility       = (float)statistic.VolatilityPerDay,
                    Avatar           = ratingAccount.Avatar,
                    Rating           = ratingAccount.Rating,
                    ClientNickname   = ratingAccount.ClientNickname,
                    Currency         = ratingAccount.Currency,
                    Chart            = statisticRepository.GetDecimatedChart(ratingAccount.AccountId, Constants.PointsCountInSmallChart,
                                                                             StatisticRepository.StatisticType.ProfitInPercentTotal),
                    AccountsNumber = ratingAccount.AccountsNumber,
                });
                break;
            }
        }