Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 532924e218 |
@@ -168,16 +168,13 @@ def _issue_or_reuse_token(creds: KisCredentials) -> str:
|
|||||||
|
|
||||||
# 2. 토큰이 만료되었거나 없을 시 KIS API로 새로 발급 요청
|
# 2. 토큰이 만료되었거나 없을 시 KIS API로 새로 발급 요청
|
||||||
requests = _requests()
|
requests = _requests()
|
||||||
try:
|
resp = requests.post(
|
||||||
resp = requests.post(
|
f"{creds.domain}/oauth2/tokenP",
|
||||||
f"{creds.domain}/oauth2/tokenP",
|
json={"grant_type": "client_credentials", "appkey": creds.app_key, "appsecret": creds.app_secret},
|
||||||
json={"grant_type": "client_credentials", "appkey": creds.app_key, "appsecret": creds.app_secret},
|
timeout=15,
|
||||||
timeout=15,
|
)
|
||||||
)
|
resp.raise_for_status()
|
||||||
resp.raise_for_status()
|
body = resp.json()
|
||||||
body = resp.json()
|
|
||||||
except Exception as exc:
|
|
||||||
raise RuntimeError("KIS token refresh failed; check credentials and API availability.") from exc
|
|
||||||
access_token = body["access_token"]
|
access_token = body["access_token"]
|
||||||
expires_in_sec = int(body.get("expires_in", 86400))
|
expires_in_sec = int(body.get("expires_in", 86400))
|
||||||
expires_at = dt.datetime.now(dt.timezone.utc) + dt.timedelta(seconds=expires_in_sec)
|
expires_at = dt.datetime.now(dt.timezone.utc) + dt.timedelta(seconds=expires_in_sec)
|
||||||
@@ -212,12 +209,9 @@ def _send_request(creds: KisCredentials, path: str, tr_id: str, params: dict[str
|
|||||||
"custtype": "P",
|
"custtype": "P",
|
||||||
}
|
}
|
||||||
requests = _requests()
|
requests = _requests()
|
||||||
try:
|
resp = requests.get(f"{creds.domain}{path}", headers=headers, params=params, timeout=15)
|
||||||
resp = requests.get(f"{creds.domain}{path}", headers=headers, params=params, timeout=15)
|
resp.raise_for_status()
|
||||||
resp.raise_for_status()
|
return resp.json()
|
||||||
return resp.json()
|
|
||||||
except Exception as exc:
|
|
||||||
raise RuntimeError(f"KIS read-only request failed for {path} / {tr_id}.") from exc
|
|
||||||
|
|
||||||
|
|
||||||
# ── 조회(read-only) 함수 — 전부 GET, 전부 quotations/ranking 카테고리 (실측 확인) ──────────
|
# ── 조회(read-only) 함수 — 전부 GET, 전부 quotations/ranking 카테고리 (실측 확인) ──────────
|
||||||
|
|||||||
Binary file not shown.
@@ -1,9 +1,9 @@
|
|||||||
"""KIS-first data collector for the CI scheduler.
|
"""KIS-first data collector for the CI scheduler.
|
||||||
|
|
||||||
The collector treats SQLite as the canonical persistence layer.
|
The collector uses the existing `GatherTradingData.json` snapshot as the seed
|
||||||
`GatherTradingData.json` is emitted only after the DB-backed collection run
|
universe, then enriches Korean tickers with read-only KIS quotations and
|
||||||
finishes, so the JSON acts as a derived reporting artifact rather than the
|
orderbook data, while retaining Naver/Yahoo fallbacks when available.
|
||||||
source of truth.
|
The canonical persistence target is SQLite.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user