aria-code 0.52.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.
- aria_code/__init__.py +42 -0
- aria_code/_version.py +20 -0
- aria_code/adk_apps/__init__.py +1 -0
- aria_code/adk_apps/aria_code_review/__init__.py +1 -0
- aria_code/adk_apps/aria_code_review/agent.py +32 -0
- aria_code/adk_apps/aria_research/__init__.py +1 -0
- aria_code/adk_apps/aria_research/agent.py +31 -0
- aria_code/agents/__init__.py +34 -0
- aria_code/agents/base.py +318 -0
- aria_code/agents/code_review.py +200 -0
- aria_code/agents/deep/__init__.py +37 -0
- aria_code/agents/deep/calibration_loop.py +144 -0
- aria_code/agents/deep/critic.py +125 -0
- aria_code/agents/deep/deepen.py +193 -0
- aria_code/agents/deep/models.py +149 -0
- aria_code/agents/deep/pipeline.py +164 -0
- aria_code/agents/deep/quant_fusion.py +192 -0
- aria_code/agents/deep/themes.py +95 -0
- aria_code/agents/deep/tiers.py +106 -0
- aria_code/agents/engineering/__init__.py +14 -0
- aria_code/agents/engineering/coder.py +222 -0
- aria_code/agents/engineering/tester.py +145 -0
- aria_code/agents/financial/__init__.py +21 -0
- aria_code/agents/financial/cashflow_burn.py +119 -0
- aria_code/agents/financial/catalyst.py +279 -0
- aria_code/agents/financial/corporate_finance.py +175 -0
- aria_code/agents/financial/debate.py +224 -0
- aria_code/agents/financial/earnings.py +303 -0
- aria_code/agents/financial/fundamental.py +191 -0
- aria_code/agents/financial/macro.py +99 -0
- aria_code/agents/financial/news.py +207 -0
- aria_code/agents/financial/risk.py +165 -0
- aria_code/agents/financial/sector.py +279 -0
- aria_code/agents/financial/strategist.py +121 -0
- aria_code/agents/financial/stripe_revenue.py +127 -0
- aria_code/agents/financial/synthesis.py +274 -0
- aria_code/agents/financial/technical.py +258 -0
- aria_code/agents/orchestrator.py +44 -0
- aria_code/agents/portfolio_agent.py +363 -0
- aria_code/agents/realty/__init__.py +62 -0
- aria_code/agents/realty/asset_diagnosis.py +152 -0
- aria_code/agents/realty/business_match.py +166 -0
- aria_code/agents/realty/cashflow_verify.py +209 -0
- aria_code/agents/realty/contract_rules.py +210 -0
- aria_code/agents/realty/energy_anomaly.py +189 -0
- aria_code/agents/realty/exit_settlement.py +208 -0
- aria_code/agents/realty/fulfillment_risk.py +206 -0
- aria_code/agents/realty/ops_optimize.py +160 -0
- aria_code/agents/realty/revenue_share.py +215 -0
- aria_code/agents/registry.py +158 -0
- aria_code/agents/signal_scheme.py +111 -0
- aria_code/agents/sports/__init__.py +0 -0
- aria_code/agents/sports/football_agent.py +197 -0
- aria_code/agents/supervisor.py +113 -0
- aria_code/agents/team.py +492 -0
- aria_code/agents/warehouse/__init__.py +25 -0
- aria_code/agents/warehouse/contracts.py +26 -0
- aria_code/agents/warehouse/dashboard.py +155 -0
- aria_code/agents/warehouse/fulfillment_leadtime.py +95 -0
- aria_code/agents/warehouse/inbound_exceptions.py +25 -0
- aria_code/agents/warehouse/inventory_health.py +24 -0
- aria_code/agents/warehouse/local_run.py +71 -0
- aria_code/agents/warehouse/local_snapshot.py +132 -0
- aria_code/agents/warehouse/logistics_cost.py +84 -0
- aria_code/agents/warehouse/logistics_sync.py +21 -0
- aria_code/agents/warehouse/workflow.py +31 -0
- aria_code/aliyun_data_client.py +4 -0
- aria_code/apps/README.md +12 -0
- aria_code/apps/__init__.py +2 -0
- aria_code/apps/channels/README.md +15 -0
- aria_code/apps/channels/__init__.py +17 -0
- aria_code/apps/channels/intake.py +92 -0
- aria_code/apps/channels/registry.py +95 -0
- aria_code/apps/channels/tradingview.py +94 -0
- aria_code/apps/cli/README.md +13 -0
- aria_code/apps/cli/__init__.py +2 -0
- aria_code/apps/cli/_optional.py +120 -0
- aria_code/apps/cli/bootstrap.py +145 -0
- aria_code/apps/cli/broker_render.py +206 -0
- aria_code/apps/cli/codegen_paths.py +29 -0
- aria_code/apps/cli/commands/__init__.py +16 -0
- aria_code/apps/cli/commands/_business_render.py +78 -0
- aria_code/apps/cli/commands/_ui.py +71 -0
- aria_code/apps/cli/commands/analysis_cmds.py +369 -0
- aria_code/apps/cli/commands/ashare_prediction_cmds.py +327 -0
- aria_code/apps/cli/commands/auth_cmds.py +239 -0
- aria_code/apps/cli/commands/backtest_cmds.py +2543 -0
- aria_code/apps/cli/commands/broker_cmds.py +1234 -0
- aria_code/apps/cli/commands/business_workflow_cmds.py +319 -0
- aria_code/apps/cli/commands/canvas_cmds.py +77 -0
- aria_code/apps/cli/commands/catalog.py +87 -0
- aria_code/apps/cli/commands/core_cmds.py +2520 -0
- aria_code/apps/cli/commands/data_cmds.py +457 -0
- aria_code/apps/cli/commands/diagnostic_cmds.py +230 -0
- aria_code/apps/cli/commands/diagnostic_ops_cmds.py +813 -0
- aria_code/apps/cli/commands/file_cmds.py +312 -0
- aria_code/apps/cli/commands/finance_service_cmds.py +60 -0
- aria_code/apps/cli/commands/fx_commodity_cmds.py +123 -0
- aria_code/apps/cli/commands/market.py +434 -0
- aria_code/apps/cli/commands/market_cmds.py +1381 -0
- aria_code/apps/cli/commands/market_context.py +425 -0
- aria_code/apps/cli/commands/market_render.py +7 -0
- aria_code/apps/cli/commands/model_cmds.py +2153 -0
- aria_code/apps/cli/commands/ops_cmds.py +721 -0
- aria_code/apps/cli/commands/orchestrator_cmds.py +179 -0
- aria_code/apps/cli/commands/pdf_export_cmds.py +125 -0
- aria_code/apps/cli/commands/portfolio_cmds.py +1278 -0
- aria_code/apps/cli/commands/report.py +437 -0
- aria_code/apps/cli/commands/scaffold_templates.py +617 -0
- aria_code/apps/cli/commands/session_cmds.py +236 -0
- aria_code/apps/cli/commands/session_ux_cmds.py +359 -0
- aria_code/apps/cli/commands/team.py +669 -0
- aria_code/apps/cli/commands/team_render.py +8 -0
- aria_code/apps/cli/commands/ui_cmds.py +401 -0
- aria_code/apps/cli/commands/warehouse_cmds.py +79 -0
- aria_code/apps/cli/commands/workflow_cmds.py +480 -0
- aria_code/apps/cli/commands/workspace_cmds.py +1494 -0
- aria_code/apps/cli/config_paths.py +73 -0
- aria_code/apps/cli/config_store.py +78 -0
- aria_code/apps/cli/constants.py +88 -0
- aria_code/apps/cli/context.py +34 -0
- aria_code/apps/cli/deterministic.py +191 -0
- aria_code/apps/cli/direct.py +48 -0
- aria_code/apps/cli/finance_service_catalog.py +111 -0
- aria_code/apps/cli/football_reports.py +231 -0
- aria_code/apps/cli/github_app_auth.py +135 -0
- aria_code/apps/cli/google_login.py +196 -0
- aria_code/apps/cli/handlers/__init__.py +11 -0
- aria_code/apps/cli/handlers/broker_handlers.py +122 -0
- aria_code/apps/cli/handlers/chart_handlers.py +1309 -0
- aria_code/apps/cli/handlers/market_handlers.py +2513 -0
- aria_code/apps/cli/handlers/realty_handlers.py +114 -0
- aria_code/apps/cli/handlers/sports_handlers.py +22 -0
- aria_code/apps/cli/handlers/strategy_advice.py +82 -0
- aria_code/apps/cli/helpers.py +302 -0
- aria_code/apps/cli/hooks.py +180 -0
- aria_code/apps/cli/i18n.py +297 -0
- aria_code/apps/cli/intent.py +136 -0
- aria_code/apps/cli/intent_router.py +276 -0
- aria_code/apps/cli/intent_signals.py +344 -0
- aria_code/apps/cli/lifecycle_hooks.py +48 -0
- aria_code/apps/cli/local_tool_schemas.py +536 -0
- aria_code/apps/cli/main.py +29 -0
- aria_code/apps/cli/market_metadata.py +135 -0
- aria_code/apps/cli/market_universe.py +487 -0
- aria_code/apps/cli/message_processing.py +310 -0
- aria_code/apps/cli/model_catalog.py +620 -0
- aria_code/apps/cli/pdf_report.py +977 -0
- aria_code/apps/cli/plan_mode.py +139 -0
- aria_code/apps/cli/plotly_html.py +15 -0
- aria_code/apps/cli/prediction_feedback.py +202 -0
- aria_code/apps/cli/preflight.py +502 -0
- aria_code/apps/cli/project_aria.py +60 -0
- aria_code/apps/cli/prompt_assembly.py +59 -0
- aria_code/apps/cli/prompts/__init__.py +0 -0
- aria_code/apps/cli/prompts/coding.py +53 -0
- aria_code/apps/cli/prompts/select.py +142 -0
- aria_code/apps/cli/prompts/system_prompts.py +552 -0
- aria_code/apps/cli/prompts/ui.py +436 -0
- aria_code/apps/cli/provider_endpoints.py +237 -0
- aria_code/apps/cli/provider_keys.py +73 -0
- aria_code/apps/cli/providers/__init__.py +1 -0
- aria_code/apps/cli/providers/base.py +521 -0
- aria_code/apps/cli/providers/chat_routing.py +128 -0
- aria_code/apps/cli/providers/collaboration.py +98 -0
- aria_code/apps/cli/providers/llm/__init__.py +1 -0
- aria_code/apps/cli/providers/llm/offline_responses.py +68 -0
- aria_code/apps/cli/providers/llm/ollama_stream.py +1594 -0
- aria_code/apps/cli/providers/llm/response_cache.py +60 -0
- aria_code/apps/cli/providers/llm/sse_stream.py +257 -0
- aria_code/apps/cli/providers/runtime_bridge.py +353 -0
- aria_code/apps/cli/providers/vertexai_stream.py +316 -0
- aria_code/apps/cli/runtime_consumer.py +657 -0
- aria_code/apps/cli/sandbox.py +32 -0
- aria_code/apps/cli/session_export.py +120 -0
- aria_code/apps/cli/session_jsonl.py +208 -0
- aria_code/apps/cli/session_store.py +112 -0
- aria_code/apps/cli/skills_catalog.py +273 -0
- aria_code/apps/cli/todo_tracker.py +190 -0
- aria_code/apps/cli/tool_executor.py +823 -0
- aria_code/apps/cli/tool_registry.py +34 -0
- aria_code/apps/cli/tool_scope.py +106 -0
- aria_code/apps/cli/tools/__init__.py +40 -0
- aria_code/apps/cli/tools/context.py +46 -0
- aria_code/apps/cli/tools/file_tools.py +180 -0
- aria_code/apps/cli/tools/market_tools.py +620 -0
- aria_code/apps/cli/tools/notebook_tools.py +111 -0
- aria_code/apps/cli/tools/system_tools.py +726 -0
- aria_code/apps/cli/tools/write_tools.py +845 -0
- aria_code/apps/cli/tradingview_bridge.py +529 -0
- aria_code/apps/cli/turn_planning.py +137 -0
- aria_code/apps/cli/update_check.py +153 -0
- aria_code/apps/cli/utils/__init__.py +0 -0
- aria_code/apps/cli/utils/market_detect.py +1597 -0
- aria_code/apps/daemon/README.md +14 -0
- aria_code/apps/vscode/README.md +115 -0
- aria_code/apps/vscode/package.json +70 -0
- aria_code/aria_cli.py +6743 -0
- aria_code/aria_daemon.py +1398 -0
- aria_code/aria_feishu_bot.py +1423 -0
- aria_code/aria_mcp_server.py +7 -0
- aria_code/aria_relay_client.py +4 -0
- aria_code/aria_relay_server.py +490 -0
- aria_code/aria_telegram_bot.py +202 -0
- aria_code/ariarc.py +385 -0
- aria_code/artifacts.py +581 -0
- aria_code/backtest_engine.py +4 -0
- aria_code/backtest_report.py +4 -0
- aria_code/brokers/__init__.py +78 -0
- aria_code/brokers/automation.py +193 -0
- aria_code/brokers/base.py +231 -0
- aria_code/brokers/capabilities.py +264 -0
- aria_code/brokers/cn/__init__.py +10 -0
- aria_code/brokers/cn/easytrader_broker.py +193 -0
- aria_code/brokers/cn/futu_broker.py +194 -0
- aria_code/brokers/cn/longbridge_broker.py +190 -0
- aria_code/brokers/cn/tiger_broker.py +196 -0
- aria_code/brokers/cn/xtquant_broker.py +225 -0
- aria_code/brokers/config.py +414 -0
- aria_code/brokers/intl/__init__.py +5 -0
- aria_code/brokers/intl/alpaca_broker.py +183 -0
- aria_code/brokers/intl/ibkr_broker.py +215 -0
- aria_code/brokers/intl/trading212_broker.py +183 -0
- aria_code/brokers/intl/webull_broker.py +156 -0
- aria_code/brokers/paper_broker.py +266 -0
- aria_code/brokers/planning.py +296 -0
- aria_code/brokers/registry.py +213 -0
- aria_code/brokers/trading.py +267 -0
- aria_code/canva_client.py +4 -0
- aria_code/change_store.py +127 -0
- aria_code/clients/__init__.py +0 -0
- aria_code/clients/aliyun_data_client.py +660 -0
- aria_code/clients/aria_relay_client.py +182 -0
- aria_code/clients/canva_client.py +284 -0
- aria_code/clients/figma_client.py +100 -0
- aria_code/clients/football_data_client.py +1671 -0
- aria_code/clients/kling_video_client.py +182 -0
- aria_code/clients/market_data_client.py +1976 -0
- aria_code/clients/openai_image_client.py +242 -0
- aria_code/clients/runway_video_client.py +157 -0
- aria_code/clients/warehouse_erp_client.py +105 -0
- aria_code/cloud_memory.py +181 -0
- aria_code/command_safety.py +19 -0
- aria_code/computer_use_tools.py +4 -0
- aria_code/dashboard_generator.py +579 -0
- aria_code/data_analysis_tools.py +4 -0
- aria_code/data_cleaner.py +483 -0
- aria_code/data_service.py +513 -0
- aria_code/datasources/__init__.py +23 -0
- aria_code/datasources/base.py +166 -0
- aria_code/datasources/router.py +253 -0
- aria_code/datasources/sources/__init__.py +15 -0
- aria_code/datasources/sources/akshare_source.py +269 -0
- aria_code/datasources/sources/alpha_vantage_source.py +203 -0
- aria_code/datasources/sources/edgar_source.py +219 -0
- aria_code/datasources/sources/finnhub_source.py +198 -0
- aria_code/datasources/sources/fred_source.py +223 -0
- aria_code/datasources/sources/tushare_source.py +143 -0
- aria_code/datasources/sources/web_scraper_source.py +278 -0
- aria_code/datasources/sources/world_bank_source.py +206 -0
- aria_code/datasources/sources/yfinance_source.py +152 -0
- aria_code/demo_player.py +207 -0
- aria_code/doctor.py +813 -0
- aria_code/domain/__init__.py +0 -0
- aria_code/domain/backtest_engine.py +354 -0
- aria_code/domain/backtest_report.py +472 -0
- aria_code/domain/finance_formulas.py +389 -0
- aria_code/domain/portfolio_ledger.py +307 -0
- aria_code/domain/strategy_vault.py +421 -0
- aria_code/evals/__init__.py +37 -0
- aria_code/evals/harness.py +598 -0
- aria_code/evals/runner.py +238 -0
- aria_code/external_agent_runner.py +115 -0
- aria_code/figma_client.py +4 -0
- aria_code/file_analysis_tools.py +4 -0
- aria_code/finance_formulas.py +4 -0
- aria_code/football_data_client.py +4 -0
- aria_code/image_gen_tools.py +4 -0
- aria_code/intent_classifier.py +386 -0
- aria_code/kling_video_client.py +4 -0
- aria_code/licensing.py +151 -0
- aria_code/local_finance_tools.py +4 -0
- aria_code/local_image_provider.py +4 -0
- aria_code/local_llm_provider.py +4 -0
- aria_code/macro_tools.py +4 -0
- aria_code/markdown_pdf.py +289 -0
- aria_code/market_data_client.py +4 -0
- aria_code/mcp_client.py +639 -0
- aria_code/memory_manager.py +246 -0
- aria_code/model_capability.py +486 -0
- aria_code/notification_tools.py +4 -0
- aria_code/openai_image_client.py +4 -0
- aria_code/packages/__init__.py +23 -0
- aria_code/packages/adk_bridge/__init__.py +11 -0
- aria_code/packages/adk_bridge/code_review_tools.py +49 -0
- aria_code/packages/adk_bridge/market_tools.py +125 -0
- aria_code/packages/aria_agents/__init__.py +5 -0
- aria_code/packages/aria_agents/manifest.py +78 -0
- aria_code/packages/aria_core/__init__.py +34 -0
- aria_code/packages/aria_core/architecture.py +269 -0
- aria_code/packages/aria_core/export.py +147 -0
- aria_code/packages/aria_core/manifest.py +65 -0
- aria_code/packages/aria_core/paths.py +57 -0
- aria_code/packages/aria_core/secure_file.py +68 -0
- aria_code/packages/aria_infra/__init__.py +15 -0
- aria_code/packages/aria_infra/arthera.py +52 -0
- aria_code/packages/aria_infra/doctor.py +246 -0
- aria_code/packages/aria_infra/product.py +40 -0
- aria_code/packages/aria_mcp/__init__.py +25 -0
- aria_code/packages/aria_mcp/bridge.py +201 -0
- aria_code/packages/aria_mcp/circuit.py +82 -0
- aria_code/packages/aria_mcp/config.py +111 -0
- aria_code/packages/aria_mcp/installer.py +95 -0
- aria_code/packages/aria_mcp/server.py +1550 -0
- aria_code/packages/aria_mcp/tools.py +81 -0
- aria_code/packages/aria_sdk/__init__.py +19 -0
- aria_code/packages/aria_sdk/client.py +396 -0
- aria_code/packages/aria_sdk/providers.py +70 -0
- aria_code/packages/aria_sdk/streaming.py +79 -0
- aria_code/packages/aria_sdk/types.py +86 -0
- aria_code/packages/aria_services/__init__.py +92 -0
- aria_code/packages/aria_services/cache.py +60 -0
- aria_code/packages/aria_services/context.py +356 -0
- aria_code/packages/aria_services/context_checkpoints.py +157 -0
- aria_code/packages/aria_services/data.py +11 -0
- aria_code/packages/aria_services/provider_health.py +268 -0
- aria_code/packages/aria_services/references.py +247 -0
- aria_code/packages/aria_services/registry.py +249 -0
- aria_code/packages/aria_services/research_protocol.py +57 -0
- aria_code/packages/aria_services/research_quality.py +186 -0
- aria_code/packages/aria_services/settings.py +157 -0
- aria_code/packages/aria_services/usage.py +151 -0
- aria_code/packages/aria_skills/__init__.py +46 -0
- aria_code/packages/aria_skills/catalog.py +149 -0
- aria_code/packages/aria_skills/loader.py +455 -0
- aria_code/packages/aria_skills/registry.py +84 -0
- aria_code/packages/aria_tools/__init__.py +5 -0
- aria_code/packages/aria_tools/financial/__init__.py +8 -0
- aria_code/packages/aria_tools/financial/_paths.py +130 -0
- aria_code/packages/aria_tools/financial/compliance.py +31 -0
- aria_code/packages/aria_tools/financial/factors.py +33 -0
- aria_code/packages/aria_tools/financial/risk_tools.py +33 -0
- aria_code/packages/aria_tools/financial/strategy.py +31 -0
- aria_code/packages/aria_tools/registry.py +128 -0
- aria_code/packages/quant_engine/__init__.py +34 -0
- aria_code/packages/quant_engine/_namespace.py +62 -0
- aria_code/packages/quant_engine/backtest/__init__.py +14 -0
- aria_code/packages/quant_engine/backtest/core.py +53 -0
- aria_code/packages/quant_engine/backtest/engine.py +96 -0
- aria_code/packages/quant_engine/portfolio/__init__.py +13 -0
- aria_code/packages/quant_engine/portfolio/optimizer.py +85 -0
- aria_code/packages/quant_engine/sports/__init__.py +80 -0
- aria_code/packages/quant_engine/sports/calibrator.py +354 -0
- aria_code/packages/quant_engine/sports/dixon_coles.py +234 -0
- aria_code/packages/quant_engine/sports/elo.py +300 -0
- aria_code/packages/quant_engine/sports/form.py +188 -0
- aria_code/packages/quant_engine/sports/h2h.py +195 -0
- aria_code/packages/quant_engine/sports/ml_model.py +377 -0
- aria_code/packages/quant_engine/sports/predictor.py +312 -0
- aria_code/packages/quant_engine/sports/tracker.py +665 -0
- aria_code/packages/quant_engine/stochastic/__init__.py +35 -0
- aria_code/packages/quant_engine/stochastic/gbm_enhanced.py +195 -0
- aria_code/packages/quant_engine/stochastic/ito_calculus.py +477 -0
- aria_code/packages/quant_engine/stochastic/kelly_criterion.py +181 -0
- aria_code/packages/quant_engine/stochastic/monte_carlo_advanced.py +95 -0
- aria_code/packages/quant_engine/stochastic/options_pricing.py +576 -0
- aria_code/packages/quant_engine/stochastic/stochastic_processes.py +90 -0
- aria_code/packs/__init__.py +85 -0
- aria_code/packs/base.py +168 -0
- aria_code/packs/finance/__init__.py +250 -0
- aria_code/packs/logistics/__init__.py +169 -0
- aria_code/packs/payments/__init__.py +139 -0
- aria_code/packs/realty/__init__.py +190 -0
- aria_code/packs/registry.py +202 -0
- aria_code/packs/rules.py +90 -0
- aria_code/plan_utils.py +194 -0
- aria_code/plugin_loader.py +328 -0
- aria_code/portfolio_ledger.py +4 -0
- aria_code/preview_server.py +449 -0
- aria_code/privacy/__init__.py +5 -0
- aria_code/privacy/feedback.py +123 -0
- aria_code/project_review.py +278 -0
- aria_code/project_review_api.py +235 -0
- aria_code/project_review_server.py +18 -0
- aria_code/project_tools.py +4 -0
- aria_code/providers/__init__.py +30 -0
- aria_code/providers/llm/__init__.py +19 -0
- aria_code/providers/llm/anthropic.py +184 -0
- aria_code/providers/llm/autoconfig.py +213 -0
- aria_code/providers/llm/base.py +139 -0
- aria_code/providers/llm/custom.py +158 -0
- aria_code/providers/llm/ollama.py +129 -0
- aria_code/providers/llm/openai_compat.py +313 -0
- aria_code/providers/llm/registry.py +444 -0
- aria_code/providers/local_image_provider.py +202 -0
- aria_code/providers/local_llm_provider.py +589 -0
- aria_code/realty_data_tools.py +4 -0
- aria_code/report_exporters.py +150 -0
- aria_code/report_generator.py +1764 -0
- aria_code/runtime/__init__.py +169 -0
- aria_code/runtime/acceptance.py +481 -0
- aria_code/runtime/agent_loop.py +1520 -0
- aria_code/runtime/approval.py +57 -0
- aria_code/runtime/budget.py +232 -0
- aria_code/runtime/checkpoints.py +432 -0
- aria_code/runtime/crash_report.py +174 -0
- aria_code/runtime/events.py +113 -0
- aria_code/runtime/gateway.py +150 -0
- aria_code/runtime/lsp.py +484 -0
- aria_code/runtime/orchestrator.py +55 -0
- aria_code/runtime/repo_map.py +700 -0
- aria_code/runtime/run_state.py +127 -0
- aria_code/runtime/run_store.py +450 -0
- aria_code/runtime/self_healing.py +422 -0
- aria_code/runtime/subagent.py +547 -0
- aria_code/runtime/task_ledger.py +86 -0
- aria_code/runtime/task_orchestrator.py +90 -0
- aria_code/runtime/tool_executor.py +217 -0
- aria_code/runtime/tool_policy.py +107 -0
- aria_code/runtime/worktrees.py +215 -0
- aria_code/runway_video_client.py +4 -0
- aria_code/safety/__init__.py +23 -0
- aria_code/safety/permissions.py +306 -0
- aria_code/safety/service.py +102 -0
- aria_code/setup_wizard.py +673 -0
- aria_code/spreadsheet_tools.py +4 -0
- aria_code/strategy_vault.py +4 -0
- aria_code/tools/__init__.py +0 -0
- aria_code/tools/artifact_tools.py +252 -0
- aria_code/tools/broker_tools.py +92 -0
- aria_code/tools/build_quant_engine.py +97 -0
- aria_code/tools/code_audit_tools.py +192 -0
- aria_code/tools/computer_use_tools.py +504 -0
- aria_code/tools/data_analysis_tools.py +809 -0
- aria_code/tools/enterprise_finance_tools.py +156 -0
- aria_code/tools/extended_tools.py +240 -0
- aria_code/tools/file_analysis_tools.py +885 -0
- aria_code/tools/image_gen_tools.py +114 -0
- aria_code/tools/local_finance_tools.py +3417 -0
- aria_code/tools/logistics_tools.py +135 -0
- aria_code/tools/macro_tools.py +369 -0
- aria_code/tools/notification_tools.py +249 -0
- aria_code/tools/project_tools.py +525 -0
- aria_code/tools/realty_data_tools.py +659 -0
- aria_code/tools/spreadsheet_tools.py +388 -0
- aria_code/tools/stripe_tools.py +115 -0
- aria_code/ui/__init__.py +105 -0
- aria_code/ui/banner.py +508 -0
- aria_code/ui/completer.py +501 -0
- aria_code/ui/console.py +281 -0
- aria_code/ui/image_render.py +243 -0
- aria_code/ui/input_box.py +488 -0
- aria_code/ui/picker.py +201 -0
- aria_code/ui/render/__init__.py +11 -0
- aria_code/ui/render/finance.py +1705 -0
- aria_code/ui/render/market.py +225 -0
- aria_code/ui/render/output.py +775 -0
- aria_code/ui/render/responsive.py +75 -0
- aria_code/ui/render/team.py +354 -0
- aria_code/ui/robot.py +235 -0
- aria_code/ui/startup_dashboard.py +109 -0
- aria_code/utils/vscode_uri.py +37 -0
- aria_code/video_analysis.py +147 -0
- aria_code/video_editor.py +271 -0
- aria_code/workspace/__init__.py +6 -0
- aria_code/workspace/files.py +193 -0
- aria_code/workspace/verify.py +113 -0
- aria_code/workspace_changes.py +199 -0
- aria_code/workspace_context.py +233 -0
- aria_code/workspace_service.py +196 -0
- aria_code/workspace_tools.py +150 -0
- aria_code-0.52.0.dist-info/METADATA +237 -0
- aria_code-0.52.0.dist-info/RECORD +478 -0
- aria_code-0.52.0.dist-info/WHEEL +5 -0
- aria_code-0.52.0.dist-info/entry_points.txt +3 -0
- aria_code-0.52.0.dist-info/licenses/LICENSE +201 -0
- aria_code-0.52.0.dist-info/licenses/NOTICE +49 -0
- aria_code-0.52.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""
|
|
2
|
+
brokers/cn/tiger_broker.py — 老虎证券 OpenAPI 适配器
|
|
3
|
+
======================================================
|
|
4
|
+
支持市场:美股、港股、A股
|
|
5
|
+
|
|
6
|
+
安装:pip install tigeropen
|
|
7
|
+
文档:https://quant.tigerfintech.com/
|
|
8
|
+
|
|
9
|
+
配置示例::
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
"id": "tiger_us",
|
|
13
|
+
"type": "tiger",
|
|
14
|
+
"label": "老虎美股",
|
|
15
|
+
"tiger_id": "YOUR_TIGER_ID",
|
|
16
|
+
"private_key_path": "~/.arthera/tiger_rsa.pem",
|
|
17
|
+
"account": "YOUR_ACCOUNT_ID",
|
|
18
|
+
"sandbox": false
|
|
19
|
+
}
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from typing import Any, Dict, List
|
|
25
|
+
|
|
26
|
+
from ..base import BrokerBase, AccountInfo, Position, Order, OrderResult
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TigerBroker(BrokerBase):
|
|
30
|
+
broker_type = "tiger"
|
|
31
|
+
broker_name = "老虎证券"
|
|
32
|
+
market = "US"
|
|
33
|
+
|
|
34
|
+
def __init__(self, broker_id: str, config: Dict[str, Any]):
|
|
35
|
+
super().__init__(broker_id, config)
|
|
36
|
+
self._tiger_id = config.get("tiger_id", "")
|
|
37
|
+
self._private_key_path = config.get("private_key_path", "")
|
|
38
|
+
self._account = config.get("account", "")
|
|
39
|
+
self._sandbox = bool(config.get("sandbox", False))
|
|
40
|
+
self._client_config = None
|
|
41
|
+
self._trade_client = None
|
|
42
|
+
self._quote_client = None
|
|
43
|
+
|
|
44
|
+
def connect(self) -> bool:
|
|
45
|
+
try:
|
|
46
|
+
from tigeropen.tiger_open_config import TigerOpenClientConfig
|
|
47
|
+
from tigeropen.common.consts import TigerApiConstants
|
|
48
|
+
from tigeropen.trade.trade_client import TradeClient
|
|
49
|
+
from tigeropen.quote.quote_client import QuoteClient
|
|
50
|
+
except ImportError:
|
|
51
|
+
raise ImportError("tigeropen 未安装。请运行: pip install tigeropen")
|
|
52
|
+
|
|
53
|
+
import os
|
|
54
|
+
pk_path = os.path.expanduser(self._private_key_path)
|
|
55
|
+
if not os.path.exists(pk_path):
|
|
56
|
+
raise FileNotFoundError(f"老虎证券私钥文件不存在: {pk_path}")
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
cfg = TigerOpenClientConfig(sandbox_debug=self._sandbox)
|
|
60
|
+
cfg.tiger_id = self._tiger_id
|
|
61
|
+
cfg.private_key = open(pk_path).read()
|
|
62
|
+
cfg.account = self._account
|
|
63
|
+
self._client_config = cfg
|
|
64
|
+
self._trade_client = TradeClient(cfg)
|
|
65
|
+
self._quote_client = QuoteClient(cfg)
|
|
66
|
+
# 测试连接
|
|
67
|
+
self._trade_client.get_managed_accounts()
|
|
68
|
+
self._connected = True
|
|
69
|
+
return True
|
|
70
|
+
except Exception as e:
|
|
71
|
+
raise RuntimeError(f"老虎证券连接失败: {e}") from e
|
|
72
|
+
|
|
73
|
+
def account_info(self) -> AccountInfo:
|
|
74
|
+
self._require_connected()
|
|
75
|
+
try:
|
|
76
|
+
assets = self._trade_client.get_assets(account=self._account)
|
|
77
|
+
a = assets[0] if assets else None
|
|
78
|
+
if not a:
|
|
79
|
+
raise RuntimeError("老虎证券返回空账户数据")
|
|
80
|
+
return AccountInfo(
|
|
81
|
+
broker_id=self.broker_id,
|
|
82
|
+
broker_type=self.broker_type,
|
|
83
|
+
label=self.label,
|
|
84
|
+
account_id=self._account,
|
|
85
|
+
currency=str(getattr(a, "currency", "USD")),
|
|
86
|
+
total_assets=float(getattr(a, "net_liquidation", 0)),
|
|
87
|
+
cash=float(getattr(a, "cash_balance", 0)),
|
|
88
|
+
market_value=float(getattr(a, "gross_position_value", 0)),
|
|
89
|
+
pnl_today=float(getattr(a, "realized_pnl", 0)),
|
|
90
|
+
pnl_total=float(getattr(a, "unrealized_pnl", 0)),
|
|
91
|
+
)
|
|
92
|
+
except Exception as e:
|
|
93
|
+
raise RuntimeError(f"老虎证券账户查询失败: {e}") from e
|
|
94
|
+
|
|
95
|
+
def positions(self) -> List[Position]:
|
|
96
|
+
self._require_connected()
|
|
97
|
+
try:
|
|
98
|
+
raw = self._trade_client.get_positions(account=self._account)
|
|
99
|
+
except Exception as e:
|
|
100
|
+
raise RuntimeError(f"老虎证券持仓查询失败: {e}") from e
|
|
101
|
+
|
|
102
|
+
result = []
|
|
103
|
+
for p in (raw or []):
|
|
104
|
+
sym = str(getattr(p, "contract", {}).symbol if hasattr(p, "contract") else getattr(p, "symbol", ""))
|
|
105
|
+
qty = float(getattr(p, "quantity", 0))
|
|
106
|
+
avail = float(getattr(p, "available_qty", qty))
|
|
107
|
+
cost = float(getattr(p, "average_cost", 0))
|
|
108
|
+
price = float(getattr(p, "market_price", 0))
|
|
109
|
+
mv = float(getattr(p, "position_value", 0))
|
|
110
|
+
pnl = float(getattr(p, "unrealized_pnl", 0))
|
|
111
|
+
pnl_pct = float(getattr(p, "unrealized_pnl_ratio", 0)) * 100
|
|
112
|
+
currency = str(getattr(p, "currency", "USD"))
|
|
113
|
+
result.append(Position(
|
|
114
|
+
symbol=sym, name=sym,
|
|
115
|
+
quantity=qty, available_qty=avail,
|
|
116
|
+
cost_price=cost, current_price=price,
|
|
117
|
+
market_value=mv, pnl=pnl, pnl_pct=pnl_pct,
|
|
118
|
+
currency=currency, market="us",
|
|
119
|
+
))
|
|
120
|
+
return result
|
|
121
|
+
|
|
122
|
+
def orders(self, status: str = "all", limit: int = 50) -> List[Order]:
|
|
123
|
+
self._require_connected()
|
|
124
|
+
try:
|
|
125
|
+
from tigeropen.common.consts import OrderStatus
|
|
126
|
+
raw = self._trade_client.get_orders(account=self._account, limit=limit)
|
|
127
|
+
except Exception as e:
|
|
128
|
+
raise RuntimeError(f"老虎证券订单查询失败: {e}") from e
|
|
129
|
+
|
|
130
|
+
result = []
|
|
131
|
+
for o in (raw or []):
|
|
132
|
+
side = "buy" if str(getattr(o, "action", "")).upper() == "BUY" else "sell"
|
|
133
|
+
mapped = _tiger_order_status(str(getattr(o, "status", "")))
|
|
134
|
+
if status != "all" and mapped != status:
|
|
135
|
+
continue
|
|
136
|
+
contract = getattr(o, "contract", None)
|
|
137
|
+
sym = str(contract.symbol if contract else getattr(o, "symbol", ""))
|
|
138
|
+
result.append(Order(
|
|
139
|
+
order_id=str(getattr(o, "id", getattr(o, "order_id", ""))),
|
|
140
|
+
symbol=sym, name=sym,
|
|
141
|
+
side=side,
|
|
142
|
+
order_type=str(getattr(o, "order_type", "limit")).lower(),
|
|
143
|
+
quantity=float(getattr(o, "quantity", 0)),
|
|
144
|
+
filled_qty=float(getattr(o, "filled", 0)),
|
|
145
|
+
price=float(getattr(o, "limit_price", 0)),
|
|
146
|
+
avg_price=float(getattr(o, "avg_fill_price", 0)),
|
|
147
|
+
status=mapped,
|
|
148
|
+
created_at=str(getattr(o, "order_time", "")),
|
|
149
|
+
currency=str(getattr(o, "currency", "USD")),
|
|
150
|
+
))
|
|
151
|
+
return result
|
|
152
|
+
|
|
153
|
+
def place_order(self, symbol: str, side: str, quantity: float,
|
|
154
|
+
order_type: str = "limit", price: float = 0.0, **kwargs) -> OrderResult:
|
|
155
|
+
self._require_connected()
|
|
156
|
+
try:
|
|
157
|
+
from tigeropen.trade.domain.order import market_order, limit_order
|
|
158
|
+
from tigeropen.common.consts import Currency, Market
|
|
159
|
+
|
|
160
|
+
if order_type == "market":
|
|
161
|
+
order = market_order(
|
|
162
|
+
account=self._account, symbol=symbol,
|
|
163
|
+
action=side.upper(), quantity=int(quantity),
|
|
164
|
+
)
|
|
165
|
+
else:
|
|
166
|
+
order = limit_order(
|
|
167
|
+
account=self._account, symbol=symbol,
|
|
168
|
+
action=side.upper(), quantity=int(quantity), limit_price=price,
|
|
169
|
+
)
|
|
170
|
+
ret = self._trade_client.place_order(order)
|
|
171
|
+
return OrderResult(success=True, order_id=str(ret), broker_id=self.broker_id)
|
|
172
|
+
except Exception as e:
|
|
173
|
+
return OrderResult(success=False, message=str(e), broker_id=self.broker_id)
|
|
174
|
+
|
|
175
|
+
def cancel_order(self, order_id: str) -> bool:
|
|
176
|
+
self._require_connected()
|
|
177
|
+
try:
|
|
178
|
+
self._trade_client.cancel_order(account=self._account, id=int(order_id))
|
|
179
|
+
return True
|
|
180
|
+
except Exception:
|
|
181
|
+
return False
|
|
182
|
+
|
|
183
|
+
def _require_connected(self):
|
|
184
|
+
if not self._connected:
|
|
185
|
+
raise RuntimeError("老虎证券未连接,请先调用 connect()")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _tiger_order_status(raw: str) -> str:
|
|
189
|
+
raw = raw.upper()
|
|
190
|
+
if raw in ("FILLED",):
|
|
191
|
+
return "filled"
|
|
192
|
+
if raw in ("PARTIALLY_FILLED",):
|
|
193
|
+
return "partial"
|
|
194
|
+
if raw in ("CANCELLED", "EXPIRED", "REJECTED"):
|
|
195
|
+
return "cancelled"
|
|
196
|
+
return "open"
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"""
|
|
2
|
+
brokers/cn/xtquant_broker.py — 迅投 XTQuant 适配器
|
|
3
|
+
====================================================
|
|
4
|
+
支持券商:中信证券、华鑫证券、浙商证券(通过迅投QMT平台)
|
|
5
|
+
|
|
6
|
+
安装:pip install xtquant
|
|
7
|
+
文档:https://dict.thinktrader.net/nativeApi/
|
|
8
|
+
|
|
9
|
+
配置示例::
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
"id": "xt_main",
|
|
13
|
+
"type": "xtquant",
|
|
14
|
+
"label": "中信主账户",
|
|
15
|
+
"account_id": "1234567890",
|
|
16
|
+
"path": "C:\\国金QMT交易端模拟\\userdata_mini"
|
|
17
|
+
}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from typing import Any, Dict, List, Optional
|
|
23
|
+
|
|
24
|
+
from ..base import BrokerBase, AccountInfo, Position, Order, OrderResult
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _lot_size_violation(side: str, quantity: float) -> Optional[str]:
|
|
28
|
+
"""A股买入必须是100股整数倍;卖出允许零股清仓(不受此约束)。"""
|
|
29
|
+
if side == "buy" and quantity % 100 != 0:
|
|
30
|
+
return f"买入数量 {quantity:g} 不是100股整数倍"
|
|
31
|
+
if quantity <= 0:
|
|
32
|
+
return f"数量必须为正数,收到 {quantity:g}"
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _t_plus_1_violation(side: str, quantity: float, position: Optional[Position]) -> Optional[str]:
|
|
37
|
+
"""A股 T+1:当日买入的份额要到下一交易日才能卖出。
|
|
38
|
+
|
|
39
|
+
可卖数量直接读 XTQuant 返回的 can_use_volume(positions() 里映射成
|
|
40
|
+
available_qty)——这是柜台自己算好的、已经扣掉当日买入未解冻部分的
|
|
41
|
+
数字,不用本地另外维护一套持仓时间戳去猜哪些是"今天买的"。
|
|
42
|
+
"""
|
|
43
|
+
if side != "sell":
|
|
44
|
+
return None
|
|
45
|
+
available = position.available_qty if position else 0.0
|
|
46
|
+
if quantity > available:
|
|
47
|
+
return f"卖出 {quantity:g} 股超过可用持仓 {available:g} 股(当日买入部分尚未解冻,或持仓不足)"
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class XTQuantBroker(BrokerBase):
|
|
52
|
+
broker_type = "xtquant"
|
|
53
|
+
broker_name = "迅投 XTQuant"
|
|
54
|
+
market = "CN"
|
|
55
|
+
|
|
56
|
+
def __init__(self, broker_id: str, config: Dict[str, Any]):
|
|
57
|
+
super().__init__(broker_id, config)
|
|
58
|
+
self._account_id = config.get("account_id", "")
|
|
59
|
+
self._path = config.get("path", "")
|
|
60
|
+
self._xt_trader = None
|
|
61
|
+
|
|
62
|
+
def connect(self) -> bool:
|
|
63
|
+
try:
|
|
64
|
+
import os
|
|
65
|
+
import sys
|
|
66
|
+
with open(os.devnull, "w") as _null:
|
|
67
|
+
_old, sys.stdout = sys.stdout, _null
|
|
68
|
+
try:
|
|
69
|
+
from xtquant.xttrader import XtQuantTrader
|
|
70
|
+
from xtquant import xtdata
|
|
71
|
+
finally:
|
|
72
|
+
sys.stdout = _old
|
|
73
|
+
path = self._path or "."
|
|
74
|
+
trader = XtQuantTrader(path, int(self.config.get("session_id", 1)))
|
|
75
|
+
conn = trader.connect()
|
|
76
|
+
if conn != 0:
|
|
77
|
+
raise RuntimeError(f"XTQuant 连接失败: code={conn}")
|
|
78
|
+
trader.subscribe_position(self._account_id)
|
|
79
|
+
trader.subscribe_order(self._account_id)
|
|
80
|
+
trader.subscribe_trade(self._account_id)
|
|
81
|
+
self._xt_trader = trader
|
|
82
|
+
self._connected = True
|
|
83
|
+
return True
|
|
84
|
+
except ImportError:
|
|
85
|
+
raise ImportError("xtquant 未安装。请运行: pip install xtquant")
|
|
86
|
+
except Exception as e:
|
|
87
|
+
self._connected = False
|
|
88
|
+
raise RuntimeError(f"XTQuant 连接失败: {e}") from e
|
|
89
|
+
|
|
90
|
+
def disconnect(self) -> None:
|
|
91
|
+
if self._xt_trader:
|
|
92
|
+
try:
|
|
93
|
+
self._xt_trader.disconnect()
|
|
94
|
+
except Exception:
|
|
95
|
+
pass
|
|
96
|
+
self._xt_trader = None
|
|
97
|
+
self._connected = False
|
|
98
|
+
|
|
99
|
+
def account_info(self) -> AccountInfo:
|
|
100
|
+
self._require_connected()
|
|
101
|
+
acct = self._xt_trader.query_stock_asset(self._account_id)
|
|
102
|
+
if not acct:
|
|
103
|
+
raise RuntimeError("XTQuant 查询账户资金失败")
|
|
104
|
+
# XTQuant StockAsset fields
|
|
105
|
+
total = float(getattr(acct, "total_asset", 0))
|
|
106
|
+
cash = float(getattr(acct, "cash", 0))
|
|
107
|
+
frozen = float(getattr(acct, "frozen_cash", 0))
|
|
108
|
+
mv = float(getattr(acct, "market_value", 0))
|
|
109
|
+
return AccountInfo(
|
|
110
|
+
broker_id=self.broker_id,
|
|
111
|
+
broker_type=self.broker_type,
|
|
112
|
+
label=self.label,
|
|
113
|
+
account_id=self._account_id,
|
|
114
|
+
currency="CNY",
|
|
115
|
+
total_assets=total,
|
|
116
|
+
cash=cash,
|
|
117
|
+
market_value=mv,
|
|
118
|
+
frozen=frozen,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def positions(self) -> List[Position]:
|
|
122
|
+
self._require_connected()
|
|
123
|
+
raw = self._xt_trader.query_stock_positions(self._account_id)
|
|
124
|
+
result = []
|
|
125
|
+
for p in (raw or []):
|
|
126
|
+
cost = float(getattr(p, "open_price", 0))
|
|
127
|
+
price = float(getattr(p, "market_price", 0))
|
|
128
|
+
qty = float(getattr(p, "volume", 0))
|
|
129
|
+
avail = float(getattr(p, "can_use_volume",0))
|
|
130
|
+
mv = float(getattr(p, "market_value", 0))
|
|
131
|
+
pnl = float(getattr(p, "open_pnl", 0))
|
|
132
|
+
sym = str(getattr(p, "stock_code", ""))
|
|
133
|
+
name = str(getattr(p, "stock_name", ""))
|
|
134
|
+
pnl_pct = (pnl / (mv - pnl) * 100) if (mv - pnl) > 0 else 0.0
|
|
135
|
+
result.append(Position(
|
|
136
|
+
symbol=sym, name=name,
|
|
137
|
+
quantity=qty, available_qty=avail,
|
|
138
|
+
cost_price=cost, current_price=price,
|
|
139
|
+
market_value=mv, pnl=pnl, pnl_pct=pnl_pct,
|
|
140
|
+
currency="CNY", market="a_share",
|
|
141
|
+
))
|
|
142
|
+
return result
|
|
143
|
+
|
|
144
|
+
def orders(self, status: str = "all", limit: int = 50) -> List[Order]:
|
|
145
|
+
self._require_connected()
|
|
146
|
+
raw = self._xt_trader.query_stock_orders(self._account_id)
|
|
147
|
+
result = []
|
|
148
|
+
for o in (raw or [])[:limit]:
|
|
149
|
+
raw_status = int(getattr(o, "order_status", 0))
|
|
150
|
+
mapped = _xt_order_status(raw_status)
|
|
151
|
+
if status != "all" and mapped != status:
|
|
152
|
+
continue
|
|
153
|
+
side = "buy" if int(getattr(o, "order_type", 23)) in (23, 90) else "sell"
|
|
154
|
+
result.append(Order(
|
|
155
|
+
order_id=str(getattr(o, "order_id", "")),
|
|
156
|
+
symbol=str(getattr(o, "stock_code", "")),
|
|
157
|
+
name=str(getattr(o, "stock_name", "")),
|
|
158
|
+
side=side,
|
|
159
|
+
order_type="limit",
|
|
160
|
+
quantity=float(getattr(o, "order_volume", 0)),
|
|
161
|
+
filled_qty=float(getattr(o, "traded_volume", 0)),
|
|
162
|
+
price=float(getattr(o, "price", 0)),
|
|
163
|
+
avg_price=float(getattr(o, "traded_price", 0)),
|
|
164
|
+
status=mapped,
|
|
165
|
+
created_at=str(getattr(o, "order_time", "")),
|
|
166
|
+
currency="CNY",
|
|
167
|
+
))
|
|
168
|
+
return result
|
|
169
|
+
|
|
170
|
+
def place_order(self, symbol: str, side: str, quantity: float,
|
|
171
|
+
order_type: str = "limit", price: float = 0.0, **kwargs) -> OrderResult:
|
|
172
|
+
"""下单前跑本地前置检查(整手、T+1),不通过则直接拒绝,不发往柜台。
|
|
173
|
+
|
|
174
|
+
2026-08 补:这层之前是空的——brokers/trading.py 的 RiskRuleSet 是
|
|
175
|
+
跨市场通用风控(仓位占比/现金留存/做空/碎股),不认 A股特有的整手
|
|
176
|
+
和 T+1 规则,之前完全没人挡,只能指望交易所柜台自己拒单。
|
|
177
|
+
|
|
178
|
+
故意没做的一项:涨跌停价格禁区检查。那需要额外拉实时行情
|
|
179
|
+
(xtdata.get_market_data 查 lastclose),这里还没有稳定验证过的调用
|
|
180
|
+
路径,宁可先不做半成品的价格校验,也不要给一个看似做了、实际没
|
|
181
|
+
测过的检查——柜台本身对超出涨跌停的委托单是硬性拒单,不会被这个
|
|
182
|
+
缺口放过一笔真实成交,只是少一层"提前失败、省一次网络往返"的
|
|
183
|
+
便利,不是安全缺口。
|
|
184
|
+
"""
|
|
185
|
+
self._require_connected()
|
|
186
|
+
|
|
187
|
+
side = str(side or "").lower()
|
|
188
|
+
lot_error = _lot_size_violation(side, float(quantity))
|
|
189
|
+
if lot_error:
|
|
190
|
+
return OrderResult(success=False, message=f"本地前置检查未通过:{lot_error}", broker_id=self.broker_id)
|
|
191
|
+
|
|
192
|
+
if side == "sell":
|
|
193
|
+
current = next((p for p in self.positions() if p.symbol == symbol), None)
|
|
194
|
+
t1_error = _t_plus_1_violation(side, float(quantity), current)
|
|
195
|
+
if t1_error:
|
|
196
|
+
return OrderResult(success=False, message=f"本地前置检查未通过:{t1_error}", broker_id=self.broker_id)
|
|
197
|
+
|
|
198
|
+
from xtquant.xttype import StockOrderType, StockPriceType
|
|
199
|
+
xt_type = 23 if side == "buy" else 24 # XTQuant buy/sell constants
|
|
200
|
+
price_tp = StockPriceType.LATEST if order_type == "market" else StockPriceType.FIX
|
|
201
|
+
oid = self._xt_trader.order_stock(
|
|
202
|
+
self._account_id, symbol, xt_type, int(quantity), price_tp, price,
|
|
203
|
+
strategy_name="aria_code", order_remark="",
|
|
204
|
+
)
|
|
205
|
+
if oid == -1:
|
|
206
|
+
return OrderResult(success=False, message="XTQuant 下单失败(返回 -1)", broker_id=self.broker_id)
|
|
207
|
+
return OrderResult(success=True, order_id=str(oid), broker_id=self.broker_id)
|
|
208
|
+
|
|
209
|
+
def cancel_order(self, order_id: str) -> bool:
|
|
210
|
+
self._require_connected()
|
|
211
|
+
ret = self._xt_trader.cancel_order_stock(self._account_id, int(order_id))
|
|
212
|
+
return ret == 0
|
|
213
|
+
|
|
214
|
+
def _require_connected(self):
|
|
215
|
+
if not self._connected or not self._xt_trader:
|
|
216
|
+
raise RuntimeError("XTQuant 未连接,请先调用 connect()")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _xt_order_status(code: int) -> str:
|
|
220
|
+
_MAP = {
|
|
221
|
+
48: "open", 49: "open", 50: "open",
|
|
222
|
+
51: "filled", 52: "partial",
|
|
223
|
+
53: "cancelled", 54: "cancelled", 55: "cancelled",
|
|
224
|
+
}
|
|
225
|
+
return _MAP.get(code, "open")
|