Пример #1
0
        public async Task OrdersFromAStrategyArePlaced(
            long id, Side side, double price, double size)
        {
            _subscription.WithMarketChange(new MarketChange());
            var o1 = new LimitOrder(id, side, price, size);

            _strategy.WithOrder(o1);
            await _trader.TradeMarket("1.2345", 0, default);

            var placedOrder = _orderService.LastOrdersPlaced
                              .First(o => o.SelectionId == id);

            Assert.Equal(side, placedOrder.Side);
            Assert.Equal(price, placedOrder.Price);
            Assert.Equal(size, placedOrder.Size);
        }
Пример #2
0
        public async Task PlaceTradesFromMultipleStrategies()
        {
            _subscription.WithMarketChange(new MarketChange());
            var s2 = new StrategySpy();

            _trader.AddStrategy(s2);

            var o1 = new LimitOrder(1, Side.Back, 2.5, 10.99);

            _strategy.WithOrder(o1);
            s2.WithOrder(o1);

            await _trader.TradeMarket("1.2345", 0, default);

            Assert.Equal(2, _orderService.LastOrdersPlaced.Count);
        }