11from __future__ import annotations
22
3- from dataclasses import dataclass
4-
5- US_EQUITY_DOMAIN = "us_equity"
6- CRYPTO_DOMAIN = "crypto"
3+ from quant_platform_kit .common .strategies import (
4+ US_EQUITY_DOMAIN ,
5+ StrategyDefinition ,
6+ get_supported_profiles_for_platform as qpk_get_supported_profiles_for_platform ,
7+ resolve_strategy_definition as qpk_resolve_strategy_definition ,
8+ )
79
810LONGBRIDGE_PLATFORM = "longbridge"
911
1012
11- @dataclass (frozen = True )
12- class StrategyDefinition :
13- profile : str
14- domain : str
15- supported_platforms : frozenset [str ]
16-
17-
1813DEFAULT_STRATEGY_PROFILE = "semiconductor_rotation_income"
1914
2015STRATEGY_DEFINITIONS : dict [str , StrategyDefinition ] = {
@@ -33,11 +28,10 @@ class StrategyDefinition:
3328
3429
3530def get_supported_profiles_for_platform (platform_id : str ) -> frozenset [str ]:
36- return frozenset (
37- profile
38- for profile , definition in STRATEGY_DEFINITIONS .items ()
39- if platform_id in definition .supported_platforms
40- and definition .domain in PLATFORM_SUPPORTED_DOMAINS .get (platform_id , frozenset ())
31+ return qpk_get_supported_profiles_for_platform (
32+ STRATEGY_DEFINITIONS ,
33+ PLATFORM_SUPPORTED_DOMAINS ,
34+ platform_id = platform_id ,
4135 )
4236
4337
@@ -46,23 +40,10 @@ def resolve_strategy_definition(
4640 * ,
4741 platform_id : str ,
4842) -> StrategyDefinition :
49- profile = (raw_value or DEFAULT_STRATEGY_PROFILE ).strip ().lower ()
50- definition = STRATEGY_DEFINITIONS .get (profile )
51- supported = ", " .join (sorted (get_supported_profiles_for_platform (platform_id )))
52-
53- if definition is None :
54- raise ValueError (
55- f"Unsupported STRATEGY_PROFILE={ raw_value !r} ; supported values: { supported } "
56- )
57-
58- if platform_id not in definition .supported_platforms :
59- raise ValueError (
60- f"Unsupported STRATEGY_PROFILE={ raw_value !r} ; supported values: { supported } "
61- )
62-
63- if definition .domain not in PLATFORM_SUPPORTED_DOMAINS .get (platform_id , frozenset ()):
64- raise ValueError (
65- f"Unsupported strategy domain { definition .domain !r} for platform { platform_id !r} "
66- )
67-
68- return definition
43+ return qpk_resolve_strategy_definition (
44+ raw_value ,
45+ platform_id = platform_id ,
46+ strategy_definitions = STRATEGY_DEFINITIONS ,
47+ platform_supported_domains = PLATFORM_SUPPORTED_DOMAINS ,
48+ default_profile = DEFAULT_STRATEGY_PROFILE ,
49+ )
0 commit comments