Skip to content

Commit

Permalink
Update portfolio.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 10, 2024
1 parent 5063695 commit cd9ef39
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions eth_portfolio/_ledgers/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ async def df(self, start_block: Block, end_block: Block) -> DataFrame:
df = self._cleanup_df(df)
return df

async def sent(
self, start_block: Optional[Block] = None, end_block: Optional[Block] = None
) -> AsyncIterator[T]:
portfolio_addresses = set(self.portfolio.addresses.keys())
async for obj in self[start_block:end_block]:
if obj.from_address in portfolio_addresses and obj.to_address not in portfolio_addresses:
yield obj

async def received(
self, start_block: Optional[Block] = None, end_block: Optional[Block] = None
) -> AsyncIterator[T]:
portfolio_addresses = set(self.portfolio.addresses.keys())
async for obj in self[start_block:end_block]:
if obj.to_address in portfolio_addresses and obj.from_address not in portfolio_addresses:
yield obj

async def _df_base(self, start_block: Block, end_block: Block) -> DataFrame:
"""
Fetches and concatenates raw ledger data into a :class:`~DataFrame` for all addresses in the portfolio.
Expand Down

0 comments on commit cd9ef39

Please sign in to comment.