alphasift 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alphasift/__init__.py +52 -0
- alphasift/__main__.py +7 -0
- alphasift/audit.py +191 -0
- alphasift/candidate_context.py +738 -0
- alphasift/cli.py +2797 -0
- alphasift/config.py +705 -0
- alphasift/context.py +672 -0
- alphasift/daily.py +1256 -0
- alphasift/daily_brief.py +593 -0
- alphasift/daily_report.py +1115 -0
- alphasift/daily_report_html.py +1257 -0
- alphasift/doctor.py +1123 -0
- alphasift/dsa.py +302 -0
- alphasift/dsa_adapter.py +178 -0
- alphasift/dsa_provider.py +192 -0
- alphasift/evaluate.py +2418 -0
- alphasift/filter.py +517 -0
- alphasift/hotspot.py +1713 -0
- alphasift/industry.py +959 -0
- alphasift/llm_client.py +349 -0
- alphasift/market_digest.py +284 -0
- alphasift/market_news.py +446 -0
- alphasift/market_regime.py +578 -0
- alphasift/markets.py +160 -0
- alphasift/mcp.py +720 -0
- alphasift/models.py +315 -0
- alphasift/normalize.py +113 -0
- alphasift/notify.py +2608 -0
- alphasift/overview.py +225 -0
- alphasift/pack.py +1470 -0
- alphasift/pack_features.py +431 -0
- alphasift/pattern_replay.py +1449 -0
- alphasift/patterns/bottom_volume_yang.yaml +32 -0
- alphasift/patterns/box_breakout.yaml +36 -0
- alphasift/patterns/double_bottom_breakout.yaml +38 -0
- alphasift/patterns/ma20_shrink_pullback.yaml +37 -0
- alphasift/patterns/shooting_star_confirm.yaml +49 -0
- alphasift/patterns/single_yang_hold.yaml +44 -0
- alphasift/patterns/steady_trend_breakout.yaml +39 -0
- alphasift/patterns/three_white_soldiers.yaml +72 -0
- alphasift/patterns/three_white_soldiers_pullback.yaml +91 -0
- alphasift/patterns.py +1233 -0
- alphasift/performance_history.py +297 -0
- alphasift/pipeline.py +1010 -0
- alphasift/post_analysis.py +337 -0
- alphasift/ranker.py +990 -0
- alphasift/report.py +379 -0
- alphasift/result_schema.py +179 -0
- alphasift/risk.py +452 -0
- alphasift/run_history.py +164 -0
- alphasift/scorer.py +597 -0
- alphasift/server.py +680 -0
- alphasift/snapshot.py +1025 -0
- alphasift/snapshot_us.py +280 -0
- alphasift/snapshot_yahoo.py +358 -0
- alphasift/source_guard.py +70 -0
- alphasift/source_history.py +306 -0
- alphasift/store.py +294 -0
- alphasift/strategies/balanced_alpha.yaml +76 -0
- alphasift/strategies/blue_chip_income.yaml +87 -0
- alphasift/strategies/capital_heat.yaml +74 -0
- alphasift/strategies/dual_low.yaml +80 -0
- alphasift/strategies/global_value.yaml +65 -0
- alphasift/strategies/low_volatility_quality.yaml +95 -0
- alphasift/strategies/momentum_quality.yaml +81 -0
- alphasift/strategies/oversold_reversal.yaml +75 -0
- alphasift/strategies/quality_value.yaml +80 -0
- alphasift/strategies/shrink_pullback.yaml +77 -0
- alphasift/strategies/us_momentum_quality.yaml +74 -0
- alphasift/strategies/volume_breakout.yaml +78 -0
- alphasift/strategy.py +1090 -0
- alphasift/strategy_cards.py +424 -0
- alphasift/strategy_templates.py +291 -0
- alphasift/timeutil.py +38 -0
- alphasift/valuation_kr.py +149 -0
- alphasift/workbench_ui.py +1051 -0
- alphasift-0.3.1.data/data/.env.example +151 -0
- alphasift-0.3.1.data/data/LICENSE +184 -0
- alphasift-0.3.1.data/data/SKILL.md +190 -0
- alphasift-0.3.1.data/data/agents/openai.yaml +7 -0
- alphasift-0.3.1.dist-info/METADATA +312 -0
- alphasift-0.3.1.dist-info/RECORD +86 -0
- alphasift-0.3.1.dist-info/WHEEL +5 -0
- alphasift-0.3.1.dist-info/entry_points.txt +2 -0
- alphasift-0.3.1.dist-info/licenses/LICENSE +184 -0
- alphasift-0.3.1.dist-info/top_level.txt +1 -0
alphasift/__init__.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""alphasift — 自动选股 Skill"""
|
|
3
|
+
|
|
4
|
+
__version__ = "0.3.1"
|
|
5
|
+
|
|
6
|
+
from alphasift.pipeline import screen
|
|
7
|
+
from alphasift.evaluate import evaluate_saved_run, evaluate_saved_runs
|
|
8
|
+
from alphasift.daily_brief import generate_ai_daily_brief
|
|
9
|
+
from alphasift.daily_report import build_daily_report
|
|
10
|
+
from alphasift.daily_report_html import render_daily_report_html
|
|
11
|
+
from alphasift.doctor import doctor_radar_readiness
|
|
12
|
+
from alphasift.market_regime import compute_market_regime, compute_market_regime_series
|
|
13
|
+
from alphasift.notify import push_daily_report
|
|
14
|
+
from alphasift.patterns import list_patterns, scan_patterns
|
|
15
|
+
from alphasift.performance_history import build_strategy_performance_summary
|
|
16
|
+
from alphasift.strategy import compare_strategies, list_strategies, strategy_facets
|
|
17
|
+
from alphasift.audit import audit_project
|
|
18
|
+
from alphasift.overview import build_overview
|
|
19
|
+
from alphasift.run_history import build_strategy_run_summary
|
|
20
|
+
from alphasift.server import build_api_response, serve_api
|
|
21
|
+
from alphasift.source_history import build_data_source_history
|
|
22
|
+
from alphasift.strategy_cards import build_strategy_cards
|
|
23
|
+
from alphasift.strategy_templates import get_strategy_template, list_strategy_templates
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"__version__",
|
|
27
|
+
"screen",
|
|
28
|
+
"evaluate_saved_run",
|
|
29
|
+
"evaluate_saved_runs",
|
|
30
|
+
"build_daily_report",
|
|
31
|
+
"generate_ai_daily_brief",
|
|
32
|
+
"render_daily_report_html",
|
|
33
|
+
"doctor_radar_readiness",
|
|
34
|
+
"compute_market_regime",
|
|
35
|
+
"compute_market_regime_series",
|
|
36
|
+
"push_daily_report",
|
|
37
|
+
"list_patterns",
|
|
38
|
+
"scan_patterns",
|
|
39
|
+
"build_strategy_performance_summary",
|
|
40
|
+
"list_strategies",
|
|
41
|
+
"compare_strategies",
|
|
42
|
+
"strategy_facets",
|
|
43
|
+
"get_strategy_template",
|
|
44
|
+
"list_strategy_templates",
|
|
45
|
+
"audit_project",
|
|
46
|
+
"build_overview",
|
|
47
|
+
"build_strategy_run_summary",
|
|
48
|
+
"build_data_source_history",
|
|
49
|
+
"build_strategy_cards",
|
|
50
|
+
"build_api_response",
|
|
51
|
+
"serve_api",
|
|
52
|
+
]
|
alphasift/__main__.py
ADDED
alphasift/audit.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Project and strategy audit helpers."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from collections import Counter
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from alphasift.config import Config
|
|
10
|
+
from alphasift.filter import requires_daily_features
|
|
11
|
+
from alphasift.strategy import load_all_strategies
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def audit_project(strategies_dir: Path | None = None) -> dict[str, object]:
|
|
15
|
+
"""Return a structured audit of current strategy coverage and known gaps."""
|
|
16
|
+
if strategies_dir is None:
|
|
17
|
+
strategies_dir = Config.from_env().strategies_dir
|
|
18
|
+
|
|
19
|
+
strategies = load_all_strategies(strategies_dir)
|
|
20
|
+
strategy_items = list(strategies.values())
|
|
21
|
+
categories = Counter(strategy.category for strategy in strategy_items)
|
|
22
|
+
profile_fields = [
|
|
23
|
+
"scoring_profile",
|
|
24
|
+
"risk_profile",
|
|
25
|
+
"portfolio_profile",
|
|
26
|
+
"scorecard_profile",
|
|
27
|
+
]
|
|
28
|
+
profile_coverage = {
|
|
29
|
+
field: {
|
|
30
|
+
"configured": sum(1 for strategy in strategy_items if getattr(strategy.screening, field)),
|
|
31
|
+
"missing": [
|
|
32
|
+
strategy.name
|
|
33
|
+
for strategy in strategy_items
|
|
34
|
+
if not getattr(strategy.screening, field)
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
for field in profile_fields
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
strategy_findings = []
|
|
41
|
+
for strategy in strategy_items:
|
|
42
|
+
strategy_findings.extend(_audit_strategy(strategy))
|
|
43
|
+
|
|
44
|
+
project_gaps = _known_project_gaps()
|
|
45
|
+
strengths = _current_strengths()
|
|
46
|
+
return {
|
|
47
|
+
"project": "alphasift",
|
|
48
|
+
"positioning": "全市场候选发现与 LLM 横向排序引擎",
|
|
49
|
+
"strategy_count": len(strategy_items),
|
|
50
|
+
"categories": dict(sorted(categories.items())),
|
|
51
|
+
"profile_coverage": profile_coverage,
|
|
52
|
+
"strengths": strengths,
|
|
53
|
+
"strategy_findings": strategy_findings,
|
|
54
|
+
"project_gaps": project_gaps,
|
|
55
|
+
"next_priorities": _next_priorities(strategy_findings, project_gaps),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _audit_strategy(strategy) -> list[dict[str, str]]:
|
|
60
|
+
findings: list[dict[str, str]] = []
|
|
61
|
+
screening = strategy.screening
|
|
62
|
+
hard_filters = screening.hard_filters
|
|
63
|
+
uses_daily = requires_daily_features(hard_filters)
|
|
64
|
+
tags = {str(tag).lower() for tag in strategy.tags}
|
|
65
|
+
is_shape_strategy = strategy.category in {"trend", "pattern"} or bool(
|
|
66
|
+
tags & {"breakout", "pullback", "daily_k"}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if is_shape_strategy and not uses_daily:
|
|
70
|
+
findings.append({
|
|
71
|
+
"severity": "warn",
|
|
72
|
+
"strategy": strategy.name,
|
|
73
|
+
"area": "l1_shape_validation",
|
|
74
|
+
"message": "趋势/形态策略尚未声明日 K 硬条件,可能只是在快照上近似形态。",
|
|
75
|
+
"recommendation": "补充 require_ma_bullish、price_above_ma20、change_60d 或更严格的形态特征。",
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
if not screening.ranking_hints.strip():
|
|
79
|
+
findings.append({
|
|
80
|
+
"severity": "warn",
|
|
81
|
+
"strategy": strategy.name,
|
|
82
|
+
"area": "llm_ranking",
|
|
83
|
+
"message": "缺少 ranking_hints,LLM 无法获得策略级取舍偏好。",
|
|
84
|
+
"recommendation": "补充候选排序优先级、风险排除条件和组合分散要求。",
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
for field in ("scoring_profile", "risk_profile", "portfolio_profile", "scorecard_profile"):
|
|
88
|
+
if not getattr(screening, field):
|
|
89
|
+
findings.append({
|
|
90
|
+
"severity": "info",
|
|
91
|
+
"strategy": strategy.name,
|
|
92
|
+
"area": "configurability",
|
|
93
|
+
"message": f"未配置 {field},将使用默认规则。",
|
|
94
|
+
"recommendation": "如该策略风格与默认基线不同,应在 YAML 中显式配置。",
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
if screening.max_output > 10:
|
|
98
|
+
findings.append({
|
|
99
|
+
"severity": "info",
|
|
100
|
+
"strategy": strategy.name,
|
|
101
|
+
"area": "output",
|
|
102
|
+
"message": "max_output 较大,L3/LLM 输出可能变成列表而不是精选候选。",
|
|
103
|
+
"recommendation": "保持最终输出精简,更多候选可通过保存 run 和后续评估管理。",
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return findings
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _current_strengths() -> list[dict[str, str]]:
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
"area": "positioning",
|
|
113
|
+
"message": "定位在全市场候选发现,位于 DSA 单股深度分析和通知助手上游。",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"area": "llm",
|
|
117
|
+
"message": "LLM 只在候选池内做结构化横向排序,支持按 code 注入文件线索或抓取 Top K 新闻/公告/资金流,并输出 thesis、sector、theme、risk、watch_items 和 invalidators。",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"area": "risk",
|
|
121
|
+
"message": "风险层和组合分散层独立于 alpha 排序,扣分字段可审计。",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"area": "configurability",
|
|
125
|
+
"message": "策略 YAML 可覆盖评分曲线、风险阈值、组合风险桶和 scorecard 规则。",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"area": "evaluation",
|
|
129
|
+
"message": "支持保存运行、单次 T+N 最新快照评估、可选日 K 路径最大回撤/最大浮盈,以及按单只和等权组合维度聚合最近 runs。",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"area": "daily_shape",
|
|
133
|
+
"message": "日 K 增强已支持 20 日突破幅度、区间振幅、20 日量能比、实体强度、MA20 回踩距离和平台持续天数。",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"area": "data",
|
|
137
|
+
"message": "行业/概念锚点支持本地映射文件、可选 AkShare 板块反查、板块热度分、主题热度摘要,以及 history JSONL 滚动趋势、持续性、降温、状态回填和异常热度值过滤。",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"area": "shape_validation",
|
|
141
|
+
"message": "T+N 评估会对突破、MA20 回踩和平台整理候选打形态后验标签,用于发现突破延续或失败回落。",
|
|
142
|
+
},
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _known_project_gaps() -> list[dict[str, str]]:
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
"severity": "gap",
|
|
150
|
+
"area": "data",
|
|
151
|
+
"message": "行业/概念和板块热度已能进入 LLM 上下文与 theme_heat 因子,industry-cache 会写 metadata/history sidecar 并回填滚动趋势、持续性和降温信号,但数据源仍偏本地/AkShare。",
|
|
152
|
+
"recommendation": "补多源映射、板块层级口径归一和更完整的数据质量报告。",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"severity": "gap",
|
|
156
|
+
"area": "news_context",
|
|
157
|
+
"message": "LLM 上下文支持候选级文件注入、Top K 抓取、缓存、基础去重、来源置信度、来源权重分、压缩摘要、公告类别和粗粒度事件/负面风险标签;策略可配置事件偏好和来源权重,但事件权重尚未进入可学习评估闭环。",
|
|
158
|
+
"recommendation": "将事件类型偏好纳入 T+N 归因统计,补更细公告分类和来源质量评估。",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"severity": "gap",
|
|
162
|
+
"area": "backtest",
|
|
163
|
+
"message": "当前 T+N 批量评估覆盖多维聚合、交易成本扣减、可选日 K 路径指标和等权组合摘要,但不是复权、持仓约束和调仓约束完整回测。",
|
|
164
|
+
"recommendation": "增加持仓约束和组合层面的逐日权益曲线;完整研究后端可接 Qlib/Backtrader。",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"severity": "gap",
|
|
168
|
+
"area": "market_scope",
|
|
169
|
+
"message": "A 股之外的美股/港股/日本/韩国/台湾/印度通过 Yahoo 筛选器接入,但还没有按交易所日历计算 T+N、没有跨币种的金额阈值;韩国 PE/PB 依赖 Naver 非官方接口。",
|
|
170
|
+
"recommendation": "引入 exchange_calendars 计算各市场交易日,为策略增加按市场覆盖的金额阈值,再考虑台湾交易所官方 OpenAPI 等更完整的数据源。",
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"severity": "gap",
|
|
174
|
+
"area": "shape_validation",
|
|
175
|
+
"message": "突破、回踩等形态策略已有平台、20 日形态特征、T+N 后验标签和可选日 K 路径指标,但还没有前高压力密集度和盘中失效条件。",
|
|
176
|
+
"recommendation": "补充前高压力密集度和盘中止损约束。",
|
|
177
|
+
},
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _next_priorities(strategy_findings: list[dict[str, str]], project_gaps: list[dict[str, str]]) -> list[str]:
|
|
182
|
+
priorities = [
|
|
183
|
+
"给行业/概念 history JSONL 增加板块层级口径归一和更完整的数据质量报告。",
|
|
184
|
+
"将候选上下文事件类型偏好纳入 T+N 归因统计,补更细公告分类和来源质量评估。",
|
|
185
|
+
"给批量 T+N 评估补持仓约束和组合层面的逐日权益曲线。",
|
|
186
|
+
]
|
|
187
|
+
if any(item["area"] == "l1_shape_validation" for item in strategy_findings):
|
|
188
|
+
priorities.insert(0, "补强趋势/形态策略的日 K 结构验证,尤其是放量突破类策略。")
|
|
189
|
+
if any(item["area"] == "backtest" for item in project_gaps):
|
|
190
|
+
priorities.append("后续再考虑接入 backtrader/qlib 这类完整回测框架,而不是在主链里硬塞。")
|
|
191
|
+
return priorities
|