feat: Add debug logging to get_open_trades function
This commit is contained in:
parent
c4b253cc88
commit
52839b451e
@ -512,13 +512,23 @@ def get_open_trades_summary() -> dict:
|
||||
raise
|
||||
|
||||
def get_open_trades():
|
||||
print("\n=== Fetching Open Trades ===") # Debug
|
||||
with create_client() as client:
|
||||
query = "SELECT * FROM stock_db.trades WHERE exit_price IS NULL ORDER BY entry_date DESC"
|
||||
result = client.query(query).result_rows
|
||||
columns = ['id', 'position_id', 'ticker', 'entry_date', 'shares', 'entry_price', 'target_price',
|
||||
'stop_loss', 'strategy', 'order_type', 'followed_rules', 'entry_reason', 'exit_price',
|
||||
'exit_date', 'exit_reason', 'notes', 'created_at']
|
||||
return [dict(zip(columns, row)) for row in result]
|
||||
print(f"Executing query: {query}") # Debug
|
||||
try:
|
||||
result = client.query(query).result_rows
|
||||
print(f"Query returned {len(result)} rows") # Debug
|
||||
|
||||
columns = ['id', 'position_id', 'ticker', 'entry_date', 'shares', 'entry_price', 'target_price',
|
||||
'stop_loss', 'strategy', 'order_type', 'followed_rules', 'entry_reason', 'exit_price',
|
||||
'exit_date', 'exit_reason', 'notes', 'created_at']
|
||||
trades = [dict(zip(columns, row)) for row in result]
|
||||
print(f"Processed trades: {trades}") # Debug
|
||||
return trades
|
||||
except Exception as e:
|
||||
print(f"Error in get_open_trades: {str(e)}") # Debug
|
||||
raise
|
||||
|
||||
def get_current_prices(tickers: list) -> dict:
|
||||
"""Get current prices for multiple tickers using yfinance"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user