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,90 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
QuantNodes Operators - Polars 算子模块
|
|
4
|
+
|
|
5
|
+
基于 Polars 的因子运算算子,提供简洁的表达式接口。
|
|
6
|
+
|
|
7
|
+
Modules:
|
|
8
|
+
time_series: 时间序列算子 (ts_mean, ts_std, ts_corr...)
|
|
9
|
+
section: 截面算子 (rank, zscore, winsorize...)
|
|
10
|
+
math: 数学算子 (add, mul, log, pow...)
|
|
11
|
+
composite: 组合算子 (weighted_sum, combine...)
|
|
12
|
+
talib: TA-Lib 技术分析指标 (rsi, sma, macd, bbands, ...)
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
from QuantNodes.operators import ts, sec, math, talib_ops
|
|
16
|
+
|
|
17
|
+
# 时间序列
|
|
18
|
+
result = ts.ts_mean(pl.col("close"), 20)
|
|
19
|
+
|
|
20
|
+
# 截面
|
|
21
|
+
result = sec.rank(pl.col("factor"))
|
|
22
|
+
|
|
23
|
+
# 数学
|
|
24
|
+
result = math.add(pl.col("factor"), 1.0)
|
|
25
|
+
|
|
26
|
+
# TA-Lib
|
|
27
|
+
result = talib_ops.rsi(pl.col("close"), timeperiod=14)
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from .time_series import TimeSeriesOperators as _ts
|
|
31
|
+
from .section import SectionOperators as _sec
|
|
32
|
+
from .math import MathOperators as _math
|
|
33
|
+
from .composite import CompositeOperators as _composite
|
|
34
|
+
from .proxy import list_operators, get_operator, register_operator
|
|
35
|
+
from .custom import CustomOperator, OperatorTemplate, point, time, section
|
|
36
|
+
# PR-QN-3a (2026-06-21): Composite DAG re-exports
|
|
37
|
+
from .composite_dag import (
|
|
38
|
+
composite_operator,
|
|
39
|
+
CompositeSpec,
|
|
40
|
+
ParamSpec,
|
|
41
|
+
is_composite_op,
|
|
42
|
+
get_composite_spec,
|
|
43
|
+
list_composite_ops,
|
|
44
|
+
get_composite_doc_for_llm,
|
|
45
|
+
load_composites_from_yaml,
|
|
46
|
+
_COMPOSITE_REGISTRY_POLARS,
|
|
47
|
+
_COMPOSITE_REGISTRY_PANDAS,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# PR-QN-3b (2026-06-21): 20 个内置 composite op (注册副作用)
|
|
51
|
+
from . import composite_dag_ops # noqa: F401 — 模块导入即注册
|
|
52
|
+
|
|
53
|
+
# PR-QN-4 (2026-06-22): 20 个 pandas 镜像 composite op (注册副作用)
|
|
54
|
+
from . import composite_dag_pandas_ops # noqa: F401 — 模块导入即注册
|
|
55
|
+
|
|
56
|
+
# PR-QN-4 (2026-06-22): Dual-Engine support
|
|
57
|
+
from ._engine import Engine, detect_engine
|
|
58
|
+
|
|
59
|
+
# Phase 3.2 (2026-06-22): 3 层注册表统一只读门面 (Facade)
|
|
60
|
+
from .facade import OperatorFacade, operator_facade
|
|
61
|
+
|
|
62
|
+
# 统一导出
|
|
63
|
+
ts = _ts()
|
|
64
|
+
sec = _sec()
|
|
65
|
+
math = _math()
|
|
66
|
+
composite = _composite()
|
|
67
|
+
|
|
68
|
+
# TA-Lib (可选)
|
|
69
|
+
try:
|
|
70
|
+
from .talib import TaLibOperators as _talib
|
|
71
|
+
talib_ops = _talib()
|
|
72
|
+
except ImportError:
|
|
73
|
+
talib_ops = None
|
|
74
|
+
|
|
75
|
+
__all__ = [
|
|
76
|
+
"ts", "sec", "math", "composite", "talib_ops",
|
|
77
|
+
"TimeSeriesOperators", "SectionOperators", "MathOperators", "CompositeOperators",
|
|
78
|
+
"list_operators", "get_operator", "register_operator",
|
|
79
|
+
"CustomOperator", "OperatorTemplate",
|
|
80
|
+
"point", "time", "section",
|
|
81
|
+
# PR-QN-3a (2026-06-21): Composite DAG
|
|
82
|
+
"composite_operator", "CompositeSpec", "ParamSpec",
|
|
83
|
+
"is_composite_op", "get_composite_spec", "list_composite_ops",
|
|
84
|
+
"get_composite_doc_for_llm", "load_composites_from_yaml",
|
|
85
|
+
# PR-QN-4 (2026-06-22): Dual-Engine
|
|
86
|
+
"Engine", "detect_engine",
|
|
87
|
+
"_COMPOSITE_REGISTRY_POLARS", "_COMPOSITE_REGISTRY_PANDAS",
|
|
88
|
+
# Phase 3.2 (2026-06-22): Operator Facade
|
|
89
|
+
"OperatorFacade", "operator_facade",
|
|
90
|
+
]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""Dual-Engine support for Composite DAG operators (PR-QN-4, 2026-06-22)
|
|
3
|
+
|
|
4
|
+
Provides engine detection for LLM-generated code and dual whitelists
|
|
5
|
+
for YAML template validation (polars vs pandas, strict separation).
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
from QuantNodes.operators._engine import Engine, detect_engine
|
|
9
|
+
|
|
10
|
+
engine = detect_engine("import pandas as pd\\nresult = df.groupby('x').mean()")
|
|
11
|
+
assert engine == Engine.PANDAS
|
|
12
|
+
|
|
13
|
+
engine = detect_engine("import polars as pl\\nresult = pl.col('x').mean()")
|
|
14
|
+
assert engine == Engine.POLARS
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import ast
|
|
19
|
+
from enum import Enum
|
|
20
|
+
from typing import Set
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Engine(str, Enum):
|
|
24
|
+
POLARS = "polars"
|
|
25
|
+
PANDAS = "pandas"
|
|
26
|
+
AUTO = "auto"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def detect_engine(code: str) -> Engine:
|
|
30
|
+
"""Scan code for import statements to detect which engine is used.
|
|
31
|
+
|
|
32
|
+
Heuristics:
|
|
33
|
+
- `import polars as pl` or `from polars` → POLARS
|
|
34
|
+
- `import pandas as pd` or `from pandas` → PANDAS
|
|
35
|
+
- Both present → POLARS (default, faster path)
|
|
36
|
+
- Neither present → POLARS (safe default)
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Engine.POLARS or Engine.PANDAS (never AUTO)
|
|
40
|
+
"""
|
|
41
|
+
try:
|
|
42
|
+
tree = ast.parse(code)
|
|
43
|
+
except SyntaxError:
|
|
44
|
+
return Engine.POLARS
|
|
45
|
+
|
|
46
|
+
has_pl = False
|
|
47
|
+
has_pd = False
|
|
48
|
+
|
|
49
|
+
for node in ast.walk(tree):
|
|
50
|
+
if isinstance(node, ast.Import):
|
|
51
|
+
for alias in node.names:
|
|
52
|
+
if alias.name == "polars" or alias.name.startswith("polars."):
|
|
53
|
+
has_pl = True
|
|
54
|
+
elif alias.name == "pandas" or alias.name.startswith("pandas."):
|
|
55
|
+
has_pd = True
|
|
56
|
+
elif isinstance(node, ast.ImportFrom):
|
|
57
|
+
if node.module and (node.module == "polars" or node.module.startswith("polars.")):
|
|
58
|
+
has_pl = True
|
|
59
|
+
elif node.module and (node.module == "pandas" or node.module.startswith("pandas.")):
|
|
60
|
+
has_pd = True
|
|
61
|
+
|
|
62
|
+
if has_pd and not has_pl:
|
|
63
|
+
return Engine.PANDAS
|
|
64
|
+
return Engine.POLARS
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ===== YAML Template Whitelists (Strict Separation) =====
|
|
68
|
+
|
|
69
|
+
ALLOWED_FUNC_NAMES_POLARS: Set[str] = {
|
|
70
|
+
# polars Expr methods
|
|
71
|
+
"col", "lit", "when", "then", "otherwise",
|
|
72
|
+
"abs", "log", "sqrt", "pow", "exp",
|
|
73
|
+
"rolling_mean", "rolling_std", "rolling_corr",
|
|
74
|
+
"rolling_sum", "rolling_min", "rolling_max", "rolling_median",
|
|
75
|
+
"ewm_mean", "ewm_std",
|
|
76
|
+
"shift", "diff", "pct_change", "rank",
|
|
77
|
+
"mean", "std", "sum", "min", "max", "median", "quantile",
|
|
78
|
+
"count", "first", "last",
|
|
79
|
+
"group_by", "over", "alias",
|
|
80
|
+
"clip", "fill_null", "fill_nan", "drop_nulls", "drop_nans",
|
|
81
|
+
"is_null", "is_nan", "is_not_null",
|
|
82
|
+
"round", "floor", "ceil",
|
|
83
|
+
"and_", "or_", "not_",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
ALLOWED_FUNC_NAMES_PANDAS: Set[str] = {
|
|
87
|
+
# pandas Series/DataFrame methods
|
|
88
|
+
"groupby", "transform", "agg", "apply", "pipe",
|
|
89
|
+
"rolling", "expanding", "ewm",
|
|
90
|
+
"shift", "diff", "pct_change", "rank",
|
|
91
|
+
"fillna", "dropna", "isna", "notna", "isnull", "notnull",
|
|
92
|
+
"clip", "round", "abs", "astype",
|
|
93
|
+
"mean", "std", "sum", "min", "max", "median", "quantile",
|
|
94
|
+
"count", "first", "last",
|
|
95
|
+
"where", "mask", "assign",
|
|
96
|
+
"resample", "asfreq",
|
|
97
|
+
"merge", "join", "concat",
|
|
98
|
+
"reset_index", "set_index",
|
|
99
|
+
"head", "tail", "sort_values",
|
|
100
|
+
"to_numpy", "values",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
__all__ = [
|
|
104
|
+
"Engine",
|
|
105
|
+
"detect_engine",
|
|
106
|
+
"ALLOWED_FUNC_NAMES_POLARS",
|
|
107
|
+
"ALLOWED_FUNC_NAMES_PANDAS",
|
|
108
|
+
]
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
组合算子(代理层)
|
|
4
|
+
|
|
5
|
+
基于 factor_functions/composite_ops.py 的实现,提供统一的类接口。
|
|
6
|
+
|
|
7
|
+
Available Operators:
|
|
8
|
+
- weighted_sum: 加权求和
|
|
9
|
+
- weighted_avg: 加权平均
|
|
10
|
+
- max: 最大值
|
|
11
|
+
- min: 最小值
|
|
12
|
+
- abs_max: 绝对值最大
|
|
13
|
+
- combine: 组合两个因子
|
|
14
|
+
- blend: 混合两个因子
|
|
15
|
+
- select_top: 选择顶部
|
|
16
|
+
- filter_positive: 过滤正信号
|
|
17
|
+
- filter_negative: 过滤负信号
|
|
18
|
+
- abs_filter: 绝对值过滤
|
|
19
|
+
- rank_sort: 排名排序
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
>>> composite.weighted_sum([pl.col("f1"), pl.col("f2")], [0.6, 0.4])
|
|
23
|
+
>>> composite.blend("f1", "f2", 0.5)
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from typing import Union, List, Optional
|
|
29
|
+
|
|
30
|
+
import polars as pl
|
|
31
|
+
from polars import Expr
|
|
32
|
+
|
|
33
|
+
from QuantNodes.factor_node.factor_functions.composite_ops import (
|
|
34
|
+
blend as _blend,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class CompositeOperators:
|
|
39
|
+
"""组合算子(代理层)"""
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def weighted_sum(factors: List[Union[Expr, str]], weights: List[float]) -> Expr:
|
|
43
|
+
exprs = [_ensure_expr(f) for f in factors]
|
|
44
|
+
weights_arr = pl.Series(weights)
|
|
45
|
+
weights_arr = weights_arr / weights_arr.sum()
|
|
46
|
+
|
|
47
|
+
first_factor = factors[0]
|
|
48
|
+
if isinstance(first_factor, str):
|
|
49
|
+
col_name = first_factor
|
|
50
|
+
elif hasattr(first_factor, 'meta') and hasattr(first_factor.meta, 'output_name'):
|
|
51
|
+
try:
|
|
52
|
+
col_name = first_factor.meta.output_name()
|
|
53
|
+
except Exception:
|
|
54
|
+
col_name = "result"
|
|
55
|
+
else:
|
|
56
|
+
col_name = "result"
|
|
57
|
+
|
|
58
|
+
return sum(e * w for e, w in zip(exprs, weights_arr)).alias(col_name)
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def weighted_avg(
|
|
62
|
+
factors: List[Union[Expr, str]], weights: Optional[List[float]] = None,
|
|
63
|
+
) -> Expr:
|
|
64
|
+
if weights is None:
|
|
65
|
+
weights = [1.0] * len(factors)
|
|
66
|
+
return CompositeOperators.weighted_sum(factors, weights)
|
|
67
|
+
|
|
68
|
+
@staticmethod
|
|
69
|
+
def max(factors: List[Union[Expr, str]]) -> Expr:
|
|
70
|
+
exprs = [_ensure_expr(f) for f in factors]
|
|
71
|
+
first_factor = factors[0] if isinstance(factors[0], str) else "result"
|
|
72
|
+
return pl.max_horizontal(*exprs).alias(first_factor)
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def min(factors: List[Union[Expr, str]]) -> Expr:
|
|
76
|
+
exprs = [_ensure_expr(f) for f in factors]
|
|
77
|
+
first_factor = factors[0] if isinstance(factors[0], str) else "result"
|
|
78
|
+
return pl.min_horizontal(*exprs).alias(first_factor)
|
|
79
|
+
|
|
80
|
+
@staticmethod
|
|
81
|
+
def abs_max(factors: List[Union[Expr, str]]) -> Expr:
|
|
82
|
+
exprs = [_ensure_expr(f).abs() for f in factors]
|
|
83
|
+
first_factor = factors[0] if isinstance(factors[0], str) else "result"
|
|
84
|
+
return pl.max_horizontal(*exprs).alias(first_factor)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def combine(factors: List[Union[Expr, str]], method: str = "add") -> Expr:
|
|
88
|
+
exprs = [_ensure_expr(f) for f in factors]
|
|
89
|
+
first_factor = factors[0] if isinstance(factors[0], str) else "result"
|
|
90
|
+
|
|
91
|
+
if method in ("add", "sum"):
|
|
92
|
+
return sum(exprs).alias(first_factor)
|
|
93
|
+
elif method == "avg":
|
|
94
|
+
return (sum(exprs) / len(exprs)).alias(first_factor)
|
|
95
|
+
elif method == "mul":
|
|
96
|
+
result = exprs[0]
|
|
97
|
+
for e in exprs[1:]:
|
|
98
|
+
result = result * e
|
|
99
|
+
return result.alias(first_factor)
|
|
100
|
+
elif method == "max":
|
|
101
|
+
return pl.max_horizontal(*exprs).alias(first_factor)
|
|
102
|
+
elif method == "min":
|
|
103
|
+
return pl.min_horizontal(*exprs).alias(first_factor)
|
|
104
|
+
return exprs[0].alias(first_factor)
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def blend(f1: Union[Expr, str], f2: Union[Expr, str], alpha: float = 0.5) -> Expr:
|
|
108
|
+
return _blend(f1, f2, alpha=alpha)
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def select_top(f: Union[Expr, str], n: int = 1, ascending: bool = False) -> Expr:
|
|
112
|
+
e = _ensure_expr(f)
|
|
113
|
+
col_name = f if isinstance(f, str) else "result"
|
|
114
|
+
if ascending:
|
|
115
|
+
return e.rank(method="dense").alias(col_name)
|
|
116
|
+
else:
|
|
117
|
+
return (e.count() - e.rank(method="dense") + 1).alias(col_name)
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def filter_positive(f: Union[Expr, str]) -> Expr:
|
|
121
|
+
e = _ensure_expr(f)
|
|
122
|
+
col_name = f if isinstance(f, str) else "result"
|
|
123
|
+
return pl.when(e > 0).then(pl.lit(0.0)).otherwise(e).alias(col_name)
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def filter_negative(f: Union[Expr, str]) -> Expr:
|
|
127
|
+
e = _ensure_expr(f)
|
|
128
|
+
col_name = f if isinstance(f, str) else "result"
|
|
129
|
+
return pl.when(e < 0).then(pl.lit(0.0)).otherwise(e).alias(col_name)
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def abs_filter(f: Union[Expr, str], threshold: float = 0.0) -> Expr:
|
|
133
|
+
e = _ensure_expr(f)
|
|
134
|
+
col_name = f if isinstance(f, str) else "result"
|
|
135
|
+
return pl.when(e.abs() > threshold).then(e).otherwise(pl.lit(0.0)).alias(col_name)
|
|
136
|
+
|
|
137
|
+
@staticmethod
|
|
138
|
+
def rank_sort(
|
|
139
|
+
factors: List[Union[Expr, str]], weights: Optional[List[float]] = None,
|
|
140
|
+
) -> List[Expr]:
|
|
141
|
+
exprs = [_ensure_expr(f) for f in factors]
|
|
142
|
+
|
|
143
|
+
if weights is not None:
|
|
144
|
+
weights_arr = pl.Series(weights)
|
|
145
|
+
weights_arr = weights_arr / weights_arr.sum()
|
|
146
|
+
weighted_expr = sum(e * w for e, w in zip(exprs, weights_arr))
|
|
147
|
+
combined = weighted_expr
|
|
148
|
+
else:
|
|
149
|
+
combined = pl.max_horizontal(*exprs)
|
|
150
|
+
|
|
151
|
+
ranked = combined.rank()
|
|
152
|
+
return [
|
|
153
|
+
ranked.eq(i + 1).alias(f) if isinstance(f, str) else ranked.eq(i + 1)
|
|
154
|
+
for i, f in enumerate(factors)
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _ensure_expr(f: Union[Expr, str]) -> Expr:
|
|
159
|
+
if isinstance(f, str):
|
|
160
|
+
return pl.col(f)
|
|
161
|
+
return f
|