fix: reconcile KIS exchange rejections
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""KIS poll_fill external-cancel detection (dcy-013 / REQ-012, issue #9).
|
||||
"""KIS poll_fill terminal-order detection (dcy-013 / REQ-012, issue #9).
|
||||
|
||||
inquire-daily-ccld marks a cancelled order with cncl_yn="Y". These tests stub
|
||||
the HTTP layer (token pre-seeded, httpx.get faked) and assert the FillStatus
|
||||
mapping for full cancel / partial-fill-then-cancel / not-cancelled.
|
||||
inquire-daily-ccld marks a cancelled order with cncl_yn="Y" and an
|
||||
exchange-rejected order with rjct_qty. These tests stub the HTTP layer (token
|
||||
pre-seeded, httpx.get faked) and assert the FillStatus mapping.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -49,6 +49,7 @@ def _row(**kw):
|
||||
"tot_ccld_qty": "0",
|
||||
"avg_prvs": "0",
|
||||
"cncl_yn": "N",
|
||||
"rjct_qty": "0",
|
||||
"ord_dt": "20260608",
|
||||
"ord_gno_brno": "06010",
|
||||
}
|
||||
@@ -68,6 +69,34 @@ def test_zero_fill_not_cancelled_stays_accepted(monkeypatch):
|
||||
assert fs.state == "accepted" and not fs.is_terminal_reject
|
||||
|
||||
|
||||
def test_zero_fill_full_rejection_maps_to_rejected(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
kis_mod.httpx,
|
||||
"get",
|
||||
_fake_get(
|
||||
_row(
|
||||
ord_qty="4",
|
||||
tot_ccld_qty="0",
|
||||
rmn_qty="0",
|
||||
rjct_qty="4",
|
||||
cncl_yn="",
|
||||
)
|
||||
),
|
||||
)
|
||||
fs = _broker().poll_fill(f"06010:{ODNO}", side="buy", symbol="005930")
|
||||
assert fs.state == "rejected" and fs.is_terminal_reject
|
||||
|
||||
|
||||
def test_zero_fill_partial_rejection_does_not_infer_terminal(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
kis_mod.httpx,
|
||||
"get",
|
||||
_fake_get(_row(ord_qty="10", tot_ccld_qty="0", rjct_qty="4", cncl_yn="")),
|
||||
)
|
||||
fs = _broker().poll_fill(f"06010:{ODNO}", side="buy", symbol="005930")
|
||||
assert fs.state == "accepted" and not fs.is_terminal_reject
|
||||
|
||||
|
||||
def test_partial_fill_then_cancel_flags_partial_cancel(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
kis_mod.httpx,
|
||||
|
||||
Reference in New Issue
Block a user