mirror of
https://ghfast.top/https://github.com/aeroxw/easy-tdx.git
synced 2026-09-12 14:34:15 +08:00
- Add MacClient/AsyncMacClient with full MAC protocol support (quotes, kline with adjustment, tick charts, transactions, boards, capital flow, auction, unusual, symbol info, server info) - Add MacExClient/AsyncMacExClient for extended markets (HK, US, futures) - Add UnifiedTdxClient auto-routing between A-share and extended markets - Add `easy-tdx` CLI tool with JSON default output, Agent-friendly - Add field bitmap protocol for custom quote field selection - Fix quote-list missing fields (default to BASIC+VOLUME preset) - Add config.py with centralized host management and auto-discovery - Add 50+ examples covering all APIs (01-20) - Rewrite README with CLI-first, Agent-friendly documentation - Bump version to 1.1.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
"""K 线命令。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import click
|
|
|
|
|
|
@click.command()
|
|
@click.argument("market")
|
|
@click.argument("code")
|
|
@click.option(
|
|
"--period", default="DAILY", help="K线周期: DAILY/5MIN/15MIN/30MIN/60MIN/1MIN/WEEKLY/MONTHLY"
|
|
)
|
|
@click.option("--count", default=800, type=int, help="K线数量")
|
|
@click.option("--start", default=0, type=int, help="起始偏移(0=最新)")
|
|
@click.option("--adjust", default="NONE", help="复权: NONE/QFQ/HFQ")
|
|
@click.option("--table", "use_table", is_flag=True, help="表格输出")
|
|
@click.option("--output", "output_fmt", type=click.Choice(["json", "table", "csv"]), default="json")
|
|
def kline(
|
|
market: str,
|
|
code: str,
|
|
period: str,
|
|
count: int,
|
|
start: int,
|
|
adjust: str,
|
|
use_table: bool,
|
|
output_fmt: str,
|
|
) -> None:
|
|
"""获取 K 线数据。
|
|
|
|
示例:
|
|
|
|
easy-tdx kline SZ 000001
|
|
|
|
easy-tdx kline SH 600519 --adjust QFQ --count 30
|
|
|
|
easy-tdx kline SZ 000001 --period 5MIN --table
|
|
"""
|
|
from .conn import get_mac_client
|
|
from .output import print_output
|
|
from .parsers import parse_adjust, parse_market, parse_period
|
|
|
|
fmt = "table" if use_table else output_fmt
|
|
mkt = parse_market(market)
|
|
with get_mac_client() as client:
|
|
df = client.get_stock_kline(
|
|
mkt,
|
|
code,
|
|
period=parse_period(period),
|
|
start=start,
|
|
count=count,
|
|
adjust=parse_adjust(adjust),
|
|
)
|
|
print_output(df, fmt)
|