statistics#

tradeexecutor.state.statistics module.

Module description#

Various statistics calculated across portfolios and positions.

Statistics are calculated/refreshed on the server-side and exported as a part of the state. This way the clients (JavaScript) do not need to reconstruct this information.

Any statistics are optional: they are not needed to make any state transitions, they are purely there for profit and loss calculations.

Classes#

FinalPositionStatistics

When position is closed, its final statistics are calculated.

PortfolioStatistics

PortfolioStatistics(calculated_at: datetime.datetime, total_equity: tradingstrategy.types.USDollarAmount, free_cash: tradingstrategy.types.USDollarAmount, open_position_count: int, open_position_equity: tradingstrategy.types.USDollarAmount, frozen_position_count: int, frozen_position_equity: tradingstrategy.types.USDollarAmount, closed_position_count: int, unrealised_profit_usd: tradingstrategy.types.USDollarAmount, first_trade_at: datetime.datetime, last_trade_at: datetime.datetime, realised_profit_usd: tradingstrategy.types.USDollarAmount = 0)

PositionStatistics

PositionStatistics(calculated_at: datetime.datetime, last_valuation_at: datetime.datetime, profitability: float, profit_usd: tradingstrategy.types.USDollarAmount, quantity: float, value: tradingstrategy.types.USDollarAmount)

Statistics

Statistics for a trade execution state.