Esempio n. 1
0
        public async Task InitializeTradingsServiceAsync()
        {
            IsStarted = true;

            await _masterTraderManager.AppendUserAsync(_traderAccount.EmailAddress, _traderAccount.Password);

            var result = await _followerManager.GetActiveAccountNotOnFollowersTask();

            result.ForEach(y => _followerManager.AppendUser(y, _masterTraderManager.MasterOpenOrderStream));

            //auto subscribe to azure-bus
            _activeAccountBusReceiver
            .MessageObservable
            .Subscribe(x => {
                if (x.IsActive)
                {
                    var iqAccount = _queryProcessor
                                    .ProcessAsync(new GetIqAccountByIqUserIdQuery(x.UserId), CancellationToken.None)
                                    .Result;

                    _logger.LogInformation($"Bus Received new Active account is {x.UserId}");
                    _followerManager.AppendUser(iqAccount, _masterTraderManager.MasterOpenOrderStream);
                }
                else
                {
                    _logger.LogInformation($"Bus Received new InActive account is {x.UserId}");
                    _followerManager.RemoveByUserId(x.UserId);
                }
            });
        }
Esempio n. 2
0
        public async Task InitializeTradingsServiceAsync()
        {
            IsStarted = true;

            await _masterTraderManager.AppendUserAsync(_traderAccount.EmailAddress, _traderAccount.Password);


            var result = await _followerManager.GetActiveAccountNotOnFollowersTask();


            result.ForEach(y => _followerManager.AppendUser(y, _masterTraderManager.MasterOpenOrderStream));



            var interval = Observable.Interval(TimeSpan.FromSeconds(60), Scheduler.Immediate)
                           .Publish().RefCount();



            ////var interval = Observable
            ////    .Interval(TimeSpan.FromSeconds(60), Scheduler.Immediate)
            ////    .Publish();

            interval
            .Select(x => _followerManager.GetActiveAccountNotOnFollowersTask().Result)
            .Subscribe(x => {
                x.ForEach(y => {
                    _followerManager.AppendUser(y, _masterTraderManager.MasterOpenOrderStream);
                });
            });

            interval
            .Select(x => _followerManager.GetInActiveAccountNotOnFollowersTask().Result)
            .Subscribe(x => { x.ForEach(y => { _followerManager.RemoveByEmailAddress(y.IqOptionUserName); }); });

            ////interval.Connect();


            ////foreach (var client in _followerManager.Followers) {
            ////    client.SubScribeForTraderStream(_masterTraderManager.MasterOpenOrderStream);
        }