Exemplo n.º 1
0
        private AccountCheckStream()
        {
            walletRepository = new WalletRepository();
            accountRepository = AccountRepository.Instance;
            orderRepository = OrderRepository.Instance;
            profitCalculator = ProfitCalculator.Instance;
            tradeManager = ManagerTrade.Instance.tradeManager;
            brokerRepository = new BrokerRepository();

            threadIntervalMils = AppConfig.GetIntParam("CheckLoop.Interval", 100);

            schedules = new[]
                {
                    new Schedule(CheckOrders, AppConfig.GetIntParam("CheckLoop.IntervalOrders", 300)),
                    new Schedule(CheckMargin, AppConfig.GetIntParam("CheckLoop.IntervalMargin", 15000)),
                    new Schedule(CheckSwap, AppConfig.GetIntParam("CheckLoop.IntervalSwap", 1000)),
                    new Schedule(RenewSubscriptions, AppConfig.GetIntParam("CheckLoop.UpdateSubscriptions", 1000))
                };

            // параметры начисления свопов
            var dicMetadata = brokerRepository.GetMetadataByCategory("SWAP");
            object swapHourGmtObj, minutesToCheckSwapObj;
            if (!dicMetadata.TryGetValue("Hour.GMT", out swapHourGmtObj))
                swapHourGmtObj = 21;
            swapCheckHourGmt = (int) swapHourGmtObj;

            if (!dicMetadata.TryGetValue("MinutesToCheck", out minutesToCheckSwapObj))
                minutesToCheckSwapObj = 0;
            minutesToCheckSwap = (int)minutesToCheckSwapObj;
        }
Exemplo n.º 2
0
        public void InitTest()
        {
            // забить котировки
            QuoteMaker.FillQuoteStorageWithDefaultValues();

            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);
            DalSpot.Instantiate(TradeSharpDictionary.Instance.proxy);

            tradeManager = new TradeManager(
                null,
                null,
                QuoteStorage.Instance, accountId =>
                    {
                        // ReSharper disable ConvertToLambdaExpression
                        return LinqToEntity.DecorateAccountGroup(conn.ACCOUNT.First(a => a.ID == accountId).ACCOUNT_GROUP);
                        // ReSharper restore ConvertToLambdaExpression
                    });
            ManagerTrade.MakeTestInstance();

            // временно удалить файл начального наполнения (открытые ордера)
            TradeSharpConnectionPersistent.RestoreCsvFilesInMoqDbFolder();
            TradeSharpConnectionPersistent.RenameCsvFilesContainingAccountDataInMoqDbFolder();
            conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection();
            MakeTestContents();
        }
Exemplo n.º 3
0
        public void Setup()
        {
            // подготовить свежие котировки
            QuoteMaker.FillQuoteStorageWithDefaultValues();

            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            // замочить прокси
            MakeTradeSharpAccountProxy();
            MakeTradeSharpServerTradeProxy();

            tradeManager = new TradeManager(
                fakeServerTrade,
                fakeAccountManager,
                QuoteStorage.Instance, accountId => testGroup);
        }
Exemplo n.º 4
0
 private static void StartTradeLib()
 {
     Logger.Info("Старт торговой библиотеки...");
     var managerTrade = ManagerTrade.Instance;
     try
     {
         var tradeManager = new TradeManager(
             managerTrade,
             ManagerAccount.Instance,
             QuoteStorage.Instance,
             AccountRepository.Instance.GetAccountGroup);
         managerTrade.tradeManager = tradeManager;
         ProviderQueueReader.Instance.orderManager = managerTrade;
         ProviderQueueReader.Instance.OnExecutionReportReceived += managerTrade.OnProviderReport;
         ServiceManagerClientManagerProxy.Instance.StartDistribution();
     }
     catch (Exception ex)
     {
         Logger.Error("Ошибка инициализации торговой библиотеки", ex);
         throw;
     }
 }