From 9429c8ac1e7504ed3a6327b2342650f77a6f07de Mon Sep 17 00:00:00 2001 From: Neil Murphy Date: Mon, 2 Aug 2021 08:38:35 -0400 Subject: [PATCH] Fixes issue #61: self.positions throws attibute error when IB Broker used. self.positions = collections.defaultdict(Position) is consistent in all the other brokers, was missed in IB. --- backtrader/brokers/ibbroker.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backtrader/brokers/ibbroker.py b/backtrader/brokers/ibbroker.py index 2c1b0d9a0..3f1651594 100644 --- a/backtrader/brokers/ibbroker.py +++ b/backtrader/brokers/ibbroker.py @@ -276,6 +276,7 @@ def __init__(self, **kwargs): self.ordstatus = collections.defaultdict(dict) self.notifs = queue.Queue() # holds orders which are notified self.tonotify = collections.deque() # hold oids to be notified + self.positions = self.ib.positions def start(self): super(IBBroker, self).start()