From 6b09c85587ed0e67413c72e3496691cb34664a4d Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Mon, 10 Feb 2025 09:47:44 -0800 Subject: [PATCH] feat: Add target_price, stop_loss, and strategy to position summary query --- src/trading/journal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/trading/journal.py b/src/trading/journal.py index 979145b..c20a2f9 100644 --- a/src/trading/journal.py +++ b/src/trading/journal.py @@ -151,7 +151,10 @@ def get_position_summary(ticker: str) -> dict: sum(shares * entry_price) / sum(shares) as avg_entry_price, min(entry_date) as first_entry, max(entry_date) as last_entry, - count() as num_orders + count() as num_orders, + any(target_price) as target_price, + any(stop_loss) as stop_loss, + any(strategy) as strategy FROM stock_db.trades WHERE ticker = '{ticker}' AND exit_price IS NULL @@ -160,7 +163,8 @@ def get_position_summary(ticker: str) -> dict: """ result = client.query(query).result_rows columns = ['position_id', 'total_shares', 'avg_entry_price', - 'first_entry', 'last_entry', 'num_orders'] + 'first_entry', 'last_entry', 'num_orders', + 'target_price', 'stop_loss', 'strategy'] return [dict(zip(columns, row)) for row in result] def get_order_type() -> str: