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.
Files changed (86) hide show
  1. alphasift/__init__.py +52 -0
  2. alphasift/__main__.py +7 -0
  3. alphasift/audit.py +191 -0
  4. alphasift/candidate_context.py +738 -0
  5. alphasift/cli.py +2797 -0
  6. alphasift/config.py +705 -0
  7. alphasift/context.py +672 -0
  8. alphasift/daily.py +1256 -0
  9. alphasift/daily_brief.py +593 -0
  10. alphasift/daily_report.py +1115 -0
  11. alphasift/daily_report_html.py +1257 -0
  12. alphasift/doctor.py +1123 -0
  13. alphasift/dsa.py +302 -0
  14. alphasift/dsa_adapter.py +178 -0
  15. alphasift/dsa_provider.py +192 -0
  16. alphasift/evaluate.py +2418 -0
  17. alphasift/filter.py +517 -0
  18. alphasift/hotspot.py +1713 -0
  19. alphasift/industry.py +959 -0
  20. alphasift/llm_client.py +349 -0
  21. alphasift/market_digest.py +284 -0
  22. alphasift/market_news.py +446 -0
  23. alphasift/market_regime.py +578 -0
  24. alphasift/markets.py +160 -0
  25. alphasift/mcp.py +720 -0
  26. alphasift/models.py +315 -0
  27. alphasift/normalize.py +113 -0
  28. alphasift/notify.py +2608 -0
  29. alphasift/overview.py +225 -0
  30. alphasift/pack.py +1470 -0
  31. alphasift/pack_features.py +431 -0
  32. alphasift/pattern_replay.py +1449 -0
  33. alphasift/patterns/bottom_volume_yang.yaml +32 -0
  34. alphasift/patterns/box_breakout.yaml +36 -0
  35. alphasift/patterns/double_bottom_breakout.yaml +38 -0
  36. alphasift/patterns/ma20_shrink_pullback.yaml +37 -0
  37. alphasift/patterns/shooting_star_confirm.yaml +49 -0
  38. alphasift/patterns/single_yang_hold.yaml +44 -0
  39. alphasift/patterns/steady_trend_breakout.yaml +39 -0
  40. alphasift/patterns/three_white_soldiers.yaml +72 -0
  41. alphasift/patterns/three_white_soldiers_pullback.yaml +91 -0
  42. alphasift/patterns.py +1233 -0
  43. alphasift/performance_history.py +297 -0
  44. alphasift/pipeline.py +1010 -0
  45. alphasift/post_analysis.py +337 -0
  46. alphasift/ranker.py +990 -0
  47. alphasift/report.py +379 -0
  48. alphasift/result_schema.py +179 -0
  49. alphasift/risk.py +452 -0
  50. alphasift/run_history.py +164 -0
  51. alphasift/scorer.py +597 -0
  52. alphasift/server.py +680 -0
  53. alphasift/snapshot.py +1025 -0
  54. alphasift/snapshot_us.py +280 -0
  55. alphasift/snapshot_yahoo.py +358 -0
  56. alphasift/source_guard.py +70 -0
  57. alphasift/source_history.py +306 -0
  58. alphasift/store.py +294 -0
  59. alphasift/strategies/balanced_alpha.yaml +76 -0
  60. alphasift/strategies/blue_chip_income.yaml +87 -0
  61. alphasift/strategies/capital_heat.yaml +74 -0
  62. alphasift/strategies/dual_low.yaml +80 -0
  63. alphasift/strategies/global_value.yaml +65 -0
  64. alphasift/strategies/low_volatility_quality.yaml +95 -0
  65. alphasift/strategies/momentum_quality.yaml +81 -0
  66. alphasift/strategies/oversold_reversal.yaml +75 -0
  67. alphasift/strategies/quality_value.yaml +80 -0
  68. alphasift/strategies/shrink_pullback.yaml +77 -0
  69. alphasift/strategies/us_momentum_quality.yaml +74 -0
  70. alphasift/strategies/volume_breakout.yaml +78 -0
  71. alphasift/strategy.py +1090 -0
  72. alphasift/strategy_cards.py +424 -0
  73. alphasift/strategy_templates.py +291 -0
  74. alphasift/timeutil.py +38 -0
  75. alphasift/valuation_kr.py +149 -0
  76. alphasift/workbench_ui.py +1051 -0
  77. alphasift-0.3.1.data/data/.env.example +151 -0
  78. alphasift-0.3.1.data/data/LICENSE +184 -0
  79. alphasift-0.3.1.data/data/SKILL.md +190 -0
  80. alphasift-0.3.1.data/data/agents/openai.yaml +7 -0
  81. alphasift-0.3.1.dist-info/METADATA +312 -0
  82. alphasift-0.3.1.dist-info/RECORD +86 -0
  83. alphasift-0.3.1.dist-info/WHEEL +5 -0
  84. alphasift-0.3.1.dist-info/entry_points.txt +2 -0
  85. alphasift-0.3.1.dist-info/licenses/LICENSE +184 -0
  86. alphasift-0.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,151 @@
1
+ # === LLM 配置 ===
2
+ # 通过 OpenAI 兼容的 Chat Completions 接口调用模型。
3
+ # 主模型优先级为 LITELLM_MODEL > LLM_MODEL > AGENT_LITELLM_MODEL > 首个渠道模型 > 供应商默认模型。
4
+
5
+ # 极简方式:填一个供应商 key 即可
6
+ # GEMINI_API_KEY=
7
+ # GEMINI_API_KEYS=key1,key2
8
+ # DEEPSEEK_API_KEY=
9
+ # OPENAI_API_KEY=
10
+ # OPENAI_BASE_URL=
11
+ # OLLAMA_API_BASE=http://localhost:11434
12
+ # OLLAMA_MODEL=qwen3:8b
13
+
14
+ # 以下模型变量名仅为兼容旧配置而保留。
15
+ # LITELLM_MODEL=gemini/gemini-3.8-flash
16
+ # LITELLM_FALLBACK_MODELS=gemini/gemini-4-hydrogen
17
+
18
+ # 兼容旧变量
19
+ # LLM_API_KEY=your_api_key
20
+ # LLM_MODEL=gemini/gemini-3.8-flash
21
+ # LLM_BASE_URL=
22
+
23
+ # 多渠道模式
24
+ # LLM_CHANNELS=primary
25
+ # LLM_PRIMARY_PROTOCOL=openai
26
+ # LLM_PRIMARY_BASE_URL=https://api.deepseek.com/v1
27
+ # LLM_PRIMARY_API_KEYS=sk-xxx,sk-yyy
28
+ # LLM_PRIMARY_MODELS=deepseek-chat,deepseek-reasoner
29
+
30
+ # 从 Router YAML 迁移时,请删除 LITELLM_CONFIG 并改用上面的 LLM_CHANNELS 配置。
31
+
32
+ # === 可选 ===
33
+ # LLM_CONTEXT=
34
+ # LLM_TEMPERATURE=0.2
35
+ # LLM_JSON_MODE=true
36
+ # LLM_SILENT=true
37
+ # LLM_RANK_WEIGHT=0.40
38
+ # LLM_CANDIDATE_MULTIPLIER=6
39
+ # LLM_MAX_CANDIDATES=30
40
+ # LLM_MAX_RETRIES=1
41
+ # LLM_MIN_COVERAGE=0.60
42
+ # LLM_CONTEXT_MAX_CHARS=4000
43
+ # LLM_TIMEOUT_SEC=60
44
+ # 单次 LLM 输出 token 严格硬上限(绝不自动扩容);深度推理模型如在 8192 下仍截断,可显式调大至如 16384
45
+ # LLM_MAX_TOKENS=8192
46
+ # LLM_CANDIDATE_CONTEXT_ENABLED=false
47
+ # LLM_CANDIDATE_CONTEXT_MAX_CANDIDATES=8
48
+ # LLM_CANDIDATE_CONTEXT_PROVIDERS=news,fund_flow,announcement
49
+ # LLM_CANDIDATE_CONTEXT_NEWS_LIMIT=3
50
+ # LLM_CANDIDATE_CONTEXT_ANNOUNCEMENT_LIMIT=3
51
+ # LLM_CANDIDATE_CONTEXT_CACHE_ENABLED=true
52
+ # LLM_CANDIDATE_CONTEXT_CACHE_TTL_HOURS=24
53
+ # 未显式设置 SNAPSHOT_SOURCE_PRIORITY 时:无 Tushare token 默认 em_datacenter,sina,efinance,akshare_em;
54
+ # 有 token 默认 tushare,em_datacenter,sina,efinance,akshare_em。Tushare 数据为最近交易日日线与 daily_basic,不是实时盘口
55
+ # SNAPSHOT_SOURCE_PRIORITY=em_datacenter,sina,efinance,akshare_em
56
+ # ALPHASIFT_FALLBACK_SNAPSHOT_PATH=./data/snapshot.last_good.json
57
+ # TUSHARE_TOKEN=
58
+ # TUSHARE_API_URL=http://api.waditu.com
59
+ # 可选:固定 Tushare 交易日,格式 YYYYMMDD,便于复现实验
60
+ # TUSHARE_TRADE_DATE=
61
+
62
+ # 稳定行业/概念锚点:优先使用本地映射文件;可选 akshare 板块反查默认关闭
63
+ # INDUSTRY_MAP_FILES=./data/industry_map.csv
64
+ # INDUSTRY_PROVIDER=none
65
+ # INDUSTRY_PROVIDER_MAX_BOARDS=80
66
+ # INDUSTRY_PROVIDER_CACHE_DIR=./data/industry_provider_cache
67
+ # INDUSTRY_PROVIDER_CACHE_TTL_HOURS=24
68
+
69
+ # L3 后置分析器,默认启用本地 scorecard;设为 none 可关闭
70
+ # 可选:scorecard,dsa,external_http
71
+ # POST_ANALYZERS=scorecard
72
+ # POST_ANALYSIS_MAX_PICKS=3
73
+ # POST_ANALYZER_URL=http://localhost:9000/rank
74
+ # POST_ANALYZER_TIMEOUT_SEC=120
75
+
76
+ # DSA 是可选 L3 分析器之一,不是默认依赖
77
+ # DSA_API_URL=http://localhost:8000
78
+ # DSA_REPORT_TYPE=detailed
79
+ # DSA_MAX_PICKS=3
80
+ # DSA_TIMEOUT_SEC=120
81
+ # DSA_FORCE_REFRESH=false
82
+ # DSA_NOTIFY=false
83
+
84
+ # 日 K 增强默认关闭;策略必需日 K 字段时会自动启用候选级增强
85
+ # DAILY_ENRICH_ENABLED=false
86
+ # DAILY_ENRICH_MAX_CANDIDATES=100
87
+ # DAILY_LOOKBACK_DAYS=120
88
+ # DAILY_SOURCE=akshare
89
+ # 可选:tushare 使用 Tushare Pro 前复权日线;auto 在有 TUSHARE_TOKEN 时优先用 tushare
90
+ # TUSHARE_DAILY_ADJ=qfq
91
+ # DAILY_FETCH_RETRIES=2
92
+ # DAILY_FETCH_MAX_WORKERS=1
93
+ # DAILY_HISTORY_CACHE_DIR=./data/daily_history
94
+ # DAILY_HISTORY_CACHE_TTL_HOURS=24
95
+
96
+ # 独立风险层
97
+ # RISK_ENABLED=true
98
+ # RISK_MAX_PENALTY=12
99
+ # RISK_VETO_HIGH=false
100
+
101
+ # LLM 行业/主题风险桶驱动的组合分散层
102
+ # PORTFOLIO_DIVERSITY_ENABLED=true
103
+ # PORTFOLIO_MAX_SAME_LLM_SECTOR=1
104
+ # PORTFOLIO_CONCENTRATION_PENALTY=4
105
+
106
+ # T+N 评估收益扣除的往返成本,单位 bps
107
+ # EVALUATION_COST_BPS=0
108
+ # 形态后验验证阈值:用于 evaluate/evaluate-batch 标记突破延续或失败
109
+ # EVALUATION_FOLLOW_THROUGH_PCT=3
110
+ # EVALUATION_FAILED_BREAKOUT_PCT=-3
111
+ # 可选:评估时抓取日 K 路径,计算最大回撤和最大浮盈;会增加外部请求
112
+ # EVALUATION_PRICE_PATH_ENABLED=false
113
+ # EVALUATION_PRICE_PATH_LOOKBACK_DAYS=90
114
+
115
+ # ALPHASIFT_DATA_DIR=./data
116
+ # STRATEGIES_DIR=./strategies
117
+
118
+ # === 通知推送、离线日线包与看板 ===
119
+ # 最简方式:一行 NOTIFY_URLS 自动识别全部 12 种通道(逗号/换行分隔,未配置则静默跳过)
120
+ # 支持:企微/飞书/钉钉 Webhook、pushplus://TOKEN、sct://SENDKEY、bark://KEY、
121
+ # mailto://user:pass@qq.com?to=a@b.com、tgram://BOT/CHAT、discord/slack Webhook、ntfy://TOPIC
122
+ # NOTIFY_URLS=
123
+ #
124
+ # 也支持分渠道独立环境变量(与 NOTIFY_URLS 可同时使用,自动去重):
125
+ # WECOM_WEBHOOK_URL=
126
+ # FEISHU_WEBHOOK_URL=
127
+ # FEISHU_WEBHOOK_SECRET=
128
+ # DINGTALK_WEBHOOK_URL=
129
+ # DINGTALK_WEBHOOK_SECRET=
130
+ # PUSHPLUS_TOKEN=
131
+ # PUSHPLUS_TOPIC=
132
+ # SERVERCHAN_SENDKEY=
133
+ # BARK_URL=
134
+ # EMAIL_SENDER=
135
+ # EMAIL_PASSWORD=
136
+ # EMAIL_RECEIVERS=
137
+ # EMAIL_SMTP_HOST=
138
+ # EMAIL_SMTP_PORT=
139
+ # TELEGRAM_BOT_TOKEN=
140
+ # TELEGRAM_CHAT_ID=
141
+ # DISCORD_WEBHOOK_URL=
142
+ # SLACK_WEBHOOK_URL=
143
+ # NTFY_URL=
144
+ # CUSTOM_WEBHOOK_URL=
145
+ # CUSTOM_WEBHOOK_TOKEN=
146
+ # ALPHASIFT_CANDIDATE_CONTEXT_CACHE_DIR=./data/candidate_context
147
+ # ALPHASIFT_NOTIFY_STATE_PATH=./data/notify_state.json
148
+ # ALPHASIFT_NOTIFY_TIMEOUT_SEC=10
149
+ # ALPHASIFT_DASHBOARD_URL=https://alphasift.zhulinsen.tech/
150
+ # ALPHASIFT_PACK_DIR=./data/pack/cn
151
+ # TICKPLUS_API_KEY=
@@ -0,0 +1,184 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and
27
+ configuration files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object
31
+ code, generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work (an example is provided in the Appendix
36
+ below).
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ "Contribution" shall mean any work of authorship, including the original
46
+ version of the Work and any modifications or additions to that Work or
47
+ Derivative Works thereof, that is intentionally submitted to Licensor for
48
+ inclusion in the Work by the copyright owner or by an individual or Legal
49
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal, or
51
+ written communication sent to the Licensor or its representatives, including
52
+ but not limited to communication on electronic mailing lists, source code
53
+ control systems, and issue tracking systems that are managed by, or on behalf
54
+ of, the Licensor for the purpose of discussing and improving the Work, but
55
+ excluding communication that is conspicuously marked or otherwise designated in
56
+ writing by the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
63
+ License, each Contributor hereby grants to You a perpetual, worldwide,
64
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
65
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
66
+ sublicense, and distribute the Work and such Derivative Works in Source or
67
+ Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of this
70
+ License, each Contributor hereby grants to You a perpetual, worldwide,
71
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
72
+ section) patent license to make, have made, use, offer to sell, sell, import,
73
+ and otherwise transfer the Work, where such license applies only to those
74
+ patent claims licensable by such Contributor that are necessarily infringed by
75
+ their Contribution(s) alone or by combination of their Contribution(s) with the
76
+ Work to which such Contribution(s) was submitted. If You institute patent
77
+ litigation against any entity (including a cross-claim or counterclaim in a
78
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
79
+ constitutes direct or contributory patent infringement, then any patent
80
+ licenses granted to You under this License for that Work shall terminate as of
81
+ the date such litigation is filed.
82
+
83
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
84
+ Derivative Works thereof in any medium, with or without modifications, and in
85
+ Source or Object form, provided that You meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or Derivative Works a copy
88
+ of this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices stating that
91
+ You changed the files; and
92
+
93
+ (c) You must retain, in the Source form of any Derivative Works that You
94
+ distribute, all copyright, patent, trademark, and attribution notices from the
95
+ Source form of the Work, excluding those notices that do not pertain to any
96
+ part of the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
99
+ any Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of
102
+ the following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents
106
+ of the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+
112
+ You may add Your own copyright statement to Your modifications and may provide
113
+ additional or different license terms and conditions for use, reproduction, or
114
+ distribution of Your modifications, or for any such Derivative Works as a
115
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
116
+ complies with the conditions stated in this License.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
119
+ Contribution intentionally submitted for inclusion in the Work by You to the
120
+ Licensor shall be under the terms and conditions of this License, without any
121
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
122
+ supersede or modify the terms of any separate license agreement you may have
123
+ executed with Licensor regarding such Contributions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade names,
126
+ trademarks, service marks, or product names of the Licensor, except as
127
+ required for reasonable and customary use in describing the origin of the Work
128
+ and reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
131
+ writing, Licensor provides the Work (and each Contributor provides its
132
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
133
+ KIND, either express or implied, including, without limitation, any warranties
134
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
135
+ PARTICULAR PURPOSE. You are solely responsible for determining the
136
+ appropriateness of using or redistributing the Work and assume any risks
137
+ associated with Your exercise of permissions under this License.
138
+
139
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
140
+ tort (including negligence), contract, or otherwise, unless required by
141
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
142
+ writing, shall any Contributor be liable to You for damages, including any
143
+ direct, indirect, special, incidental, or consequential damages of any
144
+ character arising as a result of this License or out of the use or inability to
145
+ use the Work (including but not limited to damages for loss of goodwill, work
146
+ stoppage, computer failure or malfunction, or any and all other commercial
147
+ damages or losses), even if such Contributor has been advised of the
148
+ possibility of such damages.
149
+
150
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
151
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
152
+ acceptance of support, warranty, indemnity, or other liability obligations
153
+ and/or rights consistent with this License. However, in accepting such
154
+ obligations, You may act only on Your own behalf and on Your sole
155
+ responsibility, not on behalf of any other Contributor, and only if You agree
156
+ to indemnify, defend, and hold each Contributor harmless for any liability
157
+ incurred by, or claims asserted against, such Contributor by reason of your
158
+ accepting any such warranty or additional liability.
159
+
160
+ END OF TERMS AND CONDITIONS
161
+
162
+ APPENDIX: How to apply the Apache License to your work.
163
+
164
+ To apply the Apache License to your work, attach the following boilerplate
165
+ notice, with the fields enclosed by brackets "[]" replaced with your own
166
+ identifying information. (Don't include the brackets!) The text should be
167
+ enclosed in the appropriate comment syntax for the file format. We also
168
+ recommend that a file or class name and description of purpose be included on
169
+ the same "printed page" as the copyright notice for easier identification
170
+ within third-party archives.
171
+
172
+ Copyright [yyyy] [name of copyright owner]
173
+
174
+ Licensed under the Apache License, Version 2.0 (the "License");
175
+ you may not use this file except in compliance with the License.
176
+ You may obtain a copy of the License at
177
+
178
+ http://www.apache.org/licenses/LICENSE-2.0
179
+
180
+ Unless required by applicable law or agreed to in writing, software
181
+ distributed under the License is distributed on an "AS IS" BASIS,
182
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183
+ See the License for the specific language governing permissions and
184
+ limitations under the License.
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: alphasift
3
+ description: "全市场选股 Skill。Use when: 用户要按策略筛选 A 股、美股、港股、日股、韩股、台股或印度股票,列出可用策略,运行双低/放量突破/全球低估值等选股,或保存运行并做 T+N 后验评估。通过 alphasift CLI 或 Python 接口输出候选股票列表。"
4
+ ---
5
+
6
+ # alphasift — 自动选股 Skill
7
+
8
+ 按策略筛选、评分并排序候选股票:A 股,以及美股、港股、日本、韩国、台湾、印度。
9
+
10
+ 定位:全市场候选发现与横向排序引擎。它站在 `daily_stock_analysis` 这类单股深度分析服务上游;DSA 只是可选 L3 后置分析器,不是主筛选依赖。
11
+
12
+ ## Use When
13
+
14
+ - 用户要列出当前可用策略
15
+ - 用户要按 `dual_low`、`volume_breakout` 这类策略筛选 A 股,或用 `global_value` 筛选其他市场
16
+ - 用户要拿到结构化 JSON 结果,供后续 agent 继续分析
17
+ - 用户要保存选股运行,并在之后用最新快照评估结果
18
+ - 用户第一次接触本项目,想用 `alphasift quickstart` 一键看到全市场→候选→排名的最小闭环
19
+
20
+ ## Preconditions
21
+
22
+ - 默认 `market="cn"`;`market` 也可以是 `us` / `hk` / `jp` / `kr` / `tw` / `in`(Yahoo 筛选器快照 + yfinance 日 K,代码为 Yahoo 代码如 `0700.HK`;无 hotspot/board_heat/tushare/候选级新闻等 A 股专属数据),需使用 `market_scope` 包含该市场的策略:`global_value`(us/hk/jp/kr/tw/in)或 `us_momentum_quality`(us)。韩国 PE/PB 来自 Naver Finance
23
+ - 需要先安装软件包:直接安装 `v0.3.1` Release Wheel(`pip install https://github.com/ZhuLinsen/alphasift/releases/download/v0.3.1/alphasift-0.3.1-py3-none-any.whl`),或在仓库根目录执行 `pip install -e .`
24
+ - 如需 LLM 排序,可设置 `GEMINI_API_KEY`(默认主模型 `gemini/gemini-3.8-flash`,未覆盖时自动挂载 `gemini/gemini-4-hydrogen` 备选)、`OPENAI_API_KEY`、`DEEPSEEK_API_KEY`、`LITELLM_MODEL`、`LLM_CHANNELS` 或旧变量 `LLM_API_KEY/LLM_MODEL/LLM_BASE_URL`
25
+ - LLM 排序直接通过轻量 HTTP 客户端调用 OpenAI 兼容 `/chat/completions` 接口;`LITELLM_MODEL`、`AGENT_LITELLM_MODEL` 和 `LITELLM_FALLBACK_MODELS` 变量名仅为兼容 `daily_stock_analysis` 配置而保留,供应商密钥与地址环境变量均可复用。若曾设置 `LITELLM_CONFIG`,请删除该变量并迁移到 `LLM_CHANNELS`
26
+ - 策略 YAML 可通过 `scoring_profile`、`risk_profile`、`portfolio_profile`、`scorecard_profile` 覆盖默认规则
27
+ - 策略 YAML 可通过 `event_profile` 配置偏好/规避事件、公告类别和候选上下文来源权重
28
+ - LLM 会输出候选行业/主题标签;如候选提供 `industry/concepts/board_heat_score/board_heat_trend_score`,会作为 LLM、主题热度因子与组合分散层锚点;history sidecar 可回填持续性、降温和状态字段。默认组合分散层会用这些标签映射风险桶,降低同一拥挤交易重复占位
29
+ - L3 默认启用本地 `scorecard` 后置评分器,也可追加 `dsa` 或 `external_http`
30
+ - 如需 DSA 后置分析,设置 `DSA_API_URL`,默认调用 `POST /api/v1/analysis/analyze`
31
+ - 依赖日 K 的策略会在 L1 后自动对 Top N 候选做日 K 增强
32
+ - 日 K 数据源 `DAILY_SOURCE` 支持 `auto`(默认,优先走 `tushare`(若配置 token)、`tencent`、`sina` 直连源,再降级到 `akshare`、`baostock`)或显式指定单源
33
+
34
+ ## Operations
35
+
36
+ ### 1. 列出策略
37
+
38
+ ```bash
39
+ alphasift strategies
40
+ ```
41
+
42
+ ### 1.1 一键演示(无 API key)
43
+
44
+ ```bash
45
+ alphasift quickstart
46
+ alphasift quickstart --strategy balanced_alpha --max-output 8
47
+ ```
48
+
49
+ ### 2. 执行选股
50
+
51
+ ```bash
52
+ alphasift screen dual_low --no-llm
53
+ alphasift screen volume_breakout --max-output 10
54
+ alphasift screen balanced_alpha --no-llm
55
+ alphasift screen capital_heat
56
+ alphasift screen balanced_alpha --context "今日券商板块放量,低估值金融获得资金回流"
57
+ alphasift --env-file /path/to/daily_stock_analysis/.env screen balanced_alpha
58
+ alphasift screen balanced_alpha --explain
59
+ alphasift screen balanced_alpha --candidate-context-file candidate_context.csv
60
+ alphasift screen dual_low --no-post-analysis
61
+ alphasift screen shrink_pullback --no-llm
62
+ alphasift screen dual_low --post-analyzer dsa
63
+ alphasift audit
64
+ alphasift industry-cache --output data/industry_map.csv --explain
65
+ alphasift screen dual_low --no-llm --save-run
66
+ alphasift runs
67
+ alphasift evaluate <run_id> --explain
68
+ alphasift evaluate-batch --limit 20 --explain
69
+ alphasift evaluate <run_id> --with-price-path --explain
70
+ alphasift patterns list --include-experimental
71
+ alphasift patterns scan --pack-dir data/pack/cn
72
+ alphasift patterns replay --pack-dir data/pack/cn --output-md replay.md
73
+ alphasift daily-report --pack-dir data/pack/cn --output-html report.html --push
74
+ alphasift notify status
75
+ alphasift notify test --dry-run
76
+ alphasift mcp
77
+ alphasift serve --host 127.0.0.1 --port 8765
78
+ ```
79
+
80
+ ### 3. Python 调用
81
+
82
+ ```python
83
+ from alphasift import evaluate_saved_run, evaluate_saved_runs, list_strategies, screen
84
+
85
+ list_strategies()
86
+ screen("dual_low", market="cn", use_llm=False)
87
+ evaluate_saved_run("<run_id>")
88
+ evaluate_saved_runs(limit=20)
89
+ ```
90
+
91
+ ## Output
92
+
93
+ 返回 `ScreenResult` JSON,核心字段有:
94
+ - `strategy`
95
+ - `market`
96
+ - `strategy_version`
97
+ - `snapshot_count`
98
+ - `after_filter_count`
99
+ - `picks`
100
+ - `llm_ranked`
101
+ - `llm_market_view`
102
+ - `llm_selection_logic`
103
+ - `llm_portfolio_risk`
104
+ - `llm_coverage`
105
+ - `post_analyzers`
106
+ - `daily_enriched`
107
+ - `daily_enrich_count`
108
+ - `daily_source_counts`
109
+ - `daily_quality_flag_counts`
110
+ - `risk_enabled`
111
+ - `portfolio_concentration_notes`
112
+ - `degradation`
113
+ - `snapshot_source`
114
+ - `source_errors`
115
+
116
+ 每个 `Pick` 包含:
117
+ - `rank`
118
+ - `code`
119
+ - `name`
120
+ - `final_score`
121
+ - `screen_score`
122
+ - `ranking_reason`
123
+ - `risk_summary`
124
+ - `price`
125
+ - `change_pct`
126
+ - `amount`
127
+ - `total_mv`
128
+ - `turnover_rate`
129
+ - `volume_ratio`
130
+ - `pe_ratio`
131
+ - `pb_ratio`
132
+ - `industry`
133
+ - `concepts`
134
+ - `board_heat_score`
135
+ - `board_heat_latest_score`
136
+ - `board_heat_trend_score`
137
+ - `board_heat_persistence_score`
138
+ - `board_heat_cooling_score`
139
+ - `board_heat_observations`
140
+ - `board_heat_state`
141
+ - `board_heat_summary`
142
+ - `change_60d`
143
+ - `signal_score`
144
+ - `macd_status`
145
+ - `rsi_status`
146
+ - `breakout_20d_pct`
147
+ - `range_20d_pct`
148
+ - `volume_ratio_20d`
149
+ - `body_pct`
150
+ - `pullback_to_ma20_pct`
151
+ - `consolidation_days_20d`
152
+ - `factor_scores`
153
+ - `llm_confidence`
154
+ - `llm_sector`
155
+ - `llm_theme`
156
+ - `llm_tags`
157
+ - `llm_catalysts`
158
+ - `llm_risks`
159
+ - `llm_thesis`
160
+ - `llm_style_fit`
161
+ - `llm_watch_items`
162
+ - `llm_invalidators`
163
+ - `risk_score`
164
+ - `risk_level`
165
+ - `risk_penalty`
166
+ - `risk_flags`
167
+ - `portfolio_penalty`
168
+ - `portfolio_flags`
169
+ - `post_analysis_status`
170
+ - `post_analysis_score_deltas`
171
+ - `deep_analysis_status`
172
+ - `deep_analysis_summary`
173
+ - `deep_analysis_result`
174
+ - `deep_analysis_signal_score`
175
+ - `deep_analysis_sentiment_score`
176
+ - `deep_analysis_operation_advice`
177
+ - `deep_analysis_trend_prediction`
178
+ - `deep_analysis_risk_flags`
179
+
180
+ ## Boundaries
181
+
182
+ - 当前没有独立的远程 `get_result` 服务;本地用 `--save-run`、`runs`、`evaluate`、`evaluate-batch` 管理运行记录
183
+ - `audit` 用于自检策略 profile 覆盖、已知能力短板和下一步优先级
184
+ - `--candidate-context-file` 支持 CSV/JSON/JSONL,通过 `code` 对齐候选级新闻、公告、资金流或研究摘要,只注入当前候选池相关行;可选抓取会附带 `source_count`、`source_confidence`、`source_weight_score`、`context_summary` 和公告类别
185
+ - 候选级上下文会识别粗粒度事件标签和负面风险标签,供 LLM 横向排序参考
186
+ - `industry-cache` 会缓存行业/概念映射和板块热度字段,并写入 history sidecar;后续加载映射时可回填板块热度滚动趋势、持续性、降温和状态字段,供 LLM 上下文与 `theme_heat` 因子使用
187
+ - 组合分散层优先使用 LLM 返回的行业/主题标签,也可回退到候选 `industry` 字段;两者都缺失时不会改变规则分数
188
+ - L3 后置分析器只在最终候选上运行,不参与全市场初筛;本地 `scorecard` 默认启用,DSA 只是其中一个可追加后端
189
+ - `evaluate-strategies --window 5,10,20` 按入场后第 N 个交易日收盘计算 T+N 收益,并与市场基准指数对比输出超额收益;未满 N 日的记为 pending
190
+ - 不带窗口的 T+N 评估基于保存价和评估时最新快照价,不等同完整复权回测;可扣减交易成本并输出突破/回踩形态后验标签;`--with-price-path` 会额外估算最大回撤和最大浮盈
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "AlphaSift"
3
+ short_description: "Screen, score, and rank A-share stock ideas"
4
+ default_prompt: "Use $alphasift to list strategies or run an A-share screening strategy."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true