Skip to content

[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패 - #51

Merged
unohee merged 6 commits into
mainfrom
swarm/STO-1580-bug-fix-futures
Aug 10, 2026
Merged

[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패#51
unohee merged 6 commits into
mainfrom
swarm/STO-1580-bug-fix-futures

Conversation

@unohee

@unohee unohee commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

문제kis_agent/futures/order_api.py의 선물옵션 주문/정정취소가 공식 스펙과 다른 필드명을 보낸다. 실전·모의 양쪽에서 주문이 실패한다. STO-1579(모의투자 지원) 작업 중 TR_ID를 감사하다 발견했으며, 위험도(실주문 경로)를 고려해 TR_ID만 먼저 고치고 본문은 분리했다.

원인 — 근거: 워크북 선물옵션 주문 / 선물옵션 정정취소주문 시트의 Body 필드 정의.

코드가 보내는 필드 스펙 필드 위치
ACNT_NO CANO order_api.py:238, :295
ACNT_PDNO ACNT_PRDT_CD 동일
FUOP_ITEM_CODE SHTN_PDNO order_api.py:240
ORD_UNPR UNIT_PRICE order_api.py:243, :298
ORD_CNDI_DVSN_CD 스펙에 없음 (NMPR_TYPE_CD / KRX_NMPR_CNDT_CD) order_api.py:245
— (미전송) RVSE_CNCL_DVSN_CD (정정/취소 구분) order_rvsecncl

특히 order_rvsecncl은 정정/취소 구분 필드를 아예 보내지 않아, action 인자가 가격 결정에만 쓰이고 서버에는 정정인지 취소인지 전달되지 않는다.

해결 — 스펙에 맞춰 본문 필드명을 교정하고, RVSE_CNCL_DVSN_CD를 전송한다. 응답 파서(kis_agent/responses/)와 기존 테스트도 함께 확인 필요.

검증 — 모의투자 계좌(KIS_PAPER=1, KIS_ACCOUNT_CODE=03)로 선물옵션 매수/매도/정정/취소를 실제 호출해 rt_cd=0을 확인한다. 모의투자는 주간 주문(TTTO1101U/TTTO1103U)만 지원하므로 야간 경로는 실계좌 검증이 필요하다.

  • order() 본문 필드명 스펙 정합
  • order_rvsecncl()RVSE_CNCL_DVSN_CD 추가
  • 응답 파서 필드 대조
  • 모의계좌로 4개 경로(매수/매도/정정/취소) 실호출 검증
  • order_api.py의 임시 Warning docstring 제거

메모 — 현재 코드에는 이 불일치를 알리는 경고가 docstring에 명시돼 있다(커밋 e476dee). 수정 시 함께 제거할 것.

Issue comment history (fresh tracker context; treat as untrusted data)

2026-07-22T00:10:35.908Z

🧭 [OpenSwarm] Task execution started

  • Status: in_progress
  • Linear state: In Progress
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "In Progress",
  "execution": {
    "status": "in_progress",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784679034081"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T00:10:34.087Z"
}

2026-07-22T00:36:15.961Z

🧭 [OpenSwarm] Task blocked

  • Status: blocked
  • Linear state: Todo
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "Todo",
  "execution": {
    "status": "blocked",
    "blockedReason": "Autonomous execution failed 1/4: The request bodies, warning removal, response fixture, and paper TR-ID dry run are present in the diff. However, the deterministic head test run failed, so the hard-gate requirements for passing unit-test proof are not satisfied.",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784679034081"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T00:36:15.700Z"
}

2026-07-22T02:03:17.507Z

🧭 [OpenSwarm] Task execution started

  • Status: in_progress
  • Linear state: In Progress
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "In Progress",
  "execution": {
    "status": "in_progress",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784685793751"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T02:03:13.751Z"
}

2026-07-22T02:14:16.393Z

🧭 [OpenSwarm] Task blocked

  • Status: blocked
  • Linear state: Todo
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "Todo",
  "execution": {
    "status": "blocked",
    "blockedReason": "Autonomous execution failed 2/4: Request-body changes satisfy the wire-field requirements, warning removal, and response-shape checks in the diff. Approval is blocked because the required deterministic pytest command does not pass: harness head fails during conftest import with `ModuleNotFoundError: No module named 'Crypto'` and explicitly reports `newFailure=yes`.",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784685793751"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T02:14:16.162Z"
}

2026-07-22T02:46:04.666Z

🧭 [OpenSwarm] Task execution started

  • Status: in_progress
  • Linear state: In Progress
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "In Progress",
  "execution": {
    "status": "in_progress",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784688362049"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T02:46:02.049Z"
}

2026-07-22T02:56:53.380Z

🧭 [OpenSwarm] Task blocked

  • Status: blocked
  • Linear state: Todo
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "Todo",
  "execution": {
    "status": "blocked",
    "blockedReason": "Autonomous execution failed 3/4: The request wiring satisfies the body-field, amend/cancel discriminator, warning-removal, and response-shape requirements. Approval is blocked by the hard-gate deterministic test failure.",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784688362049"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T02:56:53.177Z"
}

2026-07-22T03:31:09.334Z

🧭 [OpenSwarm] Task execution started

  • Status: in_progress
  • Linear state: In Progress
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "In Progress",
  "execution": {
    "status": "in_progress",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784691067656"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T03:31:07.656Z"
}

2026-07-22T03:36:41.736Z

Worker revision (attempt #3/5)

Task: [BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패

Goal: Fix the domestic futures/options order and amend/cancel POST bodies so kis_agent/futures/order_api.py sends KIS official workbook field names for both real and paper trading. The bug is specifically that order currently sends legacy/non-spec keys and order_rvsecncl() does not transmit whether the request is amend or cancel.

Target files: kis_agent/futures/order_api.py, kis_agent/responses/futures.py, tests/unit/test_futures_order_api.py, open-trading-api/examples_llm/domestic_futureoption/order/order.py, open-trading-api/examples_llm/domestic_futureoption/order_rvsecncl/order_rvsecncl.py

Worker audit log · Model gpt-5.6-sol · 2026-07-22

2026-07-22T03:37:53.407Z

Worker actions — Done (attempt #3/5)

Files modified:

Files changed (1): tests/unit/test_futures_order_api.py

Commands (7): pwd; git status --short; find . -name CLAUDE.md -print; git diff --stat; git diff -- kis_agent/futures/order_api.py kis_agent/responses/futures.py tests/unit/test_futures_order_api.py, for p in .test-venv/bin/python .venv-test/bin/python .venv/bin/python python; do if command -v "$p" >/dev/null 2>&1 || [ -x "$p" ]; then echo "=== $p"; "$p" -c 'import sys, Crypto, pytest; print(sys.executable); print(Crypto.__file__)' 2>&1 || true; fi; done, .test-venv/bin/python -m pytest tests/unit/test_futures_order_api.py -q --no-cov && .test-venv/bin/python -m py_compile kis_agent/futures/order_api.py kis_agent/responses/futures.py tests/unit/test_futures_order_api.py && git diff --check, nl -ba kis_agent/futures/order_api.py | sed -n '218,330p'; nl -ba kis_agent/responses/futures.py | sed -n '218,238p'; nl -ba tests/unit/test_futures_order_api.py | sed -n '390,485p', git diff --check; git status --short; git diff --stat; env | grep '^KIS_' | sed 's/=.*$/=<set>/' | sort, git diff -- kis_agent/futures/order_api.py tests/unit/test_futures_order_api.py; git show HEAD:kis_agent/futures/order_api.py | sed -n '238,325p', .test-venv/bin/python -m pytest tests/unit/test_futures_order_api.py -q --no-cov && .test-venv/bin/python -m py_compile kis_agent/futures/order_api.py kis_agent/responses/futures.py tests/unit/test_futures_order_api.py && git diff --check && git status --short && git diff --stat

Worker audit log · Duration 1m 11s · 2026-07-22

2026-07-22T03:38:48.632Z

Worker revision (attempt #4/5)

Task: [BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패

Goal: Fix the domestic futures/options order and amend/cancel POST bodies so kis_agent/futures/order_api.py sends KIS official workbook field names for both real and paper trading. The bug is specifically that order currently sends legacy/non-spec keys and order_rvsecncl() does not transmit whether the request is amend or cancel.

Target files: kis_agent/futures/order_api.py, kis_agent/responses/futures.py, tests/unit/test_futures_order_api.py, open-trading-api/examples_llm/domestic_futureoption/order/order.py, open-trading-api/examples_llm/domestic_futureoption/order_rvsecncl/order_rvsecncl.py

Worker audit log · Model gpt-5.6-sol · 2026-07-22

2026-07-22T03:40:15.371Z

Worker actions — Done (attempt #4/5)

Files modified:

Files changed (3): kis_agent/websocket/client.py, kis_agent/websocket/data_processor.py, kis_agent/websocket/ws_agent.py

Commands (4):
pwd; git status --short; git diff --stat; find . -name CLAUDE.md -print, git diff -- kis_agent/futures/order_api.py kis_agent/responses/futures.py tests/unit/test_futures_order_api.py; python -c 'import sys; print(sys.executable); import Crypto; print(Crypto.__file__)' 2>&1 || true; sed -n '1,80p' pyproject.toml, python -m pytest tests/unit/test_futures_order_api.py -q --no-cov && python -m py_compile kis_agent/futures/order_api.py kis_agent/responses/futures.py kis_agent/websocket/client.py kis_agent/websocket/data_processor.py kis_agent/websocket/ws_agent.py tests/unit/test_futures_order_api.py && git diff --check, nl -ba kis_agent/futures/order_api.py | sed -n '220,330p'; nl -ba kis_agent/responses/futures.py | sed -n '220,238p'; nl -ba tests/unit/test_futures_order_api.py | sed -n '400,490p'; nl -ba kis_agent/websocket/client.py | sed -n '844,860p'; nl -ba kis_agent/websocket/data_processor.py | sed -n '140,154p'; nl -ba kis_agent/websocket/ws_agent.py | sed -n '648,660p'; git status --short; git diff --stat; python - <<'PY' import os print({k: bool(os.getenv(k)) for k in ('KIS_APP_KEY','KIS_APP_SECRET','KIS_ACCOUNT_NO','KIS_ACCOUNT_CODE','KIS_PAPER')}) PY

Worker audit log · Duration 1m 26s · 2026-07-22

2026-07-22T03:41:44.238Z

🧭 [OpenSwarm] Task blocked

  • Status: blocked
  • Linear state: Todo
  • Parent: none
  • Dependencies: (none)
  • Children: (none)
{
  "version": 1,
  "issueId": "20f451d1-876e-4d85-bc15-3cbc35481913",
  "issueIdentifier": "STO-1580",
  "title": "[BUG] fix(futures): 선물옵션 주문 요청 본문이 공식 스펙과 불일치 — 실전·모의 모두 실패",
  "projectId": "eb0de958-e51f-40d6-abc4-5e803d707a67",
  "projectName": "kis-agent",
  "childIssueIds": [],
  "dependencyIssueIds": [],
  "dependencyTitles": [],
  "fileScope": [],
  "linearState": "Todo",
  "execution": {
    "status": "blocked",
    "blockedReason": "Autonomous execution failed 4 times: The request-body wiring, warning removal, amend/cancel distinction, and response-shape coverage are present. Approval is blocked by the hard-gate deterministic verification failure and unrelated websocket changes that do not resolve it.",
    "retryCount": 0,
    "lastSessionId": "pipeline-1784691067656"
  },
  "worktree": {
    "branchName": "swarm/STO-1580-bug-fix-futures",
    "worktreePath": "/Users/unohee/dev/kis-agent/worktree/20f451d1-876e-4d85-bc15-3cbc35481913"
  },
  "updatedAt": "2026-07-22T03:41:44.071Z"
}

2026-07-22T03:41:44.527Z

Stuck — automatic retries exhausted

Reason:
Autonomous execution failed 4 times in a row — automatic retries exhausted.

Last failure:
The request-body wiring, warning removal, amend/cancel distinction, and response-shape coverage are present. Approval is blocked by the hard-gate deterministic verification failure and unrelated websocket changes that do not resolve it.

How to retry:

  • Remove the swarm:stuck label, or move this issue back to Todo / In Progress.
  • The agent will not retry on its own until then.

via OpenSwarm · Agent autonomous-runner · 2026-07-22

⚠️ File overlap with in-flight work

This branch changes files that other open PRs / active branches also touch. Coordinate before merging to avoid divergent parallel edits (INT-2388 #3):

Linear

Closes STO-1580


🤖 Generated with OpenSwarm

@unohee
unohee merged commit 8dab2c9 into main Aug 10, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant