portfolio_toolkit.position.closed.get_closed_positions_stats module

portfolio_toolkit.position.closed.get_closed_positions_stats.get_closed_positions_stats(positions: ClosedPositionList, date: str) Dict[str, Any][source]

Calculates a summary of closed positions with key metrics.

Parameters:
  • positions (List[ClosedPosition]) – List of ClosedPosition objects representing closed positions.

  • date (str) – The date for which the positions are calculated.

Returns:

Dictionary containing summary metrics:
  • date: Reference date

  • total_positions: Total number of positions

  • winning_positions: Number of profitable positions

  • losing_positions: Number of unprofitable positions

  • win_rate: Win rate percentage

  • total_profit: Total profit/loss

  • best_return: Best return percentage

  • best_ticker: Ticker with best performance

  • worst_return: Worst return percentage

  • worst_ticker: Ticker with worst performance

Return type:

Dict[str, Any]

portfolio_toolkit.position.closed.get_closed_positions_stats.print_closed_positions_summary(positions: ClosedPositionList, date: str) None[source]

Prints a summary of closed positions with key metrics only.

This function uses get_closed_positions_summary() and formats the output.

Parameters:
  • positions (List[ClosedPosition]) – List of ClosedPosition objects representing closed positions.

  • date (str) – The date for which the positions are printed.

Returns:

None