young-stock-cli 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.
- young_stock_cli-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
- young_stock_cli-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- young_stock_cli-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- young_stock_cli-0.1.0/.github/workflows/ci.yml +32 -0
- young_stock_cli-0.1.0/.github/workflows/publish.yml +34 -0
- young_stock_cli-0.1.0/.gitignore +35 -0
- young_stock_cli-0.1.0/CHANGELOG.md +18 -0
- young_stock_cli-0.1.0/CODE_OF_CONDUCT.md +28 -0
- young_stock_cli-0.1.0/CONTRIBUTING.md +39 -0
- young_stock_cli-0.1.0/LICENSE +21 -0
- young_stock_cli-0.1.0/PKG-INFO +154 -0
- young_stock_cli-0.1.0/README.md +121 -0
- young_stock_cli-0.1.0/pyproject.toml +62 -0
- young_stock_cli-0.1.0/src/young_stock/__init__.py +3 -0
- young_stock_cli-0.1.0/src/young_stock/_core.py +1231 -0
- young_stock_cli-0.1.0/src/young_stock/cli.py +104 -0
- young_stock_cli-0.1.0/tests/test_cli.py +31 -0
- young_stock_cli-0.1.0/tests/test_core.py +20 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report a problem with young-stock-cli
|
|
4
|
+
title: "[BUG] "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**What happened**
|
|
9
|
+
A short description of the bug.
|
|
10
|
+
|
|
11
|
+
**Steps to reproduce**
|
|
12
|
+
1. Run `young ...`
|
|
13
|
+
2. ...
|
|
14
|
+
|
|
15
|
+
**Expected behavior**
|
|
16
|
+
What you expected to see.
|
|
17
|
+
|
|
18
|
+
**Environment**
|
|
19
|
+
- `young --version`:
|
|
20
|
+
- Python version:
|
|
21
|
+
- OS:
|
|
22
|
+
|
|
23
|
+
**Output / traceback**
|
|
24
|
+
```
|
|
25
|
+
paste here
|
|
26
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new feature or data source
|
|
4
|
+
title: "[FEAT] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Problem**
|
|
9
|
+
What problem would this solve?
|
|
10
|
+
|
|
11
|
+
**Proposed solution**
|
|
12
|
+
What would the CLI / API look like?
|
|
13
|
+
|
|
14
|
+
**Alternatives considered**
|
|
15
|
+
|
|
16
|
+
**Data source (if applicable)**
|
|
17
|
+
URL / endpoint / docs link, and whether it requires login.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## What
|
|
2
|
+
|
|
3
|
+
<!-- short description -->
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
<!-- problem being solved or motivation -->
|
|
8
|
+
|
|
9
|
+
## How tested
|
|
10
|
+
|
|
11
|
+
- [ ] `pytest` passes locally
|
|
12
|
+
- [ ] `ruff check .` passes
|
|
13
|
+
- [ ] Manual test: `young ...`
|
|
14
|
+
|
|
15
|
+
## Checklist
|
|
16
|
+
|
|
17
|
+
- [ ] Updated `CHANGELOG.md` if user-visible
|
|
18
|
+
- [ ] Updated README if behavior changed
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
18
|
+
- run: ruff check .
|
|
19
|
+
|
|
20
|
+
test:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
- run: pip install -e ".[dev]"
|
|
32
|
+
- run: pytest --cov=young_stock --cov-report=term-missing
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-python@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.12"
|
|
16
|
+
- run: pip install build
|
|
17
|
+
- run: python -m build
|
|
18
|
+
- uses: actions/upload-artifact@v4
|
|
19
|
+
with:
|
|
20
|
+
name: dist
|
|
21
|
+
path: dist/
|
|
22
|
+
|
|
23
|
+
publish:
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment: pypi
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/download-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
htmlcov/
|
|
15
|
+
.tox/
|
|
16
|
+
.mypy_cache/
|
|
17
|
+
|
|
18
|
+
# Virtual envs
|
|
19
|
+
.venv/
|
|
20
|
+
venv/
|
|
21
|
+
env/
|
|
22
|
+
|
|
23
|
+
# IDE
|
|
24
|
+
.vscode/
|
|
25
|
+
.idea/
|
|
26
|
+
*.swp
|
|
27
|
+
.DS_Store
|
|
28
|
+
|
|
29
|
+
# Project
|
|
30
|
+
.young_stock/
|
|
31
|
+
*.cast
|
|
32
|
+
.env
|
|
33
|
+
|
|
34
|
+
# Lock files (uv)
|
|
35
|
+
uv.lock
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-05-31
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial public release.
|
|
12
|
+
- `young a` — A-share after-hours dashboard (indices, ZT/DT pool, fund flow, sector boards).
|
|
13
|
+
- `young hk`, `young us`, `young global` — Hong Kong / US / global indices snapshots.
|
|
14
|
+
- `young indices`, `young zt-pool`, `young flow` — focused subcommands.
|
|
15
|
+
- `young cache-clear` — manage the local response cache.
|
|
16
|
+
- Eastmoney public endpoints (`push2.eastmoney.com`, `push2ex.eastmoney.com`) integrated, no login required.
|
|
17
|
+
- Built-in 7-day response cache (`~/.young_stock/cache/`).
|
|
18
|
+
- Rich terminal tables for human-friendly output.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to a positive environment:
|
|
15
|
+
|
|
16
|
+
- Demonstrating empathy and kindness toward other people
|
|
17
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
18
|
+
- Giving and gracefully accepting constructive feedback
|
|
19
|
+
- Accepting responsibility and apologising to those affected by our mistakes
|
|
20
|
+
|
|
21
|
+
## Enforcement
|
|
22
|
+
|
|
23
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
24
|
+
reported by opening a confidential issue or by contacting the project
|
|
25
|
+
maintainer.
|
|
26
|
+
|
|
27
|
+
This Code of Conduct is adapted from the
|
|
28
|
+
[Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for considering a contribution! This project welcomes pull requests, bug reports, and feature suggestions.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/AdvancingTitans/young-stock-cli.git
|
|
9
|
+
cd young-stock-cli
|
|
10
|
+
pip install -e ".[dev]"
|
|
11
|
+
pytest
|
|
12
|
+
ruff check .
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Pull requests
|
|
16
|
+
|
|
17
|
+
1. Fork → create a topic branch (`feat/...` or `fix/...`).
|
|
18
|
+
2. Add or update tests for your change.
|
|
19
|
+
3. Run `pytest` and `ruff check .` locally — CI runs both.
|
|
20
|
+
4. Open a PR with a clear description: what + why.
|
|
21
|
+
|
|
22
|
+
## Reporting bugs
|
|
23
|
+
|
|
24
|
+
Please include:
|
|
25
|
+
|
|
26
|
+
- `young --version`
|
|
27
|
+
- Python version (`python --version`)
|
|
28
|
+
- OS
|
|
29
|
+
- The exact command you ran and the full traceback / output.
|
|
30
|
+
|
|
31
|
+
## Code style
|
|
32
|
+
|
|
33
|
+
- `ruff` for linting and import sorting.
|
|
34
|
+
- Type hints encouraged but not required for small fixes.
|
|
35
|
+
- Keep functions focused; prefer composing small helpers.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
By contributing, you agree your contribution will be licensed under the MIT license.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AdvancingTitans
|
|
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.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: young-stock-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A-share (China stock market) after-hours CLI — no login, no scraping tricks, just data.
|
|
5
|
+
Project-URL: Homepage, https://github.com/AdvancingTitans/young-stock-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/AdvancingTitans/young-stock-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/AdvancingTitans/young-stock-cli/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/AdvancingTitans/young-stock-cli/blob/main/CHANGELOG.md
|
|
9
|
+
Author: AdvancingTitans
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: a-share,china,cli,eastmoney,finance,stock
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: click>=8.1
|
|
26
|
+
Requires-Dist: requests>=2.31
|
|
27
|
+
Requires-Dist: rich>=13.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest-cov>=4; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# young-stock-cli
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/young-stock-cli/)
|
|
37
|
+
[](https://pypi.org/project/young-stock-cli/)
|
|
38
|
+
[](https://github.com/AdvancingTitans/young-stock-cli/blob/main/LICENSE)
|
|
39
|
+
[](https://github.com/AdvancingTitans/young-stock-cli/actions/workflows/ci.yml)
|
|
40
|
+
[](https://pepy.tech/project/young-stock-cli)
|
|
41
|
+
|
|
42
|
+
> An A-share (China stock market) after-hours CLI that **just works** — no login, no API keys, no scraping tricks.
|
|
43
|
+
> Also covers HK & US indices and a global snapshot.
|
|
44
|
+
|
|
45
|
+
A single command (`young a`) prints a complete after-hours dashboard: major indices, limit-up (涨停) and limit-down pools, fund flow, and top sector boards. Everything pulls from Eastmoney's public endpoints, with a 7-day local cache so repeated calls during the same session don't hammer the server.
|
|
46
|
+
|
|
47
|
+
Born out of a real workflow: every trading day after close I wanted the same five numbers in one place without opening a browser or paying for a data terminal. So I packaged it.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install young-stock-cli
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Requires Python 3.10+.
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
young a # A-share after-hours dashboard (the main thing)
|
|
63
|
+
young hk # Hong Kong indices snapshot
|
|
64
|
+
young us # US indices snapshot
|
|
65
|
+
young global # A + HK + US in one view
|
|
66
|
+
young indices # A-share indices only
|
|
67
|
+
young zt-pool # limit-up (涨停) / limit-down / 炸板 pool
|
|
68
|
+
young flow # north-bound + main-capital fund flow
|
|
69
|
+
young a -d 20260530 # historical date (YYYYMMDD)
|
|
70
|
+
young a --refresh # bypass cache, force re-fetch
|
|
71
|
+
young --help
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example output (`young indices`)
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
A股主要指数 — 2026-05-30 收盘
|
|
78
|
+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┓
|
|
79
|
+
┃ 指数 ┃ 收盘 ┃ 涨跌幅 ┃ 成交额 ┃ 振幅 ┃
|
|
80
|
+
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━┩
|
|
81
|
+
│ 上证指数 │ 3,347.49 │ +0.62% │ 4,821亿 │ 1.18% │
|
|
82
|
+
│ 深证成指 │ 10,402.91 │ +0.95% │ 6,015亿 │ 1.42% │
|
|
83
|
+
│ 创业板指 │ 2,135.66 │ +1.21% │ 2,310亿 │ 1.68% │
|
|
84
|
+
│ 科创50 │ 1,028.74 │ +0.81% │ 412亿 │ 1.05% │
|
|
85
|
+
└─────────────────────────────┴───────────┴────────┴─────────┴──────────┘
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Why this exists
|
|
91
|
+
|
|
92
|
+
Most A-share data libraries either (a) require paid accounts, (b) break the moment a portal redesigns its DOM, or (c) ship hundreds of MB of dependencies for a one-off after-hours glance. This is a 1-file core, three runtime deps (`requests`, `click`, `rich`), opinionated output, and a single command that prints what a trader actually wants at 15:01.
|
|
93
|
+
|
|
94
|
+
It is also a foundation for analysis pipelines: every subcommand maps to a Python function in `young_stock._core`, so you can `from young_stock._core import get_zt_pool, get_fund_flow` and feed the dicts into your own notebook or LLM prompt.
|
|
95
|
+
|
|
96
|
+
## What's in the box
|
|
97
|
+
|
|
98
|
+
- **Eastmoney public endpoints** — no login, no token. The same endpoints the official web UI uses.
|
|
99
|
+
- **Smart caching** — `~/.young_stock/cache/`, 7-day TTL, auto-pruned. Pass `--refresh` to skip.
|
|
100
|
+
- **Trade-day awareness** — nearest-trade-day resolution including weekends and (best-effort) holidays.
|
|
101
|
+
- **Rich terminal tables** — readable on dark and light terminals.
|
|
102
|
+
- **Sector boards via browser fallback** — when Eastmoney's board API rate-limits, falls back to rendering the public web page (optional, requires a local browser engine).
|
|
103
|
+
|
|
104
|
+
## Library usage
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from young_stock._core import get_index, get_zt_pool, nearest_trade_date
|
|
108
|
+
|
|
109
|
+
date = nearest_trade_date()
|
|
110
|
+
print(get_index(date))
|
|
111
|
+
print(get_zt_pool(date))
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git clone https://github.com/AdvancingTitans/young-stock-cli.git
|
|
118
|
+
cd young-stock-cli
|
|
119
|
+
pip install -e ".[dev]"
|
|
120
|
+
pytest
|
|
121
|
+
ruff check .
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Roadmap
|
|
125
|
+
|
|
126
|
+
- [ ] Optional JSON output (`--json`) for piping into downstream tools.
|
|
127
|
+
- [ ] Built-in trading-calendar (公开节假日) for accurate non-trade-day skipping.
|
|
128
|
+
- [ ] Plugin hooks for additional data sources (THS, Sina).
|
|
129
|
+
- [ ] `young watch` — live ticker mode during trading hours.
|
|
130
|
+
|
|
131
|
+
PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT — see [LICENSE](LICENSE).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 中文说明
|
|
140
|
+
|
|
141
|
+
A 股盘后行情命令行工具。免登录、免 API key、免反爬技巧 — 一行命令把当日涨跌、涨停板、资金流向、板块榜全部打到终端。同时支持港股、美股指数和全球快照视图。
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install young-stock-cli
|
|
145
|
+
young a # A 股盘后总览(主命令)
|
|
146
|
+
young zt-pool # 涨停 / 跌停 / 炸板分析
|
|
147
|
+
young flow # 北向资金 + 主力资金流向
|
|
148
|
+
young global # 全球指数一屏
|
|
149
|
+
young a -d 20260530 --refresh # 指定日期 + 强制刷新
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
数据来源:东方财富公开行情接口(`push2.eastmoney.com` / `push2ex.eastmoney.com`),与官网网页同源。本地缓存 7 天,目录 `~/.young_stock/cache/`,可用 `young cache-clear` 清理。
|
|
153
|
+
|
|
154
|
+
适用人群:每天盘后想用一条命令看完五张图的开发者 / 量化研究者 / 自动化爱好者。欢迎 issue / PR。
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# young-stock-cli
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/young-stock-cli/)
|
|
4
|
+
[](https://pypi.org/project/young-stock-cli/)
|
|
5
|
+
[](https://github.com/AdvancingTitans/young-stock-cli/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/AdvancingTitans/young-stock-cli/actions/workflows/ci.yml)
|
|
7
|
+
[](https://pepy.tech/project/young-stock-cli)
|
|
8
|
+
|
|
9
|
+
> An A-share (China stock market) after-hours CLI that **just works** — no login, no API keys, no scraping tricks.
|
|
10
|
+
> Also covers HK & US indices and a global snapshot.
|
|
11
|
+
|
|
12
|
+
A single command (`young a`) prints a complete after-hours dashboard: major indices, limit-up (涨停) and limit-down pools, fund flow, and top sector boards. Everything pulls from Eastmoney's public endpoints, with a 7-day local cache so repeated calls during the same session don't hammer the server.
|
|
13
|
+
|
|
14
|
+
Born out of a real workflow: every trading day after close I wanted the same five numbers in one place without opening a browser or paying for a data terminal. So I packaged it.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install young-stock-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Requires Python 3.10+.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
young a # A-share after-hours dashboard (the main thing)
|
|
30
|
+
young hk # Hong Kong indices snapshot
|
|
31
|
+
young us # US indices snapshot
|
|
32
|
+
young global # A + HK + US in one view
|
|
33
|
+
young indices # A-share indices only
|
|
34
|
+
young zt-pool # limit-up (涨停) / limit-down / 炸板 pool
|
|
35
|
+
young flow # north-bound + main-capital fund flow
|
|
36
|
+
young a -d 20260530 # historical date (YYYYMMDD)
|
|
37
|
+
young a --refresh # bypass cache, force re-fetch
|
|
38
|
+
young --help
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Example output (`young indices`)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
A股主要指数 — 2026-05-30 收盘
|
|
45
|
+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┓
|
|
46
|
+
┃ 指数 ┃ 收盘 ┃ 涨跌幅 ┃ 成交额 ┃ 振幅 ┃
|
|
47
|
+
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━┩
|
|
48
|
+
│ 上证指数 │ 3,347.49 │ +0.62% │ 4,821亿 │ 1.18% │
|
|
49
|
+
│ 深证成指 │ 10,402.91 │ +0.95% │ 6,015亿 │ 1.42% │
|
|
50
|
+
│ 创业板指 │ 2,135.66 │ +1.21% │ 2,310亿 │ 1.68% │
|
|
51
|
+
│ 科创50 │ 1,028.74 │ +0.81% │ 412亿 │ 1.05% │
|
|
52
|
+
└─────────────────────────────┴───────────┴────────┴─────────┴──────────┘
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Why this exists
|
|
58
|
+
|
|
59
|
+
Most A-share data libraries either (a) require paid accounts, (b) break the moment a portal redesigns its DOM, or (c) ship hundreds of MB of dependencies for a one-off after-hours glance. This is a 1-file core, three runtime deps (`requests`, `click`, `rich`), opinionated output, and a single command that prints what a trader actually wants at 15:01.
|
|
60
|
+
|
|
61
|
+
It is also a foundation for analysis pipelines: every subcommand maps to a Python function in `young_stock._core`, so you can `from young_stock._core import get_zt_pool, get_fund_flow` and feed the dicts into your own notebook or LLM prompt.
|
|
62
|
+
|
|
63
|
+
## What's in the box
|
|
64
|
+
|
|
65
|
+
- **Eastmoney public endpoints** — no login, no token. The same endpoints the official web UI uses.
|
|
66
|
+
- **Smart caching** — `~/.young_stock/cache/`, 7-day TTL, auto-pruned. Pass `--refresh` to skip.
|
|
67
|
+
- **Trade-day awareness** — nearest-trade-day resolution including weekends and (best-effort) holidays.
|
|
68
|
+
- **Rich terminal tables** — readable on dark and light terminals.
|
|
69
|
+
- **Sector boards via browser fallback** — when Eastmoney's board API rate-limits, falls back to rendering the public web page (optional, requires a local browser engine).
|
|
70
|
+
|
|
71
|
+
## Library usage
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from young_stock._core import get_index, get_zt_pool, nearest_trade_date
|
|
75
|
+
|
|
76
|
+
date = nearest_trade_date()
|
|
77
|
+
print(get_index(date))
|
|
78
|
+
print(get_zt_pool(date))
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git clone https://github.com/AdvancingTitans/young-stock-cli.git
|
|
85
|
+
cd young-stock-cli
|
|
86
|
+
pip install -e ".[dev]"
|
|
87
|
+
pytest
|
|
88
|
+
ruff check .
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Roadmap
|
|
92
|
+
|
|
93
|
+
- [ ] Optional JSON output (`--json`) for piping into downstream tools.
|
|
94
|
+
- [ ] Built-in trading-calendar (公开节假日) for accurate non-trade-day skipping.
|
|
95
|
+
- [ ] Plugin hooks for additional data sources (THS, Sina).
|
|
96
|
+
- [ ] `young watch` — live ticker mode during trading hours.
|
|
97
|
+
|
|
98
|
+
PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT — see [LICENSE](LICENSE).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 中文说明
|
|
107
|
+
|
|
108
|
+
A 股盘后行情命令行工具。免登录、免 API key、免反爬技巧 — 一行命令把当日涨跌、涨停板、资金流向、板块榜全部打到终端。同时支持港股、美股指数和全球快照视图。
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pip install young-stock-cli
|
|
112
|
+
young a # A 股盘后总览(主命令)
|
|
113
|
+
young zt-pool # 涨停 / 跌停 / 炸板分析
|
|
114
|
+
young flow # 北向资金 + 主力资金流向
|
|
115
|
+
young global # 全球指数一屏
|
|
116
|
+
young a -d 20260530 --refresh # 指定日期 + 强制刷新
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
数据来源:东方财富公开行情接口(`push2.eastmoney.com` / `push2ex.eastmoney.com`),与官网网页同源。本地缓存 7 天,目录 `~/.young_stock/cache/`,可用 `young cache-clear` 清理。
|
|
120
|
+
|
|
121
|
+
适用人群:每天盘后想用一条命令看完五张图的开发者 / 量化研究者 / 自动化爱好者。欢迎 issue / PR。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "young-stock-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A-share (China stock market) after-hours CLI — no login, no scraping tricks, just data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "AdvancingTitans" }]
|
|
13
|
+
keywords = ["stock", "a-share", "china", "finance", "cli", "eastmoney"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"requests>=2.31",
|
|
29
|
+
"rich>=13.0",
|
|
30
|
+
"click>=8.1",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/AdvancingTitans/young-stock-cli"
|
|
35
|
+
Repository = "https://github.com/AdvancingTitans/young-stock-cli"
|
|
36
|
+
Issues = "https://github.com/AdvancingTitans/young-stock-cli/issues"
|
|
37
|
+
Changelog = "https://github.com/AdvancingTitans/young-stock-cli/blob/main/CHANGELOG.md"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
young = "young_stock.cli:cli"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=7",
|
|
45
|
+
"pytest-cov>=4",
|
|
46
|
+
"ruff>=0.4",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["src/young_stock"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
line-length = 110
|
|
54
|
+
target-version = "py310"
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = ["E", "F", "W", "I", "B", "UP"]
|
|
58
|
+
ignore = ["E501", "F402"]
|
|
59
|
+
|
|
60
|
+
[tool.pytest.ini_options]
|
|
61
|
+
testpaths = ["tests"]
|
|
62
|
+
addopts = "-v"
|