Code#

BackTester#

class Portfolio#

Bases: pybind11_object

Capital-constrained portfolio simulator.

A portfolio selects executable positions, records the equity path, and provides performance metrics after simulate has completed.

property debug_mode#

Enable or disable debug output for development purposes.

display(self: TradeTide.portfolio.Portfolio) → None#

Total time elapsed in the simulation, as a timedelta.

get_metrics(self: TradeTide.portfolio.Portfolio) → TradeTide.portfolio.Metrics#

Access the Metrics object containing performance metrics.

get_positions(self: TradeTide.portfolio.Portfolio, count: SupportsInt | SupportsIndex = 18446744073709551615) → list[TradeTide.position.BasePosition]#

Get the list of activated positions up to an optional maximum.

Parameters:

count (int, optional) – Maximum number of positions to return (default = all)

Returns:

Positions selected by the portfolio during simulation.

Return type:

List[BasePosition]

property market#

Access the Market object backing the portfolio.

property record#

Access the Record object containing historical state data.

simulate(self: TradeTide.portfolio.Portfolio, capital_management: TradeTide.capital_management.BaseCapitalManagement) → None#

Run the full simulation, opening/closing trades according to constraints.

property state#

Access the current state of the portfolio, including equity and position count.