public void TestSubscribeOnCustomPortfolio() { var managerTrade = ManagerTrade.Instance; var portfolio = new TopPortfolio { Criteria = "P", DescendingOrder = true, ParticipantCount = 6, Name = "UserGeniusExclusiveTop", }; var tradeSets = AutoTradeSettingsSampler.MakeSampleTradeSettings(); tradeSets.TargetAccount = conn.PLATFORM_USER_ACCOUNT.First(pa => pa.PlatformUser == subscriber.ID).Account; var status = managerTrade.SubscribeOnPortfolio(ProtectedOperationContext.MakeServerSideContext(), subscriber.Login, portfolio, null, tradeSets); Assert.AreEqual(RequestStatus.OK, status, "SubscribeOnPortfolio - удалось подписаться"); // проверить количество подписок var userSubsCount = conn.SUBSCRIPTION.Count(s => s.User == subscriber.ID); Assert.AreEqual(portfolio.ParticipantCount, userSubsCount, "SubscribeOnPortfolio - подписался на всех в портфеле"); // проверить настройки авто-торговли var subSettings = conn.SUBSCRIPTION_SIGNAL.First(ss => ss.User == subscriber.ID); var wrongFields = AutoTradeSettingsSampler.TradeSignalSetsAreCorrect(tradeSets, subSettings); if (!string.IsNullOrEmpty(wrongFields)) Assert.Fail("SubscribeOnPortfolio - настройки авто-торговли не сохранены в подписке: " + wrongFields); // настройки авто-торговли для самого портфеля var portfolioTradeSets = (from upf in conn.USER_TOP_PORTFOLIO join pf in conn.TOP_PORTFOLIO on upf.Portfolio equals pf.Id where upf.User == subscriber.ID select upf).FirstOrDefault(); Assert.IsNotNull(portfolioTradeSets, "SubscribeOnPortfolio - портфель создан"); var portfolioSignalSets = new SUBSCRIPTION_SIGNAL { AutoTrade = portfolioTradeSets.AutoTrade, MaxLeverage = portfolioTradeSets.MaxLeverage, PercentLeverage = portfolioTradeSets.PercentLeverage, HedgingOrdersEnabled = portfolioTradeSets.HedgingOrdersEnabled, FixedVolume = portfolioTradeSets.FixedVolume, MinVolume = portfolioTradeSets.MinVolume, MaxVolume = portfolioTradeSets.MaxVolume, VolumeRound = portfolioTradeSets.VolumeRound, StepVolume = portfolioTradeSets.StepVolume, TargetAccount = portfolioTradeSets.TargetAccount }; wrongFields = AutoTradeSettingsSampler.TradeSignalSetsAreCorrect(tradeSets, portfolioSignalSets); if (!string.IsNullOrEmpty(wrongFields)) Assert.Fail("SubscribeOnPortfolio - настройки авто-торговли не сохранены в портфеле: " + wrongFields); // отписаться от портфеля status = managerTrade.UnsubscribePortfolio(ProtectedOperationContext.MakeServerSideContext(), subscriber.Login, true, true); Assert.AreEqual(RequestStatus.OK, status, "SubscribeOnPortfolio - удалось отписаться"); userSubsCount = conn.SUBSCRIPTION.Count(s => s.User == subscriber.ID); Assert.AreEqual(0, userSubsCount, "SubscribeOnPortfolio - отписался ото всех в портфеле"); }
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; }
public void SetupPortfolio(TopPortfolio portfolio) { this.portfolio = portfolio; lblPortfolioName.Text = (portfolio.IsCompanyPortfolio ? (Localizer.GetString("TitlePortfolio") + " \"" + portfolio.Name + "\"") : (Localizer.GetString("TitleUserPortfolio")) + " [" + portfolio.ParticipantCount + "]"); // сформировать формулу с подсветкой formulaBrowser.DocumentText = PerformerStatField.GetFormulaHighlightedHtml(portfolio.Criteria); tbCount.Value = portfolio.ParticipantCount; if (portfolio.IsCompanyPortfolio) tbCount.Enabled = false; }
/// <summary> /// подписать на портфель /// отключить остальные подписки /// если портфель пользовательский - сохранить его /// </summary> public RequestStatus SubscribeOnPortfolio( ProtectedOperationContext secCtx, string subscriberLogin, TopPortfolio portfolio, decimal? maxFee, AutoTradeSettings tradeAutoSettings) { //Logger.InfoFormat("SubscribeOnPortfolio({0})", subscriberLogin); if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.BindToSignal)) if (!UserSessionStorage.Instance.PermitUserOperation(secCtx, UserOperationRightsStorage.IsTradeOperation(UserOperation.BindToSignal), false)) return RequestStatus.Unauthorized; try { using (var ctx = DatabaseContext.Instance.Make()) return walletRepository.SubscribeUserOnPortfolio(ctx, subscriberLogin, portfolio, maxFee, tradeAutoSettings); } catch (Exception ex) { Logger.Error("Ошибка в SubscribeOnPortfolio()", ex); return RequestStatus.ServerError; } }
public RequestStatus SubscribeUserOnPortfolio( TradeSharpConnection ctx, string subscriberLogin, TopPortfolio portfolio, decimal? maxFee, AutoTradeSettings tradeAutoSettings) { var user = ctx.PLATFORM_USER.FirstOrDefault(u => u.Login == subscriberLogin); if (user == null) return RequestStatus.Unauthorized; TOP_PORTFOLIO targetPortfolio = null; if (portfolio.Id > 0) targetPortfolio = ctx.TOP_PORTFOLIO.FirstOrDefault(p => p.Id == portfolio.Id); if (targetPortfolio != null) portfolio.ManagedAccount = targetPortfolio.ManagedAccount; // если портфель - пользовательский - сохранить его // для пользователя или обновить его имеющийся портфель if (!portfolio.IsCompanyPortfolio) { Logger.Info("SubscribeOnPortfolio() - user portfolio"); try { var existPortfolio = ctx.TOP_PORTFOLIO.FirstOrDefault(p => p.OwnerUser == user.ID); if (existPortfolio != null) { if (!LinqToEntity.DecoratePortfolio(existPortfolio).AreSame(portfolio)) { // удалить старый портфель пользователя ctx.TOP_PORTFOLIO.Remove(existPortfolio); existPortfolio = null; } else targetPortfolio = existPortfolio; } // создать портфель пользователя if (existPortfolio == null) { targetPortfolio = LinqToEntity.UndecoratePortfolio(portfolio); targetPortfolio.OwnerUser = user.ID; targetPortfolio.ManagedAccount = null; ctx.TOP_PORTFOLIO.Add(targetPortfolio); ctx.SaveChanges(); } } catch (DbEntityValidationException dbEx) { Logger.Error("SubscribeUserOnPortfolio - ошибка сохранения портфеля"); foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Logger.ErrorFormat("Свойство: {0}, ошибка: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } catch (Exception ex) { Logger.Error("Ошибка в SubscribeOnPortfolio() - обновление портфеля", ex); return RequestStatus.ServerError; } } else {// портфель компании Logger.Info("SubscribeOnPortfolio() - company portfolio"); if (targetPortfolio == null) { Logger.Error("Пользователь запросил несуществующий портфель компании " + portfolio.Id); return RequestStatus.ServerError; } } // очистить подписки пользователя на портфели // и привязать его к целевому портфелю //Logger.Info("SubscribeOnPortfolio() - removing bindings"); var oldBinding = ctx.USER_TOP_PORTFOLIO.FirstOrDefault(u => u.User == user.ID); // "посмотреть" настройки портфельной торговли в имеющейся подписке if (tradeAutoSettings == null) { if (oldBinding == null) { Logger.ErrorFormat("Подписка пользователя {0} на портфель {1} - нет данных по автоматической торговле", user.Login, portfolio.Id > 0 ? portfolio.Id.ToString() : portfolio.Name); return RequestStatus.BadRequest; } tradeAutoSettings = new AutoTradeSettings { FixedVolume = oldBinding.FixedVolume, HedgingOrdersEnabled = oldBinding.HedgingOrdersEnabled, MaxLeverage = oldBinding.MaxLeverage, MaxVolume = oldBinding.MaxVolume, MinVolume = oldBinding.MinVolume, PercentLeverage = oldBinding.PercentLeverage ?? 100, StepVolume = oldBinding.StepVolume, TargetAccount = oldBinding.TargetAccount, TradeAuto = oldBinding.AutoTrade ?? false, VolumeRound = (VolumeRoundType?)oldBinding.VolumeRound }; } if (oldBinding != null) ctx.USER_TOP_PORTFOLIO.Remove(oldBinding); //Logger.Info("SubscribeOnPortfolio() - adding binding"); ctx.USER_TOP_PORTFOLIO.Add(new USER_TOP_PORTFOLIO { User = user.ID, Portfolio = targetPortfolio.Id, MaxFee = maxFee, AutoTrade = tradeAutoSettings.TradeAuto, MaxLeverage = tradeAutoSettings.MaxLeverage, PercentLeverage = tradeAutoSettings.PercentLeverage, HedgingOrdersEnabled = tradeAutoSettings.HedgingOrdersEnabled, FixedVolume = tradeAutoSettings.FixedVolume, MinVolume = tradeAutoSettings.MinVolume, MaxVolume = tradeAutoSettings.MaxVolume, VolumeRound = (int?)tradeAutoSettings.VolumeRound, StepVolume = tradeAutoSettings.StepVolume, TargetAccount = tradeAutoSettings.TargetAccount }); ctx.SaveChanges(); //Logger.Info("SubscribeOnPortfolio() - changes are saved"); // найти трейдеров, удовлетворяющих критерию List<PerformerStat> performers; try { try { performers = TradeSharpAccountStatistics.Instance.proxy.GetAllPerformersWithCriteria(true, targetPortfolio.Criteria, targetPortfolio.ParticipantCount, !targetPortfolio.DescendingOrder, (float?)targetPortfolio.MarginValue, 0); } catch (Exception ex) { Logger.Error( "Ошибка в SubscribeOnPortfolio() - получение перформеров (" + targetPortfolio.Criteria + ")", ex); return RequestStatus.ServerError; } if (performers == null) { Logger.Error("Ошибка в SubscribeOnPortfolio() - список перформеров не получен (" + targetPortfolio.Criteria + ")"); return RequestStatus.ServerError; } } catch (Exception ex) { Logger.Error("Ошибка в SubscribeOnPortfolio() - подписка", ex); return RequestStatus.ServerError; } // сравнить полученный список с текущими подписками заказчика ("инвестора") // сформировать список для "отписки" и список для подписки var performerAcs = performers.Select(p => p.Account).ToList(); var subsToRemove = ctx.SUBSCRIPTION.Where(s => s.User == user.ID && s.SERVICE1.ServiceType == (int)PaidServiceType.Signals && !performerAcs.Contains(s.SERVICE1.AccountId ?? 0)).ToList(); foreach (var sub in subsToRemove) { WalletError error; SubscribeOnService(ctx, user.ID, sub.Service, false, true, tradeAutoSettings, out error); if (error != WalletError.OK) { Logger.ErrorFormat("Portfolio - unsubscribe user {0} from srv {1}: error {2}", user.ID, sub.Service, error); } } // новоподписавшиеся foreach (var pf in performers) { WalletError error; SubscribeOnService(ctx, user.ID, pf.Service, true, false, tradeAutoSettings, out error); if (error != WalletError.OK) { Logger.DebugFormat("Подписка SubscribeOnPortfolio({0}), сигн. {1}: {2}", subscriberLogin, pf.Service, error); } } return RequestStatus.OK; }
public RequestStatus SubscribeOnPortfolio(ProtectedOperationContext secCtx, string subscriberLogin, TopPortfolio portfolio, decimal? maxFee, AutoTradeSettings tradeSets) { throw new NotImplementedException(); }
public RequestStatus SubscribeOnPortfolio(ProtectedOperationContext secCtx, string subscriberLogin, TopPortfolio portfolio, decimal? maxFee, AutoTradeSettings tradeAutoSettings) { return RequestStatus.CommonError; }
public static void UndecoratePortfolio(TOP_PORTFOLIO dest, TopPortfolio src) { dest.Criteria = src.Criteria; dest.DescendingOrder = src.DescendingOrder; dest.ManagedAccount = src.ManagedAccount; dest.MarginValue = src.MarginValue; dest.Name = src.Name; dest.OwnerUser = src.OwnerUser; dest.ParticipantCount = src.ParticipantCount; }
private void CreatePortfolioButtonClick(object sender, EventArgs e) { var portfolioName = "TOP " + AccountModel.Instance.GetUserLogin(); if (portfolioName.Length > 50) portfolioName = portfolioName.Substring(0, 50); var portfolio = new TopPortfolio { Name = portfolioName, Criteria = SelectedFunction.Function, DescendingOrder = SelectedFunction.PreferredSortOrder == SortOrder.Descending, MarginValue = SelectedFunction.MarginValue, ParticipantCount = ParticipantCount }; var complete = new CompleteSubscribeOnPortfolioDlg(portfolio).ShowDialog() == DialogResult.OK; if (!complete) return; // открыть диалог настройки авто-торговли var dlg = new AutoTradeSettingsForm(); if (dlg.ShowDialog(this) != DialogResult.OK) return; var tradeSettings = dlg.sets; RequestStatus status; try { status = AccountModel.Instance.ServerProxy.SubscribeOnPortfolio( CurrentProtectedContext.Instance.MakeProtectedContext(), AccountModel.Instance.GetUserLogin(), portfolio, null, tradeSettings); } catch (Exception ex) { //4 debug MessageBox.Show(this, "Операция выполнена с ошибкой:" + Environment.NewLine + ex.Message, "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Logger.Info("TopPortfolioControl.Subscribe: error calling SubscribeOnPortfolio/UnsubscribePortfolio", ex); return; } if (status == RequestStatus.OK) MessageBox.Show(this, "Операция выполнена успешно", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(this, "Операция выполнена с ошибкой:" + Environment.NewLine + EnumFriendlyName<RequestStatus>.GetString(status), "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
public TopPortfolio GetTopPortfolio(int id, out AccountEfficiency userAccountEfficiency) { userAccountEfficiency = null; TopPortfolio result; try { // reading db using (var context = DatabaseContext.Instance.Make()) { try { var portfolio = context.TOP_PORTFOLIO.FirstOrDefault(p => p.Id == id); if (portfolio == null) return null; result = new TopPortfolio { Id = portfolio.Id, Name = portfolio.Name, Criteria = portfolio.Criteria, ParticipantCount = portfolio.ParticipantCount, DescendingOrder = portfolio.DescendingOrder, MarginValue = (float?) portfolio.MarginValue, ManagedAccount = portfolio.ManagedAccount, OwnerUser = portfolio.OwnerUser }; } catch (Exception ex) { Logger.Error("AccountEfficiencyCache.GetTopPortfolio.db - read error", ex); return null; } } // Statistics if (result.ManagedAccount.HasValue) result.Statistics = GetPerformerByAccountId(result.ManagedAccount.Value); // идентификаторы сигнальщиков // тут будут корректировки, потому что вхождение сигнальщика в топ не всегда на данный момент времени соответствует критерию // потому что обновление топов и обновлние статистики сигнальщиков выполняются в разное время, а результаты выборки хранятся только run-time var performers = GetAllPerformersWithCriteria(true, result.Criteria, result.ParticipantCount, !result.DescendingOrder, result.MarginValue, 0); if (result.Statistics == null || performers == null) { Logger.ErrorFormat("GetTopPortfolio() - статистика / перформеры не получены, кеш обновлен: {0}", cacheUpdated); return result; } // ManagerIds result.ManagerIds = performers.Select(p => p.Account).ToList(); // Manages result.Managers = performers; // Orders if (result.ManagedAccount.HasValue) result.Orders = GetAccountDeals(result.ManagedAccount.Value, true); if (result.IsCompanyPortfolio) return result; // ---------------- // 4 user portfolio // ---------------- if (!cacheUpdated) return null; var managersFullStat = new List<AccountEfficiency>(); // beginning of profit1000 chart if (result.ManagerIds == null) throw new Exception("GetTopPortfolio(польз. портфель) - список Id менеджеров = null"); DateTime? beginDate = null; try { foreach (var managerId in result.ManagerIds) { var stat = dicPerformers.ReceiveValue(managerId); if (stat == null) { Logger.Error("AccountEfficiencyCache.GetTopPortfolio.dicPerformers.TryGetValue returned null"); return null; // ManagerIds.Count != managersFullStat.Count } if (stat.listProfit1000 == null || stat.listProfit1000.Count == 0) continue; managersFullStat.Add(stat); // detect beginning var firstDate = stat.listProfit1000.Min(e => e.time); if (!beginDate.HasValue) beginDate = firstDate; else if (firstDate < beginDate.Value) beginDate = firstDate; } } catch (Exception ex) { Logger.Error("AccountEfficiencyCache.GetTopPortfolio - stat gen error", ex); return null; } // userAccountEfficiency userAccountEfficiency = new AccountEfficiency { listProfit1000 = new List<EquityOnTime>(), }; // pofit1000 calc if (beginDate.HasValue) for (var date = beginDate.Value.Date; date < DateTime.Now; date = date.AddDays(1)) { float equity = 0; var equityCount = 0; foreach (var fullStat in managersFullStat) { var equityOnTime = fullStat.listProfit1000.Find(e => e.time == date); if (equityOnTime.time == default(DateTime)) continue; equity += equityOnTime.equity; equityCount++; } if (equityCount == 0) // данных на этот день недостаточно - пропускаем continue; equity /= equityCount; userAccountEfficiency.listProfit1000.Add(new EquityOnTime(equity, date)); } // stats calc userAccountEfficiency.Statistics.DealsCount = managersFullStat.Sum(s => s.Statistics.DealsCount); Logger.InfoFormat("запрошен портфель - GetTopPortfolio({0}, {1} управляющих)", result.Name, result.Managers); return result; } catch (Exception ex) { Logger.Error("Ошибка в GetTopPortfolio", ex); throw; } }
private RequestStatus SubscribeOnUserOrCustomPortfolio(string hash, string userLogin, long localTime, TopPortfolio portfolio, AutoTradeSettings tradeAutoSettings) { if (portfolio == null) { Logger.Error("SubscribeOnUserOrCustomPortfolio(null)"); return RequestStatus.BadRequest; } Logger.InfoFormat("SubscribeOnUserOrCustomPortfolio({0}, портфель {1})", userLogin, portfolio.Id > 0 ? "#" + portfolio.Id : portfolio.Criteria); try { using (var ctx = DatabaseContext.Instance.Make()) { var user = ctx.PLATFORM_USER.FirstOrDefault(u => u.Login == userLogin); if (user == null) return RequestStatus.Unauthorized; var userHash = CredentialsHash.MakeCredentialsHash(userLogin, user.Password, localTime); if (userHash != hash) return RequestStatus.Unauthorized; var status = walletRepository.SubscribeUserOnPortfolio(ctx, userLogin, portfolio, null, tradeAutoSettings); if (status != RequestStatus.OK) Logger.Info("SubscribeOnUserOrCustomPortfolio: status: " + status); return status; } } catch (Exception ex) { Logger.Error("Ошибка в SubscribeOnUserOrCustomPortfolio()", ex); return RequestStatus.ServerError; } }
public CompleteSubscribeOnPortfolioDlg(TopPortfolio portfolio) : this() { completeSubscribeOnPortfolioControl1.SetupPortfolio(portfolio); }
public bool AreSame(TopPortfolio p) { return Name == p.Name && Criteria == p.Criteria && ParticipantCount == p.ParticipantCount && DescendingOrder == p.DescendingOrder && MarginValue == p.MarginValue; }
public bool AreSame(TopPortfolio p) { return(Name == p.Name && Criteria == p.Criteria && ParticipantCount == p.ParticipantCount && DescendingOrder == p.DescendingOrder && MarginValue == p.MarginValue); }
public RequestStatus GetUserPortfolioAndSubscriptions(string hash, string userLogin, long localTime, out List<Subscription> signals, out TopPortfolio portfolio) { portfolio = null; using (var ctx = DatabaseContext.Instance.Make()) { var error = GetUserSubscribedCats(ctx, userLogin, hash, localTime, out signals); if (error != RequestStatus.OK) return error; try { var query = from us in ctx.PLATFORM_USER join up in ctx.USER_TOP_PORTFOLIO on us.ID equals up.User join pf in ctx.TOP_PORTFOLIO on up.Portfolio equals pf.Id where us.Login == userLogin select new TopPortfolio { Id = pf.Id, ParticipantCount = pf.ParticipantCount, Criteria = pf.Criteria, MarginValue = (float?)pf.MarginValue, DescendingOrder = pf.DescendingOrder, ManagedAccount = pf.ManagedAccount, Name = pf.Name, OwnerUser = pf.OwnerUser }; portfolio = query.FirstOrDefault(); return RequestStatus.OK; } catch (Exception ex) { Logger.Error("Ошибка в GetUserPortfolioAndSubscriptions", ex); return RequestStatus.ServerError; } } }
public TopPortfolioForm(TopPortfolio portfolio) : this() { Text = portfolio.Name; topPortfolioControl.Portfolio = portfolio; }
public RequestStatus SubscribeOnCustomPortfolio(string hash, string userLogin, long localTime, string formula, float? marginValue, int topCount, AutoTradeSettings tradeAutoSettings) { var portfolio = new TopPortfolio { Criteria = formula, MarginValue = marginValue, ParticipantCount = topCount }; return SubscribeOnUserOrCustomPortfolio(hash, userLogin, localTime, portfolio, tradeAutoSettings); }
private static AccountEfficiency GeneratePortfolioAccountEfficiency(TopPortfolio portfolio, IAccountStatistics proxy) { var portfolioEfficiency = new AccountEfficiency(); var efficiencies = new List<AccountEfficiency>(); // detect beginning DateTime? beginDate = null; foreach (var performerStat in portfolio.Managers) { var efficiency = proxy.GetAccountEfficiencyShort(performerStat.Account, false, false); efficiencies.Add(efficiency); var firstDate = efficiency.listProfit1000.Min(e => e.time); if (!beginDate.HasValue) beginDate = firstDate; else if (firstDate < beginDate.Value) beginDate = firstDate; } if (!beginDate.HasValue) return null; // pofit1000 calc portfolioEfficiency.listProfit1000 = new List<EquityOnTime>(); portfolioEfficiency.listEquity = new List<EquityOnTime>(); for (var date = beginDate.Value; date < DateTime.Now; date = date.AddDays(1)) { float equity = 0; foreach (var efficiency in efficiencies) { var equityOnTime = efficiency.listProfit1000.Find(e => e.time == date); if (equityOnTime.time == default(DateTime)) continue; equity += equityOnTime.equity; } equity /= efficiencies.Count; portfolioEfficiency.listProfit1000.Add(new EquityOnTime(equity, date)); } if (!AccountModel.Instance.AccountId.HasValue || portfolioEfficiency.listProfit1000.Count == 0) return null; // pofit calc var stat = proxy.GetPerformerByAccountId(AccountModel.Instance.AccountId.Value); // пусть performerStat.Equity соответствует последней точке на кривой доходности на 1000 var profitFactor = stat.Equity / portfolioEfficiency.listProfit1000.Last().equity; foreach (var equityOnTime in portfolioEfficiency.listProfit1000) { portfolioEfficiency.listEquity.Add(new EquityOnTime(equityOnTime.equity * profitFactor, equityOnTime.time)); } // stats calc portfolioEfficiency.listTransaction = new List<BalanceChange>(); portfolioEfficiency.InitialBalance = portfolioEfficiency.listEquity[0].equity; portfolioEfficiency.StartDate = portfolioEfficiency.listEquity[0].time; new EfficiencyCalculator().CalculateProfitCoeffs(portfolioEfficiency); return portfolioEfficiency; }
public RequestStatus SubscribeOnPortfolio(string hash, string userLogin, long localTime, int portfolioId, AutoTradeSettings tradeAutoSettings) { var portfolio = new TopPortfolio { Id = portfolioId }; return SubscribeOnUserOrCustomPortfolio(hash, userLogin, localTime, portfolio, tradeAutoSettings); }
private void LoadPortfolioSubscribers(TopPortfolio portfolio) { var perfs = new List<PerformerStatEx>(); var cats = SubscriptionModel.Instance.SubscribedCategories ?? new List<Contract.Entity.Subscription>(); try { perfs.AddRange(portfolio.Managers.Select(performer => new PerformerStatEx(performer) { IsSubscribed = cats.Any(c => c.Service == performer.Service), })); } catch (Exception ex) { Logger.Info("SubscriptionControl.LoadPortfolioSubscribers", ex); } performers = perfs; performerGridCtrl.DataBind(performers, chat); topFilterControl.RefreshButtonEnabled = true; refreshButton.Enabled = true; }
public static TOP_PORTFOLIO UndecoratePortfolio(TopPortfolio p) { return new TOP_PORTFOLIO { Criteria = p.Criteria, DescendingOrder = p.DescendingOrder, Id = p.Id, ManagedAccount = p.ManagedAccount, MarginValue = p.MarginValue, Name = p.Name, ParticipantCount = p.ParticipantCount, OwnerUser = p.OwnerUser }; }