BalanceUpdate#
tradeexecutor.state.balance_update.BalanceUpdate Python class in Trading Strategy framework.
- class BalanceUpdate[source]#
Bases:
object
Processed balance update event.
Events that are generated on
Deposits
Redemptions
Interest payments
Events are stored in
TradingPosition
andReservePosition
by their id.Events are referred in
tradeexecutor.sync.Treasury
..- __init__(balance_update_id, cause, position_type, asset, block_mined_at, chain_id, quantity, old_balance, owner_address=None, tx_hash=None, log_index=None, position_id=None)#
- Parameters:
balance_update_id (int) –
cause (BalanceUpdateCause) –
position_type (BalanceUpdatePositionType) –
asset (AssetIdentifier) –
block_mined_at (datetime) –
chain_id (int) –
quantity (Decimal) –
old_balance (Decimal) –
- Return type:
None
Methods
__init__
(balance_update_id, cause, ...[, ...])from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])Return whether this event updates reserve balance or open position balance
schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
Log that updated the balance
Investor address that the balance update is related to
If this update was for open position
Transaction that updated the balance
Allocated from portfolio
What caused the balance update event to happen
What kind of position this event modified
Asset that was updated
When the update happened
Chain that updated the balance
What was delta of the asset.
What was the total of the asset in the position before this event was applied.
- balance_update_id: int#
Allocated from portfolio
This id is referred in
tradeexecutor.state.position.TradingPosition
andtradeexecutor.state.reserve.ReservePosition
- cause: BalanceUpdateCause#
What caused the balance update event to happen
- position_type: BalanceUpdatePositionType#
What kind of position this event modified
- asset: AssetIdentifier#
Asset that was updated
- old_balance: Decimal#
What was the total of the asset in the position before this event was applied.
- tx_hash: Optional[str] = None#
Transaction that updated the balance
Set None for interested calculation updates
- position_id: Optional[int] = None#
If this update was for open position
Set None for reserve updates
- is_reserve_update()[source]#
Return whether this event updates reserve balance or open position balance
- Return type:
- __init__(balance_update_id, cause, position_type, asset, block_mined_at, chain_id, quantity, old_balance, owner_address=None, tx_hash=None, log_index=None, position_id=None)#
- Parameters:
balance_update_id (int) –
cause (BalanceUpdateCause) –
position_type (BalanceUpdatePositionType) –
asset (AssetIdentifier) –
block_mined_at (datetime) –
chain_id (int) –
quantity (Decimal) –
old_balance (Decimal) –
- Return type:
None