AssetWithTrackedValue#
API documentation for tradeexecutor.state.identifier.AssetWithTrackedValue Python class in Trading Strategy framework.
- class AssetWithTrackedValue[source]#
Bases:
object
Track one asset with a value.
Track asset quantity
The asset can be vToken/aToken for interest based tracking, in this case
presentation
is setAny tracked asset must get USD oracle price from somewhere
- __init__(asset, quantity, last_usd_price, last_pricing_at, created_at=<factory>, created_strategy_cycle_at=None)#
Methods
__init__
(asset, quantity, last_usd_price, ...)change_quantity_and_value
(delta, price, when)The tracked asset amount is changing due to position increase/reduce.
from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])Rrturn the approximate value of this tracked asset.
revalue
(price, when)Update the latest known price of the asset.
schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
Asset we are tracking
How many token units we have.
What was the last known USD price of a single unit of quantity
When the last pricing happened
Strategy cycle time stamp when the tracking was started
Strategy cycle time stamp when the tracking was started
- asset: AssetIdentifier#
Asset we are tracking
The is aToken or vToken asset.
Use
asset.underlying
to get the token.
- quantity: Decimal#
How many token units we have.
In the case of loans this represents the underlying asset (WETH), not any gained interest (vWETH).
- created_strategy_cycle_at: datetime.datetime | None#
Strategy cycle time stamp when the tracking was started
- get_usd_value()[source]#
Rrturn the approximate value of this tracked asset.
Priced in the last_usd_price
- Return type:
- __init__(asset, quantity, last_usd_price, last_pricing_at, created_at=<factory>, created_strategy_cycle_at=None)#
- change_quantity_and_value(delta, price, when, allow_negative=False, available_accrued_interest=Decimal('0'), epsilon=Decimal('1.00000000000000007154242405462192450852805618492324772617063644020163337700068950653076171875E-18'), close_position=False)[source]#
The tracked asset amount is changing due to position increase/reduce.
- Parameters:
allow_negative (bool) –
Backtesting helper parameter.
Bail out with an exception if delta is too high and balance would go negative.
available_accrued_interest (Decimal) –
How much interest we have gained.
To be used with
allow_negative
.delta (Decimal) –
price (float) –
when (datetime) –
epsilon (Decimal) –