|
8 | 8 | from quant_platform_kit.common.strategy_plugins import ( |
9 | 9 | CRISIS_RESPONSE_SHADOW_SUPPORTED_STRATEGIES, |
10 | 10 | DEFAULT_STRATEGY_PLUGIN_DEFINITIONS, |
| 11 | + MACRO_RISK_GOVERNOR_SUPPORTED_STRATEGIES, |
11 | 12 | PLUGIN_CRISIS_RESPONSE_SHADOW, |
| 13 | + PLUGIN_MARKET_REGIME_CONTROL, |
| 14 | + PLUGIN_MACRO_RISK_GOVERNOR, |
12 | 15 | PLUGIN_TACO_REBOUND_SHADOW, |
13 | 16 | PLUGIN_MODE_SHADOW, |
14 | 17 | STRATEGY_PLUGIN_ALERT_CHANNEL_EMAIL, |
15 | 18 | STRATEGY_PLUGIN_ALERT_CHANNEL_PUSH, |
16 | 19 | STRATEGY_PLUGIN_ALERT_CHANNEL_SMS, |
17 | 20 | STRATEGY_PLUGIN_ALERT_CHANNEL_TELEGRAM, |
| 21 | + MARKET_REGIME_CONTROL_SUPPORTED_STRATEGIES, |
18 | 22 | TACO_REBOUND_SHADOW_SUPPORTED_STRATEGIES, |
19 | 23 | StrategyPluginDefinition, |
20 | 24 | attach_strategy_plugin_metadata, |
@@ -145,6 +149,62 @@ def test_default_plugin_definition_limits_taco_rebound_to_tqqq_notifications(sel |
145 | 149 | mode=PLUGIN_MODE_SHADOW, |
146 | 150 | ) |
147 | 151 |
|
| 152 | + def test_default_plugin_definition_limits_macro_risk_governor_to_tqqq(self): |
| 153 | + definition = DEFAULT_STRATEGY_PLUGIN_DEFINITIONS[PLUGIN_MACRO_RISK_GOVERNOR] |
| 154 | + |
| 155 | + self.assertEqual(definition.supported_strategies, MACRO_RISK_GOVERNOR_SUPPORTED_STRATEGIES) |
| 156 | + self.assertEqual( |
| 157 | + definition.alert_channels, |
| 158 | + ( |
| 159 | + STRATEGY_PLUGIN_ALERT_CHANNEL_EMAIL, |
| 160 | + STRATEGY_PLUGIN_ALERT_CHANNEL_SMS, |
| 161 | + STRATEGY_PLUGIN_ALERT_CHANNEL_PUSH, |
| 162 | + STRATEGY_PLUGIN_ALERT_CHANNEL_TELEGRAM, |
| 163 | + ), |
| 164 | + ) |
| 165 | + validate_strategy_plugin_compatibility( |
| 166 | + strategy="tqqq_growth_income", |
| 167 | + plugin=PLUGIN_MACRO_RISK_GOVERNOR, |
| 168 | + mode=PLUGIN_MODE_SHADOW, |
| 169 | + ) |
| 170 | + with self.assertRaisesRegex( |
| 171 | + ValueError, |
| 172 | + "macro_risk_governor does not support strategy soxl_soxx_trend_income", |
| 173 | + ): |
| 174 | + validate_strategy_plugin_compatibility( |
| 175 | + strategy="soxl_soxx_trend_income", |
| 176 | + plugin=PLUGIN_MACRO_RISK_GOVERNOR, |
| 177 | + mode=PLUGIN_MODE_SHADOW, |
| 178 | + ) |
| 179 | + |
| 180 | + def test_default_plugin_definition_limits_market_regime_control_to_tqqq(self): |
| 181 | + definition = DEFAULT_STRATEGY_PLUGIN_DEFINITIONS[PLUGIN_MARKET_REGIME_CONTROL] |
| 182 | + |
| 183 | + self.assertEqual(definition.supported_strategies, MARKET_REGIME_CONTROL_SUPPORTED_STRATEGIES) |
| 184 | + self.assertEqual( |
| 185 | + definition.alert_channels, |
| 186 | + ( |
| 187 | + STRATEGY_PLUGIN_ALERT_CHANNEL_EMAIL, |
| 188 | + STRATEGY_PLUGIN_ALERT_CHANNEL_SMS, |
| 189 | + STRATEGY_PLUGIN_ALERT_CHANNEL_PUSH, |
| 190 | + STRATEGY_PLUGIN_ALERT_CHANNEL_TELEGRAM, |
| 191 | + ), |
| 192 | + ) |
| 193 | + validate_strategy_plugin_compatibility( |
| 194 | + strategy="tqqq_growth_income", |
| 195 | + plugin=PLUGIN_MARKET_REGIME_CONTROL, |
| 196 | + mode=PLUGIN_MODE_SHADOW, |
| 197 | + ) |
| 198 | + with self.assertRaisesRegex( |
| 199 | + ValueError, |
| 200 | + "market_regime_control does not support strategy soxl_soxx_trend_income", |
| 201 | + ): |
| 202 | + validate_strategy_plugin_compatibility( |
| 203 | + strategy="soxl_soxx_trend_income", |
| 204 | + plugin=PLUGIN_MARKET_REGIME_CONTROL, |
| 205 | + mode=PLUGIN_MODE_SHADOW, |
| 206 | + ) |
| 207 | + |
148 | 208 | def test_parse_strategy_plugin_mounts_rejects_unsupported_crisis_response_strategy(self): |
149 | 209 | raw = [ |
150 | 210 | { |
@@ -174,6 +234,34 @@ def test_parse_strategy_plugin_mounts_accepts_taco_rebound_tqqq_notification(sel |
174 | 234 | self.assertEqual(mounts[0].strategy, "tqqq_growth_income") |
175 | 235 | self.assertEqual(mounts[0].plugin, PLUGIN_TACO_REBOUND_SHADOW) |
176 | 236 |
|
| 237 | + def test_parse_strategy_plugin_mounts_accepts_macro_risk_governor_tqqq(self): |
| 238 | + mounts = parse_strategy_plugin_mounts( |
| 239 | + [ |
| 240 | + { |
| 241 | + "strategy": "tqqq_growth_income", |
| 242 | + "plugin": PLUGIN_MACRO_RISK_GOVERNOR, |
| 243 | + "signal_path": "gs://bucket/macro/latest_signal.json", |
| 244 | + } |
| 245 | + ] |
| 246 | + ) |
| 247 | + |
| 248 | + self.assertEqual(mounts[0].strategy, "tqqq_growth_income") |
| 249 | + self.assertEqual(mounts[0].plugin, PLUGIN_MACRO_RISK_GOVERNOR) |
| 250 | + |
| 251 | + def test_parse_strategy_plugin_mounts_accepts_market_regime_control_tqqq(self): |
| 252 | + mounts = parse_strategy_plugin_mounts( |
| 253 | + [ |
| 254 | + { |
| 255 | + "strategy": "tqqq_growth_income", |
| 256 | + "plugin": PLUGIN_MARKET_REGIME_CONTROL, |
| 257 | + "signal_path": "gs://bucket/market_regime/latest_signal.json", |
| 258 | + } |
| 259 | + ] |
| 260 | + ) |
| 261 | + |
| 262 | + self.assertEqual(mounts[0].strategy, "tqqq_growth_income") |
| 263 | + self.assertEqual(mounts[0].plugin, PLUGIN_MARKET_REGIME_CONTROL) |
| 264 | + |
177 | 265 | def test_plugin_definition_can_extend_future_strategy_support(self): |
178 | 266 | raw = [ |
179 | 267 | { |
|
0 commit comments