From 08726f893a1b78cf8f00b8ca9992c0a581e5911b Mon Sep 17 00:00:00 2001 From: Peter Dekkers Date: Tue, 27 Feb 2024 22:33:17 +0100 Subject: [PATCH] fixed IBKR bug --- roboquant/brokers/ibkrbroker.py | 2 +- tests/integration/test_ibkrbroker.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/roboquant/brokers/ibkrbroker.py b/roboquant/brokers/ibkrbroker.py index 05c222b..87ebfc7 100644 --- a/roboquant/brokers/ibkrbroker.py +++ b/roboquant/brokers/ibkrbroker.py @@ -99,7 +99,7 @@ def orderStatus( ): logger.debug("order status orderId=%s status=%s fill=%s", orderId, status, filled) orderId = str(orderId) - if id in self.orders: + if orderId in self.orders: order = self.orders[orderId] order.fill = filled match status: diff --git a/tests/integration/test_ibkrbroker.py b/tests/integration/test_ibkrbroker.py index 00915ac..a00f076 100644 --- a/tests/integration/test_ibkrbroker.py +++ b/tests/integration/test_ibkrbroker.py @@ -46,9 +46,10 @@ def test_ibkrbroker(self): time.sleep(5) account = broker.sync() self.assertEqual(len(account.orders), 1) - self.assertTrue(account.orders[0].closed) - self.assertEqual(OrderStatus.CANCELLED, account.orders[0].status) - + order = account.orders[0] + self.assertTrue(order.closed) + self.assertEqual(OrderStatus.CANCELLED, order.status) + print() print(account)