Native Python access to KIS-NET YTM Matrix data.
Project description
kisnet-ytm
kisnet-ytm provides typed, synchronous Python access to the KIS-NET YTM
Matrix. It requires Python 3.11 or newer and never invokes Node.js or drives a
browser.
After publication:
python -m pip install kisnet-ytm
Matrix lookup
from datetime import date
from kisnet_ytm import fetch_matrix
matrix = fetch_matrix(date(2026, 6, 8), "국채")
print(matrix.base_date)
print(matrix.rows[0].yields["10Y"])
Exact-date lookup is the default. Pass previous_available_days=N only when a
caller explicitly wants the requested date followed by at most N earlier
calendar dates. N must be between 0 and 31:
matrix = fetch_matrix(
date(2026, 6, 7),
"국채",
previous_available_days=10,
)
print(matrix.requested_date)
print(matrix.date_resolution.attempted_dates)
print(matrix.date_resolution.used_previous_available)
Fallback continues only when KIS-NET confirms that matrix data is unavailable. Transport, nonzero Nexacro protocol statuses, and source-format errors stop immediately.
Kinds and results
from datetime import date
from kisnet_ytm import list_kinds
known_kinds = list_kinds() # static known source values
current_kinds = list_kinds(date.today()) # refresh from KIS-NET
fetch_matrix returns a frozen Pydantic Matrix containing Kind,
DateResolution, and MatrixRow models. Dates are datetime.date values and
yields are Decimal | None. Source - and empty yield cells become None in
yields and remain available in yield_text; every row also retains its raw
source columns.
Kinds and tenors are source-compatible strings so KIS-NET can add values without requiring a package interface change.
Errors and logging
All public package errors inherit YtmError:
InvalidInputError: invalid date, kind, or fallback windowDataUnavailableError: no data for every attempted date; exposesrequested_dateandattempted_datesSourceTransportError: request or HTTP failureSourceProtocolError: nonzero NexacroErrorCode; exposes the sourceerror_codeanderror_messageSourceFormatError: malformed XML, missing required columns, or invalid data
The package uses standard-library logging under kisnet_ytm and installs no
handlers. It logs request decisions and metadata, never raw response bodies.
Development
From the repository root:
uv sync --locked --project packages/python
bun run validate:python
bun run test:python
bun run build:python
The regular suite does not use the network. To exercise the public API against the live KIS-NET service, run:
bun run test:python:live
Live tests default to today's date, 국채, and a 10-calendar-day fallback. Run
pytest directly with --live-base-date, --live-kind, or --live-lookback to
override those values. The live suite also samples three generated combinations
across recent dates and known kinds; it disables Hypothesis deadlines and
shrinking to keep external traffic bounded.
Offline contract tests use Hypothesis for generated parser, numeric-validation, and fallback-resolution coverage. They remain fixture-backed and make no network requests.
The supported Python 3.11-3.14 matrix and clean-wheel import run in CI. The source distribution also contains the tests and shared contract fixtures. After extracting it, downstream packagers can run the same locked suite with:
uv sync --locked
uv run --locked pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kisnet_ytm-0.2.0.tar.gz.
File metadata
- Download URL: kisnet_ytm-0.2.0.tar.gz
- Upload date:
- Size: 84.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2b63cd8981c044632145dc7c959156c75a43608227de69deb065873ee4f08f9
|
|
| MD5 |
ecac2e963643af489dcd8238c2064c7f
|
|
| BLAKE2b-256 |
f8e22e5c1f73e008d2983826cad9aee79400f21c1ab87981e4d5eea4afe7b657
|
File details
Details for the file kisnet_ytm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: kisnet_ytm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0269241b441deac0d6d0c4a9e2401f5f06029fd3813975f8c659256acac40319
|
|
| MD5 |
db7cebbca8688b51d8623c18d95a9739
|
|
| BLAKE2b-256 |
dd9ca46d47f44582c65ec45c4efe96b6c622f382890e4c8671bd27ee66f2cc2f
|