Skip to content

Commit

Permalink
Sort positions by DTE before printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Feb 8, 2021
1 parent 6eaacd0 commit 61ce684
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion thetagang/portfolio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 61ce684

Please sign in to comment.