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;
        }
        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;
        }
Example #3
0
 public Game(IProfitCalculator profitCalculator, IPlayer player)
 {
     _profitCalculator = profitCalculator;
     _symbols          = CreateSymbols();
     _randomizer       = new SymbolRandomizer(_symbols);
     _player           = player;
 }
Example #4
0
 public TradeManager(ITradeSharpServerTrade proxyTrade, 
     ITradeSharpAccount proxyAccount,
     IStorage<string, QuoteData> quoteStorage, Func<int, AccountGroup> getAccountGroup)
 {
     profitCalculator = ProfitCalculator.Instance;
     if (getAccountGroup == null) throw new ArgumentException("TradeManager ctor()", "getAccountGroup");
     this.proxyTrade = proxyTrade;
     this.proxyAccount = proxyAccount;
     this.quoteStorage = quoteStorage;
     this.getAccountGroup = getAccountGroup;
     timeStarted = DateTime.Now;
 }
        public static IProfitCalculator CreateInstance()
        {
            lock (_lock)
            {
                if (_instance is null)
                {
                    _instance = new ProfitCalculator();
                }

                return(_instance);
            }
        }
Example #6
0
        private ManagerTrade(Dictionary <string, IDealer> dealers)
        {
            accountRepository = AccountRepository.Instance;
            orderRepository   = OrderRepository.Instance;
            profitCalculator  = ProfitCalculator.Instance;
            walletRepository  = new WalletRepository();
            brokerRepository  = new BrokerRepository();

            this.dealers = dealers;
            foreach (var pair in dealers)
            {
                pair.Value.ServerInterface = this;
            }
        }
Example #7
0
 public TradeManager(ITradeSharpServerTrade proxyTrade,
                     ITradeSharpAccount proxyAccount,
                     IStorage <string, QuoteData> quoteStorage, Func <int, AccountGroup> getAccountGroup)
 {
     profitCalculator = ProfitCalculator.Instance;
     if (getAccountGroup == null)
     {
         throw new ArgumentException("TradeManager ctor()", "getAccountGroup");
     }
     this.proxyTrade      = proxyTrade;
     this.proxyAccount    = proxyAccount;
     this.quoteStorage    = quoteStorage;
     this.getAccountGroup = getAccountGroup;
     timeStarted          = DateTime.Now;
 }
Example #8
0
        private ManagerTrade(bool initialize)
        {
            accountRepository = AccountRepository.Instance;
            orderRepository   = OrderRepository.Instance;
            profitCalculator  = ProfitCalculator.Instance;
            brokerRepository  = new BrokerRepository();
            walletRepository  = new WalletRepository();

            if (!initialize)
            {
                return;
            }

            InitializeDealers();


            // инициализация сериализаторов
            SerializationWriter.TypeSurrogates.Add(new MarketOrderSerializer());
        }
Example #9
0
 public ProfitController(IProfitCalculator calculator, IProfitView view)
 {
     _calculator = calculator;
     _view       = view;
     _view.ShowResult(_calculator.CalculateResult(_view.GetRates()));
 }
 public void Setup()
 {
     _profitCalculator = ProfitCalculator.CreateInstance();
 }
Example #11
0
 public WalletManager()
 {
     walletRepository  = new WalletRepository();
     profitCalculator  = ProfitCalculator.Instance;
     accountRepository = AccountRepository.Instance;
 }
Example #12
0
 public WalletManager()
 {
     walletRepository = new WalletRepository();
     profitCalculator = ProfitCalculator.Instance;
     accountRepository = AccountRepository.Instance;
 }
Example #13
0
 private ManagerAccount()
 {
     profitCalculator  = ProfitCalculator.Instance;
     accountRepository = AccountRepository.Instance;
 }
Example #14
0
 private ManagerAccount()
 {
     profitCalculator = ProfitCalculator.Instance;
     accountRepository = AccountRepository.Instance;
 }