protected override void OnStart(string[] args) { try { var dailyQuoteStorage = new DailyQuoteStorage(); var equityCurveCalculator = new EquityCurveCalculator(); cache = new AccountEfficiencyCache(new EfficiencyCalculator(dailyQuoteStorage, equityCurveCalculator), dailyQuoteStorage); cache.Start(); hostServerStat = new ServiceHost(cache); hostServerStat.Open(); } catch (Exception ex) { Logger.Error("Ошибка в OnStart", ex); } }
public void NuGetPerformersByFilter() { var cache = new AccountEfficiencyCache(new FakeCalculator(), new MockDailyQuoteStorage()); cache.UpdateCache(); var filters = new List<PerformerSearchCriteria> { new PerformerSearchCriteria { propertyName = new PerformerStat().Property(p => p.Account), checkWholeWord = true, compradant = "1", ignoreCase = false } }; var performers = cache.GetPerformersByFilter(false, filters, 100); Assert.AreEqual(1, performers.Count, "GetPerformersByFilter(Account=1) - должен вернуть 1 счет"); filters[0].propertyName = new PerformerStat().Property(p => p.FullName); filters[0].compradant = "Владислав"; filters[0].ignoreCase = false; filters[0].checkWholeWord = false; performers = cache.GetPerformersByFilter(false, filters, 100); Assert.AreEqual(1, performers.Count, "GetPerformersByFilter(FullName=Владислав) - должен вернуть 1 счет"); }
public void TestGetPerformersByCriteriaGivesCorrectMatches() { var cache = new AccountEfficiencyCache(new FakeCalculator(), new MockDailyQuoteStorage()); cache.UpdateCache(); const string criteria = "((AYP>0)&(DD<30))*P"; var performerScore = testPerformers.ToDictionary(p => p, p => (p.AvgYearProfit <= 0 || p.MaxRelDrawDown >= 30) ? 0 : p.Profit); var bestScoredOne = performerScore.First(p => p.Value == performerScore.Values.Max()).Key; // по убыванию, без указания граничного критерия var performers = cache.GetAllPerformersWithCriteria(false, criteria, 100, false, null, 0); Assert.AreEqual(testPerformers.Count, performers.Count, "GetAllPerformersWithCriteria(формула) - все перформеры получены"); Assert.AreEqual(bestScoredOne, performers[0], "GetAllPerformersWithCriteria(формула) - лучший вверху списка"); performers = cache.GetAllPerformersWithCriteria(false, criteria, 100, false, 0, 0); Assert.AreEqual(performerScore.Count(s => s.Value > 0), performers.Count, "GetAllPerformersWithCriteria(формула) - все перформеры с критерием > 0 получены"); }
public void TestGetPerformersByCriteriaGivesCorrectCount() { var cache = new AccountEfficiencyCache(new FakeCalculator(), new MockDailyQuoteStorage()); try { cache.UpdateCache(); } catch (Exception ex) { Assert.Fail("Ошибка в AccountEfficiencyCache.TestGetPerformersByCriteria(): {0}", ex); } var performers = cache.GetAllPerformers(true); Assert.AreEqual(testPerformers.Count(p => p.Service > 0), performers.Count, "GetAllPerformers(managers=true) возвращает правильное количество перформеров"); performers = cache.GetAllPerformers(false); Assert.AreEqual(testPerformers.Count, performers.Count, "GetAllPerformers(managers=false) возвращает правильное количество перформеров"); }