fix: Modify trade linking query to correctly handle ClickHouse IN clause
This commit is contained in:
parent
062be5863f
commit
a2bbd31f27
@ -346,17 +346,14 @@ def link_trades_to_plan(plan_id: int, trade_ids: List[int]) -> bool:
|
||||
"""Link existing trades to a trading plan"""
|
||||
with create_client() as client:
|
||||
try:
|
||||
# Update trades to link them to the plan
|
||||
trade_ids_str = ", ".join(map(str, trade_ids))
|
||||
query = """
|
||||
# Format the trade_ids properly for the IN clause
|
||||
trade_ids_str = ", ".join(str(id) for id in trade_ids)
|
||||
query = f"""
|
||||
ALTER TABLE stock_db.trades
|
||||
UPDATE plan_id = %(plan_id)s
|
||||
WHERE id IN (%(trade_ids)s)
|
||||
UPDATE plan_id = {plan_id}
|
||||
WHERE id IN ({trade_ids_str})
|
||||
"""
|
||||
client.command(query, {
|
||||
'plan_id': plan_id,
|
||||
'trade_ids': trade_ids_str
|
||||
})
|
||||
client.command(query)
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error linking trades to plan: {e}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user