GenericPosition#
tradeexecutor.state.generic_position.GenericPosition Python class in Trading Strategy framework.
- class GenericPosition[source]#
Bases:
ABC
Base class for trading and reserve positions.
Implements common method all positions need to implement.
TODO: How to define generic balance_updates mapping.
See also
tradeexecutor.state.state.position.TradingPosition
tradeexecutor.state.state.reserve.ReservePosition
- __init__()#
Methods
__init__
()add_balance_update_event
(event)Include a new balance update event
calculate_quantity_usd_value
(quantity)Price token amount in this position in US dollar.
Iterate over all balance update events.
Get quantity of all balance updates for this position.
How to refer this position in log output.
Get the number of tokens held in this position.
- abstract calculate_quantity_usd_value(quantity)[source]#
Price token amount in this position in US dollar.
An estimation. Use whatever latest exchange rate that is appropriate.
- abstract get_balance_update_quantity()[source]#
Get quantity of all balance updates for this position.
Balance update events are
Deposits
Redemptions
Accounting corrections
… but not trades.
- Returns:
What’s the total value of non-trade events affecting the balances of this position.
- Return type:
- abstract get_balance_update_events()[source]#
Iterate over all balance update events.
Balance updates describe external events affecting the balance of this position: the update was not triggered by the trade executor itself.
Deposits
Redemptions
Account corrections
Trades are not included here
- Return type:
- abstract add_balance_update_event(event)[source]#
Include a new balance update event
- Raises:
BalanceUpdateEventAlreadyAdded – In the case of a duplicate and event id is already used.
- Parameters:
event (BalanceUpdate) –