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,474 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
philosophy.py - Alpha 101 设计哲学 + 核心算子
|
|
4
|
+
|
|
5
|
+
vs 直接移植 101 公式:本文件**仅做借鉴**,提取:
|
|
6
|
+
- 8 条设计哲学
|
|
7
|
+
- 10-20 个核心算子(含经济意义)
|
|
8
|
+
- A 股可移植性矩阵
|
|
9
|
+
|
|
10
|
+
参考:
|
|
11
|
+
- Kakushadze, Z. (2015). "101 Formulaic Alphas." arXiv:1601.00991
|
|
12
|
+
- WeChat article: 四大量化因子库
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from typing import Any, Dict, List, Optional
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class DesignPrinciple:
|
|
23
|
+
"""Alpha 101 设计原则"""
|
|
24
|
+
id: str # 原则 ID (P1-P8)
|
|
25
|
+
name: str # 名称
|
|
26
|
+
description: str # 描述
|
|
27
|
+
examples: List[str] = None # 公式示例
|
|
28
|
+
|
|
29
|
+
def __post_init__(self):
|
|
30
|
+
if self.examples is None:
|
|
31
|
+
self.examples = []
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# ==============================================================================
|
|
35
|
+
# 8 条设计原则
|
|
36
|
+
# ==============================================================================
|
|
37
|
+
|
|
38
|
+
DESIGN_PHILOSOPHY: List[DesignPrinciple] = [
|
|
39
|
+
DesignPrinciple(
|
|
40
|
+
id="P1",
|
|
41
|
+
name="数学即代码",
|
|
42
|
+
description=(
|
|
43
|
+
"每个 alpha 公式同时是数学表达式和可执行代码。"
|
|
44
|
+
"一旦定义函数、算子、输入数据,公式即可直接运行。"
|
|
45
|
+
"无需额外的解释层或中间表示。"
|
|
46
|
+
),
|
|
47
|
+
examples=[
|
|
48
|
+
"rank(ts_argmax(SignedPower(close, 2.), 5.)) - 0.5",
|
|
49
|
+
"(close - open) / ((high - low) + 0.001)",
|
|
50
|
+
],
|
|
51
|
+
),
|
|
52
|
+
DesignPrinciple(
|
|
53
|
+
id="P2",
|
|
54
|
+
name="动量 vs 反转",
|
|
55
|
+
description=(
|
|
56
|
+
"alpha 公式粗略分两类:动量(趋势跟随)和反转(均值回归)。"
|
|
57
|
+
"动量:信号方向与历史收益方向一致;"
|
|
58
|
+
"反转:信号方向与历史收益方向相反。"
|
|
59
|
+
),
|
|
60
|
+
examples=[
|
|
61
|
+
# 动量
|
|
62
|
+
"close / ts_lag(close, 5) - 1", # 5日动量
|
|
63
|
+
# 反转
|
|
64
|
+
"-1 * correlation(open, volume, 10)", # 量价背离
|
|
65
|
+
],
|
|
66
|
+
),
|
|
67
|
+
DesignPrinciple(
|
|
68
|
+
id="P3",
|
|
69
|
+
name="截面 rank",
|
|
70
|
+
description=(
|
|
71
|
+
"几乎所有 alpha 都使用截面 rank() 而非原始值。"
|
|
72
|
+
"rank 把不同价格水平的股票放到同一尺度,"
|
|
73
|
+
"消除市值/价格 bias。"
|
|
74
|
+
),
|
|
75
|
+
examples=[
|
|
76
|
+
"rank(close)", # 截面 rank
|
|
77
|
+
"rank(ts_std(returns, 20))", # 排名波动率
|
|
78
|
+
],
|
|
79
|
+
),
|
|
80
|
+
DesignPrinciple(
|
|
81
|
+
id="P4",
|
|
82
|
+
name="ts_argmax/min 提取极值位置",
|
|
83
|
+
description=(
|
|
84
|
+
"ts_argmax(x, d) 和 ts_argmin(x, d) 提取过去 d 天内极值出现的位置。"
|
|
85
|
+
"极值位置常用于捕捉时间模式(如:5 天前是否创新高)。"
|
|
86
|
+
),
|
|
87
|
+
examples=[
|
|
88
|
+
"ts_argmax(close, 5)", # 5 天内最高价出现日距今天数
|
|
89
|
+
"ts_argmin(volume, 20)", # 20 天内最低成交量出现日
|
|
90
|
+
],
|
|
91
|
+
),
|
|
92
|
+
DesignPrinciple(
|
|
93
|
+
id="P5",
|
|
94
|
+
name="signedpower 保留符号",
|
|
95
|
+
description=(
|
|
96
|
+
"signedpower(x, a) = sign(x) * |x|^a 保留正负号的同时应用幂函数。"
|
|
97
|
+
"vs 简单 pow(x, a) 会让负数变成 NaN/复杂数。"
|
|
98
|
+
"Alpha 101 #1/#21 等大量使用 signedpower。"
|
|
99
|
+
),
|
|
100
|
+
examples=[
|
|
101
|
+
"SignedPower(((close < low) ? stddev(returns, 20) : close), 2.)",
|
|
102
|
+
"signedpower(delta(close, 1), 0.5)", # sqrt with sign
|
|
103
|
+
],
|
|
104
|
+
),
|
|
105
|
+
DesignPrinciple(
|
|
106
|
+
id="P6",
|
|
107
|
+
name="decay_linear 加权",
|
|
108
|
+
description=(
|
|
109
|
+
"decay_linear(x, d) 用线性权重 [1,2,...,d]/d 加权求和,"
|
|
110
|
+
"比简单 ts_mean(x, d) 给予近期值更高权重。"
|
|
111
|
+
"捕捉动量/反转的时序模式。"
|
|
112
|
+
),
|
|
113
|
+
examples=[
|
|
114
|
+
"rank(decay_linear(volume, 9))", # 9 日线性加权成交量
|
|
115
|
+
"decay_linear(correlation(close, volume, 10), 5)",
|
|
116
|
+
],
|
|
117
|
+
),
|
|
118
|
+
DesignPrinciple(
|
|
119
|
+
id="P7",
|
|
120
|
+
name="三元条件 ? : 表达分支逻辑",
|
|
121
|
+
description=(
|
|
122
|
+
"Alpha 101 大量使用 (cond) ? a : b 三元表达式。"
|
|
123
|
+
"在 polars 中用 pl.when(cond).then(a).otherwise(b) 表达。"
|
|
124
|
+
"比 if-else 嵌套更简洁。"
|
|
125
|
+
),
|
|
126
|
+
examples=[
|
|
127
|
+
"(close < low) ? stddev(returns, 20) : close", # 异常时用波动率代替
|
|
128
|
+
],
|
|
129
|
+
),
|
|
130
|
+
DesignPrinciple(
|
|
131
|
+
id="P8",
|
|
132
|
+
name="行业中性化 IndNeutralize",
|
|
133
|
+
description=(
|
|
134
|
+
"IndNeutralize(x, ind_class) 把因子值在每个行业内去均值,"
|
|
135
|
+
"消除行业 bias。Alpha 101 假设 IndClass 已知;"
|
|
136
|
+
"QuantNodes 中 ind_class = 'citic_1' (中信一级行业)。"
|
|
137
|
+
),
|
|
138
|
+
examples=[
|
|
139
|
+
"rank(IndNeutralize(close, industry))",
|
|
140
|
+
"IndNeutralize(decay_linear(correlation(close, volume, 5), 5), industry)",
|
|
141
|
+
],
|
|
142
|
+
),
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# ==============================================================================
|
|
147
|
+
# 10-20 个核心算子(含经济意义)
|
|
148
|
+
# ==============================================================================
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@dataclass
|
|
152
|
+
class CoreOperator:
|
|
153
|
+
"""核心算子 + 经济意义"""
|
|
154
|
+
name: str # 算子名
|
|
155
|
+
category: str # 类别:time/section/point/composite
|
|
156
|
+
economic_meaning: str # 经济意义
|
|
157
|
+
complexity: int = 1 # 1=简单 2=中等 3=复杂
|
|
158
|
+
alpha101_examples: List[str] = None # Alpha 101 公式示例
|
|
159
|
+
|
|
160
|
+
def __post_init__(self):
|
|
161
|
+
if self.alpha101_examples is None:
|
|
162
|
+
self.alpha101_examples = []
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
CORE_OPERATORS: List[CoreOperator] = [
|
|
166
|
+
# ============ 截面算子(3 个)============
|
|
167
|
+
CoreOperator(
|
|
168
|
+
name="rank",
|
|
169
|
+
category="section",
|
|
170
|
+
economic_meaning=(
|
|
171
|
+
"截面 rank:把不同价格/市值的股票放到同一尺度。"
|
|
172
|
+
"消除市值/价格 bias,捕捉相对位置。"
|
|
173
|
+
),
|
|
174
|
+
complexity=1,
|
|
175
|
+
alpha101_examples=[
|
|
176
|
+
"rank(close)",
|
|
177
|
+
"rank(ts_mean(volume, 20))",
|
|
178
|
+
],
|
|
179
|
+
),
|
|
180
|
+
CoreOperator(
|
|
181
|
+
name="zscore",
|
|
182
|
+
category="section",
|
|
183
|
+
economic_meaning=(
|
|
184
|
+
"截面 z-score:标准化到 (mean, std) 区间。"
|
|
185
|
+
"比 rank 更精确(保留距离信息)。"
|
|
186
|
+
),
|
|
187
|
+
complexity=1,
|
|
188
|
+
alpha101_examples=[
|
|
189
|
+
"zscore(close)",
|
|
190
|
+
],
|
|
191
|
+
),
|
|
192
|
+
CoreOperator(
|
|
193
|
+
name="IndNeutralize",
|
|
194
|
+
category="section",
|
|
195
|
+
economic_meaning=(
|
|
196
|
+
"行业中性化:在每个行业内去均值。"
|
|
197
|
+
"消除行业 beta,捕捉行业内 alpha。"
|
|
198
|
+
),
|
|
199
|
+
complexity=2,
|
|
200
|
+
alpha101_examples=[
|
|
201
|
+
"rank(IndNeutralize(close, industry))",
|
|
202
|
+
],
|
|
203
|
+
),
|
|
204
|
+
|
|
205
|
+
# ============ 时序算子(8 个)============
|
|
206
|
+
CoreOperator(
|
|
207
|
+
name="ts_mean",
|
|
208
|
+
category="time",
|
|
209
|
+
economic_meaning=(
|
|
210
|
+
"滚动均值:平滑短期波动,提取趋势。"
|
|
211
|
+
),
|
|
212
|
+
complexity=1,
|
|
213
|
+
alpha101_examples=[
|
|
214
|
+
"ts_mean(close, 20)",
|
|
215
|
+
],
|
|
216
|
+
),
|
|
217
|
+
CoreOperator(
|
|
218
|
+
name="ts_std",
|
|
219
|
+
category="time",
|
|
220
|
+
economic_meaning=(
|
|
221
|
+
"滚动标准差:衡量波动率。"
|
|
222
|
+
"高波动率常预示反转或突破。"
|
|
223
|
+
),
|
|
224
|
+
complexity=1,
|
|
225
|
+
alpha101_examples=[
|
|
226
|
+
"ts_std(returns, 20)",
|
|
227
|
+
],
|
|
228
|
+
),
|
|
229
|
+
CoreOperator(
|
|
230
|
+
name="ts_argmax",
|
|
231
|
+
category="time",
|
|
232
|
+
economic_meaning=(
|
|
233
|
+
"滚动 argmax:过去 d 天内极值出现的位置。"
|
|
234
|
+
"位置信息常用于捕捉时间模式。"
|
|
235
|
+
),
|
|
236
|
+
complexity=2,
|
|
237
|
+
alpha101_examples=[
|
|
238
|
+
"ts_argmax(close, 5)",
|
|
239
|
+
],
|
|
240
|
+
),
|
|
241
|
+
CoreOperator(
|
|
242
|
+
name="ts_argmin",
|
|
243
|
+
category="time",
|
|
244
|
+
economic_meaning=(
|
|
245
|
+
"滚动 argmin:过去 d 天内最低值位置。"
|
|
246
|
+
),
|
|
247
|
+
complexity=2,
|
|
248
|
+
alpha101_examples=[
|
|
249
|
+
"ts_argmin(volume, 20)",
|
|
250
|
+
],
|
|
251
|
+
),
|
|
252
|
+
CoreOperator(
|
|
253
|
+
name="ts_delta",
|
|
254
|
+
category="time",
|
|
255
|
+
economic_meaning=(
|
|
256
|
+
"差分:x - lag(x, d)。"
|
|
257
|
+
"等价于 d 期间的变化量。"
|
|
258
|
+
),
|
|
259
|
+
complexity=1,
|
|
260
|
+
alpha101_examples=[
|
|
261
|
+
"ts_delta(close, 1)",
|
|
262
|
+
"sign(ts_delta(volume, 1)) * (-1 * ts_delta(close, 1))",
|
|
263
|
+
],
|
|
264
|
+
),
|
|
265
|
+
CoreOperator(
|
|
266
|
+
name="ts_rank",
|
|
267
|
+
category="time",
|
|
268
|
+
economic_meaning=(
|
|
269
|
+
"滚动 rank:x 在过去 d 天中的排名位置(0-1)。"
|
|
270
|
+
"比 ts_argmax 更精细(保留相对位置)。"
|
|
271
|
+
),
|
|
272
|
+
complexity=2,
|
|
273
|
+
alpha101_examples=[
|
|
274
|
+
"ts_rank(delta(close, 7), 5)",
|
|
275
|
+
],
|
|
276
|
+
),
|
|
277
|
+
CoreOperator(
|
|
278
|
+
name="ts_corr",
|
|
279
|
+
category="time",
|
|
280
|
+
economic_meaning=(
|
|
281
|
+
"滚动相关系数:x 和 y 在过去 d 天的相关性。"
|
|
282
|
+
"捕捉量价关系、跨资产关系。"
|
|
283
|
+
),
|
|
284
|
+
complexity=2,
|
|
285
|
+
alpha101_examples=[
|
|
286
|
+
"-1 * correlation(open, volume, 10)",
|
|
287
|
+
],
|
|
288
|
+
),
|
|
289
|
+
CoreOperator(
|
|
290
|
+
name="decay_linear",
|
|
291
|
+
category="time",
|
|
292
|
+
economic_meaning=(
|
|
293
|
+
"线性衰减加权:近期权重高,远期权重低。"
|
|
294
|
+
"比 ts_mean 更敏感于最新数据。"
|
|
295
|
+
),
|
|
296
|
+
complexity=2,
|
|
297
|
+
alpha101_examples=[
|
|
298
|
+
"rank(decay_linear(volume, 9))",
|
|
299
|
+
],
|
|
300
|
+
),
|
|
301
|
+
|
|
302
|
+
# ============ 点算子(3 个)============
|
|
303
|
+
CoreOperator(
|
|
304
|
+
name="signedpower",
|
|
305
|
+
category="point",
|
|
306
|
+
economic_meaning=(
|
|
307
|
+
"带符号幂:sign(x) * |x|^a。"
|
|
308
|
+
"Alpha 101 关键算子,应用幂变换且保留正负号。"
|
|
309
|
+
),
|
|
310
|
+
complexity=2,
|
|
311
|
+
alpha101_examples=[
|
|
312
|
+
"SignedPower(((close < low) ? stddev(returns, 20) : close), 2.)",
|
|
313
|
+
],
|
|
314
|
+
),
|
|
315
|
+
CoreOperator(
|
|
316
|
+
name="sign",
|
|
317
|
+
category="point",
|
|
318
|
+
economic_meaning=(
|
|
319
|
+
"符号函数:返回 -1/0/1。"
|
|
320
|
+
"用于捕捉方向(涨跌/正负)。"
|
|
321
|
+
),
|
|
322
|
+
complexity=1,
|
|
323
|
+
alpha101_examples=[
|
|
324
|
+
"sign(ts_delta(volume, 1))",
|
|
325
|
+
],
|
|
326
|
+
),
|
|
327
|
+
CoreOperator(
|
|
328
|
+
name="log",
|
|
329
|
+
category="point",
|
|
330
|
+
economic_meaning=(
|
|
331
|
+
"自然对数:压缩大值,保留小值细节。"
|
|
332
|
+
"对价格/收益率常做对数变换。"
|
|
333
|
+
),
|
|
334
|
+
complexity=1,
|
|
335
|
+
alpha101_examples=[
|
|
336
|
+
"log(volume)",
|
|
337
|
+
],
|
|
338
|
+
),
|
|
339
|
+
|
|
340
|
+
# ============ 组合算子(2 个)============
|
|
341
|
+
CoreOperator(
|
|
342
|
+
name="correlation",
|
|
343
|
+
category="composite",
|
|
344
|
+
economic_meaning=(
|
|
345
|
+
"等同于 ts_corr:滚动相关系数。"
|
|
346
|
+
"(composite DAG 形式,更易组合)"
|
|
347
|
+
),
|
|
348
|
+
complexity=2,
|
|
349
|
+
alpha101_examples=[
|
|
350
|
+
"decay_linear(correlation(close, volume, 5), 5)",
|
|
351
|
+
],
|
|
352
|
+
),
|
|
353
|
+
CoreOperator(
|
|
354
|
+
name="stddev",
|
|
355
|
+
category="composite",
|
|
356
|
+
economic_meaning=(
|
|
357
|
+
"标准差(同 ts_std)。"
|
|
358
|
+
),
|
|
359
|
+
complexity=1,
|
|
360
|
+
alpha101_examples=[
|
|
361
|
+
"stddev(returns, 20)",
|
|
362
|
+
],
|
|
363
|
+
),
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
# ==============================================================================
|
|
368
|
+
# A 股可移植性矩阵
|
|
369
|
+
# ==============================================================================
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
@dataclass
|
|
373
|
+
class AShareCompatibility:
|
|
374
|
+
"""A 股可移植性记录"""
|
|
375
|
+
alpha_id: str # Alpha 101 #1-#101
|
|
376
|
+
name: str # 简短名称
|
|
377
|
+
formula: str # 公式
|
|
378
|
+
a_share_compatible: bool # 是否适用 A 股
|
|
379
|
+
reason: str # 原因(适用/不适用)
|
|
380
|
+
adaptation: Optional[str] = None # A 股适配建议
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
A_SHARE_COMPATIBILITY: List[AShareCompatibility] = [
|
|
384
|
+
AShareCompatibility(
|
|
385
|
+
alpha_id="#42",
|
|
386
|
+
name="Delay-0 多空组合",
|
|
387
|
+
formula="(-1 * rank(stddev(high, 10))) * correlation(high, volume, 10)",
|
|
388
|
+
a_share_compatible=False,
|
|
389
|
+
reason="Delay-0 当日交易:A 股 T+1 制度不可行",
|
|
390
|
+
adaptation="改为 Delay-1(次日开盘价交易)",
|
|
391
|
+
),
|
|
392
|
+
AShareCompatibility(
|
|
393
|
+
alpha_id="#48",
|
|
394
|
+
name="Delay-0 极值比",
|
|
395
|
+
formula="(-1 * (rank(correlation(rank(close), rank(volume), 5)) - rank(close + volume - adv20)))",
|
|
396
|
+
a_share_compatible=False,
|
|
397
|
+
reason="Delay-0 当日交易:A 股 T+1 制度不可行",
|
|
398
|
+
adaptation="改为 Delay-1",
|
|
399
|
+
),
|
|
400
|
+
AShareCompatibility(
|
|
401
|
+
alpha_id="#53",
|
|
402
|
+
name="Delay-0 价格位置",
|
|
403
|
+
formula="-1 * delta((((close - low) - (high - close)) / (close - low)), 9)",
|
|
404
|
+
a_share_compatible=False,
|
|
405
|
+
reason="Delay-0 当日交易 + 除零风险(涨跌停 close=low)",
|
|
406
|
+
adaptation="加 + 0.001 epsilon + 改为 Delay-1",
|
|
407
|
+
),
|
|
408
|
+
AShareCompatibility(
|
|
409
|
+
alpha_id="#54",
|
|
410
|
+
name="Delay-0 量价背离",
|
|
411
|
+
formula="(-1 * (low - close) * (open^5) * ((close - high) / (close - low)) * (high - close))",
|
|
412
|
+
a_share_compatible=False,
|
|
413
|
+
reason="Delay-0 + 除零 + 极端值",
|
|
414
|
+
adaptation="需大幅改造,不推荐",
|
|
415
|
+
),
|
|
416
|
+
AShareCompatibility(
|
|
417
|
+
alpha_id="#1",
|
|
418
|
+
name="复杂反转波动率",
|
|
419
|
+
formula="rank(Ts_ArgMax(SignedPower(((returns < 0) ? stddev(returns, 20) : close), 2.), 5.)) - 0.5",
|
|
420
|
+
a_share_compatible=True,
|
|
421
|
+
reason="Delay-1,可直接用 close/returns 输入",
|
|
422
|
+
adaptation=None,
|
|
423
|
+
),
|
|
424
|
+
AShareCompatibility(
|
|
425
|
+
alpha_id="#6",
|
|
426
|
+
name="简单量价相关",
|
|
427
|
+
formula="-1 * correlation(open, volume, 10)",
|
|
428
|
+
a_share_compatible=True,
|
|
429
|
+
reason="经典量价因子,跨市场适用",
|
|
430
|
+
adaptation=None,
|
|
431
|
+
),
|
|
432
|
+
AShareCompatibility(
|
|
433
|
+
alpha_id="#12",
|
|
434
|
+
name="量价反转",
|
|
435
|
+
formula="sign(delta(volume, 1)) * (-1 * delta(close, 1))",
|
|
436
|
+
a_share_compatible=True,
|
|
437
|
+
reason="量增价跌 = 卖出信号,反之亦然",
|
|
438
|
+
adaptation=None,
|
|
439
|
+
),
|
|
440
|
+
AShareCompatibility(
|
|
441
|
+
alpha_id="#101",
|
|
442
|
+
name="日内动量",
|
|
443
|
+
formula="(close - open) / ((high - low) + 0.001)",
|
|
444
|
+
a_share_compatible=True,
|
|
445
|
+
reason="标准日内动量因子(已加 0.001 epsilon 防除零)",
|
|
446
|
+
adaptation=None,
|
|
447
|
+
),
|
|
448
|
+
]
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
# ==============================================================================
|
|
452
|
+
# 辅助函数
|
|
453
|
+
# ==============================================================================
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def get_philosophy_by_id(pid: str) -> Optional[DesignPrinciple]:
|
|
457
|
+
"""按 ID 查设计原则"""
|
|
458
|
+
for p in DESIGN_PHILOSOPHY:
|
|
459
|
+
if p.id == pid:
|
|
460
|
+
return p
|
|
461
|
+
return None
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def get_operator_by_name(name: str) -> Optional[CoreOperator]:
|
|
465
|
+
"""按名称查核心算子"""
|
|
466
|
+
for op in CORE_OPERATORS:
|
|
467
|
+
if op.name == name:
|
|
468
|
+
return op
|
|
469
|
+
return None
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def get_a_share_compatible_count() -> int:
|
|
473
|
+
"""A 股可移植的 alpha 数量"""
|
|
474
|
+
return sum(1 for x in A_SHARE_COMPATIBILITY if x.a_share_compatible)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
alpha158_design - Alpha 158/360 设计哲学借鉴(M3 PR)
|
|
4
|
+
|
|
5
|
+
Alpha 158/360 (Yang et al. 2020, arXiv:2009.11189) 是 Qlib 平台的标准化
|
|
6
|
+
ML 特征集。本子包**借鉴其特征设计思想**而非直接移植公式集
|
|
7
|
+
(实际因子集由 llmwikify 在他处生成)。
|
|
8
|
+
|
|
9
|
+
内容:
|
|
10
|
+
- DESIGN_PHILOSOPHY: Alpha 158/360 特征设计原则(4 类 × 7 条)
|
|
11
|
+
- CATEGORY_TEMPLATES: 4 类特征的设计模板(158 公式骨架 + 360 公式骨架)
|
|
12
|
+
- FEW_SHOT_EXAMPLES: 5-10 个示例特征(用于 Alpha-GPT 启动 prompt)
|
|
13
|
+
|
|
14
|
+
参考:
|
|
15
|
+
- Qlib: https://github.com/microsoft/qlib
|
|
16
|
+
- Alpha 158 = 9 KBAR + 20 Price + 5 Volume + 124 Rolling = 158
|
|
17
|
+
- Alpha 360 = 6 字段 × 60 lookback = 360
|
|
18
|
+
|
|
19
|
+
M3 范围:仅做借鉴(设计文档 + few-shot)。
|
|
20
|
+
完整特征集实现 → 路线 6 (Alpha-GPT) 阶段。
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
from QuantNodes.research.quant_alpha.alpha158_design.philosophy import (
|
|
26
|
+
FEATURE_CATEGORIES,
|
|
27
|
+
CategoryTemplate,
|
|
28
|
+
Alpha360Template,
|
|
29
|
+
ALPHA360_TEMPLATE,
|
|
30
|
+
DEFAULT_WINDOWS,
|
|
31
|
+
ALPHA360_LOOKBACK_RANGE,
|
|
32
|
+
get_template_by_category,
|
|
33
|
+
get_template_by_name,
|
|
34
|
+
list_categories,
|
|
35
|
+
total_feature_count,
|
|
36
|
+
)
|
|
37
|
+
from QuantNodes.research.quant_alpha.alpha158_design.few_shot_examples import (
|
|
38
|
+
ALPHA158_FEW_SHOT_EXAMPLES,
|
|
39
|
+
list_examples,
|
|
40
|
+
get_example,
|
|
41
|
+
get_few_shot_prompt,
|
|
42
|
+
get_categories as get_example_categories,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
# 设计模板
|
|
47
|
+
"FEATURE_CATEGORIES",
|
|
48
|
+
"CategoryTemplate",
|
|
49
|
+
"Alpha360Template",
|
|
50
|
+
"ALPHA360_TEMPLATE",
|
|
51
|
+
"DEFAULT_WINDOWS",
|
|
52
|
+
"ALPHA360_LOOKBACK_RANGE",
|
|
53
|
+
"get_template_by_category",
|
|
54
|
+
"get_template_by_name",
|
|
55
|
+
"list_categories",
|
|
56
|
+
"total_feature_count",
|
|
57
|
+
# few-shot 示例
|
|
58
|
+
"ALPHA158_FEW_SHOT_EXAMPLES",
|
|
59
|
+
"list_examples",
|
|
60
|
+
"get_example",
|
|
61
|
+
"get_few_shot_prompt",
|
|
62
|
+
"get_example_categories",
|
|
63
|
+
]
|