일단 커밋

This commit is contained in:
2026-09-09 00:47:34 +09:00
parent 3008f8e0bf
commit a190a40bde
40 changed files with 181 additions and 36 deletions
+48 -16
View File
@@ -57,6 +57,36 @@ class TradingService:
if not self._check_auth():
return {"rt_cd": "-1", "msg": "API 인증되지 않음", "order_no": ""}
if qty <= 0:
return {"rt_cd": "-1", "msg": "주문 수량은 0보다 커야 합니다", "order_no": ""}
if side not in ("buy", "sell"):
return {"rt_cd": "-1", "msg": "유효하지 않은 주문 방향입니다", "order_no": ""}
if order_type == "00" and price <= 0:
return {"rt_cd": "-1", "msg": "지정가 주문의 가격은 0보다 커야 합니다", "order_no": ""}
order_amount = qty * price
if price > 0:
if order_amount < settings.trading.min_order_amount:
return {
"rt_cd": "-1",
"msg": (
f"최소 주문 금액 미달: {order_amount:,}원 "
f"< {settings.trading.min_order_amount:,}원"
),
"order_no": "",
}
if order_amount > settings.trading.max_order_amount:
return {
"rt_cd": "-1",
"msg": (
f"최대 주문 금액 초과: {order_amount:,}원 "
f"> {settings.trading.max_order_amount:,}원"
),
"order_no": "",
}
await self._rate_limiter.acquire()
tr_id = self._get_tr_id(side)
@@ -237,22 +267,24 @@ class TradingService:
else:
side = "buy" if side_code == "01" else "sell"
trades.append({
"order_no": item.get("ord_gno_brno", ""),
"stock_code": item.get("pdno", ""),
"stock_name": item.get("prdt_name", ""),
"side": side,
"qty": qty,
"price": int(float(item.get("ft_ccld_unpr3", 0))),
"order_type": item.get("ord_dvsn", "00"),
"status": "filled",
"order_amount": float(item.get("ft_ord_amt", 0)),
"settlement_amount": float(item.get("ft_ccld_amt", 0)),
"tax": float(item.get("sttl_evlu_amt", 0)),
"commission": float(item.get("ft_lof_ruse_amt", 0)),
"created_at": item.get("ord_sttm", ""),
"filled_at": item.get("ft_ccld_no", ""),
})
trades.append(
{
"order_no": item.get("ord_gno_brno", ""),
"stock_code": item.get("pdno", ""),
"stock_name": item.get("prdt_name", ""),
"side": side,
"qty": qty,
"price": int(float(item.get("ft_ccld_unpr3", 0))),
"order_type": item.get("ord_dvsn", "00"),
"status": "filled",
"order_amount": float(item.get("ft_ord_amt", 0)),
"settlement_amount": float(item.get("ft_ccld_amt", 0)),
"tax": float(item.get("sttl_evlu_amt", 0)),
"commission": float(item.get("ft_lof_ruse_amt", 0)),
"created_at": item.get("ord_sttm", ""),
"filled_at": item.get("ft_ccld_no", ""),
}
)
logger.info("일일 체결 내역 조회: %d건", len(trades))
return trades