PositionStatistics#

API documentation for tradeexecutor.state.statistics.PositionStatistics Python class in Trading Strategy framework.

class PositionStatistics[source]#

Bases: object

Time-series of statistics calculated for each open position.

Position statistics are recalculated at the same time positions are revalued. The time-series of these statistics are stored as a part of the state, allowing one to plot the position performance over time.

__init__(calculated_at, last_valuation_at, profitability, profit_usd, quantity, value)#
Parameters:
Return type:

None

Methods

__init__(calculated_at, last_valuation_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

calculated_at

Real-time clock when these stats were calculated

last_valuation_at

When this position was revalued last time.

profitability

Profitability %

profit_usd

How much profit we made so far

quantity

The current number of owned units

value

The current position size dollars

calculated_at: datetime#

Real-time clock when these stats were calculated

last_valuation_at: datetime#

When this position was revalued last time. Should not be far off from calculated_at because we should revalue positions always before calculating their stats.

profitability: float#

Profitability %

Unrealised profitability

profit_usd: float#

How much profit we made so far

quantity: float#

The current number of owned units

value: float#

The current position size dollars

__init__(calculated_at, last_valuation_at, profitability, profit_usd, quantity, value)#
Parameters:
Return type:

None