Skip to content

Commit 4c186d5

Browse files
authored
Localize strategy plugin route reasons (#26)
1 parent ee88909 commit 4c186d5

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "quant-strategy-plugins"
7-
version = "0.1.6"
7+
version = "0.1.7"
88
description = "Open sidecar strategy plugins that emit QuantPlatformKit-compatible signal artifacts."
99
readme = "README.md"
1010
requires-python = ">=3.11"

src/quant_strategy_plugins/strategy_plugin_runner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,16 @@ class PluginNotificationTargetPolicy:
318318
"en-US": "New-high/new-low spread watch",
319319
"zh-CN": "新高新低差观察",
320320
},
321+
"no_action": {"en-US": "No action", "zh-CN": "无动作"},
322+
"opportunity_watch": {"en-US": "Opportunity watch", "zh-CN": "机会观察"},
321323
"pentagon_pizza_watch": {"en-US": "Pentagon pizza index watch", "zh-CN": "五角大楼比萨指数观察"},
322324
"panic_reversal": {"en-US": "Panic reversal context", "zh-CN": "恐慌反转上下文"},
323325
"panic_reversal_watch": {"en-US": "Panic reversal watch", "zh-CN": "恐慌反转观察"},
324326
"put_call_stress_watch": {"en-US": "Put/call stress watch", "zh-CN": "Put/call 压力观察"},
325327
"price_crisis_guard_active": {"en-US": "Price crisis guard active", "zh-CN": "价格危机保护激活"},
326328
"price_rebound_confirmation": {"en-US": "Price rebound confirmation", "zh-CN": "价格反弹确认"},
329+
"risk_off": {"en-US": "Risk off", "zh-CN": "风险关闭"},
330+
"risk_reduced": {"en-US": "Risk reduced", "zh-CN": "风险降低"},
327331
"safe_haven_demand_watch": {"en-US": "Safe-haven demand watch", "zh-CN": "避险需求观察"},
328332
"skew_high_watch": {"en-US": "SKEW high watch", "zh-CN": "SKEW 偏高观察"},
329333
"taco_rebound": {"en-US": "TACO rebound context", "zh-CN": "TACO 反弹上下文"},
@@ -341,6 +345,7 @@ class PluginNotificationTargetPolicy:
341345
"en-US": "Yield-curve inversion watch",
342346
"zh-CN": "收益率曲线倒挂观察",
343347
},
348+
"watch": {"en-US": "Watch state", "zh-CN": "观察状态"},
344349
}
345350

346351
OPPORTUNITY_REVIEW_STATUS_LABELS: dict[str, dict[str, str]] = {

tests/test_strategy_plugin_runner.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,29 @@ def test_strategy_plugin_runner_runs_unified_market_regime_control_for_tqqq(tmp_
422422
assert "macro:vix_crisis_level" not in zh_log
423423

424424

425+
def test_strategy_plugin_runner_localizes_watch_route_reason_fallback() -> None:
426+
payload = _apply_plugin_contract(
427+
{
428+
"as_of": "2026-06-16",
429+
"canonical_route": "watch",
430+
"suggested_action": "watch_only",
431+
"notification": {"should_notify": True},
432+
},
433+
strategy=SOXL_STRATEGY_NAME,
434+
plugin=PLUGIN_MARKET_REGIME_CONTROL,
435+
mode="shadow",
436+
)
437+
438+
assert payload["notification"]["localized_reason_labels"]["zh-CN"] == ["观察状态"]
439+
assert payload["notification"]["localized_reason_labels"]["en-US"] == ["Watch state"]
440+
zh_notification = payload["notification"]["localized_messages"]["zh-CN"]
441+
zh_log = payload["log_record"]["localized_messages"]["zh-CN"]
442+
assert "原因:观察状态" in zh_notification
443+
assert "原因=观察状态" in zh_log
444+
assert "watch" not in zh_notification
445+
assert "watch" not in zh_log
446+
447+
425448
def test_strategy_plugin_runner_can_enable_panic_reversal_inside_market_regime_control(tmp_path) -> None:
426449
prices_path = tmp_path / "market_regime_panic_prices.csv"
427450
output_dir = tmp_path / STRATEGY_NAME / "plugins" / PLUGIN_MARKET_REGIME_CONTROL

0 commit comments

Comments
 (0)