Exemplo n.º 1
0
        public void SpotService_Returns_Positive_Prices_Iteratively(int updatesCount)
        {
            var count = Enum.GetValues(typeof(Symbol)).Length;

            Enumerable.Range(0, updatesCount).ToList().ForEach(attemp =>
            {
                var prices = _service.GetPrices().ToList();
                prices.Count.Should().Be(count);
                prices.ForEach(price => price.Value.Should().BePositive());
            });
        }
Exemplo n.º 2
0
        private void LoadPositions()
        {
            _positions = _spotService.GetSymbols()
                         .ToDictionary(symbol => symbol, symbol => new List <PositionItem>());
            var generator    = new Random();
            var symbolsCount = _spotService.GetSymbols().Count;
            var prices       = _spotService.GetPrices();

            for (var i = 0; i < _settings.PositionsCount; i++)
            {
                var position = new PositionItem
                {
                    PositionId = i + 1,
                    Symbol     = (Symbol)generator.Next(symbolsCount),
                    Quantity   = generator.Next(_settings.MinimumQuantity, _settings.MaximumQuantity)
                };
                position.UpdateSpot(prices[position.Symbol]);
                _positions[position.Symbol].Add(position);
            }
        }