매도 히스토리 수정 API 추가 (PUT /api/portfolio/sell-history/:id)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -242,6 +242,19 @@ def get_sell_history(broker: str = None, days: int = None) -> List[Dict[str, Any
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
|
||||
def update_sell_history(record_id: int, data: Dict[str, Any]) -> Dict[str, Any] | None:
|
||||
fields = ["broker", "ticker", "name", "quantity", "avg_price", "sell_price",
|
||||
"buy_amount", "sell_amount", "realized_profit", "realized_rate", "sold_at"]
|
||||
set_clause = ", ".join(f"{f} = ?" for f in fields)
|
||||
values = [data[f] for f in fields] + [record_id]
|
||||
with _conn() as conn:
|
||||
cur = conn.execute(f"UPDATE sell_history SET {set_clause} WHERE id = ?", values)
|
||||
if cur.rowcount == 0:
|
||||
return None
|
||||
row = conn.execute("SELECT * FROM sell_history WHERE id = ?", (record_id,)).fetchone()
|
||||
return dict(row)
|
||||
|
||||
|
||||
def delete_sell_history(record_id: int) -> bool:
|
||||
with _conn() as conn:
|
||||
cur = conn.execute("DELETE FROM sell_history WHERE id = ?", (record_id,))
|
||||
|
||||
Reference in New Issue
Block a user