public void TestLoadAndUpdate()
        {
            var stor = new DailyQuoteStorage();
            try
            {
                stor.UpdateStorageSync();
            }
            catch (Exception ex)
            {
                Assert.Fail("UpdateStorageSync() failed: " + ex.Message);
            }

            // удостовериться в наличии нужной котировки
            var quotes = stor.GetQuotes("EURUSD");
            Assert.Greater(quotes.Count, 0, "GetQuotes(\"EURUSD\") - has some quotes");

            // котировки за одну дату не повторяются
            Assert.AreEqual(quotes.Select(q => q.a.Date).Distinct().Count(), quotes.Count,
                          "all dates are unique");

            // прочитать котировки снова
            stor.UpdateStorageSync();
            var quotesNew = stor.GetQuotes("EURUSD");
            Assert.Less(quotesNew.Count - quotes.Count, 2, //quotes.SequenceEqual(quotesNew),
                          "Прочитанные заново котировки - количество неизменно");
        }
Esempio n. 2
0
 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 TestSetup()
        {
            // Инициализируем методы GetTickers, GetMetadataByCategory, GetAccountGroupsWithSessionInfo
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            // Инициализируем словарь котировок
            dailyQuoteStorage = new DailyQuoteStorage();
            dailyQuoteStorage.InitializeFake(QuoteMaker.MakeQuotesForQuoteDailyStorage(null));

            // Готовим объекты, которые будем тестировать и на которых будем тестировать
            curveCalculator = new EquityCurveCalculator();
        }
        //[Test]
        public void CalculateEquityCurveVoid()
        {
            // ReSharper disable SuspiciousTypeConversion.Global
            ((IMockableProxy)fakeTradeAccount).IncludeMockMethod(getHistoryOrdersName, getHistoryOrdersFake);
            ((IMockableProxy)fakeTradeAccount).IncludeMockMethod(getMarketOrdersName, getMarketOrdersFake);
            ((IMockableProxy)fakeTradeAccount).IncludeMockMethod(getBalanceChangesName, getBalanceChangesFake);
            // ReSharper restore SuspiciousTypeConversion.Global
            var dailyQuoteStorage = new DailyQuoteStorage();
            var curveCalculator = new EquityCurveCalculator();
            try
            {
                var calc = new EfficiencyCalculator(dailyQuoteStorage, curveCalculator);
                calc.Calculate(new AccountEfficiency(new PerformerStat
                {
                    Account = 0,
                    DepoCurrency = "USD"
                }));
                Assert.Fail("NuEfficiencyCalculator.Calculate() - не выбросил ArgumentException");
            }
            catch (ArgumentException) // Это не трогать
            {
            }

            /*
                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getHistoryOrdersName, getHistoryOrdersFake);
                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getMarketOrdersName, getMarketOrdersFake);
                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getBalanceChangesName, getBalanceChangesFake);
                var accEff1 = new AccountEfficiency(new PerformerStat
                    {
                        Account = accountId,
                        DepoCurrency = "USD"
                    });
                var calc = new EfficiencyCalculator(dailyQuoteStorage, equityCurveCalculator);
                calc.Calculate(accEff1);

                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getBalanceChangesName, getBalanceChangesVoidFake);
                EfficiencyCalculator.Calculate(accEff1);

                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getHistoryOrdersName, getHistoryOrdersEmptyFake);
                ((IMockableProxy) fakeTradeAccount).IncludeMockMethod(getMarketOrdersName, getMarketOrdersEmptyFake);
                EfficiencyCalculator.Calculate(accEff1);
             */
        }
        public void TestSetup()
        {
            #region Запоминиаем имена методов, которые будем мОчить разными реализациями в ходе тестов
            List<MarketOrder> voidOrdersList;
            List<BalanceChange> voidBalanceChangesList;
            getHistoryOrdersName = ProxyBuilder.GetMethodName<ITradeSharpAccount>(a => a.GetHistoryOrders(null, null, out voidOrdersList));
            getMarketOrdersName = ProxyBuilder.GetMethodName<ITradeSharpAccount>(a => a.GetMarketOrders(0, out voidOrdersList));
            getBalanceChangesName = ProxyBuilder.GetMethodName<ITradeSharpAccount>(a => a.GetBalanceChanges(0, null, out voidBalanceChangesList));
            #endregion

            fakeTradeAccount = ProxyBuilder.Instance.GetImplementer<ITradeSharpAccount>();
            TradeSharpAccount.Initialize(fakeTradeAccount);

            // Инициализируем словарь котировок
            dailyQuoteStorage = new DailyQuoteStorage();
            dailyQuoteStorage.InitializeFake(QuoteMaker.MakeQuotesForQuoteDailyStorage(null));

            SetupMockMethodImplementation();
        }
Esempio n. 6
0
 /// <summary>
 /// принудительное обновление котировок в каталоге 'quotes' данными с сервера
 /// </summary>
 private void UpdateQuotesInFolder()
 {
     var dailyQuoteStorage = new DailyQuoteStorage();
     dailyQuoteStorage.UpdateStorageSync();
 }