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.
- QuantNodes/__init__.py +15 -0
- QuantNodes/__main__.py +14 -0
- QuantNodes/agent/__init__.py +158 -0
- QuantNodes/agent/agents/__init__.py +13 -0
- QuantNodes/agent/agents/definition.py +180 -0
- QuantNodes/agent/agents/manager.py +73 -0
- QuantNodes/agent/config/__init__.py +34 -0
- QuantNodes/agent/config/executor.py +958 -0
- QuantNodes/agent/config/loader.py +427 -0
- QuantNodes/agent/config/templates/bollinger_bands.yaml +84 -0
- QuantNodes/agent/config/templates/dual_ma.yaml +72 -0
- QuantNodes/agent/config/templates/empty.yaml +56 -0
- QuantNodes/agent/config/templates/mean_reversion.yaml +47 -0
- QuantNodes/agent/config/templates/mean_reversion_zscore.yaml +90 -0
- QuantNodes/agent/config/templates/momentum.yaml +81 -0
- QuantNodes/agent/config/templates/momentum_breakout.yaml +84 -0
- QuantNodes/agent/config/templates/rsi_strategy.yaml +72 -0
- QuantNodes/agent/config/templates/volume_price.yaml +86 -0
- QuantNodes/agent/config/types.py +156 -0
- QuantNodes/agent/config_mapper.py +293 -0
- QuantNodes/agent/core/__init__.py +19 -0
- QuantNodes/agent/core/dream.py +47 -0
- QuantNodes/agent/core/quant_dream.py +274 -0
- QuantNodes/agent/cron_jobs.py +314 -0
- QuantNodes/agent/nanobot_bridge.py +242 -0
- QuantNodes/agent/permission/__init__.py +30 -0
- QuantNodes/agent/permission/defaults.py +36 -0
- QuantNodes/agent/permission/evaluate.py +41 -0
- QuantNodes/agent/permission/models.py +59 -0
- QuantNodes/agent/permission/service.py +133 -0
- QuantNodes/agent/providers/__init__.py +11 -0
- QuantNodes/agent/providers/base.py +102 -0
- QuantNodes/agent/providers/quantnodes.py +610 -0
- QuantNodes/agent/providers/rate_limiter.py +326 -0
- QuantNodes/agent/providers/registry.py +163 -0
- QuantNodes/agent/skills/__init__.py +20 -0
- QuantNodes/agent/skills/base.py +118 -0
- QuantNodes/agent/skills/bridge.py +73 -0
- QuantNodes/agent/skills/factor/__init__.py +14 -0
- QuantNodes/agent/skills/factor/correlation.py +99 -0
- QuantNodes/agent/skills/factor/group_backtest.py +114 -0
- QuantNodes/agent/skills/factor/ic_analysis.py +106 -0
- QuantNodes/agent/skills/loader.py +107 -0
- QuantNodes/agent/skills/registry.py +105 -0
- QuantNodes/agent/skills/strategy/__init__.py +16 -0
- QuantNodes/agent/skills/strategy/bollinger.py +86 -0
- QuantNodes/agent/skills/strategy/dual_ma.py +82 -0
- QuantNodes/agent/skills/strategy/momentum.py +74 -0
- QuantNodes/agent/skills/strategy/rsi_reversal.py +99 -0
- QuantNodes/agent/skills_quant/__init__.py +14 -0
- QuantNodes/agent/skills_quant/backtest-analyze/SKILL.md +42 -0
- QuantNodes/agent/skills_quant/config-driven/SKILL.md +72 -0
- QuantNodes/agent/skills_quant/factor-research/SKILL.md +40 -0
- QuantNodes/agent/skills_quant/quant-dream/SKILL.md +55 -0
- QuantNodes/agent/skills_quant/risk-management/SKILL.md +45 -0
- QuantNodes/agent/skills_quant/strategy-design/SKILL.md +43 -0
- QuantNodes/agent/templates/__init__.py +4 -0
- QuantNodes/agent/tools/__init__.py +173 -0
- QuantNodes/agent/tools/_workspace.py +51 -0
- QuantNodes/agent/tools/alpha_backtest.py +328 -0
- QuantNodes/agent/tools/alpha_evaluate.py +493 -0
- QuantNodes/agent/tools/backtest.py +226 -0
- QuantNodes/agent/tools/base.py +133 -0
- QuantNodes/agent/tools/code_search.py +207 -0
- QuantNodes/agent/tools/config_backtest.py +401 -0
- QuantNodes/agent/tools/context.py +97 -0
- QuantNodes/agent/tools/dream_skill.py +77 -0
- QuantNodes/agent/tools/echo.py +38 -0
- QuantNodes/agent/tools/factor.py +231 -0
- QuantNodes/agent/tools/file_ops.py +201 -0
- QuantNodes/agent/tools/git_ops.py +190 -0
- QuantNodes/agent/tools/operator_lookup.py +218 -0
- QuantNodes/agent/tools/output_truncation.py +77 -0
- QuantNodes/agent/tools/path_check.py +43 -0
- QuantNodes/agent/tools/pipeline.py +62 -0
- QuantNodes/agent/tools/registry.py +150 -0
- QuantNodes/agent/tools/sandbox.py +62 -0
- QuantNodes/agent/tools/shell_safety.py +63 -0
- QuantNodes/agent/tools/strategy.py +106 -0
- QuantNodes/agent/tools/task.py +171 -0
- QuantNodes/agent/tools/web_fetch.py +142 -0
- QuantNodes/agent/tools/web_search.py +114 -0
- QuantNodes/agent/tools/wiki.py +370 -0
- QuantNodes/agent/utils/__init__.py +11 -0
- QuantNodes/agent/utils/helpers.py +43 -0
- QuantNodes/agent/utils/prompt_templates.py +30 -0
- QuantNodes/agent/workflows/__init__.py +20 -0
- QuantNodes/agent/workflows/implementations/__init__.py +8 -0
- QuantNodes/agent/workflows/implementations/alpha_gpt.py +508 -0
- QuantNodes/agent/workflows/implementations/mcts.py +442 -0
- QuantNodes/agent/workflows/parsers.py +44 -0
- QuantNodes/agent/workflows/registry.py +119 -0
- QuantNodes/agent/workflows/step_agent.py +219 -0
- QuantNodes/agent/workflows/tool.py +198 -0
- QuantNodes/ai/__init__.py +93 -0
- QuantNodes/ai/llm/__init__.py +75 -0
- QuantNodes/ai/llm/base.py +233 -0
- QuantNodes/ai/llm/decorators.py +281 -0
- QuantNodes/ai/llm/gateway.py +571 -0
- QuantNodes/ai/llm/null.py +76 -0
- QuantNodes/ai/llm/openai.py +435 -0
- QuantNodes/ai/optimizer.py +405 -0
- QuantNodes/ai/prompts/__init__.py +229 -0
- QuantNodes/ai/sandbox.py +371 -0
- QuantNodes/ai/sandbox_pandas_bridge.py +150 -0
- QuantNodes/ai/strategy_gen.py +396 -0
- QuantNodes/backtest/__init__.py +64 -0
- QuantNodes/backtest/backtest_node.py +188 -0
- QuantNodes/backtest/broker_node.py +378 -0
- QuantNodes/backtest/config_runner.py +397 -0
- QuantNodes/backtest/config_strategy.py +64 -0
- QuantNodes/backtest/risk_node.py +360 -0
- QuantNodes/backtest/strategy_node.py +268 -0
- QuantNodes/cache_node/__init__.py +19 -0
- QuantNodes/cache_node/base.py +244 -0
- QuantNodes/cache_node/cache_store.py +99 -0
- QuantNodes/cache_node/metadata.py +100 -0
- QuantNodes/cli/__init__.py +109 -0
- QuantNodes/cli/_helpers.py +511 -0
- QuantNodes/cli/command.py +110 -0
- QuantNodes/cli/commands/__init__.py +69 -0
- QuantNodes/cli/commands/agent.py +158 -0
- QuantNodes/cli/commands/alpha.py +951 -0
- QuantNodes/cli/commands/chat.py +38 -0
- QuantNodes/cli/commands/evolve.py +120 -0
- QuantNodes/cli/commands/factor.py +569 -0
- QuantNodes/cli/commands/init.py +190 -0
- QuantNodes/cli/commands/run.py +259 -0
- QuantNodes/cli/commands/serve.py +398 -0
- QuantNodes/cli/commands/version.py +120 -0
- QuantNodes/cli/enhanced.py +146 -0
- QuantNodes/conf_node/__init__.py +37 -0
- QuantNodes/conf_node/base.py +120 -0
- QuantNodes/conf_node/env_config.py +132 -0
- QuantNodes/conf_node/ini_config.py +70 -0
- QuantNodes/conf_node/json_config.py +69 -0
- QuantNodes/conf_node/yaml_config.py +78 -0
- QuantNodes/constants.py +17 -0
- QuantNodes/core/__init__.py +196 -0
- QuantNodes/core/_lookback_helpers.py +49 -0
- QuantNodes/core/ast_parser.py +198 -0
- QuantNodes/core/base.py +61 -0
- QuantNodes/core/cache_manager.py +344 -0
- QuantNodes/core/cache_utils.py +150 -0
- QuantNodes/core/cond_builder.py +53 -0
- QuantNodes/core/config.py +170 -0
- QuantNodes/core/constants.py +48 -0
- QuantNodes/core/control.py +412 -0
- QuantNodes/core/data_preprocessing.py +453 -0
- QuantNodes/core/data_source.py +46 -0
- QuantNodes/core/events.py +178 -0
- QuantNodes/core/evolution/__init__.py +22 -0
- QuantNodes/core/evolution/loop.py +583 -0
- QuantNodes/core/evolution/operators.py +289 -0
- QuantNodes/core/evolution/settings.py +44 -0
- QuantNodes/core/expression.py +841 -0
- QuantNodes/core/feedback/__init__.py +38 -0
- QuantNodes/core/feedback/channels.py +182 -0
- QuantNodes/core/feedback/collector.py +91 -0
- QuantNodes/core/feedback/dataclass.py +239 -0
- QuantNodes/core/feedback/llm_judge.py +138 -0
- QuantNodes/core/knowledge/__init__.py +69 -0
- QuantNodes/core/knowledge/knowledge_base.py +217 -0
- QuantNodes/core/knowledge/lineage_compress.py +196 -0
- QuantNodes/core/knowledge/lineage_expand.py +123 -0
- QuantNodes/core/knowledge/metrics/__init__.py +43 -0
- QuantNodes/core/knowledge/metrics/evaluator.py +176 -0
- QuantNodes/core/knowledge/metrics/metrics.py +220 -0
- QuantNodes/core/knowledge/rag_prompt.py +196 -0
- QuantNodes/core/knowledge/retriever.py +209 -0
- QuantNodes/core/lambda_node.py +81 -0
- QuantNodes/core/monitoring/__init__.py +22 -0
- QuantNodes/core/monitoring/collector.py +292 -0
- QuantNodes/core/monitoring/dashboard.py +365 -0
- QuantNodes/core/node.py +375 -0
- QuantNodes/core/pandas_utils.py +504 -0
- QuantNodes/core/parallel/__init__.py +15 -0
- QuantNodes/core/parallel/worker.py +140 -0
- QuantNodes/core/parallel/worker_process.py +265 -0
- QuantNodes/core/path_utils.py +73 -0
- QuantNodes/core/pipeline.py +328 -0
- QuantNodes/core/plugin.py +135 -0
- QuantNodes/core/quality_gate/__init__.py +32 -0
- QuantNodes/core/quality_gate/complexity.py +94 -0
- QuantNodes/core/quality_gate/consistency.py +26 -0
- QuantNodes/core/quality_gate/node.py +97 -0
- QuantNodes/core/quality_gate/redundancy.py +51 -0
- QuantNodes/core/quality_gate/settings.py +43 -0
- QuantNodes/core/quality_gate/zoo.py +98 -0
- QuantNodes/core/serializable.py +116 -0
- QuantNodes/core/serialization.py +673 -0
- QuantNodes/core/tools.py +333 -0
- QuantNodes/core/trajectory/__init__.py +25 -0
- QuantNodes/core/trajectory/entry.py +116 -0
- QuantNodes/core/trajectory/lineage.py +67 -0
- QuantNodes/core/trajectory/pool.py +211 -0
- QuantNodes/core/trajectory/selector.py +140 -0
- QuantNodes/core/visualization/__init__.py +33 -0
- QuantNodes/core/visualization/builder.py +233 -0
- QuantNodes/core/visualization/gate_breakdown.py +140 -0
- QuantNodes/core/visualization/lineage_dag.py +203 -0
- QuantNodes/core/visualization/metric_distribution.py +125 -0
- QuantNodes/core/visualization/report.py +68 -0
- QuantNodes/database_node/__init__.py +69 -0
- QuantNodes/database_node/base.py +135 -0
- QuantNodes/database_node/clickhouse_node.py +272 -0
- QuantNodes/database_node/csv_node.py +83 -0
- QuantNodes/database_node/duckdb_node.py +86 -0
- QuantNodes/database_node/factory.py +83 -0
- QuantNodes/database_node/mysql_node.py +100 -0
- QuantNodes/database_node/parquet_node.py +75 -0
- QuantNodes/database_node/sqlite_node.py +67 -0
- QuantNodes/factor_node/__init__.py +50 -0
- QuantNodes/factor_node/factor.py +563 -0
- QuantNodes/factor_node/factor_db.py +421 -0
- QuantNodes/factor_node/factor_functions/__init__.py +252 -0
- QuantNodes/factor_node/factor_functions/_helpers.py +358 -0
- QuantNodes/factor_node/factor_functions/_helpers_debug.py +317 -0
- QuantNodes/factor_node/factor_functions/composite_ops.py +136 -0
- QuantNodes/factor_node/factor_functions/math_ops.py +433 -0
- QuantNodes/factor_node/factor_functions/section_ops.py +290 -0
- QuantNodes/factor_node/factor_functions/talib_ops.py +1293 -0
- QuantNodes/factor_node/factor_functions/time_ops.py +535 -0
- QuantNodes/factor_node/factor_operation.py +1115 -0
- QuantNodes/factor_node/factor_table.py +1073 -0
- QuantNodes/factor_node/quant_nodes_object.py +60 -0
- QuantNodes/mcp_server/__init__.py +27 -0
- QuantNodes/mcp_server/__main__.py +4 -0
- QuantNodes/mcp_server/server.py +272 -0
- QuantNodes/methods/__init__.py +28 -0
- QuantNodes/methods/pipeline.py +100 -0
- QuantNodes/methods/sandbox.py +102 -0
- QuantNodes/monitor/__init__.py +27 -0
- QuantNodes/monitor/agent_tools/__init__.py +5 -0
- QuantNodes/monitor/agent_tools/monitor_tool.py +98 -0
- QuantNodes/monitor/agent_tools/schedule_tool.py +98 -0
- QuantNodes/monitor/agent_tools/version_tool.py +133 -0
- QuantNodes/monitor/monitor/__init__.py +6 -0
- QuantNodes/monitor/monitor/alerter.py +60 -0
- QuantNodes/monitor/monitor/collector.py +164 -0
- QuantNodes/monitor/monitor/dashboard.py +115 -0
- QuantNodes/monitor/monitor/drift.py +190 -0
- QuantNodes/monitor/scheduler/__init__.py +4 -0
- QuantNodes/monitor/scheduler/runner.py +133 -0
- QuantNodes/monitor/scheduler/scheduler.py +184 -0
- QuantNodes/monitor/storage/__init__.py +16 -0
- QuantNodes/monitor/storage/models.py +70 -0
- QuantNodes/monitor/storage/repository.py +407 -0
- QuantNodes/monitor/version/__init__.py +4 -0
- QuantNodes/monitor/version/diff.py +81 -0
- QuantNodes/monitor/version/version_manager.py +182 -0
- QuantNodes/operator_node/__init__.py +28 -0
- QuantNodes/operator_node/base.py +97 -0
- QuantNodes/operator_node/query_node.py +129 -0
- QuantNodes/operator_node/sql_builder.py +125 -0
- QuantNodes/operator_node/sql_utils.py +172 -0
- QuantNodes/operator_node/transform.py +130 -0
- QuantNodes/operators/__init__.py +90 -0
- QuantNodes/operators/_engine.py +108 -0
- QuantNodes/operators/composite.py +161 -0
- QuantNodes/operators/composite_dag.py +667 -0
- QuantNodes/operators/composite_dag_ops.py +343 -0
- QuantNodes/operators/composite_dag_pandas_ops.py +382 -0
- QuantNodes/operators/custom.py +408 -0
- QuantNodes/operators/facade.py +164 -0
- QuantNodes/operators/math.py +163 -0
- QuantNodes/operators/proxy.py +29 -0
- QuantNodes/operators/registry.py +144 -0
- QuantNodes/operators/section.py +99 -0
- QuantNodes/operators/talib.py +757 -0
- QuantNodes/operators/templates.py +95 -0
- QuantNodes/operators/time_series.py +136 -0
- QuantNodes/prompts/__init__.py +20 -0
- QuantNodes/prompts/backtest/__init__.py +12 -0
- QuantNodes/prompts/backtest/factor_based.py +86 -0
- QuantNodes/prompts/backtest/standard.py +73 -0
- QuantNodes/prompts/factor/__init__.py +14 -0
- QuantNodes/prompts/factor/correlation.py +77 -0
- QuantNodes/prompts/factor/group_backtest.py +86 -0
- QuantNodes/prompts/factor/ic_analysis.py +91 -0
- QuantNodes/prompts/strategy/__init__.py +18 -0
- QuantNodes/prompts/strategy/market_neutral.py +96 -0
- QuantNodes/prompts/strategy/mean_reversion.py +107 -0
- QuantNodes/prompts/strategy/momentum.py +160 -0
- QuantNodes/prompts/strategy/pairs_trading.py +107 -0
- QuantNodes/prompts/strategy/trend_following.py +96 -0
- QuantNodes/research/README.md +106 -0
- QuantNodes/research/__init__.py +154 -0
- QuantNodes/research/_legacy_3c/__init__.py +61 -0
- QuantNodes/research/_legacy_3c/auto_researcher.py +289 -0
- QuantNodes/research/_legacy_3c/factor_evaluator.py +560 -0
- QuantNodes/research/_legacy_3c/factor_miner.py +318 -0
- QuantNodes/research/_legacy_3c/mcts_search.py +324 -0
- QuantNodes/research/factor_test/__init__.py +25 -0
- QuantNodes/research/factor_test/config.py +184 -0
- QuantNodes/research/factor_test/config_builder.py +276 -0
- QuantNodes/research/factor_test/e2e/data_prep.py +163 -0
- QuantNodes/research/factor_test/e2e/run_evolution_e2e.py +309 -0
- QuantNodes/research/factor_test/evolution_adapter.py +231 -0
- QuantNodes/research/factor_test/feedback_wrapper.py +102 -0
- QuantNodes/research/factor_test/ifind_db/__init__.py +7 -0
- QuantNodes/research/factor_test/ifind_db/fetcher.py +224 -0
- QuantNodes/research/factor_test/ifind_db/ifind_database.py +689 -0
- QuantNodes/research/factor_test/nodes/__init__.py +1 -0
- QuantNodes/research/factor_test/nodes/_base.py +91 -0
- QuantNodes/research/factor_test/nodes/adjust_date_node.py +48 -0
- QuantNodes/research/factor_test/nodes/configs.py +240 -0
- QuantNodes/research/factor_test/nodes/factor_neutralize_node.py +87 -0
- QuantNodes/research/factor_test/nodes/factor_preprocess_node.py +222 -0
- QuantNodes/research/factor_test/nodes/factor_score_node.py +141 -0
- QuantNodes/research/factor_test/nodes/factor_test_report_node.py +153 -0
- QuantNodes/research/factor_test/nodes/group_analyzer_node.py +317 -0
- QuantNodes/research/factor_test/nodes/ic_analyzer_node.py +112 -0
- QuantNodes/research/factor_test/nodes/load_data_node.py +100 -0
- QuantNodes/research/factor_test/nodes/long_short_node.py +93 -0
- QuantNodes/research/factor_test/nodes/neutralizers.py +222 -0
- QuantNodes/research/factor_test/nodes/preprocess_strategies.py +277 -0
- QuantNodes/research/factor_test/nodes/risk_correlation_node.py +112 -0
- QuantNodes/research/factor_test/nodes/sample_pool_filter_node.py +110 -0
- QuantNodes/research/factor_test/nodes/tradability_filter_node.py +92 -0
- QuantNodes/research/factor_test/pipeline_runner.py +305 -0
- QuantNodes/research/factor_test/pipeline_spec.py +216 -0
- QuantNodes/research/factor_test/utils/__init__.py +26 -0
- QuantNodes/research/factor_test/utils/constants.py +86 -0
- QuantNodes/research/factor_test/utils/data_loader.py +141 -0
- QuantNodes/research/factor_test/utils/date_utils.py +232 -0
- QuantNodes/research/factor_test/utils/file_loaders.py +150 -0
- QuantNodes/research/factor_test/utils/labels.py +37 -0
- QuantNodes/research/factor_test/utils/metrics_extractor.py +55 -0
- QuantNodes/research/factor_test/utils/performance_metrics.py +175 -0
- QuantNodes/research/factor_test/utils/safe_load.py +106 -0
- QuantNodes/research/quant_alpha/CHANGELOG.md +80 -0
- QuantNodes/research/quant_alpha/README.md +142 -0
- QuantNodes/research/quant_alpha/__init__.py +45 -0
- QuantNodes/research/quant_alpha/adapters/__init__.py +99 -0
- QuantNodes/research/quant_alpha/adapters/calculator.py +503 -0
- QuantNodes/research/quant_alpha/adapters/expression.py +387 -0
- QuantNodes/research/quant_alpha/alpha101_design/__init__.py +50 -0
- QuantNodes/research/quant_alpha/alpha101_design/few_shot_examples.py +243 -0
- QuantNodes/research/quant_alpha/alpha101_design/philosophy.py +474 -0
- QuantNodes/research/quant_alpha/alpha158_design/__init__.py +63 -0
- QuantNodes/research/quant_alpha/alpha158_design/few_shot_examples.py +219 -0
- QuantNodes/research/quant_alpha/alpha158_design/philosophy.py +240 -0
- QuantNodes/research/quant_alpha/evaluation/__init__.py +47 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/__init__.py +8 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g1_handcrafted.py +135 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g2_llm_only.py +269 -0
- QuantNodes/research/quant_alpha/evaluation/baselines/g3_alpha_gpt.py +152 -0
- QuantNodes/research/quant_alpha/evaluation/clickhouse_data_loader.py +227 -0
- QuantNodes/research/quant_alpha/evaluation/contracts.py +376 -0
- QuantNodes/research/quant_alpha/evaluation/evaluators/__init__.py +6 -0
- QuantNodes/research/quant_alpha/evaluation/evaluators/polars_evaluator.py +545 -0
- QuantNodes/research/quant_alpha/evaluation/mock_data_loader.py +226 -0
- QuantNodes/research/quant_alpha/evaluation/runner.py +243 -0
- QuantNodes/research/quant_alpha/llm/__init__.py +38 -0
- QuantNodes/research/quant_alpha/llm/parser.py +681 -0
- QuantNodes/research/quant_alpha/logic_driven_pipeline.py +411 -0
- QuantNodes/research/quant_alpha/logic_mining/__init__.py +74 -0
- QuantNodes/research/quant_alpha/logic_mining/compiler.py +457 -0
- QuantNodes/research/quant_alpha/logic_mining/generator.py +366 -0
- QuantNodes/research/quant_alpha/logic_mining/models.py +252 -0
- QuantNodes/research/quant_alpha/logic_mining/parser.py +287 -0
- QuantNodes/research/quant_alpha/logic_mining/pipelines.py +297 -0
- QuantNodes/research/quant_alpha/logic_mining/sources.py +149 -0
- QuantNodes/research/quant_alpha/mcts/__init__.py +66 -0
- QuantNodes/research/quant_alpha/mcts/cache.py +262 -0
- QuantNodes/research/quant_alpha/mcts/extension_ops.py +320 -0
- QuantNodes/research/quant_alpha/mcts/feedback.py +825 -0
- QuantNodes/research/quant_alpha/mcts/op_prior.py +180 -0
- QuantNodes/research/quant_alpha/mcts/search.py +540 -0
- QuantNodes/research/quant_alpha/mcts/tree.py +201 -0
- QuantNodes/research/quant_alpha/operator_vocab/__init__.py +50 -0
- QuantNodes/research/quant_alpha/operator_vocab/config.py +54 -0
- QuantNodes/research/quant_alpha/operator_vocab/metadata.py +263 -0
- QuantNodes/research/quant_alpha/operator_vocab/vocabulary.py +481 -0
- QuantNodes/research/quant_alpha/pipeline.py +1027 -0
- QuantNodes/research/quant_alpha/types/__init__.py +27 -0
- QuantNodes/research/quant_alpha/types/constants.py +28 -0
- QuantNodes/research/quant_alpha/types/state.py +205 -0
- QuantNodes/research/quant_alpha/workflow/__init__.py +32 -0
- QuantNodes/research/quant_alpha/workflow/alpha_gpt.py +911 -0
- QuantNodes/research/quant_alpha/workflow/alpha_logics.py +416 -0
- QuantNodes/research/quant_alpha/workflow/state.py +27 -0
- QuantNodes/research/report_reproducer.py +485 -0
- QuantNodes/research/wiki.py +1155 -0
- QuantNodes/symbolic/__init__.py +51 -0
- QuantNodes/symbolic/compiler.py +113 -0
- QuantNodes/symbolic/dialect.py +260 -0
- QuantNodes/symbolic/executor.py +147 -0
- QuantNodes/symbolic/expression.py +234 -0
- QuantNodes/symbolic/functions.py +433 -0
- QuantNodes/symbolic/optimizer.py +165 -0
- QuantNodes/ui_node/__init__.py +30 -0
- QuantNodes/ui_node/base.py +222 -0
- quantnodes-3.0.0.dist-info/METADATA +463 -0
- quantnodes-3.0.0.dist-info/RECORD +399 -0
- quantnodes-3.0.0.dist-info/WHEEL +5 -0
- quantnodes-3.0.0.dist-info/entry_points.txt +24 -0
- quantnodes-3.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
logic_driven_pipeline.py - 逻辑驱动的端到端 Pipeline
|
|
4
|
+
|
|
5
|
+
基于 AlphaLogics 论文 (arXiv 2603.20247) §3.2/§3.3 + PR-5 端到端集成。
|
|
6
|
+
|
|
7
|
+
Pipeline 流程:
|
|
8
|
+
AlphaLogicsWorkflow (外层循环 + 内层循环)
|
|
9
|
+
↓
|
|
10
|
+
输出: 最佳逻辑 H* + 该逻辑下的因子池
|
|
11
|
+
↓
|
|
12
|
+
MCTS (可选, 基于最佳逻辑的 Gamma 约束继续优化)
|
|
13
|
+
↓
|
|
14
|
+
Dedup (Mutual IC)
|
|
15
|
+
↓
|
|
16
|
+
Wiki 持久化
|
|
17
|
+
|
|
18
|
+
Usage::
|
|
19
|
+
|
|
20
|
+
from QuantNodes.research.quant_alpha.logic_driven_pipeline import (
|
|
21
|
+
LogicDrivenPipeline, LogicDrivenPipelineConfig,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
config = LogicDrivenPipelineConfig(
|
|
25
|
+
objective="capture A-share reversal effect",
|
|
26
|
+
max_outer_rounds=3,
|
|
27
|
+
)
|
|
28
|
+
pipeline = LogicDrivenPipeline(config=config)
|
|
29
|
+
result = pipeline.run(data)
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from __future__ import annotations
|
|
33
|
+
|
|
34
|
+
import logging
|
|
35
|
+
import time
|
|
36
|
+
from dataclasses import dataclass, field
|
|
37
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
38
|
+
|
|
39
|
+
import polars as pl
|
|
40
|
+
|
|
41
|
+
from QuantNodes.research.quant_alpha.logic_mining import (
|
|
42
|
+
WikiLogicStructured,
|
|
43
|
+
LogicPerformanceEvidence,
|
|
44
|
+
)
|
|
45
|
+
from QuantNodes.research.quant_alpha.pipeline import (
|
|
46
|
+
AlphaPipeline,
|
|
47
|
+
PipelineConfig,
|
|
48
|
+
PipelineResult,
|
|
49
|
+
TerminationConfig,
|
|
50
|
+
RoundResult,
|
|
51
|
+
)
|
|
52
|
+
from QuantNodes.research.quant_alpha.workflow.alpha_logics import (
|
|
53
|
+
AlphaLogicsConfig,
|
|
54
|
+
AlphaLogicsWorkflow,
|
|
55
|
+
AlphaLogicsResult,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
logger = logging.getLogger(__name__)
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
"LogicDrivenPipelineConfig",
|
|
62
|
+
"LogicDrivenPipelineResult",
|
|
63
|
+
"LogicDrivenPipeline",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class LogicDrivenPipelineConfig:
|
|
69
|
+
"""逻辑驱动 Pipeline 配置
|
|
70
|
+
|
|
71
|
+
当 logic_driven=True 时,使用 AlphaLogicsWorkflow (外层+内层循环);
|
|
72
|
+
否则,使用原 AlphaPipeline (单轮内层循环)。
|
|
73
|
+
"""
|
|
74
|
+
# 基础配置 (与 PipelineConfig 类似)
|
|
75
|
+
objective: str = ""
|
|
76
|
+
wiki_path: str = "wiki/"
|
|
77
|
+
output_dir: str = "pipeline_output_logic_driven"
|
|
78
|
+
|
|
79
|
+
# 逻辑驱动开关
|
|
80
|
+
logic_driven: bool = True
|
|
81
|
+
|
|
82
|
+
# Alpha-GPT 配置
|
|
83
|
+
alphagpt_iterations: int = 3
|
|
84
|
+
alphagpt_pool_size: int = 10
|
|
85
|
+
alphagpt_top_k: int = 10
|
|
86
|
+
|
|
87
|
+
# MCTS 配置
|
|
88
|
+
mcts_iterations: int = 50
|
|
89
|
+
mcts_max_depth: int = 5
|
|
90
|
+
mcts_dedup_threshold: float = 0.7
|
|
91
|
+
|
|
92
|
+
# 去重
|
|
93
|
+
max_mutual_ic: float = 0.7
|
|
94
|
+
min_ir_threshold: float = 0.5
|
|
95
|
+
|
|
96
|
+
# 评估
|
|
97
|
+
min_ic_decay_ratio: float = 0.3
|
|
98
|
+
max_turnover: float = 2.0
|
|
99
|
+
|
|
100
|
+
# 通用
|
|
101
|
+
top_k: int = 10
|
|
102
|
+
date_column: str = "date"
|
|
103
|
+
code_column: str = "code"
|
|
104
|
+
forward_returns: Tuple[int, ...] = (1, 5, 20)
|
|
105
|
+
|
|
106
|
+
# LLM
|
|
107
|
+
llm_provider: str = "minimax"
|
|
108
|
+
llm_model: Optional[str] = None
|
|
109
|
+
temperature: float = 0.7
|
|
110
|
+
|
|
111
|
+
# 各阶段温度
|
|
112
|
+
temperature_idea_gen: float = 0.8
|
|
113
|
+
temperature_formula: float = 0.4
|
|
114
|
+
temperature_reflector: float = 0.6
|
|
115
|
+
temperature_critic: float = 0.3
|
|
116
|
+
|
|
117
|
+
# 多轮迭代
|
|
118
|
+
termination: TerminationConfig = field(default_factory=TerminationConfig)
|
|
119
|
+
|
|
120
|
+
# AlphaLogics 配置
|
|
121
|
+
alphalogics_inner_iterations: int = 2
|
|
122
|
+
alphalogics_inner_pool_size: int = 5
|
|
123
|
+
alphalogics_max_outer_rounds: int = 3
|
|
124
|
+
alphalogics_initial_sources: Tuple[str, ...] = ("alpha101", "alpha158")
|
|
125
|
+
alphalogics_initial_max_per_lib: int = 3
|
|
126
|
+
|
|
127
|
+
# 终止条件
|
|
128
|
+
timeout_seconds: int = 3600
|
|
129
|
+
|
|
130
|
+
# 一致性评分
|
|
131
|
+
consistency_use_llm: bool = False # 是否使用真实 LLM 评分(False=结构化匹配)
|
|
132
|
+
consistency_score_threshold: float = 0.5
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@dataclass
|
|
136
|
+
class LogicDrivenPipelineResult:
|
|
137
|
+
"""逻辑驱动 Pipeline 结果"""
|
|
138
|
+
# AlphaLogics 结果
|
|
139
|
+
alphalogics_result: Optional[AlphaLogicsResult] = None
|
|
140
|
+
|
|
141
|
+
# 最佳逻辑及其 Γ 约束
|
|
142
|
+
best_logic_name: Optional[str] = None
|
|
143
|
+
best_logic_structured: Optional[WikiLogicStructured] = None
|
|
144
|
+
best_evidence: Optional[LogicPerformanceEvidence] = None
|
|
145
|
+
best_gamma: Optional[Any] = None # CompiledConstraint
|
|
146
|
+
|
|
147
|
+
# 因子池
|
|
148
|
+
logic_driven_factors: List[Any] = field(default_factory=list) # FactorMetrics
|
|
149
|
+
|
|
150
|
+
# MCTS 优化结果 (可选)
|
|
151
|
+
mcts_enhanced: bool = False
|
|
152
|
+
final_pool: List[Any] = field(default_factory=list)
|
|
153
|
+
|
|
154
|
+
# Wiki
|
|
155
|
+
wiki_pages: List[str] = field(default_factory=list)
|
|
156
|
+
|
|
157
|
+
# 元数据
|
|
158
|
+
elapsed_seconds: float = 0.0
|
|
159
|
+
summary: Dict[str, Any] = field(default_factory=dict)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class LogicDrivenPipeline:
|
|
163
|
+
"""逻辑驱动的端到端 Pipeline
|
|
164
|
+
|
|
165
|
+
整合 AlphaLogics 外层循环 + MCTS 优化 + Wiki 持久化。
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
def __init__(
|
|
169
|
+
self,
|
|
170
|
+
config: LogicDrivenPipelineConfig,
|
|
171
|
+
llm_client: Any = None,
|
|
172
|
+
):
|
|
173
|
+
self.config = config
|
|
174
|
+
self.llm_client = llm_client
|
|
175
|
+
|
|
176
|
+
def run(self, data: pl.DataFrame) -> LogicDrivenPipelineResult:
|
|
177
|
+
"""运行 Pipeline
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
data: 行情数据
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
LogicDrivenPipelineResult
|
|
184
|
+
"""
|
|
185
|
+
start = time.time()
|
|
186
|
+
result = LogicDrivenPipelineResult()
|
|
187
|
+
|
|
188
|
+
if not self.config.logic_driven:
|
|
189
|
+
logger.info("logic_driven=False, fall back to standard AlphaPipeline")
|
|
190
|
+
return self._run_standard_pipeline(data, result, start)
|
|
191
|
+
|
|
192
|
+
# 逻辑驱动模式
|
|
193
|
+
logger.info("=== 逻辑驱动 Pipeline ===")
|
|
194
|
+
|
|
195
|
+
# Step 1: AlphaLogics 外层循环
|
|
196
|
+
alphalogics_result = self._run_alphalogics(data)
|
|
197
|
+
result.alphalogics_result = alphalogics_result
|
|
198
|
+
result.best_logic_name = (
|
|
199
|
+
alphalogics_result.best_logic.name
|
|
200
|
+
if alphalogics_result.best_logic else None
|
|
201
|
+
)
|
|
202
|
+
result.best_evidence = alphalogics_result.best_evidence
|
|
203
|
+
|
|
204
|
+
if alphalogics_result.best_logic is None:
|
|
205
|
+
logger.warning("AlphaLogics returned no best logic, terminating")
|
|
206
|
+
result.elapsed_seconds = time.time() - start
|
|
207
|
+
result.summary = {"error": "no_best_logic"}
|
|
208
|
+
return result
|
|
209
|
+
|
|
210
|
+
# Step 2: 获取最佳逻辑的结构化字段
|
|
211
|
+
best_logic = alphalogics_result.best_logic
|
|
212
|
+
result.best_logic_structured = best_logic.structured
|
|
213
|
+
|
|
214
|
+
# Step 3: 编译 Γ 约束
|
|
215
|
+
if best_logic.structured is None:
|
|
216
|
+
logger.warning("Best logic has no structured fields, skipping MCTS")
|
|
217
|
+
# 直接使用内层因子池
|
|
218
|
+
for ir in alphalogics_result.inner_results:
|
|
219
|
+
if ir.alphagpt_result:
|
|
220
|
+
from QuantNodes.research.quant_alpha.evaluation.contracts import (
|
|
221
|
+
FactorMetrics,
|
|
222
|
+
)
|
|
223
|
+
for f in ir.alphagpt_result.final_pool:
|
|
224
|
+
result.logic_driven_factors.append(FactorMetrics(
|
|
225
|
+
formula_id=f.formula_id,
|
|
226
|
+
status="success",
|
|
227
|
+
ic_mean=f.ic_mean,
|
|
228
|
+
ir=f.ir,
|
|
229
|
+
overall_score=f.ir,
|
|
230
|
+
))
|
|
231
|
+
else:
|
|
232
|
+
from QuantNodes.research.quant_alpha.logic_mining import compile_to_constraint
|
|
233
|
+
gamma = compile_to_constraint(
|
|
234
|
+
best_logic.structured,
|
|
235
|
+
source_logic=best_logic.name,
|
|
236
|
+
)
|
|
237
|
+
result.best_gamma = gamma
|
|
238
|
+
|
|
239
|
+
# Step 4: 使用最佳 Γ 约束运行 MCTS 优化
|
|
240
|
+
self._enhance_with_mcts(data, gamma, result)
|
|
241
|
+
|
|
242
|
+
# Step 5: Wiki 持久化
|
|
243
|
+
if result.final_pool:
|
|
244
|
+
self._persist_to_wiki(result)
|
|
245
|
+
|
|
246
|
+
# 汇总
|
|
247
|
+
result.elapsed_seconds = time.time() - start
|
|
248
|
+
result.summary = self._build_summary(result)
|
|
249
|
+
logger.info(
|
|
250
|
+
"=== 逻辑驱动 Pipeline 完成: best_logic=%s, factors=%d, %.1fs ===",
|
|
251
|
+
result.best_logic_name,
|
|
252
|
+
len(result.final_pool),
|
|
253
|
+
result.elapsed_seconds,
|
|
254
|
+
)
|
|
255
|
+
return result
|
|
256
|
+
|
|
257
|
+
def _run_alphalogics(self, data: pl.DataFrame) -> AlphaLogicsResult:
|
|
258
|
+
"""运行 AlphaLogics 外层循环"""
|
|
259
|
+
config = AlphaLogicsConfig(
|
|
260
|
+
inner_iterations=self.config.alphalogics_inner_iterations,
|
|
261
|
+
inner_pool_size=self.config.alphalogics_inner_pool_size,
|
|
262
|
+
inner_early_stop=self.config.termination.patience,
|
|
263
|
+
max_outer_rounds=self.config.alphalogics_max_outer_rounds,
|
|
264
|
+
inner_objective="ir",
|
|
265
|
+
data=data,
|
|
266
|
+
date_column=self.config.date_column,
|
|
267
|
+
code_column=self.config.code_column,
|
|
268
|
+
forward_returns=self.config.forward_returns,
|
|
269
|
+
llm_provider=self.config.llm_provider,
|
|
270
|
+
llm_model=self.config.llm_model,
|
|
271
|
+
wiki_path=self.config.wiki_path,
|
|
272
|
+
persist_best_logic=True,
|
|
273
|
+
initial_logic_sources=self.config.alphalogics_initial_sources,
|
|
274
|
+
initial_logic_max_per_lib=self.config.alphalogics_initial_max_per_lib,
|
|
275
|
+
min_ir_threshold=self.config.min_ir_threshold,
|
|
276
|
+
)
|
|
277
|
+
workflow = AlphaLogicsWorkflow(config=config, llm_client=self.llm_client)
|
|
278
|
+
return workflow.run()
|
|
279
|
+
|
|
280
|
+
def _enhance_with_mcts(
|
|
281
|
+
self,
|
|
282
|
+
data: pl.DataFrame,
|
|
283
|
+
gamma: Any,
|
|
284
|
+
result: LogicDrivenPipelineResult,
|
|
285
|
+
) -> None:
|
|
286
|
+
"""使用最佳 Γ 约束增强 MCTS"""
|
|
287
|
+
# 收集内层因子
|
|
288
|
+
for ir in result.alphalogics_result.inner_results:
|
|
289
|
+
if ir.alphagpt_result:
|
|
290
|
+
from QuantNodes.research.quant_alpha.evaluation.contracts import (
|
|
291
|
+
FactorMetrics,
|
|
292
|
+
)
|
|
293
|
+
for f in ir.alphagpt_result.final_pool:
|
|
294
|
+
result.logic_driven_factors.append(FactorMetrics(
|
|
295
|
+
formula_id=f.formula_id,
|
|
296
|
+
status="success",
|
|
297
|
+
ic_mean=f.ic_mean,
|
|
298
|
+
ir=f.ir,
|
|
299
|
+
overall_score=f.ir,
|
|
300
|
+
))
|
|
301
|
+
|
|
302
|
+
# 使用 Gamma 约束运行 Pipeline (单轮 + MCTS)
|
|
303
|
+
pipeline_config = PipelineConfig(
|
|
304
|
+
objective=self.config.objective,
|
|
305
|
+
wiki_path=self.config.wiki_path,
|
|
306
|
+
termination=self.config.termination,
|
|
307
|
+
alphagpt_iterations=self.config.alphagpt_iterations,
|
|
308
|
+
alphagpt_pool_size=self.config.alphagpt_pool_size,
|
|
309
|
+
mcts_iterations=self.config.mcts_iterations,
|
|
310
|
+
mcts_max_depth=self.config.mcts_max_depth,
|
|
311
|
+
max_mutual_ic=self.config.max_mutual_ic,
|
|
312
|
+
min_ir_threshold=self.config.min_ir_threshold,
|
|
313
|
+
top_k=self.config.top_k,
|
|
314
|
+
date_column=self.config.date_column,
|
|
315
|
+
code_column=self.config.code_column,
|
|
316
|
+
forward_returns=self.config.forward_returns,
|
|
317
|
+
llm_provider=self.config.llm_provider,
|
|
318
|
+
llm_model=self.config.llm_model,
|
|
319
|
+
gamma=gamma,
|
|
320
|
+
output_dir=self.config.output_dir,
|
|
321
|
+
)
|
|
322
|
+
pipeline = AlphaPipeline(pipeline_config)
|
|
323
|
+
pipeline_result = pipeline.run(data)
|
|
324
|
+
|
|
325
|
+
result.final_pool = pipeline_result.final_pool
|
|
326
|
+
result.mcts_enhanced = True
|
|
327
|
+
|
|
328
|
+
def _run_standard_pipeline(
|
|
329
|
+
self,
|
|
330
|
+
data: pl.DataFrame,
|
|
331
|
+
result: LogicDrivenPipelineResult,
|
|
332
|
+
start: float,
|
|
333
|
+
) -> LogicDrivenPipelineResult:
|
|
334
|
+
"""回退到标准 Pipeline"""
|
|
335
|
+
pipeline_config = PipelineConfig(
|
|
336
|
+
objective=self.config.objective,
|
|
337
|
+
wiki_path=self.config.wiki_path,
|
|
338
|
+
termination=self.config.termination,
|
|
339
|
+
alphagpt_iterations=self.config.alphagpt_iterations,
|
|
340
|
+
alphagpt_pool_size=self.config.alphagpt_pool_size,
|
|
341
|
+
mcts_iterations=self.config.mcts_iterations,
|
|
342
|
+
mcts_max_depth=self.config.mcts_max_depth,
|
|
343
|
+
max_mutual_ic=self.config.max_mutual_ic,
|
|
344
|
+
min_ir_threshold=self.config.min_ir_threshold,
|
|
345
|
+
top_k=self.config.top_k,
|
|
346
|
+
date_column=self.config.date_column,
|
|
347
|
+
code_column=self.config.code_column,
|
|
348
|
+
forward_returns=self.config.forward_returns,
|
|
349
|
+
llm_provider=self.config.llm_provider,
|
|
350
|
+
llm_model=self.config.llm_model,
|
|
351
|
+
output_dir=self.config.output_dir,
|
|
352
|
+
)
|
|
353
|
+
pipeline = AlphaPipeline(pipeline_config)
|
|
354
|
+
pipeline_result = pipeline.run(data)
|
|
355
|
+
|
|
356
|
+
result.final_pool = pipeline_result.final_pool
|
|
357
|
+
result.elapsed_seconds = time.time() - start
|
|
358
|
+
result.summary = pipeline_result.summary
|
|
359
|
+
return result
|
|
360
|
+
|
|
361
|
+
def _persist_to_wiki(self, result: LogicDrivenPipelineResult) -> None:
|
|
362
|
+
"""持久化到 Wiki"""
|
|
363
|
+
try:
|
|
364
|
+
from QuantNodes.research.wiki import (
|
|
365
|
+
WikiFactorProxy,
|
|
366
|
+
WikiFactor,
|
|
367
|
+
FactorSource,
|
|
368
|
+
FactorCategory,
|
|
369
|
+
)
|
|
370
|
+
wiki = WikiFactorProxy(self.config.wiki_path)
|
|
371
|
+
for f in result.final_pool:
|
|
372
|
+
try:
|
|
373
|
+
wiki_factor = WikiFactor(
|
|
374
|
+
name=f.formula_id,
|
|
375
|
+
formula=getattr(f, "formula", f.formula_id),
|
|
376
|
+
source=FactorSource.AUTO_RESEARCH,
|
|
377
|
+
category=FactorCategory.OTHER,
|
|
378
|
+
tags=[
|
|
379
|
+
"logic-driven",
|
|
380
|
+
f"ir={f.ir:.3f}",
|
|
381
|
+
f"logic={result.best_logic_name}",
|
|
382
|
+
],
|
|
383
|
+
ic_mean=f.ic_mean,
|
|
384
|
+
ic_std=f.ic_std,
|
|
385
|
+
icir=f.ir,
|
|
386
|
+
rank_ic_mean=f.rank_ic_mean,
|
|
387
|
+
description=f"Logic-driven factor from {result.best_logic_name}",
|
|
388
|
+
)
|
|
389
|
+
page_name = wiki.store_factor(wiki_factor)
|
|
390
|
+
result.wiki_pages.append(page_name)
|
|
391
|
+
except Exception as e:
|
|
392
|
+
logger.warning("Wiki store_factor failed for %s: %s", f.formula_id, e)
|
|
393
|
+
except Exception as e:
|
|
394
|
+
logger.warning("Wiki persistence failed: %s", e)
|
|
395
|
+
|
|
396
|
+
def _build_summary(self, result: LogicDrivenPipelineResult) -> Dict[str, Any]:
|
|
397
|
+
"""构建摘要"""
|
|
398
|
+
return {
|
|
399
|
+
"logic_driven": True,
|
|
400
|
+
"best_logic_name": result.best_logic_name,
|
|
401
|
+
"best_ir": result.best_evidence.best_ir if result.best_evidence else 0.0,
|
|
402
|
+
"best_n_factors": (
|
|
403
|
+
result.best_evidence.n_factors_explored
|
|
404
|
+
if result.best_evidence else 0
|
|
405
|
+
),
|
|
406
|
+
"logic_driven_factors": len(result.logic_driven_factors),
|
|
407
|
+
"mcts_enhanced": result.mcts_enhanced,
|
|
408
|
+
"final_factors": len(result.final_pool),
|
|
409
|
+
"wiki_pages": len(result.wiki_pages),
|
|
410
|
+
"elapsed_seconds": result.elapsed_seconds,
|
|
411
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
logic_mining - 市场逻辑驱动的因子挖掘模块
|
|
4
|
+
|
|
5
|
+
基于 AlphaLogics 论文 (arXiv 2603.20247) 实现。
|
|
6
|
+
|
|
7
|
+
核心组件:
|
|
8
|
+
- WikiLogicStructured: 逻辑结构化表示
|
|
9
|
+
- CompiledConstraint (Γ): 编译后的可执行约束
|
|
10
|
+
- compile_to_constraint(): 逻辑 → Γ 编译器
|
|
11
|
+
- LogicMiningPipeline: Logic Mining 三段式 Agent
|
|
12
|
+
- mine_logic_from_formula(): 从公式抽取逻辑
|
|
13
|
+
- build_initial_logic_library(): 构建初始逻辑库
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from QuantNodes.research.quant_alpha.logic_mining.models import (
|
|
17
|
+
LogicCondition,
|
|
18
|
+
LogicBehavior,
|
|
19
|
+
WikiLogicStructured,
|
|
20
|
+
LogicPerformanceEvidence,
|
|
21
|
+
LogicAbstractionResult,
|
|
22
|
+
)
|
|
23
|
+
from QuantNodes.research.quant_alpha.logic_mining.compiler import (
|
|
24
|
+
CompiledConstraint,
|
|
25
|
+
compile_to_constraint,
|
|
26
|
+
)
|
|
27
|
+
from QuantNodes.research.quant_alpha.logic_mining.parser import (
|
|
28
|
+
parse_formula_structure,
|
|
29
|
+
parse_financial_semantics,
|
|
30
|
+
parse_market_logic,
|
|
31
|
+
)
|
|
32
|
+
from QuantNodes.research.quant_alpha.logic_mining.pipelines import (
|
|
33
|
+
LogicMiningPipeline,
|
|
34
|
+
mine_logic_from_formula,
|
|
35
|
+
build_initial_logic_library,
|
|
36
|
+
)
|
|
37
|
+
from QuantNodes.research.quant_alpha.logic_mining.sources import (
|
|
38
|
+
SOURCES,
|
|
39
|
+
get_formulas_from_source,
|
|
40
|
+
list_available_sources,
|
|
41
|
+
)
|
|
42
|
+
from QuantNodes.research.quant_alpha.logic_mining.generator import (
|
|
43
|
+
MarketLogicGenerator,
|
|
44
|
+
MarketLogicRefinementDirection,
|
|
45
|
+
generate_logic_name,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
# Models
|
|
50
|
+
"LogicCondition",
|
|
51
|
+
"LogicBehavior",
|
|
52
|
+
"WikiLogicStructured",
|
|
53
|
+
"LogicPerformanceEvidence",
|
|
54
|
+
"LogicAbstractionResult",
|
|
55
|
+
# Compiler (Γ)
|
|
56
|
+
"CompiledConstraint",
|
|
57
|
+
"compile_to_constraint",
|
|
58
|
+
# Parser
|
|
59
|
+
"parse_formula_structure",
|
|
60
|
+
"parse_financial_semantics",
|
|
61
|
+
"parse_market_logic",
|
|
62
|
+
# Pipelines
|
|
63
|
+
"LogicMiningPipeline",
|
|
64
|
+
"mine_logic_from_formula",
|
|
65
|
+
"build_initial_logic_library",
|
|
66
|
+
# Sources
|
|
67
|
+
"SOURCES",
|
|
68
|
+
"get_formulas_from_source",
|
|
69
|
+
"list_available_sources",
|
|
70
|
+
# Generator (外层循环 PR-4)
|
|
71
|
+
"MarketLogicGenerator",
|
|
72
|
+
"MarketLogicRefinementDirection",
|
|
73
|
+
"generate_logic_name",
|
|
74
|
+
]
|