def positions_by_asset(self):
positions = None<EOL>for book in self.books():<EOL><INDENT>book_positions = book.positions_by_asset()<EOL>positions.update({position.asset_id: position for position in book_positions<EOL>if position.asset_id not in positions.keys()})<EOL>keys = [position.asset_id for position in book_positions if position.asset_id in positions.key()]<EOL>for key in keys:<EOL><INDENT>positions.get(key).quantity += book_positions.get(key).quantity<EOL><DEDENT><DEDENT>return positions<EOL>
A dictionary of Position objects keyed by asset_id.  If an asset
position exists in more than one book, they are combined into a single
position.