ERC4626Profitability
Documentation for eth_defi.erc_4626.profit_and_loss.ERC4626Profitability Python class.
- class ERC4626Profitability
Bases:
objectCapture the data needed for the vault profitability calculation.
Attributes summary
vaultstart_blockend_blockshare_pricestimestampsMethods summary
__init__(vault, start_block, end_block, ...)calculate_profitability([annualise, ...])Get profitability for the whole duration of the sampling period.
Get the block range of the profitability data.
Get the share price range of the profitability data.
Get the time range of the profitability data.
- calculate_profitability(annualise=True, year_in_seconds=31536000)
Get profitability for the whole duration of the sampling period.
This is the same as APY <https://tradingstrategy.ai/glossary/annual-percentage-yield-apy>__. But it’s incorrect to use term APY was some vaults may incur losses as well.
- Parameters
annualise – If True, calculate profit % if we can maintain this profitability for a year.
year_in_seconds – Allow custom year durations.
- Returns
Profitability as a percentage, either annualised or not.
0.07 means 7% APY.
- Return type
- get_time_range()
Get the time range of the profitability data.
- Returns
Tuple of start and end timestamps.
- Return type
- get_block_range()
Get the block range of the profitability data.
- get_share_price_range()
Get the share price range of the profitability data.
- Returns
Tuple of start and end share prices.
- Return type
- __init__(vault, start_block, end_block, share_prices, timestamps)
- Parameters
vault (eth_defi.erc_4626.vault.ERC4626Vault) –
start_block (int) –
end_block (int) –
share_prices (dict[int, decimal.Decimal]) –
timestamps (dict[int, datetime.datetime]) –
- Return type
None