accrue_interest#
API documentation for tradeexecutor.strategy.interest.accrue_interest Python function.
- accrue_interest(state, on_chain_balances, interest_distribution, block_timestamp, block_number, max_interest_gain=0.05, aave_financial_year=datetime.timedelta(days=365))[source]#
Update the internal ledger to match interest accrued on on-chain balances.
Read incoming on-chain balance updates
Distribute it to the trading positions based on our
interest_distribution
Set the interest sync checkpoint
- Parameters:
state (State) – Strategy state.
on_chain_balances (Dict[AssetIdentifier, Decimal]) – The current on-chain balances at
block_number
.block_number (int | None) – The block number when we read the balances.
block_timestamp (datetime) – The timestamp of
block_number
.max_interest_gain (float) –
Abort if some asset has gained more interest than this threshold.
A safety check to abort buggy code.
interest_distribution (InterestDistributionOperation) –
- Returns:
Balance update events applied to all positions.
- Return type: