feat: Add debug logging to open trades functions
This commit is contained in:
parent
dbb1393c08
commit
c4b253cc88
@ -473,6 +473,7 @@ def update_trade(trade_id: int, updates: dict):
|
||||
|
||||
def get_open_trades_summary() -> dict:
|
||||
"""Get summary of all open trades grouped by ticker"""
|
||||
print("\n=== Fetching Open Trades Summary ===") # Debug
|
||||
with create_client() as client:
|
||||
query = """
|
||||
SELECT
|
||||
@ -496,10 +497,19 @@ def get_open_trades_summary() -> dict:
|
||||
HAVING total_shares > 0
|
||||
ORDER BY ticker ASC
|
||||
"""
|
||||
result = client.query(query).result_rows
|
||||
columns = ['ticker', 'total_shares', 'avg_entry_price',
|
||||
'first_entry', 'last_entry', 'num_orders', 'position_ids']
|
||||
return [dict(zip(columns, row)) for row in result]
|
||||
print(f"Executing summary query: {query}") # Debug
|
||||
try:
|
||||
result = client.query(query).result_rows
|
||||
print(f"Summary query returned {len(result)} rows") # Debug
|
||||
|
||||
columns = ['ticker', 'total_shares', 'avg_entry_price',
|
||||
'first_entry', 'last_entry', 'num_orders', 'position_ids']
|
||||
summaries = [dict(zip(columns, row)) for row in result]
|
||||
print(f"Processed summaries: {summaries}") # Debug
|
||||
return summaries
|
||||
except Exception as e:
|
||||
print(f"Error in get_open_trades_summary: {str(e)}") # Debug
|
||||
raise
|
||||
|
||||
def get_open_trades():
|
||||
with create_client() as client:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user