BalanceEventRef#

tradeexecutor.state.sync.BalanceEventRef Python class in Trading Strategy framework.

class BalanceEventRef[source]#

Bases: object

Register the balance event in the treasury model.

Balance updates can happen for

  • Treasury

  • Open trading positions

We maintain a list of balance update references across all positions using BalanceEventRef. This allows us quickly to calculate net inflow/outflow.

__init__(balance_event_id, strategy_cycle_included_at, cause, position_type, position_id, usd_value)#
Parameters:
Return type:

None

Methods

__init__(balance_event_id, ...)

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

balance_event_id

Balance event id we are referring to

strategy_cycle_included_at

When this update was made.

cause

Cause of the event

position_type

Reserve currency or underlying position

position_id

Which trading positions were affected

usd_value

How much this deposit/redemption was worth

balance_event_id: int#

Balance event id we are referring to

strategy_cycle_included_at: Optional[datetime]#

When this update was made.

Strategy cycle timestamp when the deposit/redemption was included in the strategy treasury.

It might be outside the cycle frequency if treasuries were processed in a cron job outside the cycle for slow moving strategies.

cause: BalanceUpdateCause#

Cause of the event

position_type: BalanceUpdatePositionType#

Reserve currency or underlying position

position_id: Optional[int]#

Which trading positions were affected

usd_value: Optional[float]#

How much this deposit/redemption was worth

Used for deposit/redemption inflow/outflow calculation. This is the asset value from our internal price keeping at the time of the event.

__init__(balance_event_id, strategy_cycle_included_at, cause, position_type, position_id, usd_value)#
Parameters:
Return type:

None