fix(cli): 价格按品种小数位显示 + 分时时间列改真实时钟 (0.6.8) (#10)

* fix(cli): price decimals per instrument + minute time column

1) 价格按品种小数位显示:可转债 128.892 原被 %8.2f 截成 128.89;
   新增 _price_fmt/_display_dp,宽度随小数位走(%8.2f -> %9.3f)不破坏对齐。
   可转债(沪 110/111/113/118、深 123/127/128)解码是 4 位但报价步长 0.001,
   显示降到 3 位;ETF 3 位、国债/回购 4 位、股票/指数 2 位沿用 price_decimal_digits。
2) tdx minute 时间列原按序号推算(i//60, i%60)打印成 00:00~03:59,
   改用 MinuteBar.hour/minute。
3) cmd_transactions/cmd_minute 改调 get_ticks/get_minutes,消掉 DeprecationWarning。
新增 tests/test_cli_format.py(8 项);全量 354 passed。

* chore: release 0.6.8(CLI 价格小数位 + 分时时间列修复)

- 版本号 0.6.7 -> 0.6.8(pyproject / __init__.py / uv.lock / CHANGELOG 四处对齐)
- CHANGELOG:`[未发布]` -> `[0.6.8] - 2026-10-23`
- docs/cli.md:补「价格小数位按品种适配」对照表 + `tdx minute` 时间列说明

功能改动见 cd8227f(CLI 价格按品种小数位显示、分时时间列改真实时钟、
cmd_transactions/cmd_minute 改调 get_ticks/get_minutes 消 DeprecationWarning)。

实测 `tdx minute sh113708` -> 时间 09:30 起、价格 127.631(3 位);
`tdx transactions sh113708` -> 11:29:47 / 127.141 / 44 手 / 买(4笔)。

测试 354 全通过(310 + 16 + 23 + 5)。

---------

Co-authored-by: openbot-coder <openbot-coder@users.noreply.github.com>
This commit is contained in:
openbotandopenbot-coder authored and GitHub committed 2026-10-23 12:18:23 +08:00
1 parent 8a78156145
commit dc78d81be8
7 files changed
+168 -6

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ from .models import (
XdxrRecord,
)
__version__ = "0.6.7"
__version__ = "0.6.8"
__all__ = [
"TdxData",
"Market",
+3 -3
View File
@@ -162,9 +162,9 @@ def _print_quote(q) -> None:
print("=" * 58)
label = "%s %s" % (mkt, q.code) if mkt else "%s %s" % (q.code, q.server_time or datetime.now().strftime("%H:%M:%S"))
print(" %s" % label)
print((" 最新 %-10.*f 涨跌 %+8.*f (%+.2f%%)" % (dp, q.price, dp, q.price - q.pre_close, pct)))
print((" 今开 %-10.*f 最高 %.*f 最低 %.*f" % (dp, q.open, dp, q.high, dp, q.low)))
print((" 昨收 %-10.*f 成交量 %s 成交额 %s" % (dp, q.pre_close, _fmt_num(q.vol), _fmt_num(q.amount))))
print(" 最新 %-10.*f 涨跌 %+8.*f (%+.2f%%)" % (dp, q.price, dp, q.price - q.pre_close, pct))
print(" 今开 %-10.*f 最高 %.*f 最低 %.*f" % (dp, q.open, dp, q.high, dp, q.low))
print(" 昨收 %-10.*f 成交量 %s 成交额 %s" % (dp, q.pre_close, _fmt_num(q.vol), _fmt_num(q.amount)))
if q.bid and q.ask:
print(" " + "-" * 56)
pf = _price_fmt(dp)