alpheast.portfolio.portfolio_manager module

class alpheast.portfolio.portfolio_manager.PortfolioManager(event_queue, symbols=[], initial_cash=100000.0, transaction_cost_percent=Decimal('0.001'), slippage_percent=Decimal('0.0005'), position_sizing_method=None)[source]

Bases: object

Manages the portfolio’s cash and holdings, processes signals from strategies, and generates orders for the execution handler. It also processes fills to update the actual portfolio state.

on_market_event(event)[source]

Processes a MarketEvent. Updates the latest market prices cache and records the portfolio’s daily value if a new day has started.

on_signal_event(event)[source]

Processes a SignalEvent from the strategy. Decides whether to place an order by generating an OrderEvent.

on_fill_event(event)[source]

Processes a FillEvent from the execution handler. Updates the actual cash and holdings of the portfolio.

on_daily_update_event(event)[source]

Processes a DailyUpdateEvent, triggering daily portfolio value calculations for both the strategy and the benchmark by calling helper functions.

reset()[source]

Resets the portfolio manager’s state for a new backtest run. This clears all holdings, cash, and market price memory.

get_daily_values()[source]
Return type:

List[Dict[str, Any]]

get_benchmark_daily_values()[source]

Returns the benchmark’s daily portfolio value history.

Return type:

List[Dict[str, Any]]

get_trade_log()[source]
Return type:

List[Dict[str, Any]]

get_summary()[source]

Returns a summary of the final portfolio state. This correctly calls the portfolio_account’s summary.

Return type:

Dict[str, Any]