수정본
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user