PortfolioStatistics#

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

class PortfolioStatistics[source]#

Bases: object

Portfolio statistics for each timepoint.

Updated with regular ticks for a live strategy.

If backtesting, only calculated_at and total_equity are necessary for later visualisations and metrics If livetrading, then all attributes should be specified so that for displaying updated metrics after each trade

See Statistics.portfolio for reading.

__init__(calculated_at, total_equity, net_asset_value=None, unrealised_profitability=None, free_cash=None, open_position_count=None, open_position_equity=None, frozen_position_count=None, frozen_position_equity=None, closed_position_count=None, unrealised_profit_usd=None, first_trade_at=None, last_trade_at=None, realised_profit_usd=0, summary=None)#
Parameters:
Return type:

None

Methods

__init__(calculated_at, total_equity[, ...])

from_dict(kvs, *[, infer_missing])

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

get_value()

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

to_dict([encode_json])

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

Attributes

closed_position_count

first_trade_at

free_cash

frozen_position_count

frozen_position_equity

last_trade_at

net_asset_value

How much was TVL equivalent

open_position_count

open_position_equity

realised_profit_usd

summary

unrealised_profit_usd

unrealised_profitability

The unrealised all-time profitability of this strategy at this point of time

calculated_at

Real-time clock when these stats were calculated

total_equity

calculated_at: datetime#

Real-time clock when these stats were calculated

net_asset_value: Optional[float] = None#

How much was TVL equivalent

unrealised_profitability: Optional[float] = None#

The unrealised all-time profitability of this strategy at this point of time

See tradeexecutor.visualisation.equity_curve.calculate_compounding_unrealised_trading_profitability()

Set to 0 if cannot be calculated yet.

__init__(calculated_at, total_equity, net_asset_value=None, unrealised_profitability=None, free_cash=None, open_position_count=None, open_position_equity=None, frozen_position_count=None, frozen_position_equity=None, closed_position_count=None, unrealised_profit_usd=None, first_trade_at=None, last_trade_at=None, realised_profit_usd=0, summary=None)#
Parameters:
Return type:

None