ValuationUpdate#

API documentation for tradeexecutor.state.valuation.ValuationUpdate Python class in Trading Strategy framework.

class ValuationUpdate[source]#

Bases: object

Valuation update events.

Generated by tradeexecutor.strategy.valuation.ValuationModel

__init__(position_id, created_at, valued_at, new_value, new_price, old_value=None, old_price=None, block_number=None, mark_down_to_zero=None)#
Parameters:
  • position_id (int) –

  • created_at (datetime) –

  • valued_at (datetime) –

  • new_value (float) –

  • new_price (float) –

  • old_value (float | None) –

  • old_price (float | None) –

  • block_number (int | None) –

  • mark_down_to_zero (bool | None) –

Return type:

None

Methods

__init__(position_id, created_at, valued_at, ...)

from_dict(kvs, *[, infer_missing])

from_json(s, *[, parse_float, parse_int, ...])

schema(*[, infer_missing, only, exclude, ...])

to_dict([encode_json])

to_json(*[, skipkeys, ensure_ascii, ...])

Attributes

block_number

What is the block number is valuation is based on.

mark_down_to_zero

In this update, we marked down this position to zero because of the valuation failure.

old_price

What was the position base asset price before this update.

old_value

What was the position value before this update.

position_id

created_at

When this valuation was updated.

valued_at

The block timestamp this valuation is based on.

new_value

new_price

The new price of the base asset of the position.

created_at: datetime#

When this valuation was updated.

Valuation can be based on old data, this is the strategy cycle timestamp or wall-clock timestmap when this event was generated.

See also valued_at

valued_at: datetime#

The block timestamp this valuation is based on.

If not available then wall clock time of the valuation. Note that block timestamp may lag created_at because we cannot use the last block due to chain tip instability.

See also event_generated_at

new_price: float#

The new price of the base asset of the position.

Note that position value depends also on gained interest and the price of the quote asset.

old_value: float | None = None#

What was the position value before this update.

old_price: float | None = None#

What was the position base asset price before this update.

block_number: int | None = None#

What is the block number is valuation is based on.

Must match valued_at.

mark_down_to_zero: bool | None = None#

In this update, we marked down this position to zero because of the valuation failure.

Set to True indicate we lost the valuation source for this position.

See revalue_portfolio().

__init__(position_id, created_at, valued_at, new_value, new_price, old_value=None, old_price=None, block_number=None, mark_down_to_zero=None)#
Parameters:
  • position_id (int) –

  • created_at (datetime) –

  • valued_at (datetime) –

  • new_value (float) –

  • new_price (float) –

  • old_value (float | None) –

  • old_price (float | None) –

  • block_number (int | None) –

  • mark_down_to_zero (bool | None) –

Return type:

None