diff --git a/ib_async/ib.py b/ib_async/ib.py index 749b1f8..b78a437 100644 --- a/ib_async/ib.py +++ b/ib_async/ib.py @@ -2502,7 +2502,15 @@ def reqUserInfoAsync(self): future = self.wrapper.startReq(reqId) self.client.reqUserInfo(reqId) return future - + + def reqPositionsMulti(self,account,modelCode) -> List[Position]: + return self._run(self.reqPositionsMultiAsync(account,modelCode)) + + def reqPositionsMultiAsync(self,account,modelCode) -> Awaitable[List[Position]]: + reqId = self.client.getReqId() + future = self.wrapper.startReq(reqId, container=[]) + self.client.reqPositionsMulti(reqId, account, modelCode) + return future if __name__ == "__main__": loop = util.getLoop() diff --git a/ib_async/wrapper.py b/ib_async/wrapper.py index 5b9c8da..4b2e5db 100644 --- a/ib_async/wrapper.py +++ b/ib_async/wrapper.py @@ -442,18 +442,14 @@ def positionEnd(self): self._endReq("positions") def positionMulti( - self, - reqId: int, - account: str, - modelCode: str, - contract: Contract, - pos: float, - avgCost: float, - ): - pass + self, reqId: int, account: str, modelCode: str, + contract: Contract, pos: float, avgCost: float): + results = self._results.get(reqId) ; + if results is not None: + results.append({'account':account,'modelCode':modelCode , 'symbol':contract.symbol,'secType':contract.secType,'currency':contract.currency,'position':pos , 'avgCost':avgCost } ) def positionMultiEnd(self, reqId: int): - pass + self._endReq(reqId) def pnl( self, reqId: int, dailyPnL: float, unrealizedPnL: float, realizedPnL: float @@ -1495,3 +1491,6 @@ def tcpDataProcessed(self): ticker.time = self.lastTime ticker.updateEvent.emit(ticker) self.ib.pendingTickersEvent.emit(self.pendingTickers) + + +