refactor: Update trade history query to explicitly list columns
This commit is contained in:
parent
e322743f33
commit
646d4b847f
@ -536,7 +536,10 @@ def get_trade_history(limit: int = 50):
|
|||||||
with create_client() as client:
|
with create_client() as client:
|
||||||
query = f"""
|
query = f"""
|
||||||
SELECT
|
SELECT
|
||||||
*,
|
id, position_id, ticker, entry_date, shares, entry_price,
|
||||||
|
target_price, stop_loss, strategy, order_type, direction,
|
||||||
|
followed_rules, entry_reason, exit_price, exit_date,
|
||||||
|
exit_reason, notes, created_at,
|
||||||
groupArray(ticker) OVER (PARTITION BY position_id) as related_tickers,
|
groupArray(ticker) OVER (PARTITION BY position_id) as related_tickers,
|
||||||
groupArray(id) OVER (PARTITION BY position_id) as related_ids
|
groupArray(id) OVER (PARTITION BY position_id) as related_ids
|
||||||
FROM stock_db.trades
|
FROM stock_db.trades
|
||||||
@ -544,9 +547,11 @@ def get_trade_history(limit: int = 50):
|
|||||||
LIMIT {limit}
|
LIMIT {limit}
|
||||||
"""
|
"""
|
||||||
result = client.query(query).result_rows
|
result = client.query(query).result_rows
|
||||||
columns = ['id', 'position_id', 'ticker', 'entry_date', 'shares', 'entry_price', 'target_price',
|
columns = ['id', 'position_id', 'ticker', 'entry_date', 'shares',
|
||||||
'stop_loss', 'strategy', 'order_type', 'followed_rules', 'entry_reason', 'exit_price',
|
'entry_price', 'target_price', 'stop_loss', 'strategy',
|
||||||
'exit_date', 'exit_reason', 'notes', 'created_at', 'direction', 'related_tickers', 'related_ids']
|
'order_type', 'direction', 'followed_rules', 'entry_reason',
|
||||||
|
'exit_price', 'exit_date', 'exit_reason', 'notes',
|
||||||
|
'created_at', 'related_tickers', 'related_ids']
|
||||||
return [dict(zip(columns, row)) for row in result]
|
return [dict(zip(columns, row)) for row in result]
|
||||||
|
|
||||||
def journal_menu():
|
def journal_menu():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user