"""历史资金流向命令 (Category 22)。""" import struct from ..codec.volume import _decode_volume from ..models.enums import Market from ..models.stats import HistoricalFundFlow from .base import BaseCommand class GetHistoryFundFlowCmd(BaseCommand[list[HistoricalFundFlow]]): """获取历史日线资金流向序列。""" def __init__(self, market: Market, code: str, start: int, count: int) -> None: self.market = market self.code = code.encode("utf-8") self.start = start self.count = count def build_request(self) -> bytes: # Header (12 bytes) + Payload (28 bytes) = 40 bytes return struct.pack( " list[HistoricalFundFlow]: # 响应格式:9字节头 + 2字节数量 + 每条记录 36 字节 if len(body) < 11: return [] (num,) = struct.unpack("