# xths **Repository Path**: showmsg/xths ## Basic Information - **Project Name**: xths - **Description**: 童话顺 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-20 - **Last Updated**: 2026-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # easyths-order-api 同花顺策略委托服务。先登录拿到 token,再提交全局时间配置和委托任务。当前时间到达 `start` 后只检查交易客户端是否已启动,没有就打开。是否报单看 `trigger`。 委托记录里的 `response_time` 仍是空字符串。报单写进界面后 `status` 为 `submitted`,写不进去为 `failed`。还没有委托时,推送里的 `status` 与任务 `state` 相同。 需要 Python 3.12。代码使用了 3.12 才支持的泛型类写法。本机若直接执行 `python server.py`,可能会落到 3.7。 ## 配置 编辑项目根目录的 `config.toml`: ```toml [server] host = "127.0.0.1" port = 7088 [client] # 同花顺 xiadan.exe 路径 address = "C:/同花顺远航版/transaction/xiadan.exe" # 接口登录和同花顺客户端登录使用同一组账号、密码 account = "admin" password = "请填写密码" # token 有效小时数 token_hours = 12 # 同花顺里要切换到的账户名。留空表示用客户端当前账户 trade_account = "" [storage] database = "strategies.db" ``` `account`、`password`、`address` 必填。`account` 和 `password` 同时用于接口换 token,以及同花顺登录窗口里的账号和密码。`trade_account` 填写时,服务第一次连上同花顺会先查询账户再切换到该名称。 当前时间到达 `start` 后、尚未到 `trigger` 时,只检查同花顺进程是否存在。不存在就启动 `address`;出现登录窗口时填入 `account`、`password` 并点击登录,若弹出「是否继续」则点继续、是或确定。这段时间不报单。到达 `trigger` 后才开始报单,直到 `end`。 ## 启动 在项目目录双击或执行: ```bat run.bat ``` 脚本使用 Python 3.12 创建 `.venv`。已有环境若不是 3.12,会先删掉再重建,然后安装 `requirements.txt` 并启动服务。依赖已经装好时不会重复安装。 默认监听 `http://127.0.0.1:7088`。除登录外,其余接口都要带请求头: ```http Authorization: Bearer ``` 业务失败时响应体为: ```json { "message": "错误说明" } ``` 请求字段格式不合法时,FastAPI 返回 `422`,响应体是校验明细,不是上面的 `message`。 下面示例按 PowerShell 书写。先准备基地址,登录后把 token 留在 `$token`: ```powershell $base = "http://127.0.0.1:7088" $login = Invoke-RestMethod -Method Post -Uri "$base/api/login" -ContentType "application/json" -Body '{"account":"admin","password":"请填写密码"}' $token = $login.token $headers = @{ Authorization = "Bearer $token" } ``` ## 使用流程 1. `POST /api/login` 拿到 token。 2. `PUT /api/config` 写入全局策略时间。未配置时不能创建任务。 3. `POST /api/tasks` 提交股票任务,状态为 `pending`。 4. 后台同一时间只跑一条任务,按创建时间从早到晚取 `pending`。该任务会一直占住队列,直到变成 `done`、`failed` 或 `cancelled`。 5. 创建任务后连接 `GET /api/tasks/{task_id}/events`,服务会推送任务状态和已发出的委托。任务变为 `done`、`failed` 或 `cancelled` 后推送结束。未结束的任务可以 `DELETE` 取消。 服务重启时,最近一天内已经发出正式单、但还没达到自己 `max_retry` 的任务会回到 `pending` 并继续发送,不再受原来的 `end` 限制。一笔都没发出的任务不自动重跑。下单失败且说明不是窗口结束或重启中断的,保持 `failed`。 ## 公共约定 ### 时间 `start`、`trigger`、`end` 都是 9 位数字 `HHMMSSsss`,例如 `093000000` 表示 09:30:00.000。必须满足 `start <= trigger <= end`,且都落在同一天。 委托的 `inser_time` 也是这个格式,取实际发送时刻。`reff` 由「2 位前缀 + 发送时刻 `HHMMSS` + 当天 3 位递增序号」组成,例如 `AB093015001`。当天序号超过 999 后不再发单。 ### 任务状态 | state | 含义 | | --- | --- | | `pending` | 已入库,等待执行 | | `running` | 正在按时间窗口发单 | | `done` | 本轮已结束 | | `failed` | 发单失败或服务重启中断 | | `cancelled` | 调用方取消 | ### 探单模式 `skip_probe` | 值 | 行为 | | --- | --- | | `0` | 到达 `trigger` 后只发探单,不发正式单。次数为 `probe_count`。两次间隔取 `probe_interval_ms` 和任务 `ack_wait_ms` 的较大值 | | `1` | 跳过探单。到达 `trigger` 后按批次发正式单,直到 `max_retry` 或 `end` | | `2` | 到达 `trigger` 后先发探单,发满 `probe_count` 即停。探单间隔只用 `probe_interval_ms`。然后发正式单,规则同 `1` | | `3` | 探单规则同 `2`。正式单规则同 `1` | 正式单在 `end` 之前、且该任务已发送笔数未达到自己的 `max_retry` 时持续发送。发够的任务单独结束,其他任务继续。已过 `end` 仍未发够的任务先记为 `done`,说明里带已发送笔数,例如「已到结束时间,已发送9/999」。下次启动服务会把这种任务接着发完。还没发送过的记为「已过结束时间,未发送」,重启不会自动重发。 正式单按批次发送。一批最多 `batch_size` 笔,并且不超过该任务剩余的 `max_retry`。`max_retry` 是这个任务的总笔数。同一批里相邻两笔间隔该任务的 `retry_interval_ms`。`ack_wait_ms` 从该任务这一批发完时算起,只限制它自己的下一批;这段时间里可以发送其他任务。 同一窗口里有多条任务时,按创建先后轮流,每次各发一批。例如 task_A 为 `max_retry=100`、`batch_size=10`,task_B 为 `max_retry=1`、`batch_size=1`:先发 10 笔 A,接着发 1 笔 B,中间不等 A 的 `ack_wait_ms`。再次发 A 之前,必须已经离开上一批 A 至少 A 的 `ack_wait_ms`。A 继续按每批 10 笔发送,直到发满 100 笔或到达 `end`。 买入后如果弹出标题为「提示」、内容包含「可用余额不够」的对话框,或卖出后弹出内容包含「股票余额不足」的同类提示(例如「提交失败: 股票余额不足,不允许卖空。」),会点掉「确定」,并把该任务记为 `failed`。这个任务不再继续,重启也不会自动重发。同一窗口里的其他任务仍按原顺序发送。 ### 下单方向与价格 `direction` 接受 `buy` / `b` / `买入` / `1`,或 `sell` / `s` / `卖出` / `2`。 `order_type` 为 `market`、`mkt`、`市价`(英文不区分大小写)时走市价,`price` 可省略。其他取值走限价,必须带 `price`,下单时使用这个价格。 `volume`:代码以 `11` 或 `12` 开头按可转债处理,必须是 10 的倍数且不小于 10;其余代码必须是 100 的倍数且不小于 100。 ## REST 接口 ### POST /api/login 登录。不需要 token。 请求: | 字段 | 类型 | 说明 | | --- | --- | --- | | `account` | string | 与 `config.toml` 的 `[client].account` 一致 | | `password` | string | 与 `config.toml` 的 `[client].password` 一致 | ```json { "account": "admin", "password": "请填写密码" } ``` 成功 `200`: | 字段 | 类型 | 说明 | | --- | --- | --- | | `token` | string | 后续请求放在 `Authorization: Bearer` 后面 | | `expires_at` | string | 过期时间,形如 `2026-11-20 09:20:00` | ```json { "token": "0123456789abcdef0123456789abcdef", "expires_at": "2026-11-20 09:20:00" } ``` 失败 `401`:`{"message": "账号或密码错误"}`。 登录示例见上面的准备步骤。`$login.token` 是令牌,`$login.expires_at` 是过期时间。 ### PUT /api/config 写入或覆盖全局策略配置。全库只保留一份。 请求: | 字段 | 类型 | 约束 | 说明 | | --- | --- | --- | --- | | `name` | string | 1–64 字符 | 策略名称 | | `skip_probe` | int | 0–3 | 探单模式,见上文 | | `start` | string | `HHMMSSsss` | 到达后检查客户端,不存在就打开,此阶段不报单 | | `trigger` | string | `HHMMSSsss` | 到达后才开始报单 | | `end` | string | `HHMMSSsss` | 停止报单 | | `ref_prefix` | string | 2 位字母或数字 | 写入 `reff` 的前缀 | | `probe_count` | int | 1–999,默认 5 | 探单次数 | | `probe_interval_ms` | int | 0–600000 | 探单间隔(毫秒) | ```json { "name": "开盘策略", "skip_probe": 2, "start": "092500000", "trigger": "093000000", "end": "093005000", "ref_prefix": "AB", "probe_count": 5, "probe_interval_ms": 200 } ``` 成功 `200`,返回当前配置: | 字段 | 类型 | 说明 | | --- | --- | --- | | `name` | string | 策略名称 | | `skip_probe` | int | 探单模式 | | `start` | string | 开始时间 | | `trigger` | string | 触发时间 | | `end` | string | 结束时间 | | `ref_prefix` | string | 委托号前缀 | | `probe_count` | int | 探单次数 | | `probe_interval_ms` | int | 探单间隔(毫秒) | 失败:`400` 时间顺序不合法;`401` token 无效。字段格式不合法时由校验返回 `422`。 ```powershell $body = @{ name = "开盘策略"; skip_probe = 2 start = "092500000"; trigger = "093000000"; end = "093005000" ref_prefix = "AB"; probe_count = 5; probe_interval_ms = 200 } | ConvertTo-Json Invoke-RestMethod -Method Put -Uri "$base/api/config" -Headers $headers -ContentType "application/json" -Body $body ``` ### GET /api/config 读取当前全局配置。成功 `200`,字段与 `PUT /api/config` 的成功响应相同。 尚未配置时 `404`:`{"message": "尚未配置策略"}`。 ```powershell Invoke-RestMethod -Uri "$base/api/config" -Headers $headers ``` ### POST /api/tasks 创建一条委托任务。成功 `201`。 请求: | 字段 | 类型 | 约束 | 说明 | | --- | --- | --- | --- | | `task_id` | string | 1–64 字符,不能含空白 | 调用方给定的任务编号,不可重复 | | `symbol` | string | 6 位数字 | 证券代码 | | `direction` | string | 见上文方向取值 | 买入或卖出 | | `order_type` | string | 1–32 字符 | `market` / `mkt` / `市价` 为市价,其余为限价 | | `price` | number | 限价必填,大于 0 且不超过 10000;市价可省略 | 限价委托价格 | | `volume` | int | 大于 0,且满足手数规则 | 委托数量(股) | | `max_retry` | int | 1–999 | 正式单最多发送次数 | | `retry_interval_ms` | int | 0–600000 | 同一批内相邻两笔正式单的间隔(毫秒) | | `batch_size` | int | 1–999 | 每批笔数。多条任务时按批轮流 | | `ack_wait_ms` | int | 0–600000 | 同一任务两批之间的最短间隔(毫秒),不插在不同任务之间;探单模式 0 时也会参与探单间隔 | | `note` | string | 最多 200 字符,可省略 | 备注,缺省为空字符串 | ```json { "task_id": "task-000001-1", "symbol": "000001", "direction": "buy", "order_type": "limit", "price": 12.04, "volume": 100, "max_retry": 3, "retry_interval_ms": 300, "batch_size": 1, "ack_wait_ms": 500, "note": "开盘买入" } ``` 成功响应(任务对象): | 字段 | 类型 | 说明 | | --- | --- | --- | | `task_id` | string | 任务编号 | | `symbol` | string | 证券代码 | | `direction` | string | 提交时的方向原文 | | `order_type` | string | 提交时的委托类型原文 | | `price` | number \| null | 限价为委托价格,市价为 `null` | | `volume` | int | 数量 | | `max_retry` | int | 正式单上限 | | `retry_interval_ms` | int | 正式单间隔 | | `batch_size` | int | 分批大小 | | `ack_wait_ms` | int | 额外等待 | | `note` | string | 备注 | | `state` | string | 新建时为 `pending` | | `message` | string | 状态说明,新建时为空 | 失败:`400` 手数不合法;`401` token 无效;`409` 尚未配置策略,或 `task_id` 已存在。重复提交同一个 `task_id` 不会再次执行,响应说明为「任务已经存在或执行完毕」。 ```powershell $body = @{ task_id = "task-000001-1"; symbol = "000001"; direction = "buy"; order_type = "limit" price = 12.04; volume = 100; max_retry = 3; retry_interval_ms = 300; batch_size = 1 ack_wait_ms = 500; note = "开盘买入" } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "$base/api/tasks" -Headers $headers -ContentType "application/json" -Body $body ``` ### GET /api/tasks 列出当前账号最近 100 条任务,按创建时间倒序。 成功 `200`: ```json { "tasks": [ { "task_id": "task-000001-1", "symbol": "000001", "direction": "buy", "order_type": "limit", "price": 12.04, "volume": 100, "max_retry": 3, "retry_interval_ms": 300, "batch_size": 1, "ack_wait_ms": 500, "note": "开盘买入", "state": "pending", "message": "" } ] } ``` `tasks` 中每一项的字段与创建任务的成功响应相同。 ```powershell Invoke-RestMethod -Uri "$base/api/tasks" -Headers $headers ``` ### GET /api/tasks/{task_id} 查询单条任务。成功 `200`,响应体就是上面的任务对象。 任务不存在或不属于当前账号时 `404`:`{"message": "任务不存在"}`。 ```powershell Invoke-RestMethod -Uri "$base/api/tasks/task-000001-1" -Headers $headers ``` ### GET /api/tasks/{task_id}/events 订阅一条任务。请求头带 `Authorization: Bearer `。响应类型是 `text/event-stream`。任务状态变化,或一笔委托报出之后,推送一条 `task` 事件。客户端不用再轮询。 每条 `data` 都带有 `task_id`、`reff`、`status`: | 字段 | 类型 | 说明 | | --- | --- | --- | | `task_id` | string | 任务编号 | | `reff` | string | 最近一笔委托号。还没有委托时为 `""` | | `status` | string | 有委托时为该笔的 `submitted` 或 `failed`;还没有委托时与 `state` 相同 | | `symbol` | string | 证券代码 | | `direction` | string | 方向 | | `order_type` | string | 委托类型 | | `price` | number \| null | 最近一笔的价格;还没有委托时用任务价格 | | `volume` | int | 最近一笔的数量;还没有委托时用任务数量 | | `inser_time` | string | 最近一笔的发送时刻 `HHMMSSsss`,没有委托时为 `""` | | `response_time` | string | 柜台回报时间,目前仍为 `""` | | `state` | string | 任务状态:`pending`、`running`、`done`、`failed`、`cancelled` | | `message` | string | 任务说明。失败时是原因 | | `orders` | array | 该任务全部委托,字段与委托查询接口相同 | ```text event: task data: {"task_id":"buy-140555","reff":"TS140601001","status":"submitted","symbol":"000001","direction":"buy","order_type":"limit","price":12.1,"volume":100,"inser_time":"140601123","response_time":"","state":"running","message":"","orders":[{"task_id":"buy-140555","reff":"TS140601001","direction":"buy","order_type":"limit","price":12.1,"volume":100,"inser_time":"140601123","response_time":"","status":"submitted"}]} ``` 任务进入 `done`、`failed` 或 `cancelled` 后,服务推送最后一条并关闭连接。连接空闲时会发送以 `:` 开头的注释行,客户端应忽略。 任务不存在时 `404`。连接建立时如果任务已经结束,会立刻推送当前结果并关闭。 ### DELETE /api/tasks/{task_id} 取消任务,不物理删除。仅 `pending` 和 `running` 可以取消,取消后 `state` 为 `cancelled`,`message` 为「已取消」。 成功 `200`,响应体为更新后的任务对象。 失败:`404` 任务不存在;`409` 任务已是 `done` 或 `failed`,消息为「任务已结束,不能取消」。 ```powershell Invoke-RestMethod -Method Delete -Uri "$base/api/tasks/task-000001-1" -Headers $headers ``` ### GET /api/tasks/{task_id}/orders 查询某任务已发出的委托,按 `reff` 排序。 成功 `200`: | 字段 | 类型 | 说明 | | --- | --- | --- | | `orders` | array | 委托列表 | | `orders[].task_id` | string | 所属任务 | | `orders[].reff` | string | 委托号 | | `orders[].direction` | string | 方向 | | `orders[].order_type` | string | 委托类型 | | `orders[].price` | number \| null | 限价为委托价格,市价为 `null` | | `orders[].volume` | int | 数量 | | `orders[].inser_time` | string | 发送时刻 `HHMMSSsss` | | `orders[].response_time` | string | 柜台回报时间,目前为 `""` | | `orders[].status` | string \| null | `submitted` 表示已写进界面,`failed` 表示没有写进界面。旧记录可能为 `null` | ```json { "orders": [ { "task_id": "task-000001-1", "reff": "AB093000001", "direction": "buy", "order_type": "limit", "price": 12.04, "volume": 100, "inser_time": "093000123", "response_time": "", "status": "submitted" } ] } ``` 任务不存在时 `404`。 ```powershell Invoke-RestMethod -Uri "$base/api/tasks/task-000001-1/orders" -Headers $headers ``` ### GET /api/orders/{reff} 按委托号查询一笔。成功 `200`,响应体是上面 `orders` 数组中的单个对象。委托不存在,或不属于当前账号的任务时,`404`:`{"message": "委托不存在"}`。 ```powershell Invoke-RestMethod -Uri "$base/api/orders/AB093000001" -Headers $headers ``` ## 进程内客户端 `ths_api.ThsClient` 直接操作已登录的同花顺窗口,供 `server.py` 发单,也可以单独调用。界面操作在进程内串行执行。交易类方法提交后不等待柜台回报。 ```python from ths_api import ThsClient with ThsClient() as client: result = client.buy("000001", 11.00, 100) print(result["success"], result["message"], result["data"]) ``` `ThsClient(app_path=None, config=None)`:`app_path` 覆盖 `xiadan.exe` 路径;`config` 指定 TOML,默认读本目录 `config.toml`。`connect()` 失败会抛出 `RuntimeError`。 每次调用返回同一个信封: | 字段 | 类型 | 说明 | | --- | --- | --- | | `success` | bool | 是否成功 | | `status` | string | `completed` 或 `failed` | | `message` | string | 结果说明 | | `error_code` | string 或 null | 失败时的错误码 | | `current_used_account` | string 或 null | 当前使用账户,未确认过为 null | | `data` | object、array 或 null | 业务数据,见各方法 | | `timestamp` | string | 北京时间,秒级,如 `2026-11-19 21:20:00` | `error_code` 常见取值:`invalid_params`、`not_connected`、`client_rejected`、`ui_error`、`timeout`、`internal`。 手数与 REST 相同。限价和条件单的单笔金额不超过 1000 万元。价格:ETF、可转债等 `5` 或 `1` 开头的代码保留 3 位小数,其余 2 位。条件单和止盈止损的有效期只接受 `1`、`3`、`5`、`10`、`20`、`30` 天。 ### 交易 | 方法 | 入参 | `data` | | --- | --- | --- | | `buy(stock_code, price, quantity)` | 代码、价格(大于 0 且不超过 10000)、数量 | `{stock_code, price, quantity}` | | `sell(stock_code, price, quantity)` | 同买入 | 同买入 | | `market_buy(stock_code, quantity, execution_strategy=3)` | 成交策略 1–6 | `{stock_code, quantity, strategy}`,`strategy` 为实际用到的策略名称 | | `market_sell(stock_code, quantity, execution_strategy=3)` | 同市价买入 | 同市价买入 | | `fund_subscribe(fund_code, amount)` | 基金代码、申购金额(元,大于 0) | `{fund_code, fund_name, amount}` | | `cancel(stock_code=None, cancel_type="all")` | `cancel_type` 取 `all`、`buy`、`sell`;代码可空,空表示全部委托 | `{stock_code, cancel_type, cancelled_count}` | 成交策略编号:`1` 对手方最优,`2` 本方最优,`3` 五档即成剩撤,`4` 即成剩撤,`5` 全额成交或撤,`6` 五档即成剩转限。标的不支持所请求策略时,返回里的 `strategy` 为兜底策略名称。 ```python client.sell("000001", 11.20, 100) client.market_buy("000001", 100, execution_strategy=3) client.cancel(stock_code="000001", cancel_type="buy") client.fund_subscribe("510300", 1000) ``` ### 条件单与逆回购 | 方法 | 入参 | `data` | | --- | --- | --- | | `condition_buy(stock_code, target_price, quantity, expire_days=30)` | 触发价、数量、有效天数 | `{stock_code, target_price, quantity, expire_days}` | | `condition_sell(...)` | 同条件买入 | 同条件买入 | | `cancel_condition_orders(stock_code=None, order_type=None)` | `order_type` 取 `买入` 或 `卖出`,空表示不限 | `{stock_code, order_type, deleted_count}` | | `stop_loss(stock_code, stop_loss_percent, stop_profit_percent, quantity=None, expire_days=30)` | 止损、止盈百分比为大于 0 且不超过 100 的数,如 `3` 表示 3%。`quantity` 为空则卖出全部可卖持仓 | `{stock_code, stop_loss_percent, stop_profit_percent, quantity, expire_days}` | | `reverse_repo_buy(market, time_range, amount)` | `market` 为 `上海` 或 `深圳`;`time_range` 为 `1天期`、`2天期`、`3天期`、`4天期`、`7天期`;金额须为 1000 的倍数 | `{market, time_range, amount, annual_rate}`,利率为百分数值,如 `2.5` 表示 2.5% | ```python client.condition_buy("000001", 10.50, 100, expire_days=5) client.stop_loss("000001", 3, 5, quantity=100, expire_days=30) client.reverse_repo_buy("上海", "1天期", 1000) ``` ### 查询 无额外入参的方法:`account()`、`funds()`、`holdings()`、`condition_orders()`、`reverse_repo()`。`today_orders(stock_code=None)` 和 `today_trades(stock_code=None)` 可用代码过滤,不传则查全部。 `account()` 的 `data`: ```json { "available_accounts": [ { "account_name": "平安证券-王*明", "account_index": 1 } ] } ``` `funds()` 的 `data` 单位为元。客户端没有对应控件时该字段为 `null`: | 字段 | 说明 | | --- | --- | | `balance` | 资金余额 | | `frozen_amount` | 冻结金额 | | `market_value` | 股票市值 | | `total_assets` | 总资产 | | `available_amount` | 可用金额 | | `withdrawable_amount` | 可取金额 | | `holding_profit` | 持仓盈亏 | | `daily_profit` | 当日盈亏 | | `daily_profit_ratio` | 当日盈亏比(%) | `holdings()` 的 `data` 是数组,每项: | 字段 | 说明 | | --- | --- | | `stock_code` / `stock_name` | 证券代码、名称 | | `quantity` / `available_quantity` / `frozen_quantity` | 持仓、可用、冻结数量(股) | | `cost_price` / `current_price` | 参考成本价、当前价(元) | | `floating_profit` / `profit_ratio` | 浮动盈亏(元)、盈亏比例(%) | | `daily_profit` / `daily_profit_ratio` | 当日盈亏(元)、当日盈亏比(%) | | `market_value` / `position_ratio` | 最新市值(元)、仓位占比(%) | | `daily_bought` / `daily_sold` | 当日买入、卖出(股) | | `market` | 交易市场 | `today_orders()` 的 `data` 是数组,每项:`order_time`、`stock_code`、`stock_name`、`operation`(买入/卖出)、`remark`、`quantity`、`filled_quantity`、`price`、`avg_fill_price`、`cancelled_quantity`、`contract_no`、`market`。 `today_trades()` 的 `data` 是数组,每项:`trade_time`、`stock_code`、`stock_name`、`operation`、`quantity`、`price`、`amount`、`contract_no`、`trade_no`、`order_time`。 `condition_orders()` 的 `data` 是未触发条件单数组,每项:`status`、`condition_type`、`direction`、`target`、`trigger_condition`、`latest_price`、`change_ratio`、`order_detail`、`created_at`、`monitor_cycle`。 `reverse_repo()` 的 `data` 是利率数组,每项:`market`、`term`、`annual_rate`。 查询结果里的数值来自客户端文本。`--` 等占位会变成 `null`。 也可以用操作名直接调用,参数名与上表一致: ```python client.call("buy", stock_code="000001", price=11.0, quantity=100) client.call("account_switch", account_name="平安证券-王*明") ``` `account_switch` 的 `data` 为 `{previous_used_account}`。`account_name` 必须是 `account()` 返回的完整展示名。