public CurrencyPairViewModel(CurrencyPairStateDto currencyPairStateDto, IReactiveTrader reactiveTrader, IConcurrencyService concurrencyService)
 {
     _currencyPairStateDto = currencyPairStateDto;
     _reactiveTrader = reactiveTrader;
     _concurrencyService = concurrencyService;
     Symbol = currencyPairStateDto.Symbol;
     Available = currencyPairStateDto.Enabled;
     Stale = currencyPairStateDto.Stale;
     CanModify = true;
 }
        public IObservable<Unit> SetCurrencyPairState(string symbol, bool enabled, bool stale)
        {
            var dto = new CurrencyPairStateDto
            {
                Symbol = symbol,
                Enabled = enabled,
                Stale = stale
            };

            return _controlServiceClient.SetCurrencyPairState(dto)
                .Select(_ => Unit.Default);
        } 
Example #3
0
        public UnitDto SetCurrencyPairState(CurrencyPairStateDto request)
        {
            var currencyPair = _currencyPairRepository.GetAllCurrencyPairInfos()
                .FirstOrDefault(cpi => cpi.CurrencyPair.Symbol == request.Symbol);

            if (currencyPair != null)
            {
                Log.InfoFormat("Received set currency pair state [{0}] from {1}.", request.Symbol, ContextUtil.GetUserName(Context));
                if (currencyPair.Enabled != request.Enabled)
                {
                    if (request.Enabled)
                    {
                        Log.InfoFormat("Enabling currency pair {0}.", request.Symbol);
                        _currencyPairUpdatePublisher.AddCurrencyPair(currencyPair.CurrencyPair);
                    }
                    else
                    {
                        Log.InfoFormat("Disabling currency pair {0}", request.Symbol);
                        _currencyPairUpdatePublisher.RemoveCurrencyPair(currencyPair.CurrencyPair);
                    }
                    currencyPair.Enabled = request.Enabled;
                }

                if (currencyPair.Stale != request.Stale)
                {
                    if (currencyPair.Stale)
                    {
                        Log.InfoFormat("Making currency pair {0} go stale.", request.Symbol);
                    }
                    else
                    {
                        Log.InfoFormat("Making currency pair {0} no longer stale.", request.Symbol);
                    }
                    currencyPair.Stale = request.Stale;
                }
            }
            else
            {
                Log.WarnFormat("Received set currency pair state for unknown currency pair {0} from {1}.", request.Symbol, ContextUtil.GetUserName(Context));
            }

            return new UnitDto();
        }