public async Task CancelOrder_Should_CancelOrder() { // Setup TwsObjectFactory twsObjectFactory = new TwsObjectFactory("localhost", TestConstants.Port, 1); ITwsControllerBase twsController = twsObjectFactory.TwsControllerBase; await twsController.EnsureConnectedAsync(); // Initialize the contract Contract contract = new Contract { SecType = TwsContractSecType.Stock, Symbol = "MSFT", Exchange = TwsExchange.Smart, PrimaryExch = TwsExchange.Island, }; // Initialize the order Order order = new Order { Action = "BUY", OrderType = "LMT", TotalQuantity = 1, LmtPrice = 1, }; // Place an order int orderId = await twsController.GetNextValidIdAsync(); bool orderAcknowledged = await twsController.PlaceOrderAsync(orderId, contract, order); orderAcknowledged.Should().BeTrue(); // Call the API bool cancelationAcknowledged = await twsController.CancelOrderAsync(orderId); // Assert cancelationAcknowledged.Should().BeTrue(); await twsController.DisconnectAsync(); }