feat: Add target_price, stop_loss, and strategy to position summary query
This commit is contained in:
parent
0ce4bb4486
commit
6b09c85587
@ -151,7 +151,10 @@ def get_position_summary(ticker: str) -> dict:
|
|||||||
sum(shares * entry_price) / sum(shares) as avg_entry_price,
|
sum(shares * entry_price) / sum(shares) as avg_entry_price,
|
||||||
min(entry_date) as first_entry,
|
min(entry_date) as first_entry,
|
||||||
max(entry_date) as last_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
|
FROM stock_db.trades
|
||||||
WHERE ticker = '{ticker}'
|
WHERE ticker = '{ticker}'
|
||||||
AND exit_price IS NULL
|
AND exit_price IS NULL
|
||||||
@ -160,7 +163,8 @@ def get_position_summary(ticker: str) -> dict:
|
|||||||
"""
|
"""
|
||||||
result = client.query(query).result_rows
|
result = client.query(query).result_rows
|
||||||
columns = ['position_id', 'total_shares', 'avg_entry_price',
|
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]
|
return [dict(zip(columns, row)) for row in result]
|
||||||
|
|
||||||
def get_order_type() -> str:
|
def get_order_type() -> str:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user