Files
easy_tdx_max/src/easy_tdx/models/stats.py
T
GitHubandClaude Opus 4.8 4dfd18050e fix: resolve all CI mypy (265→0) and ruff (26→0) errors
- pyproject.toml: add mypy overrides for pandas/tabulate/matplotlib stubs,
  disable strict checking for vendored MyTT library
- config.py: use cast() for dict[str, Any] .get() returns
- beichi.py: widen _calc_bi_force param to BI | XD, import XD
- backtest/cli.py: split combo/single strategy into separate typed variables
- backtest/combo.py: add bool_array() helper for numpy return types
- chanlun/analyser.py: type ignore for pandas row access, fix dict type arg
- unified.py: change fields param from object to Any
- ex/mac_client.py: add type args to list literals
- cli/cmd_offline.py: wrap int market as Market enum before API call
- cli/cmd_chanlun.py: fix dict type arg
- offline/write_*.py: explicit int() cast for struct.unpack returns
- MyTT.py: fix line-too-long comments, UP038 isinstance syntax
- tests: fix E712 (==False → ~mask), E741 (noqa), F841, import sorting
- ruff format applied across codebase

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:03:41 +08:00

73 lines
2.1 KiB
Python

"""验证市场概况模型。"""
from dataclasses import dataclass
@dataclass
class MarketStat:
"""全市场涨跌统计概况。"""
up_count: int # 上涨家数
down_count: int # 下跌家数
neutral_count: int # 平盘家数
suspended_count: int # 由 total-(up+down+neutral) 得到的残差项,近似表示停牌/未参与统计家数
total_count: int # 总计(包含停牌)
total_amount: float # 总成交额
total_volume: float # 总成交量
total_market_cap: float # 总市值(亿元),来自 880001 收盘价,÷100 得万亿
limit_up_count: int # 涨停家数,来自 880006 close
limit_down_count: int # 跌停家数,来自 880006 open
@dataclass
class FundFlow:
"""个股资金流向统计(基于 Tick 数据加权计算)。"""
# 流入项 (Buy)
super_in: float # 超大单流入 (>100万)
large_in: float # 大单流入 (>20万 且 <=100万)
medium_in: float # 中单流入 (>4万 且 <=20万)
small_in: float # 小单流入 (<=4万)
# 流出项 (Sell)
super_out: float
large_out: float
medium_out: float
small_out: float
@property
def main_net_inflow(self) -> float:
"""主力净流入 (超大单 + 大单)。"""
return (self.super_in + self.large_in) - (self.super_out + self.large_out)
@property
def total_net_inflow(self) -> float:
"""全单净流入。"""
return (self.super_in + self.large_in + self.medium_in + self.small_in) - (
self.super_out + self.large_out + self.medium_out + self.small_out
)
@dataclass
class HistoricalFundFlow:
"""历史日线资金流向条目。"""
year: int
month: int
day: int
# 金额项 (单位:元)
super_in: float
super_out: float
large_in: float
large_out: float
medium_in: float
medium_out: float
small_in: float
small_out: float
@property
def main_net_inflow(self) -> float:
"""当日主力净流入。"""
return (self.super_in + self.large_in) - (self.super_out + self.large_out)