def __init__(self, tranlist): # Initialize with *TRANLIST Element dtstart, dtend = tranlist[0:2] tranlist = tranlist[2:] self.dtstart = DateTime.convert(dtstart.text) self.dtend = DateTime.convert(dtend.text) self.extend([Aggregate.from_etree(tran) for tran in tranlist])
def _init(self, invstmtrs): dtasof = invstmtrs.find('DTASOF').text self.datetime = DateTime.convert(dtasof) # INVTRANLIST tranlist = invstmtrs.find('INVTRANLIST') if tranlist is not None: self.transactions = INVTRANLIST(tranlist) else: self.transactions = [] # INVPOSLIST poslist = invstmtrs.find('INVPOSLIST') if poslist is not None: self.positions = [Aggregate.from_etree(pos) for pos in poslist] else: self.positions = [] # INVBAL invbal = invstmtrs.find('INVBAL') if invbal is not None: # First strip off BALLIST & process it ballist = invbal.find('BALLIST') if ballist is not None: invbal.remove(ballist) self.other_balances = [Aggregate.from_etree(bal) for bal in ballist] else: self.other_balances = [] # Now we can flatten the rest of INVBAL self.balances = Aggregate.from_etree(invbal) else: self.balances = [] self.other_balances = [] # Unsupported subaggregates for tag in ('INVOOLIST', 'INV401K', 'INV401KBAL', 'MKTGINFO'): child = invstmtrs.find(tag) if child is not None: invstmtrs.remove