Skip to content

Commit 733fd97

Browse files
authored
Merge pull request #11 from QuantStrategyLab/codex/crypto-shared-strategy-catalog
[codex] refactor crypto strategy catalog access
2 parents 0a2feff + ccd3e8e commit 733fd97

3 files changed

Lines changed: 52 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Shared crypto strategy catalog and implementations"
99
readme = "README.md"
1010
requires-python = ">=3.11"
1111
dependencies = [
12-
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@v0.6.0",
12+
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@6e8cc058b821aea8a54015d4b39e02fbdd3dc198",
1313
]
1414

1515
[tool.setuptools]

src/crypto_strategies/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
from .catalog import STRATEGY_DEFINITIONS, get_strategy_definition, get_strategy_definitions
1+
from .catalog import (
2+
STRATEGY_CATALOG,
3+
STRATEGY_DEFINITIONS,
4+
get_strategy_catalog,
5+
get_strategy_definition,
6+
get_strategy_definitions,
7+
get_strategy_index_rows,
8+
get_strategy_metadata,
9+
)
210

311
__all__ = [
12+
"STRATEGY_CATALOG",
413
"STRATEGY_DEFINITIONS",
14+
"get_strategy_catalog",
515
"get_strategy_definition",
616
"get_strategy_definitions",
17+
"get_strategy_index_rows",
18+
"get_strategy_metadata",
719
]

src/crypto_strategies/catalog.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
from quant_platform_kit.common.strategies import (
44
CRYPTO_DOMAIN,
5+
StrategyCatalog,
56
StrategyComponentDefinition,
67
StrategyDefinition,
8+
StrategyMetadata,
9+
build_strategy_catalog,
10+
build_strategy_index_rows,
11+
get_catalog_strategy_definition,
12+
get_catalog_strategy_metadata,
713
)
814

915
CRYPTO_LEADER_ROTATION_PROFILE = "crypto_leader_rotation"
@@ -26,16 +32,41 @@
2632
),
2733
}
2834

35+
STRATEGY_METADATA: dict[str, StrategyMetadata] = {
36+
CRYPTO_LEADER_ROTATION_PROFILE: StrategyMetadata(
37+
canonical_profile=CRYPTO_LEADER_ROTATION_PROFILE,
38+
display_name="Crypto Leader Rotation",
39+
description="Trend-following crypto rotation with staged entries, degradation controls, and cash parking.",
40+
aliases=(),
41+
cadence="daily",
42+
asset_scope="liquid_crypto_assets",
43+
benchmark="BTC",
44+
role="crypto_offensive_rotation",
45+
status="runtime_enabled",
46+
),
47+
}
48+
49+
STRATEGY_CATALOG: StrategyCatalog = build_strategy_catalog(
50+
strategy_definitions=STRATEGY_DEFINITIONS,
51+
metadata=STRATEGY_METADATA,
52+
)
53+
2954

3055
def get_strategy_definitions() -> dict[str, StrategyDefinition]:
3156
return dict(STRATEGY_DEFINITIONS)
3257

3358

59+
def get_strategy_catalog() -> StrategyCatalog:
60+
return STRATEGY_CATALOG
61+
62+
3463
def get_strategy_definition(profile: str) -> StrategyDefinition:
35-
normalized = str(profile or "").strip().lower()
36-
if normalized not in STRATEGY_DEFINITIONS:
37-
supported = ", ".join(sorted(STRATEGY_DEFINITIONS)) or "<none>"
38-
raise ValueError(
39-
f"Unknown crypto strategy profile={profile!r}; supported values: {supported}"
40-
)
41-
return STRATEGY_DEFINITIONS[normalized]
64+
return get_catalog_strategy_definition(STRATEGY_CATALOG, profile)
65+
66+
67+
def get_strategy_metadata(profile: str) -> StrategyMetadata:
68+
return get_catalog_strategy_metadata(STRATEGY_CATALOG, profile)
69+
70+
71+
def get_strategy_index_rows() -> list[dict[str, object]]:
72+
return build_strategy_index_rows(STRATEGY_CATALOG)

0 commit comments

Comments
 (0)