소스리뷰 버전 적용
This commit is contained in:
@@ -1030,6 +1030,55 @@ class KoreaInvestmentAPI:
|
||||
"odno": None
|
||||
}
|
||||
|
||||
async def get_order_execution(self, order_id: str, is_domestic: bool = True) -> Dict[str, Any]:
|
||||
"""주문 체결 내역 단건 조회.
|
||||
|
||||
국내: TTTC8001R (실전) / VTTC8001R (모의)
|
||||
Returns:
|
||||
{"filled_qty": int, "filled_price": float}
|
||||
체결 미확인 시 filled_qty=0 반환.
|
||||
"""
|
||||
try:
|
||||
account_number_prefix = self.account_number[:8]
|
||||
account_number_suffix = self.account_number[8:]
|
||||
is_virtual = "vts" in self.base_url.lower()
|
||||
today = datetime.now().strftime("%Y%m%d")
|
||||
|
||||
if is_domestic:
|
||||
tr_id = "VTTC8001R" if is_virtual else "TTTC8001R"
|
||||
result, _ = await self._make_request(
|
||||
"GET",
|
||||
"/uapi/domestic-stock/v1/trading/inquire-ccnl",
|
||||
tr_id,
|
||||
params={
|
||||
"CANO": account_number_prefix,
|
||||
"ACNT_PRDT_CD": account_number_suffix,
|
||||
"INQR_STRT_DT": today,
|
||||
"INQR_END_DT": today,
|
||||
"SLL_BUY_DVSN_CD": "00",
|
||||
"INQR_DVSN": "00",
|
||||
"PDNO": "",
|
||||
"CCLD_DVSN": "00",
|
||||
"ORD_GNO_BRNO": "",
|
||||
"ODNO": order_id,
|
||||
"INQR_DVSN_3": "00",
|
||||
"INQR_DVSN_1": "",
|
||||
"CTX_AREA_FK100": "",
|
||||
"CTX_AREA_NK100": "",
|
||||
},
|
||||
)
|
||||
output = result.get("output1", [])
|
||||
if output:
|
||||
row = output[0] if isinstance(output, list) else output
|
||||
filled_qty = int(row.get("tot_ccld_qty", 0) or 0)
|
||||
filled_price = float(row.get("avg_prvs", 0) or 0)
|
||||
return {"filled_qty": filled_qty, "filled_price": filled_price}
|
||||
# 해외 체결 조회는 별도 TR_ID 필요 — 현재 미지원 (포트폴리오 동기화로 대체)
|
||||
return {"filled_qty": 0, "filled_price": 0.0}
|
||||
except Exception as e:
|
||||
logger.debug(f"[get_order_execution] order_id={order_id} 조회 오류: {e}")
|
||||
return {"filled_qty": 0, "filled_price": 0.0}
|
||||
|
||||
async def cancel_order(self, order_id: str, quantity: int) -> Dict[str, Any]:
|
||||
"""주문 취소"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user