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,457 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
compiler.py - Logic→Γ 编译器
|
|
4
|
+
|
|
5
|
+
把 WikiLogicStructured 编译为 CompiledConstraint (Γ),
|
|
6
|
+
用于约束因子生成过程。
|
|
7
|
+
|
|
8
|
+
基于 AlphaLogics 论文 (arXiv 2603.20247) 的核心发现:
|
|
9
|
+
- Γ 约束生成 > 自由生成 (Figure 3)
|
|
10
|
+
- 逻辑库越大,因子质量单调提升 (Figure 5)
|
|
11
|
+
|
|
12
|
+
Usage::
|
|
13
|
+
|
|
14
|
+
from QuantNodes.research.quant_alpha.logic_mining.compiler import (
|
|
15
|
+
CompiledConstraint, compile_to_constraint,
|
|
16
|
+
)
|
|
17
|
+
from QuantNodes.research.quant_alpha.logic_mining.models import (
|
|
18
|
+
WikiLogicStructured, LogicCondition, LogicBehavior,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# 定义逻辑
|
|
22
|
+
logic = WikiLogicStructured(
|
|
23
|
+
predicates=[
|
|
24
|
+
LogicCondition(variable="open", op="rank", threshold=0),
|
|
25
|
+
LogicCondition(variable="volume", op="ts_corr", threshold=-0.5, window=10),
|
|
26
|
+
],
|
|
27
|
+
behavior=LogicBehavior(target="forward_return_5", direction=-1, horizon=5),
|
|
28
|
+
operator_whitelist=["rank", "ts_corr", "sign"],
|
|
29
|
+
parameter_ranges={"ts_corr": (5, 30)},
|
|
30
|
+
sign_constraint=-1,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# 编译为 Γ 约束
|
|
34
|
+
gamma = compile_to_constraint(logic)
|
|
35
|
+
|
|
36
|
+
# 校验公式
|
|
37
|
+
passed, reason = gamma.validate("sign(-ts_corr(rank(open), rank(volume), 10))")
|
|
38
|
+
assert passed == True
|
|
39
|
+
|
|
40
|
+
# 生成 prompt 注入文本
|
|
41
|
+
prompt_text = gamma.render_for_prompt()
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
from __future__ import annotations
|
|
45
|
+
|
|
46
|
+
import logging
|
|
47
|
+
import re
|
|
48
|
+
from dataclasses import dataclass, field
|
|
49
|
+
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
50
|
+
|
|
51
|
+
from QuantNodes.research.quant_alpha.logic_mining.models import WikiLogicStructured
|
|
52
|
+
|
|
53
|
+
logger = logging.getLogger(__name__)
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"CompiledConstraint",
|
|
57
|
+
"compile_to_constraint",
|
|
58
|
+
"extract_operators",
|
|
59
|
+
"extract_variables",
|
|
60
|
+
"parse_op_args",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ==============================================================================
|
|
65
|
+
# 默认配置
|
|
66
|
+
# ==============================================================================
|
|
67
|
+
|
|
68
|
+
# 默认算子白名单(OperatorVocab 中常用的量价算子)
|
|
69
|
+
DEFAULT_OPERATOR_WHITELIST: Set[str] = {
|
|
70
|
+
# 截面算子
|
|
71
|
+
"rank", "zscore",
|
|
72
|
+
# 时序算子
|
|
73
|
+
"ts_mean", "ts_std", "ts_corr", "ts_cov", "ts_delta", "ts_rank",
|
|
74
|
+
"ts_min", "ts_max", "ts_argmin", "ts_argmax", "ts_sum", "ts_count",
|
|
75
|
+
"ts_skew", "ts_kurt",
|
|
76
|
+
# 点算子
|
|
77
|
+
"abs", "sign", "log", "sqrt", "signedpower",
|
|
78
|
+
# 算术算子
|
|
79
|
+
"add", "sub", "mul", "div",
|
|
80
|
+
# 比较算子
|
|
81
|
+
"max", "min",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# 默认变量白名单(OHLCV 量价变量)
|
|
85
|
+
DEFAULT_VARIABLE_WHITELIST: Set[str] = {
|
|
86
|
+
"open", "high", "low", "close", "vol", "amount",
|
|
87
|
+
"returns", "volume",
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# 默认参数范围
|
|
91
|
+
DEFAULT_PARAMETER_RANGES: Dict[str, Tuple[float, float]] = {
|
|
92
|
+
"ts_mean": (2, 120),
|
|
93
|
+
"ts_std": (2, 120),
|
|
94
|
+
"ts_corr": (2, 60),
|
|
95
|
+
"ts_cov": (2, 60),
|
|
96
|
+
"ts_delta": (1, 60),
|
|
97
|
+
"ts_rank": (2, 120),
|
|
98
|
+
"ts_min": (2, 120),
|
|
99
|
+
"ts_max": (2, 120),
|
|
100
|
+
"ts_argmin": (2, 120),
|
|
101
|
+
"ts_argmax": (2, 120),
|
|
102
|
+
"ts_sum": (2, 120),
|
|
103
|
+
"ts_count": (2, 120),
|
|
104
|
+
"ts_skew": (2, 120),
|
|
105
|
+
"ts_kurt": (2, 120),
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# ==============================================================================
|
|
110
|
+
# 辅助函数
|
|
111
|
+
# ==============================================================================
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def extract_operators(formula: str) -> Set[str]:
|
|
115
|
+
"""从公式中提取使用的算子名
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
formula: 因子公式字符串
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
使用的算子名集合
|
|
122
|
+
"""
|
|
123
|
+
# 匹配函数调用: word(
|
|
124
|
+
pattern = r'\b([a-zA-Z_]\w*)\s*\('
|
|
125
|
+
matches = re.findall(pattern, formula)
|
|
126
|
+
|
|
127
|
+
# 过滤掉常见的非算子关键字
|
|
128
|
+
keywords = {"if", "else", "for", "while", "return", "def", "class", "None", "True", "False"}
|
|
129
|
+
ops = {m for m in matches if m not in keywords}
|
|
130
|
+
|
|
131
|
+
return ops
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def extract_variables(formula: str) -> Set[str]:
|
|
135
|
+
"""从公式中提取使用的市场变量名
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
formula: 因子公式字符串
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
使用的变量名集合
|
|
142
|
+
"""
|
|
143
|
+
# 匹配独立的变量名(不在函数调用中的标识符)
|
|
144
|
+
# 简单实现:匹配已知的 OHLCV 变量
|
|
145
|
+
known_vars = {"open", "high", "low", "close", "vol", "amount", "returns", "volume"}
|
|
146
|
+
found = set()
|
|
147
|
+
|
|
148
|
+
for var in known_vars:
|
|
149
|
+
# 使用单词边界匹配
|
|
150
|
+
if re.search(r'\b' + var + r'\b', formula):
|
|
151
|
+
found.add(var)
|
|
152
|
+
|
|
153
|
+
return found
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def parse_op_args(formula: str) -> List[Tuple[str, List[float]]]:
|
|
157
|
+
"""解析公式中算子的数值参数
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
formula: 因子公式字符串
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
[(算子名, [参数值列表]), ...]
|
|
164
|
+
"""
|
|
165
|
+
results = []
|
|
166
|
+
|
|
167
|
+
# 匹配函数调用及其参数
|
|
168
|
+
# 使用更简单的方法:找到所有 func( 的位置,然后提取参数
|
|
169
|
+
# 例如: ts_mean(close, 20) -> ("ts_mean", ["20"])
|
|
170
|
+
|
|
171
|
+
# 先找到所有函数调用
|
|
172
|
+
func_pattern = r'(\w+)\s*\('
|
|
173
|
+
for match in re.finditer(func_pattern, formula):
|
|
174
|
+
op_name = match.group(1)
|
|
175
|
+
start_pos = match.end()
|
|
176
|
+
|
|
177
|
+
# 找到匹配的右括号
|
|
178
|
+
depth = 1
|
|
179
|
+
pos = start_pos
|
|
180
|
+
while pos < len(formula) and depth > 0:
|
|
181
|
+
if formula[pos] == '(':
|
|
182
|
+
depth += 1
|
|
183
|
+
elif formula[pos] == ')':
|
|
184
|
+
depth -= 1
|
|
185
|
+
pos += 1
|
|
186
|
+
|
|
187
|
+
# 提取括号内的内容
|
|
188
|
+
args_str = formula[start_pos:pos-1]
|
|
189
|
+
|
|
190
|
+
# 提取数值参数
|
|
191
|
+
nums = []
|
|
192
|
+
for arg in args_str.split(','):
|
|
193
|
+
arg = arg.strip()
|
|
194
|
+
try:
|
|
195
|
+
nums.append(float(arg))
|
|
196
|
+
except ValueError:
|
|
197
|
+
pass
|
|
198
|
+
|
|
199
|
+
if nums:
|
|
200
|
+
results.append((op_name, nums))
|
|
201
|
+
|
|
202
|
+
return results
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def check_sign_hint(formula: str, direction: int) -> bool:
|
|
206
|
+
"""检查公式是否符合指定的符号方向
|
|
207
|
+
|
|
208
|
+
启发式检查:
|
|
209
|
+
- 如果 direction == -1,检查是否有负号或 sign 取反
|
|
210
|
+
- 如果 direction == +1,检查是否有正向结构
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
formula: 因子公式字符串
|
|
214
|
+
direction: 期望的方向 (+1/-1)
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
是否符合
|
|
218
|
+
|
|
219
|
+
Note:
|
|
220
|
+
V8 修复 (test/expand-coverage-2x Phase 1):
|
|
221
|
+
修复前 direction=-1 时无负向标记的公式被宽松接受 (return True 兜底)
|
|
222
|
+
修复后 direction=-1 严格: 必须有 - / sign(- / sub(0, ...) 才接受
|
|
223
|
+
这与 sign_constraint=-1 的语义一致 (期望负 IR, 必须有显式负向)
|
|
224
|
+
"""
|
|
225
|
+
formula_lower = formula.lower().strip()
|
|
226
|
+
|
|
227
|
+
if direction == -1:
|
|
228
|
+
# 检查是否有负号
|
|
229
|
+
if formula_lower.startswith('-'):
|
|
230
|
+
return True
|
|
231
|
+
# 检查是否有 sign(-...) 结构
|
|
232
|
+
if 'sign(-' in formula_lower or 'sign( -' in formula_lower:
|
|
233
|
+
return True
|
|
234
|
+
# 检查是否有 sub(0, ...) 结构
|
|
235
|
+
if 'sub(0' in formula_lower:
|
|
236
|
+
return True
|
|
237
|
+
# 无负向标记 → 严格拒绝 (V8 修复: 去掉宽松兜底)
|
|
238
|
+
return False
|
|
239
|
+
|
|
240
|
+
elif direction == +1:
|
|
241
|
+
# 正向约束通常不需要特殊标记
|
|
242
|
+
return True
|
|
243
|
+
|
|
244
|
+
return True
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
# ==============================================================================
|
|
248
|
+
# 核心数据结构
|
|
249
|
+
# ==============================================================================
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@dataclass
|
|
253
|
+
class CompiledConstraint:
|
|
254
|
+
"""Γ: 编译后的可执行约束
|
|
255
|
+
|
|
256
|
+
对应论文中的 Γ 约束,用于约束因子生成过程。
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
operator_whitelist: Set[str] # 允许的算子名集合
|
|
260
|
+
operator_blacklist: Set[str] = field(default_factory=set) # 显式禁止的算子
|
|
261
|
+
parameter_ranges: Dict[str, Tuple[float, float]] = field(default_factory=dict) # 参数范围
|
|
262
|
+
sign_constraint: Optional[int] = None # +1 / -1 / None
|
|
263
|
+
variable_whitelist: Optional[Set[str]] = None # 允许的市场变量
|
|
264
|
+
source_logic: Optional[str] = None # 来源逻辑名(用于追溯)
|
|
265
|
+
|
|
266
|
+
def validate(self, formula: str) -> Tuple[bool, Optional[str]]:
|
|
267
|
+
"""校验 formula 是否满足所有约束
|
|
268
|
+
|
|
269
|
+
Args:
|
|
270
|
+
formula: 因子公式字符串
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
(passed, reason): passed=True 表示通过,reason 为失败原因
|
|
274
|
+
"""
|
|
275
|
+
# 1. 提取使用的算子
|
|
276
|
+
used_ops = extract_operators(formula)
|
|
277
|
+
|
|
278
|
+
# 2. 黑名单检查
|
|
279
|
+
for op in used_ops:
|
|
280
|
+
if op in self.operator_blacklist:
|
|
281
|
+
return False, f"operator '{op}' is blacklisted"
|
|
282
|
+
|
|
283
|
+
# 3. 白名单检查
|
|
284
|
+
for op in used_ops:
|
|
285
|
+
if op not in self.operator_whitelist:
|
|
286
|
+
return False, f"operator '{op}' not in whitelist"
|
|
287
|
+
|
|
288
|
+
# 4. 提取使用的变量
|
|
289
|
+
used_vars = extract_variables(formula)
|
|
290
|
+
|
|
291
|
+
# 5. 变量白名单检查
|
|
292
|
+
if self.variable_whitelist is not None:
|
|
293
|
+
for v in used_vars:
|
|
294
|
+
if v not in self.variable_whitelist:
|
|
295
|
+
return False, f"variable '{v}' not in whitelist"
|
|
296
|
+
|
|
297
|
+
# 6. 参数范围检查
|
|
298
|
+
for op, args in parse_op_args(formula):
|
|
299
|
+
if op in self.parameter_ranges:
|
|
300
|
+
lo, hi = self.parameter_ranges[op]
|
|
301
|
+
for arg in args:
|
|
302
|
+
if not (lo <= arg <= hi):
|
|
303
|
+
return False, f"{op} arg {arg} not in [{lo}, {hi}]"
|
|
304
|
+
|
|
305
|
+
# 7. 符号方向检查(启发式)
|
|
306
|
+
if self.sign_constraint is not None:
|
|
307
|
+
if not check_sign_hint(formula, self.sign_constraint):
|
|
308
|
+
return False, f"sign_constraint {self.sign_constraint} not satisfied"
|
|
309
|
+
|
|
310
|
+
return True, None
|
|
311
|
+
|
|
312
|
+
def render_for_prompt(self) -> str:
|
|
313
|
+
"""生成可注入 LLM prompt 的人类可读描述
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
格式化的约束描述文本
|
|
317
|
+
"""
|
|
318
|
+
lines = ["## Γ 约束(必须遵守)", ""]
|
|
319
|
+
|
|
320
|
+
# 算子白名单
|
|
321
|
+
if self.operator_whitelist:
|
|
322
|
+
ops = ", ".join(sorted(self.operator_whitelist))
|
|
323
|
+
lines.append("### 允许使用的算子")
|
|
324
|
+
lines.append(f"只使用以下算子: {ops}")
|
|
325
|
+
lines.append("")
|
|
326
|
+
|
|
327
|
+
# 变量白名单
|
|
328
|
+
if self.variable_whitelist is not None:
|
|
329
|
+
vars_ = ", ".join(sorted(self.variable_whitelist))
|
|
330
|
+
lines.append("### 允许使用的变量")
|
|
331
|
+
lines.append(f"只使用以下变量: {vars_}")
|
|
332
|
+
lines.append("")
|
|
333
|
+
|
|
334
|
+
# 参数范围
|
|
335
|
+
if self.parameter_ranges:
|
|
336
|
+
lines.append("### 参数范围")
|
|
337
|
+
for op, (lo, hi) in sorted(self.parameter_ranges.items()):
|
|
338
|
+
lines.append(f"- {op}: [{lo}, {hi}]")
|
|
339
|
+
lines.append("")
|
|
340
|
+
|
|
341
|
+
# 符号约束
|
|
342
|
+
if self.sign_constraint is not None:
|
|
343
|
+
direction = "正向" if self.sign_constraint > 0 else "反向"
|
|
344
|
+
lines.append("### 符号方向")
|
|
345
|
+
lines.append(f"因子整体方向: {direction} ({self.sign_constraint:+d})")
|
|
346
|
+
lines.append("")
|
|
347
|
+
|
|
348
|
+
# 来源逻辑
|
|
349
|
+
if self.source_logic:
|
|
350
|
+
lines.append(f"### 来源逻辑")
|
|
351
|
+
lines.append(f"基于市场逻辑: {self.source_logic}")
|
|
352
|
+
lines.append("")
|
|
353
|
+
|
|
354
|
+
return "\n".join(lines)
|
|
355
|
+
|
|
356
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
357
|
+
"""转换为字典"""
|
|
358
|
+
return {
|
|
359
|
+
"operator_whitelist": sorted(self.operator_whitelist),
|
|
360
|
+
"operator_blacklist": sorted(self.operator_blacklist),
|
|
361
|
+
"parameter_ranges": {k: list(v) for k, v in self.parameter_ranges.items()},
|
|
362
|
+
"sign_constraint": self.sign_constraint,
|
|
363
|
+
"variable_whitelist": sorted(self.variable_whitelist) if self.variable_whitelist else None,
|
|
364
|
+
"source_logic": self.source_logic,
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
# ==============================================================================
|
|
369
|
+
# 编译器
|
|
370
|
+
# ==============================================================================
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def compile_to_constraint(
|
|
374
|
+
logic: WikiLogicStructured,
|
|
375
|
+
source_logic: Optional[str] = None,
|
|
376
|
+
) -> CompiledConstraint:
|
|
377
|
+
"""主入口: H_struct → Γ
|
|
378
|
+
|
|
379
|
+
把 WikiLogicStructured 编译为 CompiledConstraint。
|
|
380
|
+
|
|
381
|
+
Args:
|
|
382
|
+
logic: 结构化逻辑
|
|
383
|
+
source_logic: 来源逻辑名(用于追溯)
|
|
384
|
+
|
|
385
|
+
Returns:
|
|
386
|
+
CompiledConstraint (Γ 约束)
|
|
387
|
+
"""
|
|
388
|
+
# 1. 从谓词中提取算子和变量
|
|
389
|
+
ops_from_predicates = set(logic.get_operators())
|
|
390
|
+
vars_from_predicates = set(logic.get_variables())
|
|
391
|
+
|
|
392
|
+
# 2. 构建算子白名单
|
|
393
|
+
if logic.operator_whitelist is not None:
|
|
394
|
+
# 使用显式指定的白名单
|
|
395
|
+
op_whitelist = set(logic.operator_whitelist)
|
|
396
|
+
else:
|
|
397
|
+
# 使用谓词中的算子 + 默认算子
|
|
398
|
+
op_whitelist = ops_from_predicates.copy()
|
|
399
|
+
# 添加常用的基础算子
|
|
400
|
+
op_whitelist.update({"add", "sub", "mul", "div", "abs", "sign"})
|
|
401
|
+
# 只保留默认白名单中存在的算子
|
|
402
|
+
op_whitelist = op_whitelist.intersection(DEFAULT_OPERATOR_WHITELIST)
|
|
403
|
+
|
|
404
|
+
# 3. 构建变量白名单
|
|
405
|
+
if vars_from_predicates:
|
|
406
|
+
var_whitelist = vars_from_predicates.copy()
|
|
407
|
+
else:
|
|
408
|
+
var_whitelist = DEFAULT_VARIABLE_WHITELIST.copy()
|
|
409
|
+
|
|
410
|
+
# 4. 构建参数范围
|
|
411
|
+
param_ranges: Dict[str, Tuple[float, float]] = {}
|
|
412
|
+
|
|
413
|
+
# 从默认范围中获取
|
|
414
|
+
for op in op_whitelist:
|
|
415
|
+
if op in DEFAULT_PARAMETER_RANGES:
|
|
416
|
+
param_ranges[op] = DEFAULT_PARAMETER_RANGES[op]
|
|
417
|
+
|
|
418
|
+
# 从逻辑中获取显式范围
|
|
419
|
+
if logic.parameter_ranges is not None:
|
|
420
|
+
param_ranges.update(logic.parameter_ranges)
|
|
421
|
+
|
|
422
|
+
# 从谓词窗口中获取固定范围
|
|
423
|
+
for p in logic.predicates:
|
|
424
|
+
if p.window is not None:
|
|
425
|
+
op = p.op
|
|
426
|
+
if op in param_ranges:
|
|
427
|
+
# 收缩范围以包含窗口值
|
|
428
|
+
lo, hi = param_ranges[op]
|
|
429
|
+
param_ranges[op] = (min(lo, p.window), max(hi, p.window))
|
|
430
|
+
else:
|
|
431
|
+
# 固定窗口
|
|
432
|
+
param_ranges[op] = (p.window, p.window)
|
|
433
|
+
|
|
434
|
+
# 5. 构建符号约束
|
|
435
|
+
sign_constraint = logic.sign_constraint
|
|
436
|
+
if sign_constraint is None:
|
|
437
|
+
# 从行为方向推断
|
|
438
|
+
sign_constraint = logic.behavior.direction
|
|
439
|
+
|
|
440
|
+
# 6. 创建 CompiledConstraint
|
|
441
|
+
gamma = CompiledConstraint(
|
|
442
|
+
operator_whitelist=op_whitelist,
|
|
443
|
+
operator_blacklist=set(),
|
|
444
|
+
parameter_ranges=param_ranges,
|
|
445
|
+
sign_constraint=sign_constraint,
|
|
446
|
+
variable_whitelist=var_whitelist,
|
|
447
|
+
source_logic=source_logic,
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
logger.info(
|
|
451
|
+
"编译逻辑 → Γ: %d 算子, %d 变量, %d 参数范围",
|
|
452
|
+
len(op_whitelist),
|
|
453
|
+
len(var_whitelist),
|
|
454
|
+
len(param_ranges),
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
return gamma
|