Interest#
API documentation for tradeexecutor.state.interest.Interest Python class in Trading Strategy framework.
- class Interest[source]#
Bases:
object
Interest data tracking for positions that where the amount changes over time.
Credit positions (depositing in Aave reservess)
Longs / shorts
- __init__(opening_amount, last_token_amount, last_updated_at, last_event_at, last_accrued_interest, last_updated_block_number=None, interest_payments=Decimal('0'), reset_at=None)#
Methods
__init__
(opening_amount, last_token_amount, ...)adjust
(delta[, epsilon])Adjust the quantity on this loan.
claim_interest
(quantity)Update interest claims from profit from accuring interest on collateral/
from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])Return how many tokens exactly we have on the loan.
GEt the amount of interest this position has still left.
open_new
(opening_amount, timestamp)repay_interest
(quantity)Update interest payments needed to maintain the borrowed debt.
reset
(amount, block_timestamp, block_number)Reset the loan token amount.
schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
How many tokens we deposited to this position at amount.
How many atokens/votkens we had on the previous read.
When the denormalised data was last updated.
When the denormalised data was last updated.
How much interest we have gained
Block number for the update
If we repair/reset this interest tracked, when this happened.
- opening_amount: Decimal#
How many tokens we deposited to this position at amount.
Use this only for calculation verifications, because the amount can be increased/reduced over time
- last_token_amount: Decimal#
How many atokens/votkens we had on the previous read.
Absolute number of on-chain balance.
This is principal + interest.
- last_event_at: datetime#
When the denormalised data was last updated.
Event time (block mined timestamp).
- last_updated_block_number: int | None#
Block number for the update
When was the last time we read aToken balance.
- reset_at: datetime.datetime | None#
If we repair/reset this interest tracked, when this happened.
- get_principal_and_interest_quantity()[source]#
Return how many tokens exactly we have on the loan.
Assuming any aToken/vToken will be fully converted to the underlying.
- Return type:
- get_remaining_interest()[source]#
GEt the amount of interest this position has still left.
This is total lifetime interest + repayments / claims.
- Return type:
- claim_interest(quantity)[source]#
Update interest claims from profit from accuring interest on collateral/
- Parameters:
quantity (Decimal) –
- repay_interest(quantity)[source]#
Update interest payments needed to maintain the borrowed debt.
- Parameters:
quantity (Decimal) –
- adjust(delta, epsilon=Decimal('1.00000000000000007154242405462192450852805618492324772617063644020163337700068950653076171875E-18'))[source]#
Adjust the quantity on this loan.
Used when doing increase/reduce shorts to get a new amount. With safety checks.
- reset(amount, block_timestamp, block_number)[source]#
Reset the loan token amount.
Used in the manual account correction
- __init__(opening_amount, last_token_amount, last_updated_at, last_event_at, last_accrued_interest, last_updated_block_number=None, interest_payments=Decimal('0'), reset_at=None)#