public void Should_Notify_LimitOrder_execution() { var marketGateway = new ApiMarketGateway(marketName: "euronext", sellQuantity: 50, sellPrice: 100M); var executed = false; var order = marketGateway.CreateLimitOrder(ApiMarketWay.Buy, price: 100M, quantity: 10, allowPartial: false); marketGateway.OrderExecuted += (s, a) => executed = true; marketGateway.Send(order); Check.That(executed).IsTrue(); Check.That(marketGateway.SellQuantity).IsEqualTo(40); }
public void Should_support_partial_execution_for_LimitOrder() { var marketGateway = new ApiMarketGateway(marketName: "euronext", sellQuantity: 50, sellPrice: 100M); var executed = false; var order = marketGateway.CreateLimitOrder(ApiMarketWay.Buy, price: 100M, quantity: 110, allowPartial: true); var execQuantity = 0; marketGateway.OrderExecuted += (s, a) => { executed = true; execQuantity = a.Quantity; }; marketGateway.Send(order); Check.That(execQuantity).IsEqualTo(50); Check.That(executed).IsTrue(); Check.That(marketGateway.SellQuantity).IsEqualTo(0); }
public void Should_not_execute_LimitOrder_when_price_is_too_high() { var marketGateway = new ApiMarketGateway(marketName: "euronext", sellQuantity: 50, sellPrice: 100M); var executed = false; bool failed = false; string failureReason = null; var order = marketGateway.CreateLimitOrder(ApiMarketWay.Buy, price: 101M, quantity: 10, allowPartial: false); marketGateway.OrderExecuted += (s, a) => executed = true; marketGateway.OrderFailed += (s, failedEventArgs) => { failed = true; failureReason = failedEventArgs.FailureCause; }; marketGateway.Send(order); Check.That(executed).IsFalse(); Check.That(failed).IsTrue(); Check.That(failureReason).IsEqualTo("Invalid price"); Check.That(marketGateway.SellQuantity).IsEqualTo(50); }