PortfolioSnapshot#

tradingstrategy.analysis.portfolioanalyzer.PortfolioSnapshot class.

class PortfolioSnapshot[source]#

Bases: object

Represents the portfolio status at the start of the day/candle snapshot

__init__(tick, cash_balances, asset_snapshots, state_details=None)#
Parameters
Return type

None

Methods

__init__(tick, cash_balances, asset_snapshots)

get_ordered_assets_by_weight()

Return asset snapshots in an order where the heaviest asset is first.

get_ordered_assets_stable()

Return asset snapshots in a stable order between days.

Attributes

state_details

Internal state dump of the algorithm when this trade was made.

tick

A running counter where the first backtest simulated event is tick 1, the next one tick 2

cash_balances

What reserve currencies we have.

asset_snapshots

What reserve currencies we have.

tick: int#

A running counter where the first backtest simulated event is tick 1, the next one tick 2

cash_balances: Dict[str, float]#

What reserve currencies we have. E.g. USD: 10_000 Resever currenecies expressed as strings for the backwards compatibiltiy.

asset_snapshots: Dict[PrimaryKey, AssetSnapshot]#

What reserve currencies we have. E.g. USD: 10_000 Resever currenecies expressed as strings for the backwards compatibiltiy.

state_details: Optional[Dict] = None#

Internal state dump of the algorithm when this trade was made. This is mostly useful when doing the trade analysis try to understand why some trades were made. It also allows you to reconstruct the portfolio state over the time.

get_ordered_assets_stable()[source]#

Return asset snapshots in a stable order between days.

Return type

List[Tuple[PrimaryKey, AssetSnapshot]]

get_ordered_assets_by_weight()[source]#

Return asset snapshots in an order where the heaviest asset is first.

Return type

List[Tuple[PrimaryKey, AssetSnapshot]]

__init__(tick, cash_balances, asset_snapshots, state_details=None)#
Parameters
Return type

None