mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 15:44:18 +08:00
feat: add board-summary and board-ranking CLI commands, bump to 1.3.1
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
c825515ee6
commit
280af9ecf5
@@ -68,6 +68,10 @@ easy-tdx board-list --type GN --table
|
|||||||
easy-tdx board-list --type HY --count 200
|
easy-tdx board-list --type HY --count 200
|
||||||
easy-tdx board-members 881001 --table
|
easy-tdx board-members 881001 --table
|
||||||
easy-tdx belong-board SZ 000001 --table
|
easy-tdx belong-board SZ 000001 --table
|
||||||
|
easy-tdx board-summary 881001 --table # 板块汇总(成交额/主力净流入/涨跌家数)
|
||||||
|
easy-tdx board-summary 881001 --members --table # 含成分股明细
|
||||||
|
easy-tdx board-ranking --type HY --top 10 --table # 行业板块排行
|
||||||
|
easy-tdx board-ranking --type GN --sort-by amount # 概念板块按成交额排行
|
||||||
```
|
```
|
||||||
|
|
||||||
### 资金 / 监控
|
### 资金 / 监控
|
||||||
@@ -112,6 +116,8 @@ easy-tdx ex tick HK_MAIN_BOARD 00700 --table # 港股分时
|
|||||||
| `transaction` | 逐笔成交 |
|
| `transaction` | 逐笔成交 |
|
||||||
| `board-list` | 板块列表(行业/概念/风格) |
|
| `board-list` | 板块列表(行业/概念/风格) |
|
||||||
| `board-members` | 板块成分股报价 |
|
| `board-members` | 板块成分股报价 |
|
||||||
|
| `board-summary` | 板块汇总(成交额、主力净流入、涨跌家数) |
|
||||||
|
| `board-ranking` | 板块涨跌幅排行榜(行业/概念排行) |
|
||||||
| `belong-board` | 个股所属板块 |
|
| `belong-board` | 个股所属板块 |
|
||||||
| `capital-flow` | 资金流向 |
|
| `capital-flow` | 资金流向 |
|
||||||
| `auction` | 集合竞价 |
|
| `auction` | 集合竞价 |
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "easy-tdx"
|
name = "easy-tdx"
|
||||||
version = "1.3.0"
|
version = "1.3.1"
|
||||||
description = "通达信 TCP 协议行情数据客户端,支持在线行情与离线本地数据读取"
|
description = "通达信 TCP 协议行情数据客户端,支持在线行情与离线本地数据读取"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import click
|
|||||||
|
|
||||||
from .cmd_admin import ping, version
|
from .cmd_admin import ping, version
|
||||||
from .cmd_auction import auction
|
from .cmd_auction import auction
|
||||||
from .cmd_board import belong_board, board_list, board_members
|
from .cmd_board import belong_board, board_list, board_members, board_ranking, board_summary
|
||||||
from .cmd_capital import capital_flow
|
from .cmd_capital import capital_flow
|
||||||
from .cmd_ex import ex
|
from .cmd_ex import ex
|
||||||
from .cmd_finance import f10, fund_flow
|
from .cmd_finance import f10, fund_flow
|
||||||
@@ -19,7 +19,7 @@ from .cmd_transaction import transaction
|
|||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(version="1.3.0", prog_name="easy-tdx")
|
@click.version_option(version="1.3.1", prog_name="easy-tdx")
|
||||||
def cli() -> None:
|
def cli() -> None:
|
||||||
"""easy-tdx -- 通达信行情数据 CLI(默认 JSON 输出,适合 Agent 使用)。
|
"""easy-tdx -- 通达信行情数据 CLI(默认 JSON 输出,适合 Agent 使用)。
|
||||||
|
|
||||||
@@ -48,6 +48,8 @@ cli.add_command(transaction)
|
|||||||
cli.add_command(auction)
|
cli.add_command(auction)
|
||||||
cli.add_command(board_list)
|
cli.add_command(board_list)
|
||||||
cli.add_command(board_members)
|
cli.add_command(board_members)
|
||||||
|
cli.add_command(board_ranking)
|
||||||
|
cli.add_command(board_summary)
|
||||||
cli.add_command(belong_board)
|
cli.add_command(belong_board)
|
||||||
cli.add_command(capital_flow)
|
cli.add_command(capital_flow)
|
||||||
cli.add_command(unusual)
|
cli.add_command(unusual)
|
||||||
|
|||||||
@@ -104,3 +104,93 @@ def belong_board(market: str, code: str, use_table: bool, output_fmt: str) -> No
|
|||||||
with get_mac_client() as client:
|
with get_mac_client() as client:
|
||||||
df = client.get_belong_board(mkt, code)
|
df = client.get_belong_board(mkt, code)
|
||||||
print_output(df, fmt)
|
print_output(df, fmt)
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("board-summary")
|
||||||
|
@click.argument("board_symbol")
|
||||||
|
@click.option(
|
||||||
|
"--sort", "sort_field", default="CHANGE_PCT", help="排序字段: CHANGE_PCT/CODE/PRICE/VOLUME"
|
||||||
|
)
|
||||||
|
@click.option("--order", "sort_order", default="DESC", help="排序方向: DESC/ASC")
|
||||||
|
@click.option("--members", "show_members", is_flag=True, help="输出成分股明细而非汇总")
|
||||||
|
@click.option("--table", "use_table", is_flag=True, help="表格输出")
|
||||||
|
@click.option("--output", "output_fmt", type=click.Choice(["json", "table", "csv"]), default="json")
|
||||||
|
def board_summary(
|
||||||
|
board_symbol: str,
|
||||||
|
sort_field: str,
|
||||||
|
sort_order: str,
|
||||||
|
show_members: bool,
|
||||||
|
use_table: bool,
|
||||||
|
output_fmt: str,
|
||||||
|
) -> None:
|
||||||
|
"""获取板块汇总(成交额、主力净流入、涨跌家数)。
|
||||||
|
|
||||||
|
BOARD_SYMBOL: 板块代码(如 881001)
|
||||||
|
|
||||||
|
示例:
|
||||||
|
|
||||||
|
easy-tdx board-summary 881001 --table
|
||||||
|
|
||||||
|
easy-tdx board-summary 881001 --members --table
|
||||||
|
|
||||||
|
easy-tdx board-summary 881001 --sort VOLUME --order ASC
|
||||||
|
"""
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
from .conn import get_mac_client
|
||||||
|
from .output import print_output
|
||||||
|
from .parsers import parse_sort_order, parse_sort_type
|
||||||
|
|
||||||
|
fmt = "table" if use_table else output_fmt
|
||||||
|
st = parse_sort_type(sort_field)
|
||||||
|
so = parse_sort_order(sort_order)
|
||||||
|
with get_mac_client() as client:
|
||||||
|
result = client.get_board_summary(board_symbol, sort_type=st, sort_order=so)
|
||||||
|
|
||||||
|
if show_members:
|
||||||
|
members_df: pd.DataFrame = result["members"]
|
||||||
|
print_output(members_df, fmt)
|
||||||
|
else:
|
||||||
|
summary = {k: v for k, v in result.items() if k != "members"}
|
||||||
|
df = pd.DataFrame([summary])
|
||||||
|
print_output(df, fmt)
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("board-ranking")
|
||||||
|
@click.option("--type", "board_type", default="HY", help="板块类型: HY/GN")
|
||||||
|
@click.option("--top", "top_n", default=10, type=int, help="排行数量(默认 10)")
|
||||||
|
@click.option(
|
||||||
|
"--sort-by",
|
||||||
|
default="change_pct",
|
||||||
|
help="排序字段: change_pct/amount/main_net_amount/vol",
|
||||||
|
)
|
||||||
|
@click.option("--asc", is_flag=True, help="升序(默认降序)")
|
||||||
|
@click.option("--table", "use_table", is_flag=True, help="表格输出")
|
||||||
|
@click.option("--output", "output_fmt", type=click.Choice(["json", "table", "csv"]), default="json")
|
||||||
|
def board_ranking(
|
||||||
|
board_type: str,
|
||||||
|
top_n: int,
|
||||||
|
sort_by: str,
|
||||||
|
asc: bool,
|
||||||
|
use_table: bool,
|
||||||
|
output_fmt: str,
|
||||||
|
) -> None:
|
||||||
|
"""获取板块涨跌幅排行榜(行业/概念排行)。
|
||||||
|
|
||||||
|
示例:
|
||||||
|
|
||||||
|
easy-tdx board-ranking --table
|
||||||
|
|
||||||
|
easy-tdx board-ranking --type GN --top 20 --table
|
||||||
|
|
||||||
|
easy-tdx board-ranking --type HY --sort-by amount --asc
|
||||||
|
"""
|
||||||
|
from .conn import get_mac_client
|
||||||
|
from .output import print_output
|
||||||
|
from .parsers import parse_board_type
|
||||||
|
|
||||||
|
fmt = "table" if use_table else output_fmt
|
||||||
|
bt = parse_board_type(board_type)
|
||||||
|
with get_mac_client() as client:
|
||||||
|
df = client.get_board_ranking(board_type=bt, top_n=top_n, sort_by=sort_by, ascending=asc)
|
||||||
|
print_output(df, fmt)
|
||||||
|
|||||||
Reference in New Issue
Block a user