수정본
Some checks failed
CI/CD Pipeline / test-backend (push) Has been cancelled
CI/CD Pipeline / test-frontend (push) Has been cancelled
CI/CD Pipeline / build-and-push (push) Has been cancelled

This commit is contained in:
2026-03-27 14:47:49 +09:00
parent 844ee8944f
commit c818810667
25 changed files with 2708 additions and 266 deletions

View File

@@ -455,9 +455,17 @@ async def db_writer_worker() -> None:
record = result.scalar_one_or_none()
if record is None:
record = ActiveTrade(**data)
# remaining_pct_multiply는 신규 생성 시 무시
create_data = {k: v for k, v in data.items() if k != "remaining_pct_multiply"}
record = ActiveTrade(**create_data)
session.add(record)
else:
# remaining_pct_multiply: 기존 remaining_pct에 비율을 곱함
# (MDD 축소 시 기존 분할매도 이력 반영)
multiply_ratio = data.pop("remaining_pct_multiply", None)
if multiply_ratio is not None:
current_remaining = getattr(record, "remaining_pct", 1.0) or 1.0
record.remaining_pct = current_remaining * float(multiply_ratio)
for key, val in data.items():
if key != "stock_code" and val is not None:
setattr(record, key, val)