public List<PerformerSearchCriteria> GetFilters()
 {
     var stat = new PerformerStat();
     var result = new List<PerformerSearchCriteria>();
     if (fioCheckBox.Checked)
         result.Add(new PerformerSearchCriteria
             {
                 propertyName = stat.Property(t => t.FullName),
                 compradant = fioTextBox.Text,
                 ignoreCase = !fioCSCheckBox.Checked
             });
     if (emailCheckBox.Checked)
         result.Add(new PerformerSearchCriteria
         {
             propertyName = stat.Property(t => t.Email),
             compradant = emailTextBox.Text,
             ignoreCase = !emailCSCheckBox.Checked
         });
     if (accountCheckBox.Checked)
         result.Add(new PerformerSearchCriteria
         {
             propertyName = stat.Property(t => t.Account),
             compradant = accountNumericUpDown.Value.ToString(),
             ignoreCase = true,
             checkWholeWord = true
         });
     return result;
 }
 public SubscriberStatisticsForm(PerformerStat performer)
     : this()
 {
     performerStatistic.DataBindCompleted += PerformerStatisticDataBindCompleted;
     performerStatistic.EnterRoomRequested += OnEnterRoomRequested;
     performerStatistic.DataBindAsynch(performer);
     performerStatistic.pageTargeted += OnPageTargeted;
 }
Пример #3
0
 public TopPortfolio(TopPortfolio topPortfolio)
 {
     Id = topPortfolio.Id;
     Name = topPortfolio.Name;
     Criteria = topPortfolio.Criteria;
     ParticipantCount = topPortfolio.ParticipantCount;
     DescendingOrder = topPortfolio.DescendingOrder;
     ManagedAccount = topPortfolio.ManagedAccount;
     Statistics = topPortfolio.Statistics;
     ManagerIds = topPortfolio.ManagerIds.ToList();
     Managers = topPortfolio.Managers.ToList();
     Orders = topPortfolio.Orders.ToList();
     MarginValue = topPortfolio.MarginValue;
     OwnerUser = topPortfolio.OwnerUser;
 }
Пример #4
0
 public TopPortfolio(TopPortfolio topPortfolio)
 {
     Id               = topPortfolio.Id;
     Name             = topPortfolio.Name;
     Criteria         = topPortfolio.Criteria;
     ParticipantCount = topPortfolio.ParticipantCount;
     DescendingOrder  = topPortfolio.DescendingOrder;
     ManagedAccount   = topPortfolio.ManagedAccount;
     Statistics       = topPortfolio.Statistics;
     ManagerIds       = topPortfolio.ManagerIds.ToList();
     Managers         = topPortfolio.Managers.ToList();
     Orders           = topPortfolio.Orders.ToList();
     MarginValue      = topPortfolio.MarginValue;
     OwnerUser        = topPortfolio.OwnerUser;
 }
Пример #5
0
 public PerformerStat(PerformerStat performer)
 {
     Account          = performer.Account;
     Login            = performer.Login;
     Group            = performer.Group;
     DepoCurrency     = performer.DepoCurrency;
     Service          = performer.Service;
     ServiceType      = performer.ServiceType;
     TradeSignalTitle = performer.TradeSignalTitle;
     SubscriberCount  = performer.SubscriberCount;
     if (performer.Chart != null)
     {
         Chart = new byte[performer.Chart.Length];
         Array.Copy(performer.Chart, Chart, performer.Chart.Length);
     }
     Score                       = performer.Score;
     Profit                      = performer.Profit;
     MaxLeverage                 = performer.MaxLeverage;
     AvgLeverage                 = performer.AvgLeverage;
     MaxRelDrawDown              = performer.MaxRelDrawDown;
     Sharp                       = performer.Sharp;
     AvgYearProfit               = performer.AvgYearProfit;
     GreedyRatio                 = performer.GreedyRatio;
     UserScore                   = performer.UserScore;
     ProfitLastMonths            = performer.ProfitLastMonths;
     TotalTradedInDepoCurrency   = performer.TotalTradedInDepoCurrency;
     AvgWeightedDealProfitToLoss = performer.AvgWeightedDealProfitToLoss;
     DealsCount                  = performer.DealsCount;
     WithdrawalLastMonths        = performer.WithdrawalLastMonths;
     Equity                      = performer.Equity;
     ProfitLastMonthsAbs         = performer.ProfitLastMonthsAbs;
     UserId                      = performer.UserId;
     FeeUSD                      = performer.FeeUSD;
     DaysTraded                  = performer.DaysTraded;
     SumProfitPoints             = performer.SumProfitPoints;
     IsRealAccount               = performer.IsRealAccount;
     FullName                    = performer.FullName;
 }
Пример #6
0
 public PerformerStat(PerformerStat performer)
 {
     Account = performer.Account;
     Login = performer.Login;
     Group = performer.Group;
     DepoCurrency = performer.DepoCurrency;
     Service = performer.Service;
     ServiceType = performer.ServiceType;
     TradeSignalTitle = performer.TradeSignalTitle;
     SubscriberCount = performer.SubscriberCount;
     if (performer.Chart != null)
     {
         Chart = new byte[performer.Chart.Length];
         Array.Copy(performer.Chart, Chart, performer.Chart.Length);
     }
     Score = performer.Score;
     Profit = performer.Profit;
     MaxLeverage = performer.MaxLeverage;
     AvgLeverage = performer.AvgLeverage;
     MaxRelDrawDown = performer.MaxRelDrawDown;
     Sharp = performer.Sharp;
     AvgYearProfit = performer.AvgYearProfit;
     GreedyRatio = performer.GreedyRatio;
     UserScore = performer.UserScore;
     ProfitLastMonths = performer.ProfitLastMonths;
     TotalTradedInDepoCurrency = performer.TotalTradedInDepoCurrency;
     AvgWeightedDealProfitToLoss = performer.AvgWeightedDealProfitToLoss;
     DealsCount = performer.DealsCount;
     WithdrawalLastMonths = performer.WithdrawalLastMonths;
     Equity = performer.Equity;
     ProfitLastMonthsAbs = performer.ProfitLastMonthsAbs;
     UserId = performer.UserId;
     FeeUSD = performer.FeeUSD;
     DaysTraded = performer.DaysTraded;
     SumProfitPoints = performer.SumProfitPoints;
     IsRealAccount = performer.IsRealAccount;
     FullName = performer.FullName;
 }
Пример #7
0
        public void InvestInPAMM(PerformerStat performer, decimal amount, bool investNotWithdraw, bool withdrawAll)
        {
            var accountData = AccountStatus.Instance.AccountData;
            if (accountData == null) return;

            var status =
                investNotWithdraw
                    ? TradeSharpWalletManager.Instance.proxy.InvestInPAMM(
                        CurrentProtectedContext.Instance.MakeProtectedContext(),
                        AccountStatus.Instance.Login, performer.Account, amount)
                    : TradeSharpWalletManager.Instance.proxy.WithdrawFromPAMM(
                        CurrentProtectedContext.Instance.MakeProtectedContext(),
                        AccountStatus.Instance.Login, performer.Account, amount, withdrawAll);

            if (status == RequestStatus.OK)
            {
                var msg = investNotWithdraw
                              ? "Сумма {0} {1} зачислена на счет №{2}"
                              : "Сумма {0} {1} списана со счета №{2}";

                MessageBox.Show(string.Format(msg, amount.ToStringUniformMoneyFormat(), accountData.Currency, performer.Account),
                    investNotWithdraw ? "Зачисление проведено" : "Списание проведено",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var opStatusName = EnumFriendlyName<RequestStatus>.GetString(status);
            var msgFail = investNotWithdraw
                              ? "Сумма {0} {1} не зачислена на счет: {2}"
                              : "Сумма {0} {1} не списана со счета: {2}";

            MessageBox.Show(string.Format(msgFail,
                    amount.ToStringUniformMoneyFormat(), accountData.Currency, opStatusName),
                    investNotWithdraw ? "Зачисление не проведено" : "Списание не проведено",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Пример #8
0
        public void OpenInvestInPAMMDialog(PerformerStat performer, bool invest)
        {
            ScheduleTaskOnSynchronizationCompleted(state =>
                {
                    if (walletExplicitDetail == null || performer == null) return;

                    var performerAccount = new Account
                        {
                            ID = performer.Account,
                            Currency = performer.DepoCurrency,
                            Balance = (decimal) performer.Equity,
                            Equity = (decimal) performer.Equity
                        };

                    // сколько можно вывести средств?
                    var userShare = walletExplicitDetail.realAccounts.FirstOrDefault(a => a.AccountId == performer.Account);
                    performerAccount.Balance = userShare == null ? 0 : userShare.ShareMoneyWallet;

                    // окно пополнения - снятия
                    var dlg = new WalletWithdrawForm(walletExplicitDetail.wallet,
                                                     gridAccount.GetRowValues<AccountShared>(false)
                                                                .Select(a => a.Account)
                                                                .ToList(),
                                                     performerAccount, true);
                    if (dlg.ShowDialog() != DialogResult.OK) return;

                    if (dlg.TargetWithdrawal > 0)
                        InvestInPAMM(performer, dlg.TargetWithdrawal, false, dlg.WithdrawAll);
                    if (dlg.TargetDespoit > 0)
                        InvestInPAMM(performer, dlg.TargetDespoit, true, dlg.WithdrawAll);
                });
        }
 // x == y ? 0 : (x > y ? 1 : -1)
 private static int ComparePerformerStats(PerformerStat x, PerformerStat y)
 {
     if (x == null)
     {
         if (y == null)
             return 0;
         return -1;
     }
     if (y == null)
         return 1;
     return x.UserScore.CompareTo(y.UserScore);
 }
Пример #10
0
 public PerformerStatRecord(PerformerStat record)
     : base(record)
 {
 }
Пример #11
0
 public PerformerStatEx(PerformerStat performer)
     : base(performer)
 {
 }
Пример #12
0
        private static bool CheckUserHasEnoughMoneyOrRefusesToPay(PerformerStat performer)
        {
            try
            {
                var wallet = TradeSharpWalletManager.Instance.proxy.GetUserWallet(
                        CurrentProtectedContext.Instance.MakeProtectedContext(),
                        AccountModel.Instance.GetUserLogin());
                if (wallet == null) throw new Exception("Wallet is null");

                if (wallet.Balance == 0)
                {
                    MessageBox.Show("В вашем кошельке отсутствуют средства.\nНевозможно подписаться на платные сигналы (" +
                        performer.FeeUSD.ToStringUniformMoneyFormat() + " " + PerformerStat.FeeCurrency + ")",
                        "Недостаточно средств");
                    return false;
                }

                // перевести сумму
                var walletAmount = performer.FeeUSD;
                if (wallet.Currency != PerformerStat.FeeCurrency)
                {
                    string errorString;
                    var amount = DalSpot.Instance.ConvertSourceCurrencyToTargetCurrency(wallet.Currency,
                        PerformerStat.FeeCurrency, (double) walletAmount, QuoteStorage.Instance.ReceiveAllData(), out errorString);
                    if (!amount.HasValue)
                        throw new Exception(errorString);
                    walletAmount = amount.Value;
                }

                // достаточно ли средств
                var msgText = string.Format("Стоимость подписки: {0} {1}, баланс кошелька: {2} {1}",
                                            walletAmount.ToStringUniformMoneyFormat(), wallet.Currency,
                                            wallet.Balance.ToStringUniformMoneyFormat());
                if (walletAmount > wallet.Balance)
                {
                    MessageBox.Show("В вашем кошельке недостаточно средств.\n" + msgText, "Недостаточно средств");
                    return false;
                }
                return MessageBox.Show(msgText + "\nПродолжить?",
                    "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
            }
            catch (Exception ex)
            {
                Logger.Error("Subscribe - ошибка получения инф. по кошельку", ex);
                return MessageBox.Show("Ошибка получения информации о кошельке. Продолжить?", "Ошибка",
                                       MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes;
            }
        }
Пример #13
0
        /// <summary>
        /// Попытка асинхронного получения данных статистики с сервера с их последующей привязкой
        /// </summary>
        public void DataBindAsynch(PerformerStat performer)
        {
            Performer = performer;

            AccountModel.Instance.Chat.RoomsReceived += RoomsReceived;
            AccountModel.Instance.Chat.GetRooms();

            worker.DoWork += GetPerformerEfficiency;
            worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
            worker.RunWorkerAsync();

            workerLoadOrders.DoWork += WorkerLoadOrdersOnDoWork;
            workerLoadOrders.RunWorkerCompleted += WorkerLoadOrdersOnRunWorkerCompleted;
        }
Пример #14
0
        /// <summary>
        /// подписаться или отписаться от получения торговых сигналов
        /// </summary>
        /// <param name="performer">сигнальщик</param>
        /// <param name="tradeAuto">оказать диалог автоторговли</param>
        public static bool SubscribeOrUnsubscribe(PerformerStat performer, bool? tradeAuto)
        {
            var isSubscribed = SubscriptionModel.Instance.SubscribedCategories.Any(s => s.Service == performer.Service);
            var isOk = isSubscribed ? Unsubscribe(performer) : Subscribe(performer, tradeAuto ?? false);

            if (!isOk) return false;

            if (!isSubscribed && (tradeAuto ?? false))
            {
                // показать диалог настройки авто-торговли
                var cat = SubscriptionModel.Instance.SubscribedCategories.FirstOrDefault(
                    c => c.Service == performer.Service);
                if (cat == null)
                    return false;
                var dlg = new AutoTradeSettingsForm(cat.AutoTradeSettings ?? new AutoTradeSettings());
                if (dlg.ShowDialog() != DialogResult.OK)
                    return false;
                cat.AutoTradeSettings = dlg.sets;
            }
            else
            {
                // предупредить пользователя - изменения вступят в силу не мгновенно
                var msg = "Вы " + (isSubscribed
                                   ? "отказались от получения торговых сигналов \""
                                   : "подписались на получение торговых сигналов\n \"") + performer.TradeSignalTitle + "\"";
                MessageBox.Show(msg);
            }

            return true;
        }
Пример #15
0
        public static void RebindStatisticsFastGrid(FastGrid.FastGrid grid, PerformerStat performer, AccountEfficiency efficiency)
        {
            if (performer == null)
                return;
            var singleValueData = new List<TradeSharp.Util.Cortege2<string, string>>();
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleProfitInPercents"),
                    b = performer.Profit.ToString("f2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleDealsTotal"),
                    b = performer.DealsCount.ToStringUniformMoneyFormat()
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleMaximumRelativeDrawdownInPercents"),
                    b = performer.MaxRelDrawDown.ToString("N2")
                });

            if (efficiency != null) // при получении всех сделок
            {
                singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleProfitableDealCount"),
                    b = (efficiency.closedDeals.Count(d => d.ResultDepo > 0) +
                         efficiency.openedDeals.Count(d => d.ResultDepo > 0)).ToStringUniformMoneyFormat()
                });
                singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleLosingDealCount"),
                    b = (efficiency.closedDeals.Count(d => d.ResultDepo < 0) +
                         efficiency.openedDeals.Count(d => d.ResultDepo < 0)).ToStringUniformMoneyFormat()
                });
                singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                    {
                        a = Localizer.GetString("TitleDealsOpened"),
                        b = efficiency.DealsStillOpened.ToStringUniformMoneyFormat()
                    });
            }

            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleRatioOfAverageProfitToAverageLossShort"),
                    b = performer.GreedyRatio.ToString("N2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleMaximumLeverage"),
                    b = performer.MaxLeverage.ToString("N2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleProfitForNMonthsInPercents"),
                    b = performer.ProfitLastMonths.ToString("f2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleGAAnnualProfitInPercentsShort"),
                    b = performer.AvgYearProfit.ToString("N3")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleSharpeRatioShort"),
                    b = performer.Sharp.ToString("N2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleSubscriberCount"),
                    b = performer.SubscriberCount.ToString("d")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleFundsUnderManagementShort") + ", " + performer.DepoCurrency,
                    b = performer.Equity.ToStringUniformMoneyFormat()
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleRatingFS"),
                    b = performer.Score.ToString("f2")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleTradeTimeInDays"),
                    b = performer.DaysTraded.ToString("d")
                });
            singleValueData.Add(new TradeSharp.Util.Cortege2<string, string>
                {
                    a = Localizer.GetString("TitleProfitInPoints"),
                    b = performer.SumProfitPoints.ToStringUniformMoneyFormat(false)
                });
            grid.DataBind(singleValueData);

            // для удобочитаемости первая колонка сохраняет первоначальную минимальную ширину
            var skippedColumns = grid.Columns.Where(c => c.PropertyName == "a").ToList();
            var minWidths = skippedColumns.ToDictionary(c => c, c => c.ColumnMinWidth);
            grid.CheckSize(true);
            skippedColumns.ForEach(c => c.ColumnMinWidth = minWidths[c]);
            grid.Invalidate();
        }
Пример #16
0
        // отобразить данные суммарной статистики
        public static void BindSummaryStatistics(FastGrid.FastGrid gridSummaryStat, PerformerStat performerStat, AccountEfficiency efficiency, bool showFullInfo)
        {
            if (performerStat == null)
                return;

            // суммарная статистика
            var rowColors = new[] { Color.Red, Color.Blue, Color.Black };
            var color = performerStat.Profit >= 0 ? rowColors[1] : rowColors[0];
            var statItems = new List<SummaryStatItem>();
            if (showFullInfo)
            {
                statItems.Add(
                    new SummaryStatItem(
                        string.Format("{0}\t{1}", Localizer.GetString("TitleSubscriberCount"),
                                      performerStat.SubscriberCount),
                        rowColors[2]));
                statItems.Add(
                    new SummaryStatItem(string.Format("{0}\t{1}", Localizer.GetString("TitleInvestorCount"), 0),
                                        rowColors[2]));
                statItems.Add(new SummaryStatItem(
                                  string.Format("{0}, {1}\t{2}", Localizer.GetString("TitleFundsUnderManagementShort"),
                                                performerStat.DepoCurrency,
                                                performerStat.Equity.ToStringUniformMoneyFormat()), rowColors[2]));
            }
            statItems.Add(new SummaryStatItem(Localizer.GetString("TitleTotalProfit"), rowColors[2]));
            statItems.Add(new SummaryStatItem(string.Format("{0} {1} / {2:f2}% / {3} {4}",
                                                            performerStat.ProfitLastMonthsAbs.ToStringUniformMoneyFormat(false),
                                                            performerStat.DepoCurrency,
                                                            performerStat.Profit,
                                                            performerStat.SumProfitPoints.ToStringUniformMoneyFormat(false),
                                                            Localizer.GetString("TitlePointsUnits")), color));

            if (efficiency != null && efficiency.openedDeals != null && efficiency.openedDeals.Count > 0)
            {
                var openResultDepo = efficiency.openedDeals.Sum(o => o.ResultDepo);
                var openResultPoints = efficiency.openedDeals.Sum(o => o.ResultPoints);
                var openResultPercent = performerStat.Equity == 0 ? 0
                                            : 100 * openResultDepo / performerStat.Equity;
                var colorOpen = openResultDepo >= 0 ? rowColors[1] : rowColors[0];
                statItems.Add(new SummaryStatItem(Localizer.GetString("TitleCurrentProfit"), rowColors[2]));
                statItems.Add(new SummaryStatItem(string.Format("{0} {1} / {2:f2}% / {3} {4}",
                                                      openResultDepo.ToStringUniformMoneyFormat(),
                                                      performerStat.DepoCurrency,
                                                      openResultPercent,
                                                      openResultPoints.ToStringUniformMoneyFormat(),
                                                      Localizer.GetString("TitlePointsUnits")),
                                        colorOpen));
            }

            gridSummaryStat.DataBind(statItems);
        }
Пример #17
0
 public AccountEfficiency(PerformerStat stat)
 {
     Statistics = stat;
 }
Пример #18
0
 private void UpdateServiceTypeInSelectedFunction()
 {
     var stat = new PerformerStat();
     var serviceTypeFiled = PerformerStatField.fields.FirstOrDefault(f => f.PropertyName == stat.Property(p => p.ServiceType));
     SelectedFunction.Filters.RemoveAll(f => f.a == serviceTypeFiled);
     if (signalsToolStripMenuItem.Checked || pammsToolStripMenuItem.Checked)
         SelectedFunction.Filters.Add(
             new Cortege3<PerformerStatField, ExpressionOperator, double>(serviceTypeFiled, ExpressionOperator.Equal,
                                                                      ((signalsToolStripMenuItem.Checked ? 1 : 0) +
                                                                       (pammsToolStripMenuItem.Checked ? 2 : 0))));
     topFilterControl.SetExpression(SelectedFunction);
 }
Пример #19
0
 public void OpenInvestInPAMMDialog(PerformerStat stat, bool invest)
 {
     EnsureWalletWindow();
     var walletForm = MdiChildren.FirstOrDefault(f => f is WalletForm);
     if (walletForm == null) return;
     ((WalletForm)walletForm).OpenInvestInPAMMDialog(stat, invest);
 }
Пример #20
0
 public PerformerStatEx(PerformerStat performer)
     : base(performer)
 {
 }
Пример #21
0
        private static bool Subscribe(PerformerStat performer, bool tradeAuto)
        {
            if (performer == null) return false;

            // проверить, а хватит ли бабла в кошельке?
            // а готов ли заплатить?
            if (performer.FeeUSD > 0)
                if (!CheckUserHasEnoughMoneyOrRefusesToPay(performer))
                    return false;

            SubscriptionModel.Instance.AddSubscription(new Contract.Entity.Subscription
                {
                    RenewAuto = true,
                    Service = performer.Service,
                    TimeStarted = DateTime.Now.Date,
                    TimeEnd = DateTime.Now.Date.AddDays(1),
                    PaidService = new PaidService
                        {
                            Comment = performer.TradeSignalTitle
                        },
                    AutoTradeSettings = new AutoTradeSettings
                        {
                            TradeAuto = tradeAuto
                        }
                });
            return true;
        }
Пример #22
0
 public AccountEfficiency(PerformerStat stat)
 {
     Statistics = stat;
 }
Пример #23
0
 public void InvestInPAMM(PerformerStat performer)
 {
     if (investInPAMM != null)
         investInPAMM(performer);
 }
Пример #24
0
 private static bool Unsubscribe(PerformerStat performer)
 {
     if (performer == null)
         return false;
     SubscriptionModel.Instance.RemoveSubscription(new Contract.Entity.Subscription
         {
             Service = performer.Service
         });
     return true;
 }