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:
|
def get_open_trades_summary() -> dict:
|
||||||
"""Get summary of all open trades grouped by ticker"""
|
"""Get summary of all open trades grouped by ticker"""
|
||||||
|
print("\n=== Fetching Open Trades Summary ===") # Debug
|
||||||
with create_client() as client:
|
with create_client() as client:
|
||||||
query = """
|
query = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -496,10 +497,19 @@ def get_open_trades_summary() -> dict:
|
|||||||
HAVING total_shares > 0
|
HAVING total_shares > 0
|
||||||
ORDER BY ticker ASC
|
ORDER BY ticker ASC
|
||||||
"""
|
"""
|
||||||
result = client.query(query).result_rows
|
print(f"Executing summary query: {query}") # Debug
|
||||||
columns = ['ticker', 'total_shares', 'avg_entry_price',
|
try:
|
||||||
'first_entry', 'last_entry', 'num_orders', 'position_ids']
|
result = client.query(query).result_rows
|
||||||
return [dict(zip(columns, row)) for row in result]
|
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():
|
def get_open_trades():
|
||||||
with create_client() as client:
|
with create_client() as client:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user