diff --git a/thetagang/portfolio_manager.py b/thetagang/portfolio_manager.py index d94cafb7f..faa0eeff9 100644 --- a/thetagang/portfolio_manager.py +++ b/thetagang/portfolio_manager.py @@ -218,7 +218,13 @@ def summarize_account(self): click.echo() for symbol in portfolio_positions.keys(): click.secho(f" {symbol}:", fg="cyan") - for p in portfolio_positions[symbol]: + sorted_positions = sorted( + portfolio_positions[symbol], + key=lambda p: option_dte(p.contract.lastTradeDateOrContractMonth) + if isinstance(p.contract, Option) + else 0, + ) + for p in sorted_positions: if isinstance(p.contract, Stock): pnl = round(position_pnl(p) * 100, 2) click.secho(