sec-core 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.
- sec_core-0.1.0/.gitignore +138 -0
- sec_core-0.1.0/LICENSE +21 -0
- sec_core-0.1.0/PKG-INFO +42 -0
- sec_core-0.1.0/README.md +33 -0
- sec_core-0.1.0/docs/superpowers/plans/2026-06-23-sec-core-extraction-publish-integration.md +384 -0
- sec_core-0.1.0/docs/superpowers/specs/2026-06-23-sec-core-market-data-schema-design.md +364 -0
- sec_core-0.1.0/pyproject.toml +25 -0
- sec_core-0.1.0/src/sec_core/__init__.py +3 -0
- sec_core-0.1.0/src/sec_core/market_data/__init__.py +66 -0
- sec_core-0.1.0/src/sec_core/market_data/codec.py +19 -0
- sec_core-0.1.0/src/sec_core/market_data/constants.py +11 -0
- sec_core-0.1.0/src/sec_core/market_data/message_ids.py +38 -0
- sec_core-0.1.0/src/sec_core/market_data/schemas.py +151 -0
- sec_core-0.1.0/src/sec_core/market_data/subjects.py +223 -0
- sec_core-0.1.0/src/sec_core/market_data/validators.py +43 -0
- sec_core-0.1.0/tests/test_codec.py +20 -0
- sec_core-0.1.0/tests/test_message_ids.py +31 -0
- sec_core-0.1.0/tests/test_schemas.py +34 -0
- sec_core-0.1.0/tests/test_subjects.py +79 -0
- sec_core-0.1.0/tests/test_validators.py +80 -0
- sec_core-0.1.0/uv.lock +146 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
98
|
+
__pypackages__/
|
|
99
|
+
|
|
100
|
+
# Celery stuff
|
|
101
|
+
celerybeat-schedule
|
|
102
|
+
celerybeat.pid
|
|
103
|
+
|
|
104
|
+
# SageMath parsed files
|
|
105
|
+
*.sage.py
|
|
106
|
+
|
|
107
|
+
# Environments
|
|
108
|
+
.env
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
sec_core-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chonglie
|
|
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.
|
sec_core-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sec-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Shared securities market-data protocol contracts
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: msgpack>=1.1.2
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# sec-core
|
|
11
|
+
|
|
12
|
+
`sec-core` 是证券行情消息协议核心包,提供 subject 构造/解析、schema 常量、payload 校验、`Nats-Msg-Id` 生成和 MessagePack 编解码。
|
|
13
|
+
|
|
14
|
+
安装:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv add sec-core
|
|
18
|
+
pip install sec-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
示例:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from sec_core.market_data.subjects import format_tick_subject
|
|
25
|
+
|
|
26
|
+
print(format_tick_subject("000001.SZ"))
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
输出:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
tick.v2.sz.000001
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
第一版支持:
|
|
36
|
+
|
|
37
|
+
- `tick.v2.{market}.{code}`
|
|
38
|
+
- `backfill.tick.v2.{market}.{code}`
|
|
39
|
+
- `kl.v1.1m.{market}.{code}`
|
|
40
|
+
- `backfill.kl.v1.1m.{market}.{code}`
|
|
41
|
+
|
|
42
|
+
本包不依赖 `xtquant`、`nats-py` 或 `pyarrow`。
|
sec_core-0.1.0/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# sec-core
|
|
2
|
+
|
|
3
|
+
`sec-core` 是证券行情消息协议核心包,提供 subject 构造/解析、schema 常量、payload 校验、`Nats-Msg-Id` 生成和 MessagePack 编解码。
|
|
4
|
+
|
|
5
|
+
安装:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv add sec-core
|
|
9
|
+
pip install sec-core
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
示例:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from sec_core.market_data.subjects import format_tick_subject
|
|
16
|
+
|
|
17
|
+
print(format_tick_subject("000001.SZ"))
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
输出:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
tick.v2.sz.000001
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
第一版支持:
|
|
27
|
+
|
|
28
|
+
- `tick.v2.{market}.{code}`
|
|
29
|
+
- `backfill.tick.v2.{market}.{code}`
|
|
30
|
+
- `kl.v1.1m.{market}.{code}`
|
|
31
|
+
- `backfill.kl.v1.1m.{market}.{code}`
|
|
32
|
+
|
|
33
|
+
本包不依赖 `xtquant`、`nats-py` 或 `pyarrow`。
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# sec-core Extraction, Publish, and Integration Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Build and publish the lightweight `sec-core` market-data protocol package, then migrate `securities_miniqmt` and `securities_lab` to consume it and verify real backfill E2E flows.
|
|
6
|
+
|
|
7
|
+
**Architecture:** `sec-core` owns protocol contracts only: subject formatting/parsing, schema constants, payload validation, message-id generation, and MessagePack codec. `securities_miniqmt` keeps xtdata download and NATS publishing, but imports protocol helpers from `sec_core`. `securities_lab` keeps Arrow conversion and storage, but imports subject parsing, required fields, schema validation, and codec helpers from `sec_core`.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Python 3.11+, uv, hatchling/setuptools, msgpack, pytest, NATS JetStream, MiniQMT xtdata.
|
|
10
|
+
|
|
11
|
+
## Global Constraints
|
|
12
|
+
|
|
13
|
+
- `sec-core` PyPI project name is `sec-core`.
|
|
14
|
+
- Python import name is `sec_core`.
|
|
15
|
+
- Repository path is `D:\Workspace\python_projects\securities_core`.
|
|
16
|
+
- `sec-core` first version is `0.1.0`.
|
|
17
|
+
- `sec-core` must not depend on `xtquant`, `nats-py`, or `pyarrow`.
|
|
18
|
+
- `sec-core` first release covers only protocol core, not Arrow schema or storage conversion.
|
|
19
|
+
- Consumer-facing docs are written in Chinese; code comments may be Chinese where useful; log/output text remains English in existing services.
|
|
20
|
+
- Real E2E evidence must include `securities_miniqmt` tick backfill, `securities_miniqmt` 1m backfill, and `securities_lab` consuming backfill prefixes for tick and 1m.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## File Structure
|
|
25
|
+
|
|
26
|
+
### `D:\Workspace\python_projects\securities_core`
|
|
27
|
+
|
|
28
|
+
- Create `pyproject.toml`: package metadata, hatchling backend, runtime dependency `msgpack`.
|
|
29
|
+
- Create `README.md`: install, quick examples, supported schemas.
|
|
30
|
+
- Create `src/sec_core/__init__.py`: package version export.
|
|
31
|
+
- Create `src/sec_core/market_data/__init__.py`: public market-data API exports.
|
|
32
|
+
- Create `src/sec_core/market_data/constants.py`: dataset/source/version constants.
|
|
33
|
+
- Create `src/sec_core/market_data/subjects.py`: stock-code parsing, subject formatting, prefix helpers, subject parsing.
|
|
34
|
+
- Create `src/sec_core/market_data/schemas.py`: field-type enum, field maps, required fields, schema version lookup.
|
|
35
|
+
- Create `src/sec_core/market_data/validators.py`: payload validation.
|
|
36
|
+
- Create `src/sec_core/market_data/message_ids.py`: `Nats-Msg-Id` helpers.
|
|
37
|
+
- Create `src/sec_core/market_data/codec.py`: MessagePack encode/decode.
|
|
38
|
+
- Create tests under `tests/` for every module above.
|
|
39
|
+
- Create `docs/reports/2026-06-23-sec-core-release-report.md`: final release and integration report.
|
|
40
|
+
|
|
41
|
+
### `D:\Workspace\python_projects\securities_miniqmt`
|
|
42
|
+
|
|
43
|
+
- Modify `pyproject.toml`: add `sec-core`.
|
|
44
|
+
- Modify protocol-adjacent code to import from `sec_core`:
|
|
45
|
+
- `src/miniqmt_nats/core/schema_version.py`
|
|
46
|
+
- `src/miniqmt_nats/core/subject_formatter.py`
|
|
47
|
+
- `src/miniqmt_nats/core/serializer.py`
|
|
48
|
+
- `src/miniqmt_nats/publisher/tick_publisher.py`
|
|
49
|
+
- `src/miniqmt_nats/kline/bar_publisher.py`
|
|
50
|
+
- Keep xtdata normalizers in this repo.
|
|
51
|
+
- Run unit tests and real `tests/integration/test_backfill_tick_e2e.py`, `tests/integration/test_backfill_kline_e2e.py`.
|
|
52
|
+
|
|
53
|
+
### `D:\Workspace\python_projects\securities_lab`
|
|
54
|
+
|
|
55
|
+
- Modify `pyproject.toml`: add `sec-core`.
|
|
56
|
+
- Modify `src/sec_lab/tick_msg_handlers/transformer.py`:
|
|
57
|
+
- Use `sec_core.market_data.subjects.parse_market_data_subject`.
|
|
58
|
+
- Use `sec_core.market_data.schemas` for required fields and field type constants where compatible.
|
|
59
|
+
- Use `sec_core.market_data.validators.validate_payload`.
|
|
60
|
+
- Keep Arrow schema and Arrow row conversion local.
|
|
61
|
+
- Modify message handlers that call `msgpack.unpackb` directly to use `sec_core.market_data.codec.decode_msgpack` where it improves consistency.
|
|
62
|
+
- Add integration tests proving `backfill.tick.v2` and `backfill.kl.v1.1m` prefixes are accepted and converted.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Task 1: Implement `sec-core` Package
|
|
67
|
+
|
|
68
|
+
**Files:**
|
|
69
|
+
- Create: `pyproject.toml`
|
|
70
|
+
- Create: `README.md`
|
|
71
|
+
- Create: `src/sec_core/__init__.py`
|
|
72
|
+
- Create: `src/sec_core/market_data/*.py`
|
|
73
|
+
- Create: `tests/test_*.py`
|
|
74
|
+
|
|
75
|
+
- [ ] **Step 1: Create package scaffold**
|
|
76
|
+
|
|
77
|
+
Create a src-layout project using hatchling:
|
|
78
|
+
|
|
79
|
+
```toml
|
|
80
|
+
[project]
|
|
81
|
+
name = "sec-core"
|
|
82
|
+
version = "0.1.0"
|
|
83
|
+
description = "Shared securities market-data protocol contracts"
|
|
84
|
+
readme = "README.md"
|
|
85
|
+
requires-python = ">=3.11"
|
|
86
|
+
dependencies = [
|
|
87
|
+
"msgpack>=1.1.2",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[build-system]
|
|
91
|
+
requires = ["hatchling"]
|
|
92
|
+
build-backend = "hatchling.build"
|
|
93
|
+
|
|
94
|
+
[tool.pytest.ini_options]
|
|
95
|
+
testpaths = ["tests"]
|
|
96
|
+
|
|
97
|
+
[dependency-groups]
|
|
98
|
+
dev = [
|
|
99
|
+
"pytest>=9.0.3",
|
|
100
|
+
]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- [ ] **Step 2: Add subject tests**
|
|
104
|
+
|
|
105
|
+
Test:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
def test_format_subjects():
|
|
109
|
+
assert format_tick_subject("000001.SZ") == "tick.v2.sz.000001"
|
|
110
|
+
assert format_backfill_tick_subject("000001.SZ") == "backfill.tick.v2.sz.000001"
|
|
111
|
+
assert format_kline_subject("000001.SZ") == "kl.v1.1m.sz.000001"
|
|
112
|
+
assert format_backfill_kline_subject("000001.SZ") == "backfill.kl.v1.1m.sz.000001"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Run:
|
|
116
|
+
|
|
117
|
+
```powershell
|
|
118
|
+
uv run pytest tests/test_subjects.py -q
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Expected before implementation: fails with missing modules.
|
|
122
|
+
|
|
123
|
+
- [ ] **Step 3: Implement subject helpers**
|
|
124
|
+
|
|
125
|
+
Implement:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
parse_stock_code()
|
|
129
|
+
format_tick_subject()
|
|
130
|
+
format_backfill_tick_subject()
|
|
131
|
+
format_kline_subject()
|
|
132
|
+
format_backfill_kline_subject()
|
|
133
|
+
normalize_subject_prefix()
|
|
134
|
+
wildcard_for_prefix()
|
|
135
|
+
subject_for_prefix()
|
|
136
|
+
parse_market_data_subject()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- [ ] **Step 4: Add schema and validator tests**
|
|
140
|
+
|
|
141
|
+
Cover required fields, schema version mismatch, period mismatch, and missing fields.
|
|
142
|
+
|
|
143
|
+
- [ ] **Step 5: Implement schema and validators**
|
|
144
|
+
|
|
145
|
+
Implement `FieldType`, field maps, required fields, `validate_tick_v2_payload()`, `validate_kline_1m_v1_payload()`, and `validate_payload()`.
|
|
146
|
+
|
|
147
|
+
- [ ] **Step 6: Add message-id and codec tests**
|
|
148
|
+
|
|
149
|
+
Cover all four message-id formats and MessagePack Decimal-to-string behavior.
|
|
150
|
+
|
|
151
|
+
- [ ] **Step 7: Implement message-id and codec helpers**
|
|
152
|
+
|
|
153
|
+
Use `msgpack.packb(payload, use_bin_type=True, default=str)` and `msgpack.unpackb(data, raw=False)`.
|
|
154
|
+
|
|
155
|
+
- [ ] **Step 8: Run package tests and build**
|
|
156
|
+
|
|
157
|
+
```powershell
|
|
158
|
+
uv run pytest -q
|
|
159
|
+
uv build
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Expected: tests pass and `dist/*.whl`, `dist/*.tar.gz` are created.
|
|
163
|
+
|
|
164
|
+
- [ ] **Step 9: Commit**
|
|
165
|
+
|
|
166
|
+
```powershell
|
|
167
|
+
git add pyproject.toml README.md src tests
|
|
168
|
+
git commit -m "feat: add market data protocol core"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Task 2: Publish `sec-core`
|
|
174
|
+
|
|
175
|
+
**Files:**
|
|
176
|
+
- Modify: release report after publishing.
|
|
177
|
+
|
|
178
|
+
- [ ] **Step 1: Verify PyPI project name**
|
|
179
|
+
|
|
180
|
+
Open or query `https://pypi.org/project/sec-core/`.
|
|
181
|
+
|
|
182
|
+
Expected before first release: 404 or no existing project owned by another account.
|
|
183
|
+
|
|
184
|
+
- [ ] **Step 2: Publish**
|
|
185
|
+
|
|
186
|
+
```powershell
|
|
187
|
+
uv publish
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
If PyPI token is not configured, stop and report the exact missing credential error.
|
|
191
|
+
|
|
192
|
+
- [ ] **Step 3: Verify install from a clean temp directory**
|
|
193
|
+
|
|
194
|
+
```powershell
|
|
195
|
+
$tmp = Join-Path $env:TEMP "sec-core-install-check"
|
|
196
|
+
Remove-Item -LiteralPath $tmp -Recurse -Force -ErrorAction SilentlyContinue
|
|
197
|
+
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
|
|
198
|
+
Set-Location $tmp
|
|
199
|
+
uv init --bare
|
|
200
|
+
uv add sec-core
|
|
201
|
+
uv run python -c "from sec_core.market_data.subjects import format_tick_subject; print(format_tick_subject('000001.SZ'))"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Expected:
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
tick.v2.sz.000001
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Task 3: Integrate `sec-core` into `securities_miniqmt`
|
|
213
|
+
|
|
214
|
+
**Files:**
|
|
215
|
+
- Modify: `pyproject.toml`
|
|
216
|
+
- Modify: `src/miniqmt_nats/core/schema_version.py`
|
|
217
|
+
- Modify: `src/miniqmt_nats/core/subject_formatter.py`
|
|
218
|
+
- Modify: `src/miniqmt_nats/core/serializer.py`
|
|
219
|
+
- Modify: `src/miniqmt_nats/publisher/tick_publisher.py`
|
|
220
|
+
- Modify: `src/miniqmt_nats/kline/bar_publisher.py`
|
|
221
|
+
- Modify tests only where imports or expected helper ownership changes.
|
|
222
|
+
|
|
223
|
+
- [ ] **Step 1: Add dependency**
|
|
224
|
+
|
|
225
|
+
```powershell
|
|
226
|
+
uv add sec-core
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- [ ] **Step 2: Replace duplicated helpers**
|
|
230
|
+
|
|
231
|
+
Use `sec_core.market_data` for:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
format_tick_subject
|
|
235
|
+
format_tick_versioned_subject
|
|
236
|
+
format_backfill_tick_subject
|
|
237
|
+
format_kline_subject
|
|
238
|
+
format_backfill_kline_subject
|
|
239
|
+
encode_msgpack
|
|
240
|
+
DEFAULT_TICK_SCHEMA_VERSION
|
|
241
|
+
DEFAULT_KLINE_SCHEMA_VERSION
|
|
242
|
+
validate_tick_v2_payload
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- [ ] **Step 3: Keep producer-only normalization local**
|
|
246
|
+
|
|
247
|
+
Do not move MiniQMT raw tick normalization or K-line row normalization into `sec-core` in this task.
|
|
248
|
+
|
|
249
|
+
- [ ] **Step 4: Run unit tests**
|
|
250
|
+
|
|
251
|
+
```powershell
|
|
252
|
+
uv run pytest tests/unit -q
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Expected: all unit tests pass.
|
|
256
|
+
|
|
257
|
+
- [ ] **Step 5: Run real backfill E2E tests**
|
|
258
|
+
|
|
259
|
+
```powershell
|
|
260
|
+
uv run pytest tests/integration/test_backfill_tick_e2e.py --run-e2e -v -s
|
|
261
|
+
uv run pytest tests/integration/test_backfill_kline_e2e.py --run-e2e -v -s
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Expected: both tests pass, writing to `BACKFILL_STREAM` and consuming `backfill.tick.v2.sz.000001` / `backfill.kl.v1.1m.sz.000001`.
|
|
265
|
+
|
|
266
|
+
- [ ] **Step 6: Commit**
|
|
267
|
+
|
|
268
|
+
```powershell
|
|
269
|
+
git add pyproject.toml uv.lock src tests
|
|
270
|
+
git commit -m "refactor: use sec-core market data contracts"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Task 4: Integrate `sec-core` into `securities_lab`
|
|
276
|
+
|
|
277
|
+
**Files:**
|
|
278
|
+
- Modify: `pyproject.toml`
|
|
279
|
+
- Modify: `src/sec_lab/tick_msg_handlers/transformer.py`
|
|
280
|
+
- Modify or add tests under `tests/`
|
|
281
|
+
|
|
282
|
+
- [ ] **Step 1: Add dependency**
|
|
283
|
+
|
|
284
|
+
```powershell
|
|
285
|
+
uv add sec-core
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
- [ ] **Step 2: Replace duplicated subject and validation logic**
|
|
289
|
+
|
|
290
|
+
Use `sec_core.market_data` for:
|
|
291
|
+
|
|
292
|
+
```python
|
|
293
|
+
parse_market_data_subject
|
|
294
|
+
normalize_subject_prefix
|
|
295
|
+
subject_for_prefix
|
|
296
|
+
wildcard_for_prefix
|
|
297
|
+
validate_payload
|
|
298
|
+
TICK_V2_REQUIRED_FIELDS
|
|
299
|
+
KLINE_1M_V1_REQUIRED_FIELDS
|
|
300
|
+
decode_msgpack
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
- [ ] **Step 3: Keep Arrow conversion local**
|
|
304
|
+
|
|
305
|
+
`securities_lab` keeps `pyarrow` schemas, `rows_to_arrow_table()`, and storage path logic.
|
|
306
|
+
|
|
307
|
+
- [ ] **Step 4: Add backfill prefix tests**
|
|
308
|
+
|
|
309
|
+
Add tests proving:
|
|
310
|
+
|
|
311
|
+
```python
|
|
312
|
+
convert_payload("backfill.tick.v2.sz.000001", tick_payload, tick_subject_prefix="backfill.tick.v2")
|
|
313
|
+
convert_payload("backfill.kl.v1.1m.sz.000001", kline_payload, kline_1m_subject_prefix="backfill.kl.v1.1m")
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
both succeed and produce the same dataset names as realtime prefixes.
|
|
317
|
+
|
|
318
|
+
- [ ] **Step 5: Add or run E2E backfill-prefix message test**
|
|
319
|
+
|
|
320
|
+
Use real or existing integration harness to consume messages by configured prefixes:
|
|
321
|
+
|
|
322
|
+
```powershell
|
|
323
|
+
$env:NATS_SUBJECT_PREFIXES="backfill.tick.v2,backfill.kl.v1.1m"
|
|
324
|
+
$env:NATS_TICK_SUBJECT_PREFIX="backfill.tick.v2"
|
|
325
|
+
$env:NATS_KLINE_1M_SUBJECT_PREFIX="backfill.kl.v1.1m"
|
|
326
|
+
uv run pytest tests/integration -q
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
If the existing integration suite is not safe to run globally, create a focused test for receiving and converting one tick and one 1m backfill message.
|
|
330
|
+
|
|
331
|
+
- [ ] **Step 6: Commit**
|
|
332
|
+
|
|
333
|
+
```powershell
|
|
334
|
+
git add pyproject.toml uv.lock src tests
|
|
335
|
+
git commit -m "refactor: use sec-core market data contracts"
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Task 5: Final Verification Report
|
|
341
|
+
|
|
342
|
+
**Files:**
|
|
343
|
+
- Create: `D:\Workspace\python_projects\securities_core\docs\reports\2026-06-23-sec-core-release-report.md`
|
|
344
|
+
|
|
345
|
+
- [ ] **Step 1: Collect evidence**
|
|
346
|
+
|
|
347
|
+
Record exact outputs for:
|
|
348
|
+
|
|
349
|
+
```powershell
|
|
350
|
+
# securities_core
|
|
351
|
+
uv run pytest -q
|
|
352
|
+
uv build
|
|
353
|
+
uv publish
|
|
354
|
+
uv add sec-core install check
|
|
355
|
+
|
|
356
|
+
# securities_miniqmt
|
|
357
|
+
uv run pytest tests/unit -q
|
|
358
|
+
uv run pytest tests/integration/test_backfill_tick_e2e.py --run-e2e -v -s
|
|
359
|
+
uv run pytest tests/integration/test_backfill_kline_e2e.py --run-e2e -v -s
|
|
360
|
+
|
|
361
|
+
# securities_lab
|
|
362
|
+
uv run pytest focused backfill-prefix tests
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
- [ ] **Step 2: Write report**
|
|
366
|
+
|
|
367
|
+
Report must include:
|
|
368
|
+
|
|
369
|
+
- Published `sec-core` version.
|
|
370
|
+
- PyPI URL.
|
|
371
|
+
- Commit ids for all modified repositories.
|
|
372
|
+
- MiniQMT tick backfill E2E result.
|
|
373
|
+
- MiniQMT 1m backfill E2E result.
|
|
374
|
+
- Securities Lab backfill tick prefix validation result.
|
|
375
|
+
- Securities Lab backfill 1m prefix validation result.
|
|
376
|
+
- Known limitations or skipped checks, if any.
|
|
377
|
+
|
|
378
|
+
- [ ] **Step 3: Commit report**
|
|
379
|
+
|
|
380
|
+
```powershell
|
|
381
|
+
git add docs/reports/2026-06-23-sec-core-release-report.md
|
|
382
|
+
git commit -m "docs: add sec-core release verification report"
|
|
383
|
+
```
|
|
384
|
+
|