datagokr — KOFIA 종합통계
Fetch one 금융투자협회 (KOFIA) statistics operation over a date range. Daily
operations (market_funds, credit_balance, fund_net_asset, cma_status) take
YYYYMMDD bounds; monthly ones (trust_scale, dls_dlb, els_elb,
overseas_derivatives) take YYYYMM. The output is typed snake_case columns
(base_date, investor_deposit, margin_loan_total, ...). Data starts 2021-11-16 and
updates once a day.
Prerequisite
pipx install pydatagokr # or: pip install pydatagokr
Never print the key value (the DATAGOKR_API_KEY env var or credentials.json) to output, logs, or a summary -- if you need to check which form it is (encoding vs decoding), ask the user.
A data.go.kr decoding key must be configured (env DATAGOKR_API_KEY or
~/.config/pydatagokr/credentials.json), and the KOFIA dataset applied for
(활용신청) on that account.
Running
datagokr kofia <operation> [--begin YYYYMMDD] [--end YYYYMMDD] [--json]
Procedure
- Pick the operation. Unsure? Run
datagokr list(offline) and match the concept. - Run.
Adddatagokr kofia market_funds --begin 20240101 --end 20240131--jsonwhen the user wants machine-readable data. - Relay the result. Show the CLI's stdout; the text view caps at 20 rows, so use
--jsonfor a full series. - Error handling. A one-line
datagokr: <message>on stderr:- a
[30]/[20]auth error -> the key is wrong, is the encoding form by mistake, or the dataset is not applied for. - a
[22]/[23]rate limit -> the daily traffic limit; wait and retry. unknown operation(exit 2) -> rundatagokr listand correct the name.
- a
What this skill does not do
- It does not re-implement fetching or parsing (the package does); it always calls the CLI.
- Customs trade data is the customs skill's job.