dart-asof 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dart_asof-0.1.0/.github/workflows/release.yml +40 -0
- dart_asof-0.1.0/.gitignore +7 -0
- dart_asof-0.1.0/LICENSE +21 -0
- dart_asof-0.1.0/PKG-INFO +44 -0
- dart_asof-0.1.0/README.md +33 -0
- dart_asof-0.1.0/examples/dart_families.json +254 -0
- dart_asof-0.1.0/examples/filings.json +21 -0
- dart_asof-0.1.0/pyproject.toml +24 -0
- dart_asof-0.1.0/src/dart_asof/__init__.py +120 -0
- dart_asof-0.1.0/src/dart_asof/cli.py +23 -0
- dart_asof-0.1.0/tests/test_public.py +45 -0
- dart_asof-0.1.0/tests/test_resolution.py +29 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
- run: python -m pip install build
|
|
19
|
+
- run: python -m pip install . pytest
|
|
20
|
+
- run: python -m pytest -q
|
|
21
|
+
- run: python -m build
|
|
22
|
+
- uses: actions/upload-artifact@v4
|
|
23
|
+
with:
|
|
24
|
+
name: dist
|
|
25
|
+
path: dist/
|
|
26
|
+
|
|
27
|
+
publish:
|
|
28
|
+
needs: build
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
environment:
|
|
31
|
+
name: pypi
|
|
32
|
+
url: https://pypi.org/project/dart-asof/
|
|
33
|
+
permissions:
|
|
34
|
+
id-token: write
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/download-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: dist
|
|
39
|
+
path: dist/
|
|
40
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
dart_asof-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rion Hwang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
dart_asof-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dart-asof
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Resolve Korean filing and attachment versions as of a cutoff using local evidence.
|
|
5
|
+
Project-URL: Repository, https://github.com/RionHwang0/dart-asof
|
|
6
|
+
Author: Rion Hwang
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# dart-asof
|
|
13
|
+
|
|
14
|
+
Resolve the body and attachments that were public at the end of a Korean calendar date using a reviewed, locally saved filing manifest. Includes a Python API and a JSON CLI.
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pip install dart-asof
|
|
18
|
+
dart-asof examples/filings.json --family 20250319000001 --as-of 2025-11-21
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The example uses fictitious receipts. Its November amendment replaces only the body. The audit attachment still points to its March receipt. Supply `--archive DIRECTORY` to hash the selected original files.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import json
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from dart_asof import resolve
|
|
27
|
+
records = json.loads(Path("examples/filings.json").read_text())
|
|
28
|
+
view = resolve(records, family="20250319000001", as_of="2025-11-21")
|
|
29
|
+
print(view["documents"]["audit"])
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Start with OpenDART's `rcept_no` and `rcept_dt`. Set `family` to the verified original receipt, `kind` to original/amendment/withdrawal, and `documents` to the roles actually replaced. A null path removes a role. An empty change set records a reviewed amendment with no role changes. Same-day events need distinct integer `order` values from independent evidence; otherwise the result is ambiguous. A withdrawal terminates the family. CLI exits 0 for available, 1 for ambiguous, withdrawn or not yet filed, 2 for bad input. Completeness depends on the supplied archive. Titles alone do not establish filing identity.
|
|
33
|
+
|
|
34
|
+
[OpenDART search fields](https://opendart.fss.or.kr/guide/detail.do?apiGrpCd=DS001&apiId=2019001) · [Example of a correction affecting an attachment and notes](https://kind.krx.co.kr/external/2025/11/21/000714/20251121001637/11011.htm)
|
|
35
|
+
|
|
36
|
+
## Ten public DART filing families
|
|
37
|
+
|
|
38
|
+
The [public manifest](examples/dart_families.json) transcribes the DART viewer's body selector for ten families through 2025-11-21. Its archive paths are suggested filenames for locally saved originals. On the 20 November and 21 November cutoffs, the regression checks 20 body selections, including one same-day ambiguity. The annual report example also tracks two audit attachments. On 21 November the consolidated audit attachment changed to document 10892631. The separate audit attachment still points to 10430190 in the March receipt. [DART original and revision selector](https://dart.fss.or.kr/dsaf001/main.do?rcpNo=20251121000498)
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
dart-asof examples/dart_families.json --family 20250319000924 --as-of 2025-11-21
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use a document value of the form `{"path":"saved.html","dcm_no":"10892631"}` to include a direct attachment link. With your own annotated manifest you can also select by `--corp-code CODE --report-name NAME`. Include both fields on original events. If two original families have the same company and exact report name as of the cutoff, the resolver returns their receipt numbers for review.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# dart-asof
|
|
2
|
+
|
|
3
|
+
Resolve the body and attachments that were public at the end of a Korean calendar date using a reviewed, locally saved filing manifest. Includes a Python API and a JSON CLI.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pip install dart-asof
|
|
7
|
+
dart-asof examples/filings.json --family 20250319000001 --as-of 2025-11-21
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The example uses fictitious receipts. Its November amendment replaces only the body. The audit attachment still points to its March receipt. Supply `--archive DIRECTORY` to hash the selected original files.
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import json
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from dart_asof import resolve
|
|
16
|
+
records = json.loads(Path("examples/filings.json").read_text())
|
|
17
|
+
view = resolve(records, family="20250319000001", as_of="2025-11-21")
|
|
18
|
+
print(view["documents"]["audit"])
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Start with OpenDART's `rcept_no` and `rcept_dt`. Set `family` to the verified original receipt, `kind` to original/amendment/withdrawal, and `documents` to the roles actually replaced. A null path removes a role. An empty change set records a reviewed amendment with no role changes. Same-day events need distinct integer `order` values from independent evidence; otherwise the result is ambiguous. A withdrawal terminates the family. CLI exits 0 for available, 1 for ambiguous, withdrawn or not yet filed, 2 for bad input. Completeness depends on the supplied archive. Titles alone do not establish filing identity.
|
|
22
|
+
|
|
23
|
+
[OpenDART search fields](https://opendart.fss.or.kr/guide/detail.do?apiGrpCd=DS001&apiId=2019001) · [Example of a correction affecting an attachment and notes](https://kind.krx.co.kr/external/2025/11/21/000714/20251121001637/11011.htm)
|
|
24
|
+
|
|
25
|
+
## Ten public DART filing families
|
|
26
|
+
|
|
27
|
+
The [public manifest](examples/dart_families.json) transcribes the DART viewer's body selector for ten families through 2025-11-21. Its archive paths are suggested filenames for locally saved originals. On the 20 November and 21 November cutoffs, the regression checks 20 body selections, including one same-day ambiguity. The annual report example also tracks two audit attachments. On 21 November the consolidated audit attachment changed to document 10892631. The separate audit attachment still points to 10430190 in the March receipt. [DART original and revision selector](https://dart.fss.or.kr/dsaf001/main.do?rcpNo=20251121000498)
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
dart-asof examples/dart_families.json --family 20250319000924 --as-of 2025-11-21
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Use a document value of the form `{"path":"saved.html","dcm_no":"10892631"}` to include a direct attachment link. With your own annotated manifest you can also select by `--corp-code CODE --report-name NAME`. Include both fields on original events. If two original families have the same company and exact report name as of the cutoff, the resolver returns their receipt numbers for review.
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"family": "20251015000418",
|
|
4
|
+
"rcept_no": "20251015000418",
|
|
5
|
+
"rcept_dt": "20251015",
|
|
6
|
+
"kind": "original",
|
|
7
|
+
"report_name": "증권신고서(지분증권)",
|
|
8
|
+
"documents": {
|
|
9
|
+
"body": "20251015000418/main.html"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"family": "20251015000418",
|
|
14
|
+
"rcept_no": "20251121000500",
|
|
15
|
+
"rcept_dt": "20251121",
|
|
16
|
+
"kind": "amendment",
|
|
17
|
+
"report_name": "증권신고서(지분증권)",
|
|
18
|
+
"documents": {
|
|
19
|
+
"body": "20251121000500/main.html"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"family": "20250514001037",
|
|
24
|
+
"rcept_no": "20250514001037",
|
|
25
|
+
"rcept_dt": "20250514",
|
|
26
|
+
"kind": "original",
|
|
27
|
+
"report_name": "분기보고서",
|
|
28
|
+
"documents": {
|
|
29
|
+
"body": "20250514001037/main.html"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"family": "20250514001037",
|
|
34
|
+
"rcept_no": "20251121000499",
|
|
35
|
+
"rcept_dt": "20251121",
|
|
36
|
+
"kind": "amendment",
|
|
37
|
+
"report_name": "분기보고서",
|
|
38
|
+
"documents": {
|
|
39
|
+
"body": "20251121000499/main.html"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"family": "20250106900358",
|
|
44
|
+
"rcept_no": "20250106900358",
|
|
45
|
+
"rcept_dt": "20250106",
|
|
46
|
+
"kind": "original",
|
|
47
|
+
"report_name": "거래처와의거래중단",
|
|
48
|
+
"documents": {
|
|
49
|
+
"body": "20250106900358/main.html"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"family": "20250106900358",
|
|
54
|
+
"rcept_no": "20250124900208",
|
|
55
|
+
"rcept_dt": "20250124",
|
|
56
|
+
"kind": "amendment",
|
|
57
|
+
"report_name": "거래처와의거래중단",
|
|
58
|
+
"documents": {
|
|
59
|
+
"body": "20250124900208/main.html"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"family": "20250106900358",
|
|
64
|
+
"rcept_no": "20251121900710",
|
|
65
|
+
"rcept_dt": "20251121",
|
|
66
|
+
"kind": "amendment",
|
|
67
|
+
"report_name": "거래처와의거래중단",
|
|
68
|
+
"documents": {
|
|
69
|
+
"body": "20251121900710/main.html"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"family": "20250319000924",
|
|
74
|
+
"rcept_no": "20250319000924",
|
|
75
|
+
"rcept_dt": "20250319",
|
|
76
|
+
"kind": "original",
|
|
77
|
+
"report_name": "사업보고서",
|
|
78
|
+
"documents": {
|
|
79
|
+
"body": "20250319000924/main.html",
|
|
80
|
+
"audit": {
|
|
81
|
+
"path": "20250319000924/10430190.html",
|
|
82
|
+
"dcm_no": "10430190"
|
|
83
|
+
},
|
|
84
|
+
"consolidated_audit": {
|
|
85
|
+
"path": "20250319000924/10430191.html",
|
|
86
|
+
"dcm_no": "10430191"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"family": "20250319000924",
|
|
92
|
+
"rcept_no": "20251121000498",
|
|
93
|
+
"rcept_dt": "20251121",
|
|
94
|
+
"kind": "amendment",
|
|
95
|
+
"report_name": "사업보고서",
|
|
96
|
+
"documents": {
|
|
97
|
+
"body": "20251121000498/main.html",
|
|
98
|
+
"consolidated_audit": {
|
|
99
|
+
"path": "20251121000498/10892631.html",
|
|
100
|
+
"dcm_no": "10892631"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"family": "20250915900595",
|
|
106
|
+
"rcept_no": "20250915900595",
|
|
107
|
+
"rcept_dt": "20250915",
|
|
108
|
+
"kind": "original",
|
|
109
|
+
"report_name": "최대주주인명목회사·조합등의최대주주변경",
|
|
110
|
+
"documents": {
|
|
111
|
+
"body": "20250915900595/main.html"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"family": "20250915900595",
|
|
116
|
+
"rcept_no": "20251107900916",
|
|
117
|
+
"rcept_dt": "20251107",
|
|
118
|
+
"kind": "amendment",
|
|
119
|
+
"report_name": "최대주주인명목회사·조합등의최대주주변경",
|
|
120
|
+
"documents": {
|
|
121
|
+
"body": "20251107900916/main.html"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"family": "20250915900595",
|
|
126
|
+
"rcept_no": "20251121900697",
|
|
127
|
+
"rcept_dt": "20251121",
|
|
128
|
+
"kind": "amendment",
|
|
129
|
+
"report_name": "최대주주인명목회사·조합등의최대주주변경",
|
|
130
|
+
"documents": {
|
|
131
|
+
"body": "20251121900697/main.html"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"family": "20251118900443",
|
|
136
|
+
"rcept_no": "20251118900443",
|
|
137
|
+
"rcept_dt": "20251118",
|
|
138
|
+
"kind": "original",
|
|
139
|
+
"report_name": "소송등의제기ㆍ신청(경영권분쟁소송)",
|
|
140
|
+
"documents": {
|
|
141
|
+
"body": "20251118900443/main.html"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"family": "20251118900443",
|
|
146
|
+
"rcept_no": "20251121900680",
|
|
147
|
+
"rcept_dt": "20251121",
|
|
148
|
+
"kind": "amendment",
|
|
149
|
+
"report_name": "소송등의제기ㆍ신청(경영권분쟁소송)",
|
|
150
|
+
"documents": {
|
|
151
|
+
"body": "20251121900680/main.html"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"family": "20251118900429",
|
|
156
|
+
"rcept_no": "20251118900429",
|
|
157
|
+
"rcept_dt": "20251118",
|
|
158
|
+
"kind": "original",
|
|
159
|
+
"report_name": "소송등의제기ㆍ신청(경영권분쟁소송)",
|
|
160
|
+
"documents": {
|
|
161
|
+
"body": "20251118900429/main.html"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"family": "20251118900429",
|
|
166
|
+
"rcept_no": "20251121900669",
|
|
167
|
+
"rcept_dt": "20251121",
|
|
168
|
+
"kind": "amendment",
|
|
169
|
+
"report_name": "소송등의제기ㆍ신청(경영권분쟁소송)",
|
|
170
|
+
"documents": {
|
|
171
|
+
"body": "20251121900669/main.html"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"family": "20251001000776",
|
|
176
|
+
"rcept_no": "20251001000776",
|
|
177
|
+
"rcept_dt": "20251002",
|
|
178
|
+
"kind": "original",
|
|
179
|
+
"report_name": "주요사항보고서(유상증자결정)",
|
|
180
|
+
"documents": {
|
|
181
|
+
"body": "20251001000776/main.html"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"family": "20251001000776",
|
|
186
|
+
"rcept_no": "20251113000478",
|
|
187
|
+
"rcept_dt": "20251113",
|
|
188
|
+
"kind": "amendment",
|
|
189
|
+
"report_name": "주요사항보고서(유상증자결정)",
|
|
190
|
+
"documents": {
|
|
191
|
+
"body": "20251113000478/main.html"
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"family": "20251001000776",
|
|
196
|
+
"rcept_no": "20251121000461",
|
|
197
|
+
"rcept_dt": "20251121",
|
|
198
|
+
"kind": "amendment",
|
|
199
|
+
"report_name": "주요사항보고서(유상증자결정)",
|
|
200
|
+
"documents": {
|
|
201
|
+
"body": "20251121000461/main.html"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"family": "20251114902976",
|
|
206
|
+
"rcept_no": "20251114902976",
|
|
207
|
+
"rcept_dt": "20251114",
|
|
208
|
+
"kind": "original",
|
|
209
|
+
"report_name": "신주인수권행사",
|
|
210
|
+
"documents": {
|
|
211
|
+
"body": "20251114902976/main.html"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"family": "20251114902976",
|
|
216
|
+
"rcept_no": "20251121900634",
|
|
217
|
+
"rcept_dt": "20251121",
|
|
218
|
+
"kind": "amendment",
|
|
219
|
+
"report_name": "신주인수권행사",
|
|
220
|
+
"documents": {
|
|
221
|
+
"body": "20251121900634/main.html"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"family": "20251117000227",
|
|
226
|
+
"rcept_no": "20251117000227",
|
|
227
|
+
"rcept_dt": "20251117",
|
|
228
|
+
"kind": "original",
|
|
229
|
+
"report_name": "증권신고서(채무증권)",
|
|
230
|
+
"documents": {
|
|
231
|
+
"body": "20251117000227/main.html"
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"family": "20251117000227",
|
|
236
|
+
"rcept_no": "20251121000442",
|
|
237
|
+
"rcept_dt": "20251121",
|
|
238
|
+
"kind": "amendment",
|
|
239
|
+
"report_name": "증권신고서(채무증권)",
|
|
240
|
+
"documents": {
|
|
241
|
+
"body": "20251121000442/main.html"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"family": "20251117000227",
|
|
246
|
+
"rcept_no": "20251121000453",
|
|
247
|
+
"rcept_dt": "20251121",
|
|
248
|
+
"kind": "amendment",
|
|
249
|
+
"report_name": "증권신고서(채무증권)",
|
|
250
|
+
"documents": {
|
|
251
|
+
"body": "20251121000453/main.html"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"family": "20250319000001",
|
|
4
|
+
"rcept_no": "20250319000001",
|
|
5
|
+
"rcept_dt": "20250319",
|
|
6
|
+
"kind": "original",
|
|
7
|
+
"documents": {
|
|
8
|
+
"body": "march.xml",
|
|
9
|
+
"audit": "audit.pdf"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"family": "20250319000001",
|
|
14
|
+
"rcept_no": "20251121000002",
|
|
15
|
+
"rcept_dt": "20251121",
|
|
16
|
+
"kind": "amendment",
|
|
17
|
+
"documents": {
|
|
18
|
+
"body": "november.xml"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dart-asof"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Resolve Korean filing and attachment versions as of a cutoff using local evidence."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{name = "Rion Hwang"}]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
dart-asof = "dart_asof.cli:main"
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Repository = "https://github.com/RionHwang0/dart-asof"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["src/dart_asof"]
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Replay reviewed OpenDART filing families, by receipt day (Korean local date)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import hashlib
|
|
5
|
+
import re
|
|
6
|
+
from datetime import date, datetime
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _day(value):
|
|
11
|
+
if isinstance(value, datetime):
|
|
12
|
+
raise ValueError("Pass a calendar date, not a datetime")
|
|
13
|
+
if isinstance(value, date):
|
|
14
|
+
return value
|
|
15
|
+
if isinstance(value, str) and re.fullmatch(r"\d{8}", value):
|
|
16
|
+
return datetime.strptime(value, "%Y%m%d").date()
|
|
17
|
+
return date.fromisoformat(value)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _receipt(value):
|
|
21
|
+
if not isinstance(value, str) or not re.fullmatch(r"[0-9]{14}", value):
|
|
22
|
+
raise ValueError(f"Expected a 14-digit DART receipt, got {value!r}")
|
|
23
|
+
return value
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def resolve(filings, *, as_of, family=None, corp_code=None, report_name=None, archive=None):
|
|
27
|
+
"""Select documents at the end of a date from explicitly linked filing events.
|
|
28
|
+
|
|
29
|
+
documents maps logical roles to a relative path or null (withdraw that role).
|
|
30
|
+
Omitted roles are inherited. Every amendment must specify its changes.
|
|
31
|
+
Optional order disambiguates multiple filings received on the same day.
|
|
32
|
+
"""
|
|
33
|
+
cutoff = _day(as_of)
|
|
34
|
+
if family is None:
|
|
35
|
+
if not corp_code or not report_name:
|
|
36
|
+
raise ValueError("Supply a filing family or both corp_code and report_name")
|
|
37
|
+
filings = list(filings)
|
|
38
|
+
originals = {item["family"] for item in filings
|
|
39
|
+
if item["kind"] == "original" and _day(item["rcept_dt"]) <= cutoff
|
|
40
|
+
and item.get("corp_code") == corp_code and item.get("report_name") == report_name}
|
|
41
|
+
if len(originals) != 1:
|
|
42
|
+
return {"status": "ambiguous" if originals else "not-filed",
|
|
43
|
+
"as_of": cutoff.isoformat(), "candidates": sorted(originals)}
|
|
44
|
+
family = originals.pop()
|
|
45
|
+
elif corp_code is not None or report_name is not None:
|
|
46
|
+
raise ValueError("Choose one filing selector")
|
|
47
|
+
root = _receipt(family)
|
|
48
|
+
timeline = {}
|
|
49
|
+
seen = set()
|
|
50
|
+
for item in filings:
|
|
51
|
+
if item["family"] != root:
|
|
52
|
+
continue
|
|
53
|
+
day = _day(item["rcept_dt"])
|
|
54
|
+
if day > cutoff:
|
|
55
|
+
continue
|
|
56
|
+
receipt = _receipt(item["rcept_no"])
|
|
57
|
+
if receipt in seen:
|
|
58
|
+
raise ValueError(f"Duplicate receipt {receipt}")
|
|
59
|
+
seen.add(receipt)
|
|
60
|
+
timeline.setdefault(day, []).append(item)
|
|
61
|
+
docs = {}
|
|
62
|
+
history = []
|
|
63
|
+
status = "not-filed"
|
|
64
|
+
for day, group in sorted(timeline.items()):
|
|
65
|
+
if len(group) > 1:
|
|
66
|
+
orders = [event.get("order") for event in group]
|
|
67
|
+
if any(type(order) is not int for order in orders) or len(set(orders)) != len(orders):
|
|
68
|
+
return {"status": "ambiguous", "family": root, "as_of": cutoff.isoformat(),
|
|
69
|
+
"day": day.isoformat(), "candidates": sorted(event["rcept_no"] for event in group)}
|
|
70
|
+
group = sorted(group, key=lambda event: event["order"])
|
|
71
|
+
for event in group:
|
|
72
|
+
receipt = event["rcept_no"]
|
|
73
|
+
kind = event["kind"]
|
|
74
|
+
if not history and (kind != "original" or receipt != root):
|
|
75
|
+
raise ValueError("Family must begin with the original receipt")
|
|
76
|
+
if history and (kind == "original" or status == "withdrawn"):
|
|
77
|
+
raise ValueError("Unexpected event after withdrawal or duplicate original")
|
|
78
|
+
if kind not in ("original", "amendment", "withdrawal"):
|
|
79
|
+
raise ValueError(f"Unknown filing kind: {kind}")
|
|
80
|
+
history.append(receipt)
|
|
81
|
+
if kind == "withdrawal":
|
|
82
|
+
docs.clear()
|
|
83
|
+
status = "withdrawn"
|
|
84
|
+
continue
|
|
85
|
+
changes = event.get("documents")
|
|
86
|
+
if not isinstance(changes, dict) or (kind == "original" and not changes):
|
|
87
|
+
raise ValueError(f"Provide reviewed document roles for {receipt}")
|
|
88
|
+
for role, path in changes.items():
|
|
89
|
+
if not isinstance(role, str) or not role.strip():
|
|
90
|
+
raise ValueError("Document role must be a nonempty string")
|
|
91
|
+
if path is None:
|
|
92
|
+
docs.pop(role, None)
|
|
93
|
+
continue
|
|
94
|
+
document_number = None
|
|
95
|
+
if isinstance(path, dict):
|
|
96
|
+
document_number = path["dcm_no"]
|
|
97
|
+
if not isinstance(document_number, str) or not re.fullmatch(r"[0-9]+", document_number):
|
|
98
|
+
raise ValueError("Invalid DART document number")
|
|
99
|
+
path = path["path"]
|
|
100
|
+
if not isinstance(path, str) or not path or Path(path).is_absolute() or ".." in Path(path).parts:
|
|
101
|
+
raise ValueError("Document paths must be relative to the archive")
|
|
102
|
+
docs[role] = {"path": path, "rcept_no": receipt, "rcept_dt": day.isoformat(),
|
|
103
|
+
"url": f"https://dart.fss.or.kr/dsaf001/main.do?rcpNo={receipt}"}
|
|
104
|
+
if document_number is not None:
|
|
105
|
+
docs[role]["dcm_no"] = document_number
|
|
106
|
+
docs[role]["url"] += "&dcmNo=" + document_number
|
|
107
|
+
status = "available"
|
|
108
|
+
if archive is not None:
|
|
109
|
+
base = Path(archive).resolve(strict=True)
|
|
110
|
+
for doc in docs.values():
|
|
111
|
+
path = (base / doc["path"]).resolve(strict=True)
|
|
112
|
+
if not path.is_relative_to(base):
|
|
113
|
+
raise ValueError("Archive path escapes the archive directory")
|
|
114
|
+
digest = hashlib.sha256()
|
|
115
|
+
with path.open("rb") as stream:
|
|
116
|
+
for block in iter(lambda: stream.read(1024 * 1024), b""):
|
|
117
|
+
digest.update(block)
|
|
118
|
+
doc["sha256"] = digest.hexdigest()
|
|
119
|
+
return {"status": status, "family": root, "as_of": cutoff.isoformat(),
|
|
120
|
+
"history": history, "documents": docs}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from . import resolve
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(description="Resolve an archived DART filing family at the end of a Korean calendar date.")
|
|
10
|
+
parser.add_argument("manifest", type=Path)
|
|
11
|
+
parser.add_argument("--family")
|
|
12
|
+
parser.add_argument("--corp-code")
|
|
13
|
+
parser.add_argument("--report-name")
|
|
14
|
+
parser.add_argument("--as-of", required=True)
|
|
15
|
+
parser.add_argument("--archive", type=Path, help="Hash selected local originals under this directory")
|
|
16
|
+
args = parser.parse_args()
|
|
17
|
+
try:
|
|
18
|
+
result = resolve(json.loads(args.manifest.read_text(encoding="utf-8")), family=args.family,
|
|
19
|
+
as_of=args.as_of, archive=args.archive, corp_code=args.corp_code, report_name=args.report_name)
|
|
20
|
+
except (KeyError, ValueError, TypeError, OSError) as error:
|
|
21
|
+
parser.exit(2, f"{error}\n")
|
|
22
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
23
|
+
return 0 if result["status"] == "available" else 1
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from dart_asof import resolve
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_two_cutoffs_for_ten_families():
|
|
8
|
+
events = json.loads((Path(__file__).parents[1] / "examples/dart_families.json").read_text())
|
|
9
|
+
# Transcribed from the body selectors of 21 November filings. Each tuple
|
|
10
|
+
# gives the family root and expected bodies on 20 and 21 November.
|
|
11
|
+
labels = [
|
|
12
|
+
("20251015000418", "20251015000418", "20251121000500"),
|
|
13
|
+
("20250514001037", "20250514001037", "20251121000499"),
|
|
14
|
+
("20250106900358", "20250124900208", "20251121900710"),
|
|
15
|
+
("20250319000924", "20250319000924", "20251121000498"),
|
|
16
|
+
("20250915900595", "20251107900916", "20251121900697"),
|
|
17
|
+
("20251118900443", "20251118900443", "20251121900680"),
|
|
18
|
+
("20251118900429", "20251118900429", "20251121900669"),
|
|
19
|
+
("20251001000776", "20251113000478", "20251121000461"),
|
|
20
|
+
("20251114902976", "20251114902976", "20251121900634"),
|
|
21
|
+
("20251117000227", "20251117000227", None),
|
|
22
|
+
]
|
|
23
|
+
for family, before, after in labels:
|
|
24
|
+
for day, expected in [("2025-11-20", before), ("2025-11-21", after)]:
|
|
25
|
+
result = resolve(events, family=family, as_of=day)
|
|
26
|
+
if expected is None:
|
|
27
|
+
assert result["status"] == "ambiguous"
|
|
28
|
+
assert result["candidates"] == ["20251121000442", "20251121000453"]
|
|
29
|
+
else:
|
|
30
|
+
assert result["documents"]["body"]["rcept_no"] == expected
|
|
31
|
+
assert all(d["rcept_dt"] <= day for d in result["documents"].values())
|
|
32
|
+
docs = resolve(events, family="20250319000924", as_of="2025-11-21")["documents"]
|
|
33
|
+
assert docs["audit"]["url"].endswith("rcpNo=20250319000924&dcmNo=10430190")
|
|
34
|
+
assert docs["consolidated_audit"]["url"].endswith("rcpNo=20251121000498&dcmNo=10892631")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_company_and_report_name_candidates():
|
|
38
|
+
rows = [{"kind":"original", "rcept_no":r, "family":r, "rcept_dt":r[:8],
|
|
39
|
+
"corp_code":"A", "report_name":"annual", "documents":{"body":"body.html"}}
|
|
40
|
+
for r in ["20240101000001", "20250101000002"]]
|
|
41
|
+
def select(day):
|
|
42
|
+
return resolve(rows, corp_code="A", report_name="annual", as_of=day)
|
|
43
|
+
assert select("2023-12-31")["status"] == "not-filed"
|
|
44
|
+
assert select("2024-01-02")["family"] == rows[0]["family"]
|
|
45
|
+
assert select("2025-01-02")["candidates"] == [r["family"] for r in rows]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from dart_asof import resolve
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
root = "20250319000001"
|
|
5
|
+
def event(day, seq, kind, docs=None, **kwargs):
|
|
6
|
+
return {"rcept_dt":day,"rcept_no":day + f"{seq:06d}", "family":root,"kind":kind,"documents":docs,**kwargs}
|
|
7
|
+
|
|
8
|
+
def test_roll_forward_with_attachment_inheritance(tmp_path):
|
|
9
|
+
entries = [event("20250319",1,"original",{"body":"first.xml","audit":"audit.xml"}),
|
|
10
|
+
event("20251121",2,"amendment",{"body":"second.xml"}),
|
|
11
|
+
event("20251201",3,"amendment",{"audit":None}),
|
|
12
|
+
event("20251203",4,"withdrawal")]
|
|
13
|
+
assert resolve(entries,family=root,as_of="2025-03-18")["status"]=="not-filed"
|
|
14
|
+
for file in ["second.xml","audit.xml"]:
|
|
15
|
+
(tmp_path/file).write_text(file)
|
|
16
|
+
current=resolve(reversed(entries),family=root,as_of="20251121",archive=tmp_path)
|
|
17
|
+
assert current["documents"]["body"]["rcept_no"]=="20251121000002"
|
|
18
|
+
assert current["documents"]["audit"]["rcept_no"]==root
|
|
19
|
+
assert len(current["documents"]["audit"]["sha256"])==64
|
|
20
|
+
assert list(resolve(entries,family=root,as_of="20251202")["documents"])==["body"]
|
|
21
|
+
assert resolve(entries,family=root,as_of="20251203")["status"]=="withdrawn"
|
|
22
|
+
|
|
23
|
+
def test_ties_need_explicit_evidence():
|
|
24
|
+
a=event("20250319",1,"original",{"body":"a"})
|
|
25
|
+
b=event("20250319",2,"amendment",{"body":"b"})
|
|
26
|
+
assert resolve([b,a],family=root,as_of="20250319")["status"]=="ambiguous"
|
|
27
|
+
assert resolve([dict(b,order=2),dict(a,order=1)],family=root,as_of="20250319")["documents"]["body"]["path"]=="b"
|
|
28
|
+
with pytest.raises(ValueError):
|
|
29
|
+
resolve([b],family=root,as_of="20250319")
|