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)#
Parameters:
Return type:

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, ...])

get_principal_and_interest_quantity()

Return how many tokens exactly we have on the loan.

get_remaining_interest()

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

opening_amount

How many tokens we deposited to this position at amount.

last_token_amount

How many atokens/votkens we had on the previous read.

last_updated_at

When the denormalised data was last updated.

last_event_at

When the denormalised data was last updated.

last_accrued_interest

How much interest we have gained

last_updated_block_number

Block number for the update

interest_payments

reset_at

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_updated_at: datetime#

When the denormalised data was last updated.

Wall clock time.

last_event_at: datetime#

When the denormalised data was last updated.

Event time (block mined timestamp).

last_accrued_interest: Decimal#

How much interest we have gained

last_updated_block_number: int | None#

Block number for the update

When was the last time we read aToken balance.

interest_payments: Decimal#
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:

Decimal

get_remaining_interest()[source]#

GEt the amount of interest this position has still left.

This is total lifetime interest + repayments / claims.

Return type:

Decimal

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.

Parameters:
  • delta (Decimal) – Positive: increase amount, negative decrease amount.

  • epsilon (Decimal) –

reset(amount, block_timestamp, block_number)[source]#

Reset the loan token amount.

  • Used in the manual account correction

Parameters:
__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)#
Parameters:
Return type:

None