Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality reqPositionsMulti #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

paramkr2
Copy link

@paramkr2 paramkr2 commented Jun 7, 2024

No description provided.

@eyalk11
Copy link

eyalk11 commented Jun 8, 2024

Lol implemented it a long ago. Just fixed it.
Your implementation doesn't seem to be async (I don't get how it works too)

    async def reqTickersAsync(
            self,genericTickList='', *contracts: Contract):
        s=self._ibsource.ibrem.ib
        futures = []
        tickers = []
        reqIds = []
        contracts = set(list(contracts))
        for contract in contracts:
            reqId = s.client.getReqId()
            reqIds.append(reqId)
            future = s.wrapper.startReq(reqId, contract)
            futures.append(future)
            ticker = s.wrapper.startTicker(reqId, contract, "mktData")
            tickers.append(ticker)
            def kk(reqId,contract,aa):
                logging.debug(('called', reqId))
                #s.cancelMktData(contract)
                s.wrapper._endReq(reqId)

                

            ticker.updateEvent += partial(kk,reqId,contract)
            s.client.reqMktData(
                reqId, contract,genericTickList=genericTickList,snapshot=False,regulatorySnapshot=False,mktDataOptions=[])


        ls=await asyncio.gather(*futures,return_exceptions=True)
        logging.debug('gathered')
        for w,id in enumerate(ls):
            if isinstance(w,Exception):
                logging.debug(('error',w,id))

        for contract in contracts:
            s.cancelMktData(contract)
            #s.wrapper.endTicker(ticker, "aa")
        logging.debug('ended tickers')
        return tickers

@paramkr2
Copy link
Author

paramkr2 commented Jun 8, 2024

@eyalk11
Thansk for looking into it, I was trying to get positions within a specified modelCode , and for me async works fine.
I needed functionality for Position Update Subscription by Model, which is not implemented here.
I am new to this, so i don't understand how your code achieves this.

@eyalk11
Copy link

eyalk11 commented Jun 9, 2024

Hi, I probably didn't understand your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants