55from quant_platform_kit .common .strategies import (
66 CRYPTO_DOMAIN ,
77 US_EQUITY_DOMAIN ,
8+ StrategyComponentDefinition ,
89 StrategyDefinition ,
910 get_supported_profiles_for_platform ,
11+ load_strategy_component_module ,
1012 resolve_strategy_definition ,
1113)
1214
@@ -18,11 +20,23 @@ def setUp(self) -> None:
1820 profile = "global_etf_rotation" ,
1921 domain = US_EQUITY_DOMAIN ,
2022 supported_platforms = frozenset ({"ibkr" , "schwab" , "longbridge" }),
23+ components = (
24+ StrategyComponentDefinition (
25+ name = "signal_logic" ,
26+ module_path = "math" ,
27+ ),
28+ ),
2129 ),
2230 "crypto_leader_rotation" : StrategyDefinition (
2331 profile = "crypto_leader_rotation" ,
2432 domain = CRYPTO_DOMAIN ,
2533 supported_platforms = frozenset ({"binance" }),
34+ components = (
35+ StrategyComponentDefinition (
36+ name = "core" ,
37+ module_path = "math" ,
38+ ),
39+ ),
2640 ),
2741 }
2842 self .platform_supported_domains = {
@@ -69,3 +83,22 @@ def test_resolve_strategy_definition_rejects_profile_outside_platform_domain(sel
6983 strategy_definitions = self .strategy_definitions ,
7084 platform_supported_domains = self .platform_supported_domains ,
7185 )
86+
87+ def test_load_strategy_component_module_imports_named_component (self ) -> None :
88+ definition = self .strategy_definitions ["global_etf_rotation" ]
89+
90+ module = load_strategy_component_module (
91+ definition ,
92+ component_name = "signal_logic" ,
93+ )
94+
95+ self .assertEqual (module .__name__ , "math" )
96+
97+ def test_load_strategy_component_module_rejects_unknown_component (self ) -> None :
98+ definition = self .strategy_definitions ["global_etf_rotation" ]
99+
100+ with self .assertRaisesRegex (ValueError , "available components: signal_logic" ):
101+ load_strategy_component_module (
102+ definition ,
103+ component_name = "allocation" ,
104+ )
0 commit comments