quantnodes 3.0.0__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 (399) hide show
  1. QuantNodes/__init__.py +15 -0
  2. QuantNodes/__main__.py +14 -0
  3. QuantNodes/agent/__init__.py +158 -0
  4. QuantNodes/agent/agents/__init__.py +13 -0
  5. QuantNodes/agent/agents/definition.py +180 -0
  6. QuantNodes/agent/agents/manager.py +73 -0
  7. QuantNodes/agent/config/__init__.py +34 -0
  8. QuantNodes/agent/config/executor.py +958 -0
  9. QuantNodes/agent/config/loader.py +427 -0
  10. QuantNodes/agent/config/templates/bollinger_bands.yaml +84 -0
  11. QuantNodes/agent/config/templates/dual_ma.yaml +72 -0
  12. QuantNodes/agent/config/templates/empty.yaml +56 -0
  13. QuantNodes/agent/config/templates/mean_reversion.yaml +47 -0
  14. QuantNodes/agent/config/templates/mean_reversion_zscore.yaml +90 -0
  15. QuantNodes/agent/config/templates/momentum.yaml +81 -0
  16. QuantNodes/agent/config/templates/momentum_breakout.yaml +84 -0
  17. QuantNodes/agent/config/templates/rsi_strategy.yaml +72 -0
  18. QuantNodes/agent/config/templates/volume_price.yaml +86 -0
  19. QuantNodes/agent/config/types.py +156 -0
  20. QuantNodes/agent/config_mapper.py +293 -0
  21. QuantNodes/agent/core/__init__.py +19 -0
  22. QuantNodes/agent/core/dream.py +47 -0
  23. QuantNodes/agent/core/quant_dream.py +274 -0
  24. QuantNodes/agent/cron_jobs.py +314 -0
  25. QuantNodes/agent/nanobot_bridge.py +242 -0
  26. QuantNodes/agent/permission/__init__.py +30 -0
  27. QuantNodes/agent/permission/defaults.py +36 -0
  28. QuantNodes/agent/permission/evaluate.py +41 -0
  29. QuantNodes/agent/permission/models.py +59 -0
  30. QuantNodes/agent/permission/service.py +133 -0
  31. QuantNodes/agent/providers/__init__.py +11 -0
  32. QuantNodes/agent/providers/base.py +102 -0
  33. QuantNodes/agent/providers/quantnodes.py +610 -0
  34. QuantNodes/agent/providers/rate_limiter.py +326 -0
  35. QuantNodes/agent/providers/registry.py +163 -0
  36. QuantNodes/agent/skills/__init__.py +20 -0
  37. QuantNodes/agent/skills/base.py +118 -0
  38. QuantNodes/agent/skills/bridge.py +73 -0
  39. QuantNodes/agent/skills/factor/__init__.py +14 -0
  40. QuantNodes/agent/skills/factor/correlation.py +99 -0
  41. QuantNodes/agent/skills/factor/group_backtest.py +114 -0
  42. QuantNodes/agent/skills/factor/ic_analysis.py +106 -0
  43. QuantNodes/agent/skills/loader.py +107 -0
  44. QuantNodes/agent/skills/registry.py +105 -0
  45. QuantNodes/agent/skills/strategy/__init__.py +16 -0
  46. QuantNodes/agent/skills/strategy/bollinger.py +86 -0
  47. QuantNodes/agent/skills/strategy/dual_ma.py +82 -0
  48. QuantNodes/agent/skills/strategy/momentum.py +74 -0
  49. QuantNodes/agent/skills/strategy/rsi_reversal.py +99 -0
  50. QuantNodes/agent/skills_quant/__init__.py +14 -0
  51. QuantNodes/agent/skills_quant/backtest-analyze/SKILL.md +42 -0
  52. QuantNodes/agent/skills_quant/config-driven/SKILL.md +72 -0
  53. QuantNodes/agent/skills_quant/factor-research/SKILL.md +40 -0
  54. QuantNodes/agent/skills_quant/quant-dream/SKILL.md +55 -0
  55. QuantNodes/agent/skills_quant/risk-management/SKILL.md +45 -0
  56. QuantNodes/agent/skills_quant/strategy-design/SKILL.md +43 -0
  57. QuantNodes/agent/templates/__init__.py +4 -0
  58. QuantNodes/agent/tools/__init__.py +173 -0
  59. QuantNodes/agent/tools/_workspace.py +51 -0
  60. QuantNodes/agent/tools/alpha_backtest.py +328 -0
  61. QuantNodes/agent/tools/alpha_evaluate.py +493 -0
  62. QuantNodes/agent/tools/backtest.py +226 -0
  63. QuantNodes/agent/tools/base.py +133 -0
  64. QuantNodes/agent/tools/code_search.py +207 -0
  65. QuantNodes/agent/tools/config_backtest.py +401 -0
  66. QuantNodes/agent/tools/context.py +97 -0
  67. QuantNodes/agent/tools/dream_skill.py +77 -0
  68. QuantNodes/agent/tools/echo.py +38 -0
  69. QuantNodes/agent/tools/factor.py +231 -0
  70. QuantNodes/agent/tools/file_ops.py +201 -0
  71. QuantNodes/agent/tools/git_ops.py +190 -0
  72. QuantNodes/agent/tools/operator_lookup.py +218 -0
  73. QuantNodes/agent/tools/output_truncation.py +77 -0
  74. QuantNodes/agent/tools/path_check.py +43 -0
  75. QuantNodes/agent/tools/pipeline.py +62 -0
  76. QuantNodes/agent/tools/registry.py +150 -0
  77. QuantNodes/agent/tools/sandbox.py +62 -0
  78. QuantNodes/agent/tools/shell_safety.py +63 -0
  79. QuantNodes/agent/tools/strategy.py +106 -0
  80. QuantNodes/agent/tools/task.py +171 -0
  81. QuantNodes/agent/tools/web_fetch.py +142 -0
  82. QuantNodes/agent/tools/web_search.py +114 -0
  83. QuantNodes/agent/tools/wiki.py +370 -0
  84. QuantNodes/agent/utils/__init__.py +11 -0
  85. QuantNodes/agent/utils/helpers.py +43 -0
  86. QuantNodes/agent/utils/prompt_templates.py +30 -0
  87. QuantNodes/agent/workflows/__init__.py +20 -0
  88. QuantNodes/agent/workflows/implementations/__init__.py +8 -0
  89. QuantNodes/agent/workflows/implementations/alpha_gpt.py +508 -0
  90. QuantNodes/agent/workflows/implementations/mcts.py +442 -0
  91. QuantNodes/agent/workflows/parsers.py +44 -0
  92. QuantNodes/agent/workflows/registry.py +119 -0
  93. QuantNodes/agent/workflows/step_agent.py +219 -0
  94. QuantNodes/agent/workflows/tool.py +198 -0
  95. QuantNodes/ai/__init__.py +93 -0
  96. QuantNodes/ai/llm/__init__.py +75 -0
  97. QuantNodes/ai/llm/base.py +233 -0
  98. QuantNodes/ai/llm/decorators.py +281 -0
  99. QuantNodes/ai/llm/gateway.py +571 -0
  100. QuantNodes/ai/llm/null.py +76 -0
  101. QuantNodes/ai/llm/openai.py +435 -0
  102. QuantNodes/ai/optimizer.py +405 -0
  103. QuantNodes/ai/prompts/__init__.py +229 -0
  104. QuantNodes/ai/sandbox.py +371 -0
  105. QuantNodes/ai/sandbox_pandas_bridge.py +150 -0
  106. QuantNodes/ai/strategy_gen.py +396 -0
  107. QuantNodes/backtest/__init__.py +64 -0
  108. QuantNodes/backtest/backtest_node.py +188 -0
  109. QuantNodes/backtest/broker_node.py +378 -0
  110. QuantNodes/backtest/config_runner.py +397 -0
  111. QuantNodes/backtest/config_strategy.py +64 -0
  112. QuantNodes/backtest/risk_node.py +360 -0
  113. QuantNodes/backtest/strategy_node.py +268 -0
  114. QuantNodes/cache_node/__init__.py +19 -0
  115. QuantNodes/cache_node/base.py +244 -0
  116. QuantNodes/cache_node/cache_store.py +99 -0
  117. QuantNodes/cache_node/metadata.py +100 -0
  118. QuantNodes/cli/__init__.py +109 -0
  119. QuantNodes/cli/_helpers.py +511 -0
  120. QuantNodes/cli/command.py +110 -0
  121. QuantNodes/cli/commands/__init__.py +69 -0
  122. QuantNodes/cli/commands/agent.py +158 -0
  123. QuantNodes/cli/commands/alpha.py +951 -0
  124. QuantNodes/cli/commands/chat.py +38 -0
  125. QuantNodes/cli/commands/evolve.py +120 -0
  126. QuantNodes/cli/commands/factor.py +569 -0
  127. QuantNodes/cli/commands/init.py +190 -0
  128. QuantNodes/cli/commands/run.py +259 -0
  129. QuantNodes/cli/commands/serve.py +398 -0
  130. QuantNodes/cli/commands/version.py +120 -0
  131. QuantNodes/cli/enhanced.py +146 -0
  132. QuantNodes/conf_node/__init__.py +37 -0
  133. QuantNodes/conf_node/base.py +120 -0
  134. QuantNodes/conf_node/env_config.py +132 -0
  135. QuantNodes/conf_node/ini_config.py +70 -0
  136. QuantNodes/conf_node/json_config.py +69 -0
  137. QuantNodes/conf_node/yaml_config.py +78 -0
  138. QuantNodes/constants.py +17 -0
  139. QuantNodes/core/__init__.py +196 -0
  140. QuantNodes/core/_lookback_helpers.py +49 -0
  141. QuantNodes/core/ast_parser.py +198 -0
  142. QuantNodes/core/base.py +61 -0
  143. QuantNodes/core/cache_manager.py +344 -0
  144. QuantNodes/core/cache_utils.py +150 -0
  145. QuantNodes/core/cond_builder.py +53 -0
  146. QuantNodes/core/config.py +170 -0
  147. QuantNodes/core/constants.py +48 -0
  148. QuantNodes/core/control.py +412 -0
  149. QuantNodes/core/data_preprocessing.py +453 -0
  150. QuantNodes/core/data_source.py +46 -0
  151. QuantNodes/core/events.py +178 -0
  152. QuantNodes/core/evolution/__init__.py +22 -0
  153. QuantNodes/core/evolution/loop.py +583 -0
  154. QuantNodes/core/evolution/operators.py +289 -0
  155. QuantNodes/core/evolution/settings.py +44 -0
  156. QuantNodes/core/expression.py +841 -0
  157. QuantNodes/core/feedback/__init__.py +38 -0
  158. QuantNodes/core/feedback/channels.py +182 -0
  159. QuantNodes/core/feedback/collector.py +91 -0
  160. QuantNodes/core/feedback/dataclass.py +239 -0
  161. QuantNodes/core/feedback/llm_judge.py +138 -0
  162. QuantNodes/core/knowledge/__init__.py +69 -0
  163. QuantNodes/core/knowledge/knowledge_base.py +217 -0
  164. QuantNodes/core/knowledge/lineage_compress.py +196 -0
  165. QuantNodes/core/knowledge/lineage_expand.py +123 -0
  166. QuantNodes/core/knowledge/metrics/__init__.py +43 -0
  167. QuantNodes/core/knowledge/metrics/evaluator.py +176 -0
  168. QuantNodes/core/knowledge/metrics/metrics.py +220 -0
  169. QuantNodes/core/knowledge/rag_prompt.py +196 -0
  170. QuantNodes/core/knowledge/retriever.py +209 -0
  171. QuantNodes/core/lambda_node.py +81 -0
  172. QuantNodes/core/monitoring/__init__.py +22 -0
  173. QuantNodes/core/monitoring/collector.py +292 -0
  174. QuantNodes/core/monitoring/dashboard.py +365 -0
  175. QuantNodes/core/node.py +375 -0
  176. QuantNodes/core/pandas_utils.py +504 -0
  177. QuantNodes/core/parallel/__init__.py +15 -0
  178. QuantNodes/core/parallel/worker.py +140 -0
  179. QuantNodes/core/parallel/worker_process.py +265 -0
  180. QuantNodes/core/path_utils.py +73 -0
  181. QuantNodes/core/pipeline.py +328 -0
  182. QuantNodes/core/plugin.py +135 -0
  183. QuantNodes/core/quality_gate/__init__.py +32 -0
  184. QuantNodes/core/quality_gate/complexity.py +94 -0
  185. QuantNodes/core/quality_gate/consistency.py +26 -0
  186. QuantNodes/core/quality_gate/node.py +97 -0
  187. QuantNodes/core/quality_gate/redundancy.py +51 -0
  188. QuantNodes/core/quality_gate/settings.py +43 -0
  189. QuantNodes/core/quality_gate/zoo.py +98 -0
  190. QuantNodes/core/serializable.py +116 -0
  191. QuantNodes/core/serialization.py +673 -0
  192. QuantNodes/core/tools.py +333 -0
  193. QuantNodes/core/trajectory/__init__.py +25 -0
  194. QuantNodes/core/trajectory/entry.py +116 -0
  195. QuantNodes/core/trajectory/lineage.py +67 -0
  196. QuantNodes/core/trajectory/pool.py +211 -0
  197. QuantNodes/core/trajectory/selector.py +140 -0
  198. QuantNodes/core/visualization/__init__.py +33 -0
  199. QuantNodes/core/visualization/builder.py +233 -0
  200. QuantNodes/core/visualization/gate_breakdown.py +140 -0
  201. QuantNodes/core/visualization/lineage_dag.py +203 -0
  202. QuantNodes/core/visualization/metric_distribution.py +125 -0
  203. QuantNodes/core/visualization/report.py +68 -0
  204. QuantNodes/database_node/__init__.py +69 -0
  205. QuantNodes/database_node/base.py +135 -0
  206. QuantNodes/database_node/clickhouse_node.py +272 -0
  207. QuantNodes/database_node/csv_node.py +83 -0
  208. QuantNodes/database_node/duckdb_node.py +86 -0
  209. QuantNodes/database_node/factory.py +83 -0
  210. QuantNodes/database_node/mysql_node.py +100 -0
  211. QuantNodes/database_node/parquet_node.py +75 -0
  212. QuantNodes/database_node/sqlite_node.py +67 -0
  213. QuantNodes/factor_node/__init__.py +50 -0
  214. QuantNodes/factor_node/factor.py +563 -0
  215. QuantNodes/factor_node/factor_db.py +421 -0
  216. QuantNodes/factor_node/factor_functions/__init__.py +252 -0
  217. QuantNodes/factor_node/factor_functions/_helpers.py +358 -0
  218. QuantNodes/factor_node/factor_functions/_helpers_debug.py +317 -0
  219. QuantNodes/factor_node/factor_functions/composite_ops.py +136 -0
  220. QuantNodes/factor_node/factor_functions/math_ops.py +433 -0
  221. QuantNodes/factor_node/factor_functions/section_ops.py +290 -0
  222. QuantNodes/factor_node/factor_functions/talib_ops.py +1293 -0
  223. QuantNodes/factor_node/factor_functions/time_ops.py +535 -0
  224. QuantNodes/factor_node/factor_operation.py +1115 -0
  225. QuantNodes/factor_node/factor_table.py +1073 -0
  226. QuantNodes/factor_node/quant_nodes_object.py +60 -0
  227. QuantNodes/mcp_server/__init__.py +27 -0
  228. QuantNodes/mcp_server/__main__.py +4 -0
  229. QuantNodes/mcp_server/server.py +272 -0
  230. QuantNodes/methods/__init__.py +28 -0
  231. QuantNodes/methods/pipeline.py +100 -0
  232. QuantNodes/methods/sandbox.py +102 -0
  233. QuantNodes/monitor/__init__.py +27 -0
  234. QuantNodes/monitor/agent_tools/__init__.py +5 -0
  235. QuantNodes/monitor/agent_tools/monitor_tool.py +98 -0
  236. QuantNodes/monitor/agent_tools/schedule_tool.py +98 -0
  237. QuantNodes/monitor/agent_tools/version_tool.py +133 -0
  238. QuantNodes/monitor/monitor/__init__.py +6 -0
  239. QuantNodes/monitor/monitor/alerter.py +60 -0
  240. QuantNodes/monitor/monitor/collector.py +164 -0
  241. QuantNodes/monitor/monitor/dashboard.py +115 -0
  242. QuantNodes/monitor/monitor/drift.py +190 -0
  243. QuantNodes/monitor/scheduler/__init__.py +4 -0
  244. QuantNodes/monitor/scheduler/runner.py +133 -0
  245. QuantNodes/monitor/scheduler/scheduler.py +184 -0
  246. QuantNodes/monitor/storage/__init__.py +16 -0
  247. QuantNodes/monitor/storage/models.py +70 -0
  248. QuantNodes/monitor/storage/repository.py +407 -0
  249. QuantNodes/monitor/version/__init__.py +4 -0
  250. QuantNodes/monitor/version/diff.py +81 -0
  251. QuantNodes/monitor/version/version_manager.py +182 -0
  252. QuantNodes/operator_node/__init__.py +28 -0
  253. QuantNodes/operator_node/base.py +97 -0
  254. QuantNodes/operator_node/query_node.py +129 -0
  255. QuantNodes/operator_node/sql_builder.py +125 -0
  256. QuantNodes/operator_node/sql_utils.py +172 -0
  257. QuantNodes/operator_node/transform.py +130 -0
  258. QuantNodes/operators/__init__.py +90 -0
  259. QuantNodes/operators/_engine.py +108 -0
  260. QuantNodes/operators/composite.py +161 -0
  261. QuantNodes/operators/composite_dag.py +667 -0
  262. QuantNodes/operators/composite_dag_ops.py +343 -0
  263. QuantNodes/operators/composite_dag_pandas_ops.py +382 -0
  264. QuantNodes/operators/custom.py +408 -0
  265. QuantNodes/operators/facade.py +164 -0
  266. QuantNodes/operators/math.py +163 -0
  267. QuantNodes/operators/proxy.py +29 -0
  268. QuantNodes/operators/registry.py +144 -0
  269. QuantNodes/operators/section.py +99 -0
  270. QuantNodes/operators/talib.py +757 -0
  271. QuantNodes/operators/templates.py +95 -0
  272. QuantNodes/operators/time_series.py +136 -0
  273. QuantNodes/prompts/__init__.py +20 -0
  274. QuantNodes/prompts/backtest/__init__.py +12 -0
  275. QuantNodes/prompts/backtest/factor_based.py +86 -0
  276. QuantNodes/prompts/backtest/standard.py +73 -0
  277. QuantNodes/prompts/factor/__init__.py +14 -0
  278. QuantNodes/prompts/factor/correlation.py +77 -0
  279. QuantNodes/prompts/factor/group_backtest.py +86 -0
  280. QuantNodes/prompts/factor/ic_analysis.py +91 -0
  281. QuantNodes/prompts/strategy/__init__.py +18 -0
  282. QuantNodes/prompts/strategy/market_neutral.py +96 -0
  283. QuantNodes/prompts/strategy/mean_reversion.py +107 -0
  284. QuantNodes/prompts/strategy/momentum.py +160 -0
  285. QuantNodes/prompts/strategy/pairs_trading.py +107 -0
  286. QuantNodes/prompts/strategy/trend_following.py +96 -0
  287. QuantNodes/research/README.md +106 -0
  288. QuantNodes/research/__init__.py +154 -0
  289. QuantNodes/research/_legacy_3c/__init__.py +61 -0
  290. QuantNodes/research/_legacy_3c/auto_researcher.py +289 -0
  291. QuantNodes/research/_legacy_3c/factor_evaluator.py +560 -0
  292. QuantNodes/research/_legacy_3c/factor_miner.py +318 -0
  293. QuantNodes/research/_legacy_3c/mcts_search.py +324 -0
  294. QuantNodes/research/factor_test/__init__.py +25 -0
  295. QuantNodes/research/factor_test/config.py +184 -0
  296. QuantNodes/research/factor_test/config_builder.py +276 -0
  297. QuantNodes/research/factor_test/e2e/data_prep.py +163 -0
  298. QuantNodes/research/factor_test/e2e/run_evolution_e2e.py +309 -0
  299. QuantNodes/research/factor_test/evolution_adapter.py +231 -0
  300. QuantNodes/research/factor_test/feedback_wrapper.py +102 -0
  301. QuantNodes/research/factor_test/ifind_db/__init__.py +7 -0
  302. QuantNodes/research/factor_test/ifind_db/fetcher.py +224 -0
  303. QuantNodes/research/factor_test/ifind_db/ifind_database.py +689 -0
  304. QuantNodes/research/factor_test/nodes/__init__.py +1 -0
  305. QuantNodes/research/factor_test/nodes/_base.py +91 -0
  306. QuantNodes/research/factor_test/nodes/adjust_date_node.py +48 -0
  307. QuantNodes/research/factor_test/nodes/configs.py +240 -0
  308. QuantNodes/research/factor_test/nodes/factor_neutralize_node.py +87 -0
  309. QuantNodes/research/factor_test/nodes/factor_preprocess_node.py +222 -0
  310. QuantNodes/research/factor_test/nodes/factor_score_node.py +141 -0
  311. QuantNodes/research/factor_test/nodes/factor_test_report_node.py +153 -0
  312. QuantNodes/research/factor_test/nodes/group_analyzer_node.py +317 -0
  313. QuantNodes/research/factor_test/nodes/ic_analyzer_node.py +112 -0
  314. QuantNodes/research/factor_test/nodes/load_data_node.py +100 -0
  315. QuantNodes/research/factor_test/nodes/long_short_node.py +93 -0
  316. QuantNodes/research/factor_test/nodes/neutralizers.py +222 -0
  317. QuantNodes/research/factor_test/nodes/preprocess_strategies.py +277 -0
  318. QuantNodes/research/factor_test/nodes/risk_correlation_node.py +112 -0
  319. QuantNodes/research/factor_test/nodes/sample_pool_filter_node.py +110 -0
  320. QuantNodes/research/factor_test/nodes/tradability_filter_node.py +92 -0
  321. QuantNodes/research/factor_test/pipeline_runner.py +305 -0
  322. QuantNodes/research/factor_test/pipeline_spec.py +216 -0
  323. QuantNodes/research/factor_test/utils/__init__.py +26 -0
  324. QuantNodes/research/factor_test/utils/constants.py +86 -0
  325. QuantNodes/research/factor_test/utils/data_loader.py +141 -0
  326. QuantNodes/research/factor_test/utils/date_utils.py +232 -0
  327. QuantNodes/research/factor_test/utils/file_loaders.py +150 -0
  328. QuantNodes/research/factor_test/utils/labels.py +37 -0
  329. QuantNodes/research/factor_test/utils/metrics_extractor.py +55 -0
  330. QuantNodes/research/factor_test/utils/performance_metrics.py +175 -0
  331. QuantNodes/research/factor_test/utils/safe_load.py +106 -0
  332. QuantNodes/research/quant_alpha/CHANGELOG.md +80 -0
  333. QuantNodes/research/quant_alpha/README.md +142 -0
  334. QuantNodes/research/quant_alpha/__init__.py +45 -0
  335. QuantNodes/research/quant_alpha/adapters/__init__.py +99 -0
  336. QuantNodes/research/quant_alpha/adapters/calculator.py +503 -0
  337. QuantNodes/research/quant_alpha/adapters/expression.py +387 -0
  338. QuantNodes/research/quant_alpha/alpha101_design/__init__.py +50 -0
  339. QuantNodes/research/quant_alpha/alpha101_design/few_shot_examples.py +243 -0
  340. QuantNodes/research/quant_alpha/alpha101_design/philosophy.py +474 -0
  341. QuantNodes/research/quant_alpha/alpha158_design/__init__.py +63 -0
  342. QuantNodes/research/quant_alpha/alpha158_design/few_shot_examples.py +219 -0
  343. QuantNodes/research/quant_alpha/alpha158_design/philosophy.py +240 -0
  344. QuantNodes/research/quant_alpha/evaluation/__init__.py +47 -0
  345. QuantNodes/research/quant_alpha/evaluation/baselines/__init__.py +8 -0
  346. QuantNodes/research/quant_alpha/evaluation/baselines/g1_handcrafted.py +135 -0
  347. QuantNodes/research/quant_alpha/evaluation/baselines/g2_llm_only.py +269 -0
  348. QuantNodes/research/quant_alpha/evaluation/baselines/g3_alpha_gpt.py +152 -0
  349. QuantNodes/research/quant_alpha/evaluation/clickhouse_data_loader.py +227 -0
  350. QuantNodes/research/quant_alpha/evaluation/contracts.py +376 -0
  351. QuantNodes/research/quant_alpha/evaluation/evaluators/__init__.py +6 -0
  352. QuantNodes/research/quant_alpha/evaluation/evaluators/polars_evaluator.py +545 -0
  353. QuantNodes/research/quant_alpha/evaluation/mock_data_loader.py +226 -0
  354. QuantNodes/research/quant_alpha/evaluation/runner.py +243 -0
  355. QuantNodes/research/quant_alpha/llm/__init__.py +38 -0
  356. QuantNodes/research/quant_alpha/llm/parser.py +681 -0
  357. QuantNodes/research/quant_alpha/logic_driven_pipeline.py +411 -0
  358. QuantNodes/research/quant_alpha/logic_mining/__init__.py +74 -0
  359. QuantNodes/research/quant_alpha/logic_mining/compiler.py +457 -0
  360. QuantNodes/research/quant_alpha/logic_mining/generator.py +366 -0
  361. QuantNodes/research/quant_alpha/logic_mining/models.py +252 -0
  362. QuantNodes/research/quant_alpha/logic_mining/parser.py +287 -0
  363. QuantNodes/research/quant_alpha/logic_mining/pipelines.py +297 -0
  364. QuantNodes/research/quant_alpha/logic_mining/sources.py +149 -0
  365. QuantNodes/research/quant_alpha/mcts/__init__.py +66 -0
  366. QuantNodes/research/quant_alpha/mcts/cache.py +262 -0
  367. QuantNodes/research/quant_alpha/mcts/extension_ops.py +320 -0
  368. QuantNodes/research/quant_alpha/mcts/feedback.py +825 -0
  369. QuantNodes/research/quant_alpha/mcts/op_prior.py +180 -0
  370. QuantNodes/research/quant_alpha/mcts/search.py +540 -0
  371. QuantNodes/research/quant_alpha/mcts/tree.py +201 -0
  372. QuantNodes/research/quant_alpha/operator_vocab/__init__.py +50 -0
  373. QuantNodes/research/quant_alpha/operator_vocab/config.py +54 -0
  374. QuantNodes/research/quant_alpha/operator_vocab/metadata.py +263 -0
  375. QuantNodes/research/quant_alpha/operator_vocab/vocabulary.py +481 -0
  376. QuantNodes/research/quant_alpha/pipeline.py +1027 -0
  377. QuantNodes/research/quant_alpha/types/__init__.py +27 -0
  378. QuantNodes/research/quant_alpha/types/constants.py +28 -0
  379. QuantNodes/research/quant_alpha/types/state.py +205 -0
  380. QuantNodes/research/quant_alpha/workflow/__init__.py +32 -0
  381. QuantNodes/research/quant_alpha/workflow/alpha_gpt.py +911 -0
  382. QuantNodes/research/quant_alpha/workflow/alpha_logics.py +416 -0
  383. QuantNodes/research/quant_alpha/workflow/state.py +27 -0
  384. QuantNodes/research/report_reproducer.py +485 -0
  385. QuantNodes/research/wiki.py +1155 -0
  386. QuantNodes/symbolic/__init__.py +51 -0
  387. QuantNodes/symbolic/compiler.py +113 -0
  388. QuantNodes/symbolic/dialect.py +260 -0
  389. QuantNodes/symbolic/executor.py +147 -0
  390. QuantNodes/symbolic/expression.py +234 -0
  391. QuantNodes/symbolic/functions.py +433 -0
  392. QuantNodes/symbolic/optimizer.py +165 -0
  393. QuantNodes/ui_node/__init__.py +30 -0
  394. QuantNodes/ui_node/base.py +222 -0
  395. quantnodes-3.0.0.dist-info/METADATA +463 -0
  396. quantnodes-3.0.0.dist-info/RECORD +399 -0
  397. quantnodes-3.0.0.dist-info/WHEEL +5 -0
  398. quantnodes-3.0.0.dist-info/entry_points.txt +24 -0
  399. quantnodes-3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,82 @@
1
+ # coding=utf-8
2
+ """
3
+ Dual Moving Average Strategy Skill
4
+
5
+ Phase 4.3: Strategy Skills
6
+ """
7
+
8
+ from typing import Any, Dict
9
+
10
+ from ..base import Skill, SkillCategory, SkillMetadata, SkillResult
11
+
12
+
13
+ class DualMaSkill(Skill):
14
+ """Dual Moving Average Crossover Strategy"""
15
+
16
+ @property
17
+ def metadata(self) -> SkillMetadata:
18
+ return SkillMetadata(
19
+ name="dual_ma_strategy",
20
+ description="双均线交叉策略 - 短周期均线上穿长周期均线买入,下穿卖出",
21
+ category=SkillCategory.STRATEGY,
22
+ tags=["趋势跟踪", "均线", "双均线"],
23
+ examples=[
24
+ "生成双均线策略代码",
25
+ "如何使用双均线指标",
26
+ ],
27
+ )
28
+
29
+ async def execute(self, context: Dict[str, Any]) -> SkillResult:
30
+ """Execute dual MA strategy generation"""
31
+ fast_period = context.get("fast_period", 5)
32
+ slow_period = context.get("slow_period", 20)
33
+
34
+ code = f'''
35
+ def dual_ma_strategy(data, fast_period={fast_period}, slow_period={slow_period}):
36
+ """
37
+ 双均线策略
38
+ - Fast MA: {fast_period}日均线
39
+ - Slow MA: {slow_period}日均线
40
+ Signals:
41
+ - 金叉买入(1), 死叉卖出(-1), 持有(0)
42
+ """
43
+ import pandas as pd
44
+
45
+ data["fast_ma"] = data["close"].rolling({fast_period}).mean()
46
+ data["slow_ma"] = data["close"].rolling({slow_period}).mean()
47
+
48
+ data["signal"] = 0
49
+ data.loc[data["fast_ma"] > data["slow_ma"], "signal"] = 1
50
+ data.loc[data["fast_ma"] <= data["slow_ma"], "signal"] = -1
51
+
52
+ data["position"] = data["signal"].shift(1)
53
+ return data
54
+ '''
55
+ return SkillResult(
56
+ success=True,
57
+ data={
58
+ "strategy": "dual_ma",
59
+ "fast_period": fast_period,
60
+ "slow_period": slow_period,
61
+ "code": code.strip(),
62
+ "description": f"双均线策略: {fast_period}日均线与{slow_period}日均线交叉",
63
+ },
64
+ )
65
+
66
+ def get_parameters_schema(self) -> Dict[str, Any]:
67
+ """Return parameter schema"""
68
+ return {
69
+ "type": "object",
70
+ "properties": {
71
+ "fast_period": {
72
+ "type": "integer",
73
+ "description": "快速均线周期",
74
+ "default": 5,
75
+ },
76
+ "slow_period": {
77
+ "type": "integer",
78
+ "description": "慢速均线周期",
79
+ "default": 20,
80
+ },
81
+ },
82
+ }
@@ -0,0 +1,74 @@
1
+ # coding=utf-8
2
+ """
3
+ Momentum Strategy Skill
4
+
5
+ Phase 4.3: Strategy Skills
6
+ """
7
+
8
+ from typing import Any, Dict
9
+
10
+ from ..base import Skill, SkillCategory, SkillMetadata, SkillResult
11
+
12
+
13
+ class MomentumSkill(Skill):
14
+ """Momentum Strategy"""
15
+
16
+ @property
17
+ def metadata(self) -> SkillMetadata:
18
+ return SkillMetadata(
19
+ name="momentum_strategy",
20
+ description="动量策略 - 追涨杀跌,过去收益率为正则持有,为负则卖出",
21
+ category=SkillCategory.STRATEGY,
22
+ tags=["趋势跟踪", "动量", "追涨杀跌"],
23
+ examples=[
24
+ "生成动量策略代码",
25
+ "动量因子参数设置",
26
+ ],
27
+ )
28
+
29
+ async def execute(self, context: Dict[str, Any]) -> SkillResult:
30
+ """Execute momentum strategy generation"""
31
+ period = context.get("period", 20)
32
+
33
+ code = f'''
34
+ def momentum_strategy(data, period={period}):
35
+ """
36
+ 动量策略
37
+ - Period: {period}日回顾期
38
+ Signals:
39
+ - 动量为正持有(1)
40
+ - 动量为负卖出(-1)
41
+ """
42
+ import pandas as pd
43
+
44
+ data["momentum"] = data["close"] / data["close"].shift({period}) - 1
45
+
46
+ data["signal"] = 0
47
+ data.loc[data["momentum"] > 0, "signal"] = 1
48
+ data.loc[data["momentum"] <= 0, "signal"] = -1
49
+
50
+ data["position"] = data["signal"].shift(1)
51
+ return data
52
+ '''
53
+ return SkillResult(
54
+ success=True,
55
+ data={
56
+ "strategy": "momentum",
57
+ "period": period,
58
+ "code": code.strip(),
59
+ "description": f"动量策略: {period}日回顾期",
60
+ },
61
+ )
62
+
63
+ def get_parameters_schema(self) -> Dict[str, Any]:
64
+ """Return parameter schema"""
65
+ return {
66
+ "type": "object",
67
+ "properties": {
68
+ "period": {
69
+ "type": "integer",
70
+ "description": "动量回顾周期",
71
+ "default": 20,
72
+ },
73
+ },
74
+ }
@@ -0,0 +1,99 @@
1
+ # coding=utf-8
2
+ """
3
+ RSI Mean Reversion Strategy Skill
4
+
5
+ Phase 4.3: Strategy Skills
6
+ """
7
+
8
+ from typing import Any, Dict
9
+
10
+ from ..base import Skill, SkillCategory, SkillMetadata, SkillResult
11
+
12
+
13
+ class RSIReversalSkill(Skill):
14
+ """RSI Mean Reversion Strategy"""
15
+
16
+ @property
17
+ def metadata(self) -> SkillMetadata:
18
+ return SkillMetadata(
19
+ name="rsi_reversal_strategy",
20
+ description="RSI均值回归策略 - RSI超卖买入,RSI超买卖出",
21
+ category=SkillCategory.STRATEGY,
22
+ tags=["均值回归", "RSI", "超买超卖"],
23
+ examples=[
24
+ "生成RSI均值回归策略代码",
25
+ "RSI参数优化",
26
+ ],
27
+ )
28
+
29
+ async def execute(self, context: Dict[str, Any]) -> SkillResult:
30
+ """Execute RSI mean reversion strategy generation"""
31
+ period = context.get("period", 14)
32
+ oversold = context.get("oversold", 30)
33
+ overbought = context.get("overbought", 70)
34
+
35
+ code = f'''
36
+ def rsi_reversal_strategy(data, period={period}, oversold={oversold}, overbought={overbought}):
37
+ """
38
+ RSI均值回归策略
39
+ - Period: {period}日RSI计算周期
40
+ - Oversold: {oversold} (超卖阈值)
41
+ - Overbought: {overbought} (超买阈值)
42
+ Signals:
43
+ - RSI超卖时买入(1)
44
+ - RSI超买时卖出(-1)
45
+ - 持有(0)
46
+ """
47
+ import pandas as pd
48
+
49
+ delta = data["close"].diff()
50
+ gain = delta.where(delta > 0, 0)
51
+ loss = -delta.where(delta < 0, 0)
52
+
53
+ avg_gain = gain.rolling({period}).mean()
54
+ avg_loss = loss.rolling({period}).mean()
55
+
56
+ rs = avg_gain / avg_loss
57
+ data["rsi"] = 100 - (100 / (1 + rs))
58
+
59
+ data["signal"] = 0
60
+ data.loc[data["rsi"] < {oversold}, "signal"] = 1
61
+ data.loc[data["rsi"] > {overbought}, "signal"] = -1
62
+
63
+ data["position"] = data["signal"].shift(1)
64
+ return data
65
+ '''
66
+ return SkillResult(
67
+ success=True,
68
+ data={
69
+ "strategy": "rsi_reversal",
70
+ "period": period,
71
+ "oversold": oversold,
72
+ "overbought": overbought,
73
+ "code": code.strip(),
74
+ "description": f"RSI均值回归: 周期{period}, 超卖{oversold}, 超买{overbought}",
75
+ },
76
+ )
77
+
78
+ def get_parameters_schema(self) -> Dict[str, Any]:
79
+ """Return parameter schema"""
80
+ return {
81
+ "type": "object",
82
+ "properties": {
83
+ "period": {
84
+ "type": "integer",
85
+ "description": "RSI计算周期",
86
+ "default": 14,
87
+ },
88
+ "oversold": {
89
+ "type": "integer",
90
+ "description": "超卖阈值",
91
+ "default": 30,
92
+ },
93
+ "overbought": {
94
+ "type": "integer",
95
+ "description": "超买阈值",
96
+ "default": 70,
97
+ },
98
+ },
99
+ }
@@ -0,0 +1,14 @@
1
+ # coding=utf-8
2
+ """QuantNodes quant-specific skills.
3
+
4
+ Each subdirectory contains a SKILL.md following the HKUDS/nanobot
5
+ skill convention (YAML front-matter + instruction body). These
6
+ skills are auto-discovered by nanobot at startup via the
7
+ `nanobot/skills/` integration; this __init__ merely makes the
8
+ directory a proper Python package so that ``setuptools.find_packages``
9
+ includes the SKILL.md files in the built sdist / wheel.
10
+
11
+ See:
12
+ - docs/14-上游nanobot升级指南.md
13
+ - QuantNodes/agent/config_mapper.py (skills section)
14
+ """
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: backtest-analyze
3
+ description: 回测分析工作流 — 结果解读、归因分析、稳健性检验、问题诊断。
4
+ ---
5
+
6
+ # Backtest Analysis
7
+
8
+ 驱动 QuantNodes 回测结果深度分析:绩效归因、归因分解、稳健性检验、潜在问题诊断。
9
+
10
+ ## 工作流
11
+
12
+ 1. **结果解读** — 从回测输出提取关键指标:年化、夏普、最大回撤、胜率、盈亏比
13
+ 2. **归因分析** — 调用 `factor_test` 配 `mode="attribution"` 分析收益来源(因子暴露/行业暴露/风格暴露)
14
+ 3. **稳健性检验** — 拆分不同年份/不同市场环境(牛市/熊市/震荡市)的子样本表现
15
+ 4. **换手率分析** — 调用 `backtest_run` 输出换手率/手续费占比,识别过度交易
16
+ 5. **过拟合检测** — 样本内外对比、参数微扰测试、Walk-forward 验证
17
+ 6. **未来函数检测** — 检查是否用到当日收盘价才能计算的字段
18
+ 7. **问题诊断** — 若回撤>30% 或夏普<1,调用 `quant_dream` 记录问题模式
19
+
20
+ ## 工具集
21
+
22
+ | 工具 | 用途 |
23
+ |------|------|
24
+ | `backtest_run` | 单次回测 |
25
+ | `config_backtest` | 配置驱动回测 |
26
+ | `factor_test` | 因子归因(mode=attribution) |
27
+ | `wiki_write` | 写入回测报告 |
28
+ | `quant_dream` | 记录回测问题模式 |
29
+
30
+ ## 红旗指标
31
+
32
+ - 样本外夏普衰减 > 50% → 严重过拟合
33
+ - 最大回撤 > 30% → 风险过高
34
+ - 胜率 < 40% 且盈亏比 < 1.5 → 策略不稳
35
+ - 换手率 > 20%/月 → 交易成本可能侵蚀收益
36
+ - 因子最大暴露 > 0.5 → 风格集中度过高
37
+
38
+ ## 反模式
39
+
40
+ - 不要只展示样本内结果
41
+ - 不要忽视手续费和滑点
42
+ - 不要把运气当能力(短期高收益)
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: config-driven
3
+ description: 配置驱动策略 — YAML 配置文件编写、配置验证、回测自动闭环。
4
+ ---
5
+
6
+ # Config-Driven Strategy
7
+
8
+ QuantNodes v2.x 引入的**配置即策略**工作流:LLM 编写 YAML 配置而非 Python 代码,
9
+ 自动闭环到 ConfigLoader → OperatorRegistry → ConfigBacktestRunner。
10
+
11
+ ## YAML 结构
12
+
13
+ ```yaml
14
+ version: "1.0"
15
+ name: "momentum_alpha_v1"
16
+
17
+ data:
18
+ source: "clickhouse" # or duckdb/mysql/csv/parquet
19
+ conn_ini: "conn.ini"
20
+ table: "quote.cn_stock"
21
+ date_column: "date"
22
+ code_column: "code"
23
+
24
+ factors:
25
+ - name: momentum_20d
26
+ formula: "close / close.shift(20) - 1"
27
+
28
+ operations:
29
+ - type: time_series
30
+ name: momentum_ma
31
+ category: ts_mean
32
+ inputs: [momentum_20d]
33
+ params: {window: 20}
34
+
35
+ composite:
36
+ - name: alpha
37
+ formula: "momentum_ma"
38
+
39
+ backtest:
40
+ start_date: "2020-01-01"
41
+ end_date: "2024-12-31"
42
+ initial_cash: 1000000
43
+ ```
44
+
45
+ ## 工作流
46
+
47
+ 1. **配置编写** — LLM 根据研究主题生成 YAML 配置(无需写 Python)
48
+ 2. **配置验证** — 调用 `config_backtest` 工具(带 `validate_only=true`),检查:
49
+ - 数据源可达
50
+ - 因子公式合法
51
+ - 算子在 OperatorRegistry 中可查
52
+ 3. **Agent 兜底** — 若算子不可表达,Agent 编写自定义算子补充
53
+ 4. **回测执行** — 调用 `config_backtest` 自动闭环:config → 代码生成 → 验证 → 回测
54
+ 5. **结果沉淀** — 调用 `wiki_write` 写入 Wiki(附 YAML 配置 + 回测结果)
55
+
56
+ ## 工具集
57
+
58
+ | 工具 | 用途 |
59
+ |------|------|
60
+ | `config_backtest` | 配置驱动回测(核心) |
61
+ | `wiki_write` | 写入配置和结果 |
62
+
63
+ ## 算子覆盖
64
+
65
+ 默认 OperatorRegistry 覆盖 162 个常用算子(OperatorVocab)。
66
+ 不可覆盖时 Agent 兜底写自定义算子。
67
+
68
+ ## 反模式
69
+
70
+ - 不要在 YAML 中写 Python 代码(破坏配置驱动意义)
71
+ - 不要依赖未注册的算子(必须先验证)
72
+ - 不要忽略数据源配置(start with data section)
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: factor-research
3
+ description: 单因子研究工作流 — 因子生成、有效性测试、相关性分析、Wiki 沉淀。
4
+ ---
5
+
6
+ # Factor Research
7
+
8
+ 驱动 QuantNodes 单因子研究全流程:候选因子生成 → IC 测试 → 分组回测 → 相关性分析 → 写入 Wiki。
9
+
10
+ ## 工作流
11
+
12
+ 1. **生成因子候选** — 调用 `strategy_generate` 让 LLM 基于研究主题(动量/反转/质量/价值/波动率/...)生成 3-5 个因子公式
13
+ 2. **代码验证** — 调用 `pipeline_validate` 验证因子代码语法与数据依赖
14
+ 3. **单因子测试** — 调用 `factor_test` 跑 IC/ICIR/分组回测,得到 IC 序列、ICIR、分组收益表
15
+ 4. **相关性分析** — 调用 `factor_test` 配 `mode="correlation"` 检查新因子与已有因子库的相关系数(|r|>0.7 视为冗余)
16
+ 5. **沉淀 Wiki** — 调用 `wiki_write` 写入 Wiki 页面,附 IC 摘要 + 分组收益图 + 相关性矩阵
17
+ 6. **Dream 触发** — 若因子表现异常好(ICIR>3 或年化>30%),调用 `quant_dream` 工具追加洞察
18
+
19
+ ## 工具集
20
+
21
+ | 工具 | 用途 |
22
+ |------|------|
23
+ | `strategy_generate` | NL → 因子公式代码 |
24
+ | `pipeline_validate` | 语法/依赖验证 |
25
+ | `factor_test` | IC/ICIR/分组回测/相关性 |
26
+ | `wiki_write` | 写入 Wiki 页面 |
27
+ | `quant_dream` | 追加 quant dream 洞察 |
28
+
29
+ ## 验收标准
30
+
31
+ - IC 绝对值均值 > 0.03
32
+ - ICIR > 0.5
33
+ - 分组收益单调(top-bottom > 5%/年)
34
+ - 与现有因子库 |r| < 0.7
35
+
36
+ ## 反模式
37
+
38
+ - 不要跳过代码验证直接回测(浪费时间)
39
+ - 不要在同一日期截面用未来数据(未来函数)
40
+ - 不要忽略相关性分析(冗余因子)
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: quant-dream
3
+ description: 量化专属 Dream 钩子 — 因子/回测/策略洞察的自动沉淀与跨会话记忆。
4
+ ---
5
+
6
+ # Quant Dream
7
+
8
+ 在 HKUDS nanobot 通用 Dream(记忆整合)之上叠加的**量化专属**反思层。
9
+ 挂在 nanobot 的 `AgentHook` 系统上,每个 session 结束后异步运行。
10
+
11
+ ## 触发条件
12
+
13
+ 每 N 轮对话后(或显式调用 `quant_dream_analyze` 工具)触发一次:
14
+ - session 中包含因子公式关键词 (`alpha`, `factor`, `IC`, `rank`)
15
+ - session 中包含回测关键词 (`backtest`, `sharpe`, `drawdown`)
16
+ - session 中包含策略关键词 (`strategy`, `pipeline`, `weight`)
17
+
18
+ ## 分析内容
19
+
20
+ 1. **因子洞察** — 提取 IC 表现好的因子,反思构造逻辑
21
+ 2. **回测模式** — 记录过拟合/未来函数/手续费过高等问题模式
22
+ 3. **策略启发** — 跨策略对比,识别共同成功因素
23
+ 4. **风险事件** — 大回撤/极端行情下的策略表现
24
+ 5. **代码模式** — LLM 生成的常见代码 bug(除零/未来函数/look-ahead bias)
25
+
26
+ ## 输出
27
+
28
+ 写入 `.agent/memory/topic-quant-dream.md`(Markdown 索引格式):
29
+
30
+ ```markdown
31
+ ### 2026-06-23 - factor_insight
32
+ - momentum_20d 因子在 2020-2024 年化 18%, ICIR=1.2
33
+ - 构造: close / close.shift(20) - 1
34
+ - 适用: 中证 500 成分股, 调仓周期 5 日
35
+ - 失效条件: 极端反转市(2015-06, 2020-03)
36
+
37
+ ### 2026-06-23 - backtest_pattern
38
+ - 样本外夏普衰减 > 50% 提示过拟合
39
+ - 案例: momentum_v3 样本内 2.1 → 样本外 0.8
40
+ - 修正: 缩短调仓周期至 5 日, 增加中性化
41
+ ```
42
+
43
+ ## 工具集
44
+
45
+ | 工具 | 用途 |
46
+ |------|------|
47
+ | `wiki_write` | 写入 Wiki 页面(结构化) |
48
+ | `wiki_query` | 检索历史 Dream 洞察 |
49
+ | `quant_dream_analyze` | 显式触发分析 |
50
+
51
+ ## 频率控制
52
+
53
+ - 默认: 每 10 轮对话触发一次(防过度反思)
54
+ - 显式调用: 立即触发
55
+ - 失败静默: 不打断主对话流
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: risk-management
3
+ description: 风险管理 — 仓位控制、止损规则、组合分散、风险敞口监控。
4
+ ---
5
+
6
+ # Risk Management
7
+
8
+ 驱动 QuantNodes 策略风险管理:仓位控制、止损规则、组合分散度、风险敞口监控。
9
+
10
+ ## 工作流
11
+
12
+ 1. **仓位规则** — 单票最大持仓、行业最大持仓、风格最大持仓(建议 5%/15%/30%)
13
+ 2. **止损规则** — 个股止损(-8%)、组合最大回撤止损(-15%)、波动率自适应止损
14
+ 3. **行业中性** — 调用 `factor_test` 配 `mode="industry_neutral"` 检查行业暴露
15
+ 4. **风格中性** — Barra 风格因子中性化(市值/价值/动量/波动率)
16
+ 5. **风险敞口** — 计算组合 beta、行业 beta、风格 beta
17
+ 6. **压力测试** — 模拟 2008/2015/2020 极端市场下的回撤
18
+ 7. **监控告警** — 调用 `quant_dream` 记录风险事件
19
+
20
+ ## 工具集
21
+
22
+ | 工具 | 用途 |
23
+ |------|------|
24
+ | `factor_test` | 行业中性化、风格中性化 |
25
+ | `backtest_run` | 压力测试回测 |
26
+ | `config_backtest` | 风险参数扫描 |
27
+ | `wiki_write` | 写入风险规则文档 |
28
+ | `quant_dream` | 风险事件记录 |
29
+
30
+ ## 风险阈值(默认)
31
+
32
+ - 单票最大持仓: 5%
33
+ - 行业最大持仓: 15%
34
+ - 风格最大暴露: 0.3 (标准化)
35
+ - 个股止损: -8%
36
+ - 组合最大回撤: -15%
37
+ - 单日 VaR (95%): -2%
38
+ - 最大杠杆: 1.0x
39
+
40
+ ## 反模式
41
+
42
+ - 不要集中持仓(>10% 单票)
43
+ - 不要无限加仓下跌股
44
+ - 不要忽视相关性(看似分散实则集中)
45
+ - 不要只看收益不看波动
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: strategy-design
3
+ description: 策略设计工作流 — 因子组合、权重优化、回测验证、参数敏感性。
4
+ ---
5
+
6
+ # Strategy Design
7
+
8
+ 驱动 QuantNodes 策略设计全流程:因子筛选 → 组合方式 → 回测验证 → 参数敏感性 → Wiki 沉淀。
9
+
10
+ ## 工作流
11
+
12
+ 1. **因子组合方案** — 基于 `factor-research` 输出,调用 `strategy_generate` 让 LLM 设计 2-3 种组合方案(等权/IC 加权/最大化 ICIR)
13
+ 2. **Pipeline 验证** — 调用 `pipeline_validate` 验证整体 Pipeline 代码
14
+ 3. **沙箱执行** — 调用 `sandbox_validate` 检查代码安全(无 import 危险模块)
15
+ 4. **回测验证** — 调用 `backtest_run` 或 `config_backtest` 跑 3-5 年样本外回测
16
+ 5. **参数敏感性** — 修改关键参数(调仓周期/持仓数/止损),观察绩效变化
17
+ 6. **过拟合检测** — 样本内 vs 样本外对比;多空收益曲线对比;夏普衰减 < 30%
18
+ 7. **沉淀 Wiki** — 调用 `wiki_write` 写入策略页面,附参数表 + 收益曲线 + 回撤分析
19
+
20
+ ## 工具集
21
+
22
+ | 工具 | 用途 |
23
+ |------|------|
24
+ | `strategy_generate` | NL → Pipeline 代码 |
25
+ | `pipeline_validate` | Pipeline 语法/依赖验证 |
26
+ | `sandbox_validate` | 代码安全检查 |
27
+ | `backtest_run` | 快速回测(pipeline_code) |
28
+ | `config_backtest` | 配置驱动回测(YAML) |
29
+ | `wiki_write` | 写入策略 Wiki 页面 |
30
+
31
+ ## 验收标准
32
+
33
+ - 年化收益 > 15%
34
+ - 最大回撤 < 20%
35
+ - 夏普比率 > 1.5
36
+ - 样本外夏普衰减 < 30%
37
+ - 调仓成本占比 < 30% 收益
38
+
39
+ ## 反模式
40
+
41
+ - 不要在样本内做参数优化(过拟合)
42
+ - 不要忽视交易成本(手续费+滑点)
43
+ - 不要只看总收益不看回撤
@@ -0,0 +1,4 @@
1
+ # coding=utf-8
2
+ """
3
+ Prompt模板目录
4
+ """