Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Plugin artifacts may carry display-only `strategy_plugin_messages.v1` and
use those strings, while strategy and platform logic should continue to depend
on machine fields such as `canonical_route`, `suggested_action`,
`reason_codes`, and `position_control`.
General notification artifacts are loaded through `notification_targets`, not
through synthetic strategy mounts; they can trigger alerts but never attach
position controls to a strategy runtime.

Plugin alert delivery is provider-neutral at the platform boundary. Platform repositories pass runtime settings into `publish_strategy_plugin_alerts`; this repository handles configured `email`, `sms`, `push`, and `telegram` channels without coupling plugin logic to a broker platform.

Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ QuantPlatformKit

插件 artifact 可以携带展示层 `strategy_plugin_messages.v1` 和
`strategy_plugin_log.v1` 中英文通知 / 日志文案。平台 renderer 可以使用这些文案,但策略和平台逻辑应继续依赖 `canonical_route`、`suggested_action`、`reason_codes`、`position_control` 等机器字段。
通用通知 artifact 通过 `notification_targets` 加载,不再通过 synthetic strategy
挂载;它们可以触发告警,但永远不会把仓位控制附加到策略 runtime。

插件告警发送在平台边界保持 provider-neutral。平台仓库只把 runtime settings 传入 `publish_strategy_plugin_alerts`;这个仓库负责按配置发送 `email`、`sms`、`push` 和 `telegram`,不让插件逻辑耦合某个券商平台。

Expand Down
23 changes: 21 additions & 2 deletions docs/strategy_plugin_runtime_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ changes out of platform runtime code.

SOXL/SOXX is intentionally not listed as a `market_regime_control` runtime
mount. Broad macro and crisis signals for SOXL should be delivered through a
general notification artifact and reviewed manually unless a future backtest
promotes an explicit strategy-level opt-in.
general `notification_targets.market_regime_notification` artifact and reviewed
manually unless a future backtest promotes an explicit strategy-level opt-in.

## Runtime Loader

Expand All @@ -114,6 +114,25 @@ notification_lines = build_strategy_plugin_notification_lines(signals, locale="z
alert_messages = build_strategy_plugin_alert_messages(signals)
```

General notification artifacts use `notification_targets`, not synthetic
strategy names. They can be loaded and sent through the same notification and
alert builders, but they are not attached to strategy runtime metadata and
cannot authorize position changes:

```python
from quant_platform_kit.common.strategy_plugins import (
load_configured_strategy_plugin_notification_target_signals,
parse_strategy_plugin_notification_targets,
)

targets = parse_strategy_plugin_notification_targets(raw_json_config)
notification_signals = load_configured_strategy_plugin_notification_target_signals(targets)
notification_lines = build_strategy_plugin_notification_lines(
notification_signals,
locale="zh-CN",
)
```

The loader validates:

- the artifact is a JSON object
Expand Down
23 changes: 21 additions & 2 deletions docs/strategy_plugin_runtime_contract.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ artifact 内,并固定为通知/观察用途的 `shadow`。
registry 给 parser / loader。这样平台运行时代码不用承载未来插件资格变更。

SOXL/SOXX 故意不列入 `market_regime_control` 的运行时挂载清单。SOXL
相关宏观和危机信号应通过通用通知 artifact 分发,并由人工复核;除非未来
回测证明策略级 opt-in 有优势,否则不默认自动消费仓位控制。
相关宏观和危机信号应通过通用
`notification_targets.market_regime_notification` artifact 分发,并由人工复核;
除非未来回测证明策略级 opt-in 有优势,否则不默认自动消费仓位控制。

## Runtime Loader

Expand All @@ -105,6 +106,24 @@ notification_lines = build_strategy_plugin_notification_lines(signals, locale="z
alert_messages = build_strategy_plugin_alert_messages(signals)
```

通用通知 artifact 使用 `notification_targets`,不是 synthetic strategy。它们
可以复用同一套通知和告警 builder,但不会附加到策略 runtime metadata,也不能
授权仓位变化:

```python
from quant_platform_kit.common.strategy_plugins import (
load_configured_strategy_plugin_notification_target_signals,
parse_strategy_plugin_notification_targets,
)

targets = parse_strategy_plugin_notification_targets(raw_json_config)
notification_signals = load_configured_strategy_plugin_notification_target_signals(targets)
notification_lines = build_strategy_plugin_notification_lines(
notification_signals,
locale="zh-CN",
)
```

loader 会校验:

- artifact 是 JSON object
Expand Down
12 changes: 12 additions & 0 deletions src/quant_platform_kit/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .strategy_plugins import (
CRISIS_RESPONSE_SHADOW_SUPPORTED_STRATEGIES,
DEFAULT_STRATEGY_PLUGIN_DEFINITIONS,
GENERAL_MARKET_REGIME_NOTIFICATION_TARGET,
PLUGIN_CRISIS_RESPONSE_SHADOW,
PLUGIN_MARKET_REGIME_CONTROL,
PLUGIN_MACRO_RISK_GOVERNOR,
Expand All @@ -52,6 +53,7 @@
STRATEGY_PLUGIN_ALERT_CHANNEL_TELEGRAM,
STRATEGY_PLUGIN_ALERT_ACTIONS,
STRATEGY_PLUGIN_NON_ALERT_ROUTES,
STRATEGY_PLUGIN_NOTIFICATION_TARGETS,
STRATEGY_PLUGIN_SCHEMA_VERSIONS,
SUPPORTED_STRATEGY_PLUGIN_MODES,
MACRO_RISK_GOVERNOR_SUPPORTED_STRATEGIES,
Expand All @@ -60,6 +62,7 @@
StrategyPluginAlertMessage,
StrategyPluginDefinition,
StrategyPluginMountConfig,
StrategyPluginNotificationTargetConfig,
StrategyPluginSignal,
build_strategy_plugin_alert_guidance,
build_strategy_plugin_alert_key,
Expand All @@ -68,14 +71,17 @@
build_strategy_plugin_notification_lines,
build_strategy_plugin_report_payload,
extract_strategy_plugin_localized_message,
load_configured_strategy_plugin_notification_target_signals,
load_configured_strategy_plugin_signals,
load_strategy_plugin_signal,
normalize_strategy_plugin_definitions,
normalize_strategy_plugin_mode,
parse_strategy_plugin_notification_targets,
parse_strategy_plugin_mounts,
should_alert_strategy_plugin_signal,
translate_strategy_plugin_value,
validate_strategy_plugin_compatibility,
validate_strategy_plugin_notification_target,
validate_strategy_plugin_schema_version,
validate_strategy_plugin_signal_payload,
)
Expand All @@ -85,6 +91,7 @@
"CRISIS_RESPONSE_SHADOW_SUPPORTED_STRATEGIES",
"DEFAULT_EXECUTION_BLOCKING_SKIP_REASONS",
"DEFAULT_STRATEGY_PLUGIN_DEFINITIONS",
"GENERAL_MARKET_REGIME_NOTIFICATION_TARGET",
"DEFAULT_TERMINAL_FUNDING_BLOCK_SKIP_REASONS",
"DEFAULT_TERMINAL_STRATEGY_RUN_STAGES",
"PLUGIN_CRISIS_RESPONSE_SHADOW",
Expand All @@ -107,6 +114,7 @@
"STRATEGY_PLUGIN_ALERT_CHANNEL_TELEGRAM",
"STRATEGY_PLUGIN_ALERT_ACTIONS",
"STRATEGY_PLUGIN_NON_ALERT_ROUTES",
"STRATEGY_PLUGIN_NOTIFICATION_TARGETS",
"STRATEGY_PLUGIN_SCHEMA_VERSIONS",
"SUPPORTED_STRATEGY_PLUGIN_MODES",
"MACRO_RISK_GOVERNOR_SUPPORTED_STRATEGIES",
Expand All @@ -130,6 +138,7 @@
"StrategyPluginAlertMessage",
"StrategyPluginDefinition",
"StrategyPluginMountConfig",
"StrategyPluginNotificationTargetConfig",
"StrategyPluginSignal",
"build_strategy_plugin_alert_guidance",
"build_strategy_plugin_alert_key",
Expand All @@ -139,16 +148,19 @@
"build_strategy_plugin_report_payload",
"extract_strategy_plugin_localized_message",
"build_runtime_target",
"load_configured_strategy_plugin_notification_target_signals",
"load_configured_strategy_plugin_signals",
"load_strategy_plugin_signal",
"normalize_strategy_plugin_definitions",
"normalize_strategy_plugin_mode",
"parse_strategy_plugin_notification_targets",
"parse_strategy_plugin_mounts",
"resolve_runtime_target_from_env",
"should_alert_strategy_plugin_signal",
"translate_strategy_plugin_value",
"translator_uses_zh",
"validate_strategy_plugin_compatibility",
"validate_strategy_plugin_notification_target",
"validate_strategy_plugin_schema_version",
"validate_strategy_plugin_signal_payload",
]
Loading