csingley / ibflex

Python parser for Interactive Brokers Flex XML statements
MIT License
85 stars 42 forks source link

AttributeError: 'bytes' object has no attribute 'FlexStatements' #72

Closed MarioColombo closed 1 year ago

MarioColombo commented 1 year ago

Hi, I'm trying to use it. I got the response well with response = client.download(token, query_id) But trying to ge the statement gives me an error: stmt = response.FlexStatements[0]

AttributeError Traceback (most recent call last) Cell In[57], line 1 ----> 1 stmt = response.FlexStatements[0]

AttributeError: 'bytes' object has no attribute 'FlexStatements'

csingley commented 1 year ago

If you’re not a programmer, you’re going to have a bad time using this library.

eyalk11 commented 1 year ago

See this example

    def doquery(self):
        logging.info(("running query in IB  for transaction"))
        if not self.DoQuery or not (self.query_id) or not self.token_id:
            return
        try:
            response = client.download(self.token_id, self.query_id)
        except:
            logging.debug(('err in querying flex'))
            import traceback;traceback.print_exc()
            return

        p = parser.parse(response)
        return  p.FlexStatements[0].Trades