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,120 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
ConfigNode 配置节点基类模块
|
|
4
|
+
|
|
5
|
+
提供配置节点的基础架构,继承自 BaseNode。
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from abc import ABC, abstractmethod
|
|
10
|
+
from typing import Any, Dict, Optional
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from QuantNodes.core.node import BaseNode
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ConfigNode(BaseNode, ABC):
|
|
17
|
+
"""
|
|
18
|
+
配置节点基类
|
|
19
|
+
|
|
20
|
+
所有配置节点都继承自此类,提供统一的数据读取接口。
|
|
21
|
+
|
|
22
|
+
子类必须实现:
|
|
23
|
+
_load_config(): 从配置源加载配置数据
|
|
24
|
+
_get_config_path(): 返回配置路径
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
>>> ini = IniConfigNode(file_path="config.ini", section="database")
|
|
28
|
+
>>> settings = ini.execute()
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, name: str = None, config: Dict[str, Any] = None, **kwargs):
|
|
32
|
+
super().__init__(name=name or self.__class__.__name__, config=config, **kwargs)
|
|
33
|
+
self._cached_config: Optional[Dict[str, Any]] = None
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
37
|
+
"""
|
|
38
|
+
从配置源加载配置数据
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
配置字典
|
|
42
|
+
"""
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
@abstractmethod
|
|
46
|
+
def _get_config_path(self) -> Optional[Path]:
|
|
47
|
+
"""
|
|
48
|
+
返回配置路径
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
配置文件的 Path 对象,如果没有文件概念则返回 None
|
|
52
|
+
"""
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
def _execute(self, input_data: Any = None, **kwargs) -> Dict[str, Any]:
|
|
56
|
+
"""
|
|
57
|
+
执行配置加载
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
input_data: 可选的输入数据(会被忽略)
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
配置字典
|
|
64
|
+
"""
|
|
65
|
+
self._cached_config = self._load_config()
|
|
66
|
+
return self._cached_config
|
|
67
|
+
|
|
68
|
+
def execute(
|
|
69
|
+
self, input_data: Any = None, *, use_cache: bool = True, **kwargs,
|
|
70
|
+
) -> Dict[str, Any]:
|
|
71
|
+
"""
|
|
72
|
+
执行配置加载
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
input_data: 可选的输入数据(会被忽略)
|
|
76
|
+
use_cache: 是否使用缓存,默认 True
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
配置字典
|
|
80
|
+
"""
|
|
81
|
+
if use_cache and self._cached_config is not None:
|
|
82
|
+
return self._cached_config
|
|
83
|
+
return super().execute(input_data, **kwargs)
|
|
84
|
+
|
|
85
|
+
def reload(self) -> Dict[str, Any]:
|
|
86
|
+
"""
|
|
87
|
+
强制重新加载配置
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
重新加载的配置字典
|
|
91
|
+
"""
|
|
92
|
+
self._cached_config = None
|
|
93
|
+
return self.execute(use_cache=False)
|
|
94
|
+
|
|
95
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
96
|
+
"""
|
|
97
|
+
获取配置项
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
key: 配置键
|
|
101
|
+
default: 默认值
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
配置值,如果不存在则返回默认值
|
|
105
|
+
"""
|
|
106
|
+
if self._cached_config is None:
|
|
107
|
+
self.execute()
|
|
108
|
+
return self._cached_config.get(key, default)
|
|
109
|
+
|
|
110
|
+
def __getitem__(self, key: str) -> Any:
|
|
111
|
+
"""支持 dict 风格的配置访问"""
|
|
112
|
+
if self._cached_config is None:
|
|
113
|
+
self.execute()
|
|
114
|
+
return self._cached_config[key]
|
|
115
|
+
|
|
116
|
+
def __contains__(self, key: str) -> bool:
|
|
117
|
+
"""支持 'in' 操作符"""
|
|
118
|
+
if self._cached_config is None:
|
|
119
|
+
self.execute()
|
|
120
|
+
return key in self._cached_config
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
EnvConfigNode - 环境变量配置节点
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
from QuantNodes.conf_node.base import ConfigNode
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class EnvConfigNode(ConfigNode):
|
|
15
|
+
"""
|
|
16
|
+
环境变量配置节点
|
|
17
|
+
|
|
18
|
+
从环境变量读取配置,支持前缀过滤和类型转换。
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
>>> # 读取所有环境变量
|
|
22
|
+
>>> node = EnvConfigNode()
|
|
23
|
+
>>> config = node.execute()
|
|
24
|
+
>>>
|
|
25
|
+
>>> # 只读取以 DB_ 开头的环境变量
|
|
26
|
+
>>> node = EnvConfigNode(prefix="DB_")
|
|
27
|
+
>>> db_config = node.execute() # {'HOST': 'localhost', 'PORT': '5432', ...}
|
|
28
|
+
>>>
|
|
29
|
+
>>> # 带前缀和类型转换
|
|
30
|
+
>>> node = EnvConfigNode(prefix="DB_", types={'PORT': int, 'DEBUG': bool})
|
|
31
|
+
>>> config = node.execute() # {'PORT': 5432, 'DEBUG': True, ...}
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
prefix: Optional[str] = None,
|
|
37
|
+
separator: str = '_',
|
|
38
|
+
types: Optional[Dict[str, type]] = None,
|
|
39
|
+
lowercase_keys: bool = True,
|
|
40
|
+
name: str = None,
|
|
41
|
+
config: Dict[str, Any] = None,
|
|
42
|
+
**kwargs
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
Args:
|
|
46
|
+
prefix: 环境变量前缀,只读取以此前缀开头的变量
|
|
47
|
+
separator: 前缀与变量名之间的分隔符,默认 '_'
|
|
48
|
+
types: 类型转换字典,如 {'PORT': int, 'DEBUG': bool}
|
|
49
|
+
lowercase_keys: 是否将 key 转为小写,默认 True
|
|
50
|
+
name: 节点名称
|
|
51
|
+
config: 额外配置
|
|
52
|
+
**kwargs: 额外参数
|
|
53
|
+
"""
|
|
54
|
+
super().__init__(name=name, config=config, **kwargs)
|
|
55
|
+
self.prefix = prefix
|
|
56
|
+
self.separator = separator
|
|
57
|
+
self.types = types or {}
|
|
58
|
+
self.lowercase_keys = lowercase_keys
|
|
59
|
+
|
|
60
|
+
def _get_config_path(self) -> Optional[Path]:
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
64
|
+
"""加载环境变量"""
|
|
65
|
+
result = {}
|
|
66
|
+
|
|
67
|
+
for key, value in os.environ.items():
|
|
68
|
+
if self.prefix:
|
|
69
|
+
if not key.startswith(self.prefix):
|
|
70
|
+
continue
|
|
71
|
+
config_key = key[len(self.prefix):]
|
|
72
|
+
else:
|
|
73
|
+
config_key = key
|
|
74
|
+
|
|
75
|
+
if not config_key:
|
|
76
|
+
continue
|
|
77
|
+
|
|
78
|
+
if self.lowercase_keys:
|
|
79
|
+
config_key = config_key.lower()
|
|
80
|
+
|
|
81
|
+
if config_key in self.types:
|
|
82
|
+
value = self._convert_type(config_key, value)
|
|
83
|
+
|
|
84
|
+
result[config_key] = value
|
|
85
|
+
|
|
86
|
+
return result
|
|
87
|
+
|
|
88
|
+
def _convert_type(self, key: str, value: str) -> Any:
|
|
89
|
+
"""类型转换"""
|
|
90
|
+
target_type = self.types.get(key)
|
|
91
|
+
|
|
92
|
+
if target_type is bool:
|
|
93
|
+
return value.lower() in ('true', '1', 'yes', 'on')
|
|
94
|
+
elif target_type is int:
|
|
95
|
+
try:
|
|
96
|
+
return int(value)
|
|
97
|
+
except ValueError:
|
|
98
|
+
return value
|
|
99
|
+
elif target_type is float:
|
|
100
|
+
try:
|
|
101
|
+
return float(value)
|
|
102
|
+
except ValueError:
|
|
103
|
+
return value
|
|
104
|
+
else:
|
|
105
|
+
return target_type(value) if target_type else value
|
|
106
|
+
|
|
107
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
108
|
+
"""获取环境变量配置"""
|
|
109
|
+
return super().get(key, default)
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def from_env(cls, key: str, default: Any = None, target_type: type = None) -> Any:
|
|
113
|
+
"""
|
|
114
|
+
便捷方法:从环境变量读取单个值
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
key: 环境变量名
|
|
118
|
+
default: 默认值
|
|
119
|
+
target_type: 目标类型
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
环境变量值
|
|
123
|
+
"""
|
|
124
|
+
value = os.environ.get(key, default)
|
|
125
|
+
if value is None:
|
|
126
|
+
return default
|
|
127
|
+
|
|
128
|
+
if target_type is bool:
|
|
129
|
+
return value.lower() in ('true', '1', 'yes', 'on')
|
|
130
|
+
elif target_type in (int, float, str):
|
|
131
|
+
return target_type(value)
|
|
132
|
+
return value
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
IniConfigNode - INI 配置文件节点
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import configparser
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Dict, Optional, Union
|
|
10
|
+
|
|
11
|
+
from QuantNodes.conf_node.base import ConfigNode
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IniConfigNode(ConfigNode):
|
|
15
|
+
"""
|
|
16
|
+
INI 配置文件节点
|
|
17
|
+
|
|
18
|
+
解析 .ini 格式的配置文件,支持多 section。
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
>>> # 读取指定 section
|
|
22
|
+
>>> node = IniConfigNode(file_path="config.ini", section="database")
|
|
23
|
+
>>> db_config = node.execute()
|
|
24
|
+
>>> print(db_config['host'])
|
|
25
|
+
>>>
|
|
26
|
+
>>> # 读取所有 section
|
|
27
|
+
>>> node = IniConfigNode(file_path="config.ini")
|
|
28
|
+
>>> all_config = node.execute() # 返回 {'section1': {...}, 'section2': {...}}
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
file_path: Union[str, Path],
|
|
34
|
+
section: Optional[str] = None,
|
|
35
|
+
encoding: str = 'utf-8',
|
|
36
|
+
name: str = None,
|
|
37
|
+
config: Dict[str, Any] = None,
|
|
38
|
+
**kwargs
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Args:
|
|
42
|
+
file_path: INI 文件路径
|
|
43
|
+
section: 要读取的 section,None 表示读取所有 section
|
|
44
|
+
encoding: 文件编码,默认 utf-8
|
|
45
|
+
name: 节点名称
|
|
46
|
+
config: 额外配置
|
|
47
|
+
**kwargs: 额外参数
|
|
48
|
+
"""
|
|
49
|
+
super().__init__(name=name, config=config, **kwargs)
|
|
50
|
+
self.file_path = Path(file_path)
|
|
51
|
+
self.section = section
|
|
52
|
+
self.encoding = encoding
|
|
53
|
+
|
|
54
|
+
def _get_config_path(self) -> Optional[Path]:
|
|
55
|
+
return self.file_path
|
|
56
|
+
|
|
57
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
58
|
+
"""加载 INI 配置"""
|
|
59
|
+
if not self.file_path.exists():
|
|
60
|
+
raise FileNotFoundError(f"INI file not found: {self.file_path}")
|
|
61
|
+
|
|
62
|
+
parser = configparser.ConfigParser()
|
|
63
|
+
parser.read(self.file_path, encoding=self.encoding)
|
|
64
|
+
|
|
65
|
+
if self.section:
|
|
66
|
+
if self.section not in parser:
|
|
67
|
+
raise KeyError(f"Section '{self.section}' not found in {self.file_path}")
|
|
68
|
+
return dict(parser.items(self.section))
|
|
69
|
+
else:
|
|
70
|
+
return {s: dict(parser.items(s)) for s in parser.sections()}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
JSONConfigNode - JSON 配置文件节点
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Dict, Optional, Union
|
|
10
|
+
|
|
11
|
+
from QuantNodes.conf_node.base import ConfigNode
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class JSONConfigNode(ConfigNode):
|
|
15
|
+
"""
|
|
16
|
+
JSON 配置文件节点
|
|
17
|
+
|
|
18
|
+
解析 .json 格式的配置文件。
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
>>> node = JSONConfigNode(file_path="config.json")
|
|
22
|
+
>>> config = node.execute()
|
|
23
|
+
>>> node = JSONConfigNode(file_path="config.json", key="database")
|
|
24
|
+
>>> db_config = node.execute() # 只获取 database 下的配置
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
file_path: Union[str, Path],
|
|
30
|
+
key: Optional[str] = None,
|
|
31
|
+
encoding: str = 'utf-8',
|
|
32
|
+
name: str = None,
|
|
33
|
+
config: Dict[str, Any] = None,
|
|
34
|
+
**kwargs
|
|
35
|
+
):
|
|
36
|
+
"""
|
|
37
|
+
Args:
|
|
38
|
+
file_path: JSON 文件路径
|
|
39
|
+
key: 可选的顶层 key,只读取该 key 下的配置
|
|
40
|
+
encoding: 文件编码,默认 utf-8
|
|
41
|
+
name: 节点名称
|
|
42
|
+
config: 额外配置
|
|
43
|
+
**kwargs: 额外参数
|
|
44
|
+
"""
|
|
45
|
+
super().__init__(name=name, config=config, **kwargs)
|
|
46
|
+
self.file_path = Path(file_path)
|
|
47
|
+
self.key = key
|
|
48
|
+
self.encoding = encoding
|
|
49
|
+
|
|
50
|
+
def _get_config_path(self) -> Optional[Path]:
|
|
51
|
+
return self.file_path
|
|
52
|
+
|
|
53
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
54
|
+
"""加载 JSON 配置"""
|
|
55
|
+
if not self.file_path.exists():
|
|
56
|
+
raise FileNotFoundError(f"JSON file not found: {self.file_path}")
|
|
57
|
+
|
|
58
|
+
with open(self.file_path, 'r', encoding=self.encoding) as f:
|
|
59
|
+
data = json.load(f)
|
|
60
|
+
|
|
61
|
+
if not isinstance(data, dict):
|
|
62
|
+
raise ValueError(f"JSON file must contain a dictionary, got {type(data)}")
|
|
63
|
+
|
|
64
|
+
if self.key:
|
|
65
|
+
if self.key not in data:
|
|
66
|
+
raise KeyError(f"Key '{self.key}' not found in {self.file_path}")
|
|
67
|
+
return data[self.key]
|
|
68
|
+
|
|
69
|
+
return data
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""
|
|
3
|
+
YamlConfigNode - YAML 配置文件节点
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Dict, Optional, Union
|
|
9
|
+
|
|
10
|
+
from QuantNodes.conf_node.base import ConfigNode
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class YamlConfigNode(ConfigNode):
|
|
14
|
+
"""
|
|
15
|
+
YAML 配置文件节点
|
|
16
|
+
|
|
17
|
+
解析 .yaml/.yml 格式的配置文件。
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
>>> node = YamlConfigNode(file_path="config.yaml")
|
|
21
|
+
>>> config = node.execute()
|
|
22
|
+
>>> node = YamlConfigNode(file_path="config.yaml", key="database")
|
|
23
|
+
>>> db_config = node.execute() # 只获取 database 下的配置
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
file_path: Union[str, Path],
|
|
29
|
+
key: Optional[str] = None,
|
|
30
|
+
encoding: str = 'utf-8',
|
|
31
|
+
name: str = None,
|
|
32
|
+
config: Dict[str, Any] = None,
|
|
33
|
+
**kwargs
|
|
34
|
+
):
|
|
35
|
+
"""
|
|
36
|
+
Args:
|
|
37
|
+
file_path: YAML 文件路径
|
|
38
|
+
key: 可选的顶层 key,只读取该 key 下的配置
|
|
39
|
+
encoding: 文件编码,默认 utf-8
|
|
40
|
+
name: 节点名称
|
|
41
|
+
config: 额外配置
|
|
42
|
+
**kwargs: 额外参数
|
|
43
|
+
"""
|
|
44
|
+
super().__init__(name=name, config=config, **kwargs)
|
|
45
|
+
self.file_path = Path(file_path)
|
|
46
|
+
self.key = key
|
|
47
|
+
self.encoding = encoding
|
|
48
|
+
|
|
49
|
+
def _get_config_path(self) -> Optional[Path]:
|
|
50
|
+
return self.file_path
|
|
51
|
+
|
|
52
|
+
def _load_config(self) -> Dict[str, Any]:
|
|
53
|
+
"""加载 YAML 配置"""
|
|
54
|
+
if not self.file_path.exists():
|
|
55
|
+
raise FileNotFoundError(f"YAML file not found: {self.file_path}")
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
import yaml
|
|
59
|
+
except ImportError:
|
|
60
|
+
raise ImportError(
|
|
61
|
+
"PyYAML is required for YAML config. Install with: pip install pyyaml"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
with open(self.file_path, 'r', encoding=self.encoding) as f:
|
|
65
|
+
data = yaml.safe_load(f)
|
|
66
|
+
|
|
67
|
+
if data is None:
|
|
68
|
+
return {}
|
|
69
|
+
|
|
70
|
+
if not isinstance(data, dict):
|
|
71
|
+
raise ValueError(f"YAML file must contain a dictionary, got {type(data)}")
|
|
72
|
+
|
|
73
|
+
if self.key:
|
|
74
|
+
if self.key not in data:
|
|
75
|
+
raise KeyError(f"Key '{self.key}' not found in {self.file_path}")
|
|
76
|
+
return data[self.key]
|
|
77
|
+
|
|
78
|
+
return data
|
QuantNodes/constants.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""QuantNodes infrastructure defaults — single source of truth.
|
|
3
|
+
|
|
4
|
+
Import from here, NOT from cli._helpers or api.config.
|
|
5
|
+
This module has ZERO external dependencies (no numpy, no fastapi, no nanobot).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# ── Network ──────────────────────────────────────────────
|
|
9
|
+
DEFAULT_HOST = "127.0.0.1"
|
|
10
|
+
DEFAULT_API_PORT = 19380
|
|
11
|
+
DEFAULT_GATEWAY_PORT = 18090
|
|
12
|
+
DEFAULT_FRONTEND_PORT = 5173
|
|
13
|
+
DEFAULT_WEBSOCKET_PORT = 8765 # internal WS channel (not user-facing)
|
|
14
|
+
|
|
15
|
+
# ── LLM Provider ────────────────────────────────────────
|
|
16
|
+
DEFAULT_LLM_MODEL = "gpt-4"
|
|
17
|
+
DEFAULT_LLM_BASE_URL = "https://api.openai.com/v1"
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
|
|
3
|
+
from QuantNodes.core.base import (
|
|
4
|
+
BaseModel,
|
|
5
|
+
QuantNodesBase,
|
|
6
|
+
QuantNodesError,
|
|
7
|
+
ConfigError,
|
|
8
|
+
DatabaseError,
|
|
9
|
+
FactorError,
|
|
10
|
+
BacktestError,
|
|
11
|
+
ValidationError,
|
|
12
|
+
)
|
|
13
|
+
from QuantNodes.core.config import settings
|
|
14
|
+
from QuantNodes.core.node import (
|
|
15
|
+
BaseNode,
|
|
16
|
+
NodeState,
|
|
17
|
+
NodeStats,
|
|
18
|
+
NodeExecutionError,
|
|
19
|
+
SerializationError,
|
|
20
|
+
)
|
|
21
|
+
from QuantNodes.core.pipeline import (
|
|
22
|
+
Pipeline,
|
|
23
|
+
Parallel,
|
|
24
|
+
Join,
|
|
25
|
+
)
|
|
26
|
+
from QuantNodes.core.control import (
|
|
27
|
+
IfNode,
|
|
28
|
+
MapNode,
|
|
29
|
+
WhileNode,
|
|
30
|
+
)
|
|
31
|
+
from QuantNodes.core.lambda_node import LambdaNode
|
|
32
|
+
from QuantNodes.core.expression import (
|
|
33
|
+
Expression,
|
|
34
|
+
LambdaExpression,
|
|
35
|
+
)
|
|
36
|
+
from QuantNodes.core.cond_builder import Cond
|
|
37
|
+
from QuantNodes.core.serialization import (
|
|
38
|
+
serialize_node_json,
|
|
39
|
+
serialize_node_compact,
|
|
40
|
+
serialize_node_msgpack,
|
|
41
|
+
serialize_node_encrypted,
|
|
42
|
+
deserialize_node_json,
|
|
43
|
+
deserialize_node_compact,
|
|
44
|
+
deserialize_node_msgpack,
|
|
45
|
+
deserialize_node_encrypted,
|
|
46
|
+
deserialize_node_auto,
|
|
47
|
+
)
|
|
48
|
+
from QuantNodes.core.serializable import serializable, Serializable
|
|
49
|
+
from QuantNodes.core.events import (
|
|
50
|
+
Event,
|
|
51
|
+
EventBus,
|
|
52
|
+
Events,
|
|
53
|
+
get_event_bus,
|
|
54
|
+
reset_event_bus,
|
|
55
|
+
)
|
|
56
|
+
from QuantNodes.core.plugin import (
|
|
57
|
+
TOOLS_GROUP,
|
|
58
|
+
OPERATORS_GROUP,
|
|
59
|
+
discover_tools,
|
|
60
|
+
discover_operators,
|
|
61
|
+
discover_all,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
from QuantNodes.core.tools import (
|
|
65
|
+
gen_available_name,
|
|
66
|
+
partition_list,
|
|
67
|
+
partition_list_moving_sampling,
|
|
68
|
+
start_multi_process,
|
|
69
|
+
fill_na_by_lookback,
|
|
70
|
+
get_shelve_file_suffix,
|
|
71
|
+
compile_id_filter_str,
|
|
72
|
+
)
|
|
73
|
+
from QuantNodes.core.cache_utils import (
|
|
74
|
+
create_std_data,
|
|
75
|
+
create_empty_dataframe,
|
|
76
|
+
partition_ids_for_pid,
|
|
77
|
+
write_cache_file,
|
|
78
|
+
write_cache_files_for_all_pids,
|
|
79
|
+
)
|
|
80
|
+
from QuantNodes.core.pandas_utils import (
|
|
81
|
+
panel_to_dataframe,
|
|
82
|
+
dataframe_to_panel,
|
|
83
|
+
align_dataframes,
|
|
84
|
+
forward_fill_panel,
|
|
85
|
+
fillna_by_value,
|
|
86
|
+
winsorize_series,
|
|
87
|
+
standardize_zscore,
|
|
88
|
+
standardize_rank,
|
|
89
|
+
cross_section_zscore,
|
|
90
|
+
cross_section_rank,
|
|
91
|
+
shift_df,
|
|
92
|
+
resample_panel,
|
|
93
|
+
melt_panel,
|
|
94
|
+
pivot_long,
|
|
95
|
+
pivot_wide,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
__all__ = [
|
|
99
|
+
# base
|
|
100
|
+
'BaseModel',
|
|
101
|
+
'QuantNodesBase',
|
|
102
|
+
'QuantNodesError',
|
|
103
|
+
'ConfigError',
|
|
104
|
+
'DatabaseError',
|
|
105
|
+
'FactorError',
|
|
106
|
+
'BacktestError',
|
|
107
|
+
'ValidationError',
|
|
108
|
+
'settings',
|
|
109
|
+
|
|
110
|
+
# node
|
|
111
|
+
'BaseNode',
|
|
112
|
+
'NodeState',
|
|
113
|
+
'NodeStats',
|
|
114
|
+
'NodeExecutionError',
|
|
115
|
+
'SerializationError',
|
|
116
|
+
|
|
117
|
+
# pipeline
|
|
118
|
+
'Pipeline',
|
|
119
|
+
'Parallel',
|
|
120
|
+
'Join',
|
|
121
|
+
|
|
122
|
+
# control
|
|
123
|
+
'IfNode',
|
|
124
|
+
'MapNode',
|
|
125
|
+
'WhileNode',
|
|
126
|
+
|
|
127
|
+
# lambda
|
|
128
|
+
'LambdaNode',
|
|
129
|
+
|
|
130
|
+
# expression
|
|
131
|
+
'Expression',
|
|
132
|
+
'Cond',
|
|
133
|
+
'LambdaExpression',
|
|
134
|
+
|
|
135
|
+
# serialization
|
|
136
|
+
'serialize_node_json',
|
|
137
|
+
'serialize_node_compact',
|
|
138
|
+
'serialize_node_msgpack',
|
|
139
|
+
'serialize_node_encrypted',
|
|
140
|
+
'deserialize_node_json',
|
|
141
|
+
'deserialize_node_compact',
|
|
142
|
+
'deserialize_node_msgpack',
|
|
143
|
+
'deserialize_node_encrypted',
|
|
144
|
+
'deserialize_node_auto',
|
|
145
|
+
|
|
146
|
+
# serializable
|
|
147
|
+
'serializable',
|
|
148
|
+
'Serializable',
|
|
149
|
+
|
|
150
|
+
# events
|
|
151
|
+
'Event',
|
|
152
|
+
'EventBus',
|
|
153
|
+
'Events',
|
|
154
|
+
'get_event_bus',
|
|
155
|
+
'reset_event_bus',
|
|
156
|
+
|
|
157
|
+
# plugin
|
|
158
|
+
'TOOLS_GROUP',
|
|
159
|
+
'OPERATORS_GROUP',
|
|
160
|
+
'discover_tools',
|
|
161
|
+
'discover_operators',
|
|
162
|
+
'discover_all',
|
|
163
|
+
|
|
164
|
+
# tools
|
|
165
|
+
'gen_available_name',
|
|
166
|
+
'partition_list',
|
|
167
|
+
'partition_list_moving_sampling',
|
|
168
|
+
'start_multi_process',
|
|
169
|
+
'fill_na_by_lookback',
|
|
170
|
+
'get_shelve_file_suffix',
|
|
171
|
+
'compile_id_filter_str',
|
|
172
|
+
|
|
173
|
+
# cache utils
|
|
174
|
+
'create_std_data',
|
|
175
|
+
'create_empty_dataframe',
|
|
176
|
+
'partition_ids_for_pid',
|
|
177
|
+
'write_cache_file',
|
|
178
|
+
'write_cache_files_for_all_pids',
|
|
179
|
+
|
|
180
|
+
# pandas utils
|
|
181
|
+
'panel_to_dataframe',
|
|
182
|
+
'dataframe_to_panel',
|
|
183
|
+
'align_dataframes',
|
|
184
|
+
'forward_fill_panel',
|
|
185
|
+
'fillna_by_value',
|
|
186
|
+
'winsorize_series',
|
|
187
|
+
'standardize_zscore',
|
|
188
|
+
'standardize_rank',
|
|
189
|
+
'cross_section_zscore',
|
|
190
|
+
'cross_section_rank',
|
|
191
|
+
'shift_df',
|
|
192
|
+
'resample_panel',
|
|
193
|
+
'melt_panel',
|
|
194
|
+
'pivot_long',
|
|
195
|
+
'pivot_wide',
|
|
196
|
+
]
|