krx-quant-core 0.1.1__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.
- krx_quant_core-0.1.1/.github/workflows/ci.yml +31 -0
- krx_quant_core-0.1.1/.github/workflows/commit-identity.yml +103 -0
- krx_quant_core-0.1.1/.github/workflows/publish.yml +33 -0
- krx_quant_core-0.1.1/.gitignore +6 -0
- krx_quant_core-0.1.1/LICENSE +202 -0
- krx_quant_core-0.1.1/PKG-INFO +149 -0
- krx_quant_core-0.1.1/README.md +124 -0
- krx_quant_core-0.1.1/pyproject.toml +47 -0
- krx_quant_core-0.1.1/src/krx_quant_core/__init__.py +8 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/__init__.py +36 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/crosssectional.py +299 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/fills.py +62 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/ledger.py +262 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/orderbook.py +82 -0
- krx_quant_core-0.1.1/src/krx_quant_core/backtest/panels.py +53 -0
- krx_quant_core-0.1.1/src/krx_quant_core/costs/__init__.py +30 -0
- krx_quant_core-0.1.1/src/krx_quant_core/costs/model.py +205 -0
- krx_quant_core-0.1.1/src/krx_quant_core/costs/tax.py +85 -0
- krx_quant_core-0.1.1/src/krx_quant_core/execution/__init__.py +27 -0
- krx_quant_core-0.1.1/src/krx_quant_core/execution/guards.py +272 -0
- krx_quant_core-0.1.1/src/krx_quant_core/execution/kiwoom_spec.py +149 -0
- krx_quant_core-0.1.1/src/krx_quant_core/execution/orders.py +134 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/__init__.py +64 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/calendar.py +170 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/codes.py +73 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/limits.py +71 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/session.py +86 -0
- krx_quant_core-0.1.1/src/krx_quant_core/market/ticks.py +108 -0
- krx_quant_core-0.1.1/src/krx_quant_core/py.typed +0 -0
- krx_quant_core-0.1.1/src/krx_quant_core/risk/__init__.py +45 -0
- krx_quant_core-0.1.1/src/krx_quant_core/risk/dart_db.py +89 -0
- krx_quant_core-0.1.1/src/krx_quant_core/risk/disclosure.py +396 -0
- krx_quant_core-0.1.1/src/krx_quant_core/risk/killswitch.py +186 -0
- krx_quant_core-0.1.1/src/krx_quant_core/runtime/__init__.py +5 -0
- krx_quant_core-0.1.1/src/krx_quant_core/runtime/host.py +46 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/__init__.py +93 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/cv.py +296 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/fragility.py +121 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/metrics.py +251 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/sharpe.py +184 -0
- krx_quant_core-0.1.1/src/krx_quant_core/stats/trials.py +99 -0
- krx_quant_core-0.1.1/tests/backtest/test_backtest_crosssectional.py +194 -0
- krx_quant_core-0.1.1/tests/backtest/test_backtest_fills.py +60 -0
- krx_quant_core-0.1.1/tests/backtest/test_backtest_ledger.py +155 -0
- krx_quant_core-0.1.1/tests/backtest/test_backtest_orderbook.py +76 -0
- krx_quant_core-0.1.1/tests/backtest/test_backtest_panels.py +52 -0
- krx_quant_core-0.1.1/tests/costs/test_cost_model.py +244 -0
- krx_quant_core-0.1.1/tests/costs/test_tax_schedule.py +65 -0
- krx_quant_core-0.1.1/tests/execution/test_kiwoom_spec.py +54 -0
- krx_quant_core-0.1.1/tests/execution/test_order_guards.py +346 -0
- krx_quant_core-0.1.1/tests/market/test_limits.py +117 -0
- krx_quant_core-0.1.1/tests/market/test_ticks.py +188 -0
- krx_quant_core-0.1.1/tests/market/test_trading_calendar.py +165 -0
- krx_quant_core-0.1.1/tests/risk/test_dart_disclosure_db_core.py +141 -0
- krx_quant_core-0.1.1/tests/risk/test_disclosure_gate.py +314 -0
- krx_quant_core-0.1.1/tests/risk/test_killswitch.py +246 -0
- krx_quant_core-0.1.1/tests/runtime/test_host_guard.py +59 -0
- krx_quant_core-0.1.1/tests/stats/test_stats_cv.py +278 -0
- krx_quant_core-0.1.1/tests/stats/test_stats_fragility.py +80 -0
- krx_quant_core-0.1.1/tests/stats/test_stats_metrics.py +265 -0
- krx_quant_core-0.1.1/tests/stats/test_stats_sharpe.py +177 -0
- krx_quant_core-0.1.1/tests/stats/test_stats_trials.py +88 -0
- krx_quant_core-0.1.1/uv.lock +622 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.12"
|
|
17
|
+
- run: pip install ruff==0.16.2
|
|
18
|
+
- run: ruff check src/ tests/
|
|
19
|
+
|
|
20
|
+
test:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
strategy:
|
|
23
|
+
matrix:
|
|
24
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
- run: pip install -e ".[dev]"
|
|
31
|
+
- run: pytest -q
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
name: Commit Identity Guard
|
|
2
|
+
|
|
3
|
+
# 커밋 작성자/커미터 이메일이 허용 목록에 없으면 실패한다.
|
|
4
|
+
#
|
|
5
|
+
# 2026-08-29 사고: Claude Code 세션들이 세션 컨텍스트에 주어진 사용자 이메일
|
|
6
|
+
# (회사 주소)을 git 커밋 신원으로 오용해, `git -c user.email=<회사주소> commit`
|
|
7
|
+
# 형태로 커밋했다. 레포 로컬·전역 설정은 개인 이메일로 올바랐지만 명령줄이 그걸
|
|
8
|
+
# 덮었다. 그 결과 6개 레포에 회사 이메일 커밋이 쌓였고 3개는 PUBLIC 상태였다.
|
|
9
|
+
#
|
|
10
|
+
# 설정으로는 막을 수 없다(`-c`가 항상 이긴다). 그래서 CI에서 막는다.
|
|
11
|
+
#
|
|
12
|
+
# 허용 목록을 바꾸려면 ALLOWED_EMAILS를 수정하라.
|
|
13
|
+
# dependabot[bot] 은 봇 신원이다 — 회사 주소가 아니라서 허용한다.
|
|
14
|
+
|
|
15
|
+
on:
|
|
16
|
+
push:
|
|
17
|
+
pull_request:
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
contents: read
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
check-identity:
|
|
24
|
+
# 브랜치·태그 삭제 푸시엔 검사할 커밋도, checkout 할 ref 도 없다.
|
|
25
|
+
if: ${{ !github.event.deleted }}
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v7
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
|
|
32
|
+
- name: 커밋 신원 검사
|
|
33
|
+
env:
|
|
34
|
+
# 개인 이메일 + GitHub noreply만 허용.
|
|
35
|
+
# noreply@github.com 은 GitHub 머지 버튼이 만드는 커밋의 신원이다
|
|
36
|
+
# (Merge pull request #N ...). 회사 주소가 아니라 GitHub 자신이다.
|
|
37
|
+
# 에이전트 신원(noreply@anthropic.com 등)은 **허용하지 않는다** — 커밋은
|
|
38
|
+
# 사람 이름으로 남아야 한다. 에이전트 기여는 author/committer 가 아니라
|
|
39
|
+
# Co-Authored-By 트레일러로 적는다(그건 이 검사가 보지 않는다).
|
|
40
|
+
ALLOWED_EMAILS: |
|
|
41
|
+
chyohw97@gmail.com
|
|
42
|
+
48156556+younghwan91@users.noreply.github.com
|
|
43
|
+
noreply@github.com
|
|
44
|
+
49699333+dependabot[bot]@users.noreply.github.com
|
|
45
|
+
run: |
|
|
46
|
+
set -euo pipefail
|
|
47
|
+
|
|
48
|
+
# PR이면 base..head, push면 이번에 밀린 커밋만 본다.
|
|
49
|
+
# 히스토리 전체를 검사하면 과거 사고 때문에 영원히 실패한다.
|
|
50
|
+
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
51
|
+
RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
|
|
52
|
+
elif [ "${{ github.ref_type }}" = "tag" ]; then
|
|
53
|
+
# 태그 푸시는 새 커밋을 만들지 않는다. before 가 0 이라 아래 폴백을 타면
|
|
54
|
+
# 히스토리 50개를 다시 훑고, 과거 머지 커밋 때문에 영원히 실패한다.
|
|
55
|
+
# 기본 브랜치에 아직 없는 커밋만 본다 (보통 0개).
|
|
56
|
+
BASE="origin/${{ github.event.repository.default_branch }}"
|
|
57
|
+
if git rev-parse --verify -q "$BASE" >/dev/null; then
|
|
58
|
+
RANGE="$BASE..${{ github.sha }}"
|
|
59
|
+
else
|
|
60
|
+
RANGE="${{ github.sha }}~1..${{ github.sha }}"
|
|
61
|
+
fi
|
|
62
|
+
elif [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ] \
|
|
63
|
+
&& git cat-file -e "${{ github.event.before }}" 2>/dev/null; then
|
|
64
|
+
RANGE="${{ github.event.before }}..${{ github.sha }}"
|
|
65
|
+
else
|
|
66
|
+
# 새 브랜치/강제 푸시 등 before를 못 쓰는 경우: 최근 50개만
|
|
67
|
+
RANGE="$(git rev-list -n 50 ${{ github.sha }} | tail -1)^..${{ github.sha }}" || RANGE="${{ github.sha }}"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
echo "검사 범위: $RANGE"
|
|
71
|
+
echo
|
|
72
|
+
|
|
73
|
+
# 허용 목록을 정규화 (빈 줄·공백 제거)
|
|
74
|
+
ALLOWED=$(echo "$ALLOWED_EMAILS" | tr -d ' ' | grep -v '^$' | sort -u)
|
|
75
|
+
echo "허용된 이메일:"
|
|
76
|
+
echo "$ALLOWED" | sed 's/^/ /'
|
|
77
|
+
echo
|
|
78
|
+
|
|
79
|
+
BAD=0
|
|
80
|
+
while IFS='|' read -r sha author committer subject; do
|
|
81
|
+
[ -z "$sha" ] && continue
|
|
82
|
+
for email in "$author" "$committer"; do
|
|
83
|
+
if ! echo "$ALLOWED" | grep -Fxq "$email"; then
|
|
84
|
+
echo "::error::${sha:0:8} 허용되지 않은 이메일: $email ($subject)"
|
|
85
|
+
BAD=1
|
|
86
|
+
fi
|
|
87
|
+
done
|
|
88
|
+
done < <(git log --format='%H|%ae|%ce|%s' "$RANGE" 2>/dev/null || true)
|
|
89
|
+
|
|
90
|
+
if [ "$BAD" -eq 1 ]; then
|
|
91
|
+
echo
|
|
92
|
+
echo "커밋 신원이 허용 목록에 없다. 회사/조직 이메일이 섞였을 가능성이 높다."
|
|
93
|
+
echo
|
|
94
|
+
echo "고치는 법:"
|
|
95
|
+
echo " git config user.email chyohw97@gmail.com"
|
|
96
|
+
echo " git rebase -i --exec 'git commit --amend --reset-author --no-edit' <base>"
|
|
97
|
+
echo " git push --force-with-lease"
|
|
98
|
+
echo
|
|
99
|
+
echo "주의: 'git -c user.email=...' 로 신원을 덮어쓰지 말 것."
|
|
100
|
+
exit 1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
echo "✅ 커밋 신원 이상 없음"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: release
|
|
12
|
+
permissions:
|
|
13
|
+
# id-token 만 적으면 나머지 스코프가 전부 none 이 된다.
|
|
14
|
+
# 그러면 GITHUB_TOKEN 이 레포를 못 읽어 checkout 이
|
|
15
|
+
# "remote: Repository not found" 로 죽는다 (레포가 비공개일 때).
|
|
16
|
+
contents: read
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v7
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-python@v7
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
|
|
26
|
+
- name: Install build
|
|
27
|
+
run: pip install build
|
|
28
|
+
|
|
29
|
+
- name: Build
|
|
30
|
+
run: python -m build
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Younghwan Chae
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: krx-quant-core
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: 한국 주식(KOSPI·KOSDAQ) 퀀트 공통 코어 — 호가단위·가격제한폭·세션, 일자별 거래세 비용모델, 주문 가드, 공시 리스크 분류, 체결 시뮬레이션, Deflated Sharpe·purged CV 검증 통계
|
|
5
|
+
Project-URL: Homepage, https://github.com/younghwan91/krx-quant-core
|
|
6
|
+
Project-URL: Repository, https://github.com/younghwan91/krx-quant-core
|
|
7
|
+
Author-email: Younghwan Chae <chyohw97@gmail.com>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: backtest,kiwoom,kosdaq,kospi,krx,quant,trading
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: kiwoom-client>=0.4.0
|
|
19
|
+
Requires-Dist: numpy>=1.24
|
|
20
|
+
Requires-Dist: pandas>=2.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff==0.16.2; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# krx-quant-core
|
|
27
|
+
|
|
28
|
+
**한국 주식(KOSPI·KOSDAQ) 퀀트 공통 코어.** 호가단위·가격제한폭·세션 규칙, 일자별
|
|
29
|
+
증권거래세 비용모델, 키움 주문 가드, DART 중대공시 분류, 킬스위치, 체결 시뮬레이션,
|
|
30
|
+
Deflated Sharpe·purged CV 검증 통계를 한 패키지로 묶었다.
|
|
31
|
+
|
|
32
|
+
전략은 여기 없다. 전략을 가진 레포들이 **같은 시장 규칙과 같은 비용 숫자**를 쓰게 하는
|
|
33
|
+
것이 이 패키지의 존재 이유다.
|
|
34
|
+
|
|
35
|
+
| 소비자 | 매매 스타일 | 실행 | 이 패키지에서 쓰는 것 |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| [scalp-it](https://github.com/younghwan91) (비공개) | 스캘핑 | 자동 실주문 | 호가·상한가·주문 가드·호가 스윕·체결 규칙·호스트 가드 |
|
|
38
|
+
| [daytrade-it](https://github.com/younghwan91) (비공개) | 데이트레이딩 | 자동 실주문 | 비용모델·공시 리스크 게이트·DART DB·코드 정규화·호스트 가드 |
|
|
39
|
+
| [swing-it](https://github.com/younghwan91/swing-it) | 스윙 | 리서치 + 수동 체결 | DSR·purged CV·부트스트랩·취약성 진단·횡단면 시뮬 |
|
|
40
|
+
|
|
41
|
+
## 왜 따로 뺐나
|
|
42
|
+
|
|
43
|
+
세 레포가 같은 규칙을 각자 들고 있었고, 실제로 어긋나 있었다.
|
|
44
|
+
|
|
45
|
+
- `normalize_code` 가 두 레포에 **복붙**돼 있었다. 한쪽 옛 구현은 `0155E0` 을 `001550`
|
|
46
|
+
(완전히 다른 회사)으로 바꾸던 버그를 안고 있었다.
|
|
47
|
+
- 거래비용이 레포마다 `0.0023`·`0.0034`·`0.0064`·`50bp` 로 흩어져 있었고, 거래세가
|
|
48
|
+
2023→2024→2025→2026 에 네 번 바뀌었는데 일자별로 적용하는 코드가 **어디에도 없었다**.
|
|
49
|
+
- 체결 판정(`through`/`touch`)이 같은 레포 안에서도 알 수 없는 값을 받으면 한 곳은
|
|
50
|
+
through, 다른 곳은 touch 로 **반대로** 읽었다.
|
|
51
|
+
- 하한가 계산은 없었다. 대칭식으로 짜면 틀린다 — 실측 대조 결과는 아래.
|
|
52
|
+
|
|
53
|
+
## 설치
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install "krx-quant-core @ git+https://github.com/younghwan91/krx-quant-core@v0.1.1"
|
|
57
|
+
# PyPI 릴리스 전까지는 git 태그로 고정한다.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Python ≥ 3.11. 의존성은 `kiwoom-client`(호가단위 표의 정본), `numpy`, `pandas` 뿐이다.
|
|
61
|
+
|
|
62
|
+
## 모듈
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
krx_quant_core/
|
|
66
|
+
├── market/ 종목코드·Market, 호가단위, 상/하한가, KST 세션, 거래일 달력
|
|
67
|
+
├── costs/ 일자별 거래세 스케줄, KoreanCostModel(Decimal), round_trip_cost(float)
|
|
68
|
+
├── execution/ 키움 REST 주문 스펙, OrderIntent/OrderResult, OrderGuard(순수 가드)
|
|
69
|
+
├── risk/ DART 중대공시 분류·RiskGate, DartDisclosureDB, KillSwitch
|
|
70
|
+
├── backtest/ 호가 스윕 VWAP·왕복비용, 지정가 체결 규칙, 트레이드 원장 지표, 횡단면 시뮬
|
|
71
|
+
├── stats/ Deflated/Probabilistic Sharpe, t-haircut, purged walk-forward, 부트스트랩, 취약성
|
|
72
|
+
└── runtime/ 호스트 가드(백테스트는 simnode 에서만)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from datetime import date
|
|
77
|
+
from krx_quant_core.market import Market, limit_up_price, limit_down_price, shift_ticks
|
|
78
|
+
from krx_quant_core.costs import round_trip_cost, tax_rate
|
|
79
|
+
|
|
80
|
+
limit_up_price(24_250) # 31500
|
|
81
|
+
limit_down_price(239_000) # 167500.0
|
|
82
|
+
shift_ticks(49_950, 2) # Decimal('50100') — 밴드 경계를 넘어도 유효 호가
|
|
83
|
+
tax_rate(date(2025, 6, 2), Market.KOSPI).total # Decimal('0.0015')
|
|
84
|
+
round_trip_cost(date(2026, 9, 14), Market.KOSDAQ, slippage_one_way=0.0015) # 0.0053
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 설계 원칙
|
|
88
|
+
|
|
89
|
+
1. **이식은 수치 동일.** 소비 레포가 실매매일에 갈아탈 수 있어야 한다. 포트마다 원본
|
|
90
|
+
코드와 무작위 입력으로 대조했다 — 주문 가드 16,000건 사유 문자열 동일, 킬스위치
|
|
91
|
+
9,000 스텝 동일, 실제 `dart.db` 공시 26,551건 분류 동일, 통계·횡단면 시뮬 40 시드
|
|
92
|
+
NaN 포함 동일.
|
|
93
|
+
2. **판정하지 않는다.** 통계 함수는 숫자를 리포트할 뿐 `PASS`/`FAIL` 을 돌려주지 않는다
|
|
94
|
+
(테스트가 강제). 합격선은 사전등록 문서에 있어야 한다.
|
|
95
|
+
3. **모르는 건 모른다고 적는다.** 시장가 `trde_tp` 는 `"03"`/`"3"` 둘 중 무엇인지 실호출로
|
|
96
|
+
확인된 적이 없어 `TRDE_TP_MARKET_VERIFIED = False` 로 둔다. 2025 이전 거래세 단계는
|
|
97
|
+
2차 출처만 있다고 docstring 에 적었다.
|
|
98
|
+
4. **토큰은 공유 자원이다.** 두 실매매 프로세스가 같은 앱키를 쓴다. 연결 해제 시 토큰을
|
|
99
|
+
폐기하면 다른 프로세스가 죽는다(`kiwoom_spec.TOKEN_SHARING_WARNING`).
|
|
100
|
+
|
|
101
|
+
## 가격제한폭 — 실측 대조
|
|
102
|
+
|
|
103
|
+
`daily_bars`(2023-02 이후)에서 고가·저가가 기준가 ±29~31% 인 행에 후보 규칙을 대조했다.
|
|
104
|
+
|
|
105
|
+
| 규칙 | 규칙끼리 갈리는 행에서 적중 |
|
|
106
|
+
|---|---|
|
|
107
|
+
| 상한가 = ⌊기준가×1.3 을 **그 가격대** 틱⌋ | **1,211** |
|
|
108
|
+
| 상한가 = 기준가 + ⌊기준가×0.3 을 기준가 틱⌋ | 165 |
|
|
109
|
+
| 하한가 = ⌈기준가×0.7 을 그 가격대 틱⌉ (대칭식) | 25 |
|
|
110
|
+
| 하한가 = 기준가 − ⌊기준가×0.3 을 **기준가** 틱⌋ | **105** |
|
|
111
|
+
|
|
112
|
+
즉 상한가와 하한가는 **대칭이 아니다**.
|
|
113
|
+
|
|
114
|
+
## 거래세 스케줄 (매도 시)
|
|
115
|
+
|
|
116
|
+
| 시행일 | KOSPI 거래세 + 농특세 | KOSDAQ |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| 2026-01-01 | 0.05% + 0.15% = 0.20% | 0.20% |
|
|
119
|
+
| 2025-01-01 | 0.00% + 0.15% = 0.15% | 0.15% |
|
|
120
|
+
| 2024-01-01 | 0.03% + 0.15% = 0.18% | 0.18% |
|
|
121
|
+
| 2023-01-01 | 0.05% + 0.15% = 0.20% | 0.20% |
|
|
122
|
+
| 2021-01-01 | 0.08% + 0.15% = 0.23% | 0.23% |
|
|
123
|
+
| 2019-06-03 | 0.10% + 0.15% = 0.25% | 0.25% |
|
|
124
|
+
|
|
125
|
+
2026 개정은 시행령 개정 보도로 확인했고, 그 이전 단계는 2차 출처다. 법령 원문으로 확인되면
|
|
126
|
+
이 표를 갱신한다.
|
|
127
|
+
|
|
128
|
+
## 개발
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
uv sync --extra dev
|
|
132
|
+
uv run pytest -q # 437 tests
|
|
133
|
+
uv run ruff check src tests
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
태그 `v*` 를 푸시하면 `publish.yml` 이 PyPI 로 올린다(trusted publishing 설정 후).
|
|
137
|
+
|
|
138
|
+
## 로드맵
|
|
139
|
+
|
|
140
|
+
- **v0.2** 키움 주문 HTTP 클라이언트 통합 — 지금은 scalp-it(원시 httpx)과 daytrade-it
|
|
141
|
+
(kiwoom-client 기반 `KiwoomBroker`)이 서로 다른 주문 스택을 쓴다. 가드·스펙은 공유했고
|
|
142
|
+
전송 계층은 실주문 대조 뒤에 합친다.
|
|
143
|
+
- scalp-it `RiskGuard` 의 킬 판정을 `KillSwitch` 로 위임(대조 테스트는 이미 있음).
|
|
144
|
+
- 이벤트 기반 일중 백테스트 엔진(틱·호가 재생 + `fills` + `costs`).
|
|
145
|
+
- PyPI 릴리스.
|
|
146
|
+
|
|
147
|
+
## 라이선스
|
|
148
|
+
|
|
149
|
+
Apache-2.0
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# krx-quant-core
|
|
2
|
+
|
|
3
|
+
**한국 주식(KOSPI·KOSDAQ) 퀀트 공통 코어.** 호가단위·가격제한폭·세션 규칙, 일자별
|
|
4
|
+
증권거래세 비용모델, 키움 주문 가드, DART 중대공시 분류, 킬스위치, 체결 시뮬레이션,
|
|
5
|
+
Deflated Sharpe·purged CV 검증 통계를 한 패키지로 묶었다.
|
|
6
|
+
|
|
7
|
+
전략은 여기 없다. 전략을 가진 레포들이 **같은 시장 규칙과 같은 비용 숫자**를 쓰게 하는
|
|
8
|
+
것이 이 패키지의 존재 이유다.
|
|
9
|
+
|
|
10
|
+
| 소비자 | 매매 스타일 | 실행 | 이 패키지에서 쓰는 것 |
|
|
11
|
+
|---|---|---|---|
|
|
12
|
+
| [scalp-it](https://github.com/younghwan91) (비공개) | 스캘핑 | 자동 실주문 | 호가·상한가·주문 가드·호가 스윕·체결 규칙·호스트 가드 |
|
|
13
|
+
| [daytrade-it](https://github.com/younghwan91) (비공개) | 데이트레이딩 | 자동 실주문 | 비용모델·공시 리스크 게이트·DART DB·코드 정규화·호스트 가드 |
|
|
14
|
+
| [swing-it](https://github.com/younghwan91/swing-it) | 스윙 | 리서치 + 수동 체결 | DSR·purged CV·부트스트랩·취약성 진단·횡단면 시뮬 |
|
|
15
|
+
|
|
16
|
+
## 왜 따로 뺐나
|
|
17
|
+
|
|
18
|
+
세 레포가 같은 규칙을 각자 들고 있었고, 실제로 어긋나 있었다.
|
|
19
|
+
|
|
20
|
+
- `normalize_code` 가 두 레포에 **복붙**돼 있었다. 한쪽 옛 구현은 `0155E0` 을 `001550`
|
|
21
|
+
(완전히 다른 회사)으로 바꾸던 버그를 안고 있었다.
|
|
22
|
+
- 거래비용이 레포마다 `0.0023`·`0.0034`·`0.0064`·`50bp` 로 흩어져 있었고, 거래세가
|
|
23
|
+
2023→2024→2025→2026 에 네 번 바뀌었는데 일자별로 적용하는 코드가 **어디에도 없었다**.
|
|
24
|
+
- 체결 판정(`through`/`touch`)이 같은 레포 안에서도 알 수 없는 값을 받으면 한 곳은
|
|
25
|
+
through, 다른 곳은 touch 로 **반대로** 읽었다.
|
|
26
|
+
- 하한가 계산은 없었다. 대칭식으로 짜면 틀린다 — 실측 대조 결과는 아래.
|
|
27
|
+
|
|
28
|
+
## 설치
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install "krx-quant-core @ git+https://github.com/younghwan91/krx-quant-core@v0.1.1"
|
|
32
|
+
# PyPI 릴리스 전까지는 git 태그로 고정한다.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Python ≥ 3.11. 의존성은 `kiwoom-client`(호가단위 표의 정본), `numpy`, `pandas` 뿐이다.
|
|
36
|
+
|
|
37
|
+
## 모듈
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
krx_quant_core/
|
|
41
|
+
├── market/ 종목코드·Market, 호가단위, 상/하한가, KST 세션, 거래일 달력
|
|
42
|
+
├── costs/ 일자별 거래세 스케줄, KoreanCostModel(Decimal), round_trip_cost(float)
|
|
43
|
+
├── execution/ 키움 REST 주문 스펙, OrderIntent/OrderResult, OrderGuard(순수 가드)
|
|
44
|
+
├── risk/ DART 중대공시 분류·RiskGate, DartDisclosureDB, KillSwitch
|
|
45
|
+
├── backtest/ 호가 스윕 VWAP·왕복비용, 지정가 체결 규칙, 트레이드 원장 지표, 횡단면 시뮬
|
|
46
|
+
├── stats/ Deflated/Probabilistic Sharpe, t-haircut, purged walk-forward, 부트스트랩, 취약성
|
|
47
|
+
└── runtime/ 호스트 가드(백테스트는 simnode 에서만)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from datetime import date
|
|
52
|
+
from krx_quant_core.market import Market, limit_up_price, limit_down_price, shift_ticks
|
|
53
|
+
from krx_quant_core.costs import round_trip_cost, tax_rate
|
|
54
|
+
|
|
55
|
+
limit_up_price(24_250) # 31500
|
|
56
|
+
limit_down_price(239_000) # 167500.0
|
|
57
|
+
shift_ticks(49_950, 2) # Decimal('50100') — 밴드 경계를 넘어도 유효 호가
|
|
58
|
+
tax_rate(date(2025, 6, 2), Market.KOSPI).total # Decimal('0.0015')
|
|
59
|
+
round_trip_cost(date(2026, 9, 14), Market.KOSDAQ, slippage_one_way=0.0015) # 0.0053
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 설계 원칙
|
|
63
|
+
|
|
64
|
+
1. **이식은 수치 동일.** 소비 레포가 실매매일에 갈아탈 수 있어야 한다. 포트마다 원본
|
|
65
|
+
코드와 무작위 입력으로 대조했다 — 주문 가드 16,000건 사유 문자열 동일, 킬스위치
|
|
66
|
+
9,000 스텝 동일, 실제 `dart.db` 공시 26,551건 분류 동일, 통계·횡단면 시뮬 40 시드
|
|
67
|
+
NaN 포함 동일.
|
|
68
|
+
2. **판정하지 않는다.** 통계 함수는 숫자를 리포트할 뿐 `PASS`/`FAIL` 을 돌려주지 않는다
|
|
69
|
+
(테스트가 강제). 합격선은 사전등록 문서에 있어야 한다.
|
|
70
|
+
3. **모르는 건 모른다고 적는다.** 시장가 `trde_tp` 는 `"03"`/`"3"` 둘 중 무엇인지 실호출로
|
|
71
|
+
확인된 적이 없어 `TRDE_TP_MARKET_VERIFIED = False` 로 둔다. 2025 이전 거래세 단계는
|
|
72
|
+
2차 출처만 있다고 docstring 에 적었다.
|
|
73
|
+
4. **토큰은 공유 자원이다.** 두 실매매 프로세스가 같은 앱키를 쓴다. 연결 해제 시 토큰을
|
|
74
|
+
폐기하면 다른 프로세스가 죽는다(`kiwoom_spec.TOKEN_SHARING_WARNING`).
|
|
75
|
+
|
|
76
|
+
## 가격제한폭 — 실측 대조
|
|
77
|
+
|
|
78
|
+
`daily_bars`(2023-02 이후)에서 고가·저가가 기준가 ±29~31% 인 행에 후보 규칙을 대조했다.
|
|
79
|
+
|
|
80
|
+
| 규칙 | 규칙끼리 갈리는 행에서 적중 |
|
|
81
|
+
|---|---|
|
|
82
|
+
| 상한가 = ⌊기준가×1.3 을 **그 가격대** 틱⌋ | **1,211** |
|
|
83
|
+
| 상한가 = 기준가 + ⌊기준가×0.3 을 기준가 틱⌋ | 165 |
|
|
84
|
+
| 하한가 = ⌈기준가×0.7 을 그 가격대 틱⌉ (대칭식) | 25 |
|
|
85
|
+
| 하한가 = 기준가 − ⌊기준가×0.3 을 **기준가** 틱⌋ | **105** |
|
|
86
|
+
|
|
87
|
+
즉 상한가와 하한가는 **대칭이 아니다**.
|
|
88
|
+
|
|
89
|
+
## 거래세 스케줄 (매도 시)
|
|
90
|
+
|
|
91
|
+
| 시행일 | KOSPI 거래세 + 농특세 | KOSDAQ |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| 2026-01-01 | 0.05% + 0.15% = 0.20% | 0.20% |
|
|
94
|
+
| 2025-01-01 | 0.00% + 0.15% = 0.15% | 0.15% |
|
|
95
|
+
| 2024-01-01 | 0.03% + 0.15% = 0.18% | 0.18% |
|
|
96
|
+
| 2023-01-01 | 0.05% + 0.15% = 0.20% | 0.20% |
|
|
97
|
+
| 2021-01-01 | 0.08% + 0.15% = 0.23% | 0.23% |
|
|
98
|
+
| 2019-06-03 | 0.10% + 0.15% = 0.25% | 0.25% |
|
|
99
|
+
|
|
100
|
+
2026 개정은 시행령 개정 보도로 확인했고, 그 이전 단계는 2차 출처다. 법령 원문으로 확인되면
|
|
101
|
+
이 표를 갱신한다.
|
|
102
|
+
|
|
103
|
+
## 개발
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
uv sync --extra dev
|
|
107
|
+
uv run pytest -q # 437 tests
|
|
108
|
+
uv run ruff check src tests
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
태그 `v*` 를 푸시하면 `publish.yml` 이 PyPI 로 올린다(trusted publishing 설정 후).
|
|
112
|
+
|
|
113
|
+
## 로드맵
|
|
114
|
+
|
|
115
|
+
- **v0.2** 키움 주문 HTTP 클라이언트 통합 — 지금은 scalp-it(원시 httpx)과 daytrade-it
|
|
116
|
+
(kiwoom-client 기반 `KiwoomBroker`)이 서로 다른 주문 스택을 쓴다. 가드·스펙은 공유했고
|
|
117
|
+
전송 계층은 실주문 대조 뒤에 합친다.
|
|
118
|
+
- scalp-it `RiskGuard` 의 킬 판정을 `KillSwitch` 로 위임(대조 테스트는 이미 있음).
|
|
119
|
+
- 이벤트 기반 일중 백테스트 엔진(틱·호가 재생 + `fills` + `costs`).
|
|
120
|
+
- PyPI 릴리스.
|
|
121
|
+
|
|
122
|
+
## 라이선스
|
|
123
|
+
|
|
124
|
+
Apache-2.0
|