-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_execution_policy.py
More file actions
73 lines (58 loc) · 2.52 KB
/
Copy pathruntime_execution_policy.py
File metadata and controls
73 lines (58 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from __future__ import annotations
try:
from quant_platform_kit.common.execution_capabilities import (
FRACTIONAL_SHARE_EXECUTION_SKIP_REASON,
definition_requires_fractional_share_execution,
fractional_share_execution_unsupported_reason,
notional_buy_compat_mode_enabled,
)
except ImportError: # pragma: no cover - compatibility with older pinned shared wheels
FRACTIONAL_SHARE_EXECUTION_SKIP_REASON = "fractional_share_execution_unsupported"
def definition_requires_fractional_share_execution(_definition: object) -> bool:
return False
def fractional_share_execution_unsupported_reason(
strategy_profile: str,
strategy_catalog: object = None,
capability_matrix: object = None,
) -> str | None:
return FRACTIONAL_SHARE_EXECUTION_SKIP_REASON
def notional_buy_compat_mode_enabled(
strategy_profile: str,
strategy_catalog: object = None,
capability_matrix: object = None,
) -> bool:
return False
from quant_platform_kit.common.strategies import normalize_profile_name
from strategy_registry import PLATFORM_CAPABILITY_MATRIX, STRATEGY_CATALOG
FRACTIONAL_BUY_QUANTITY_STEP = 0.0001
def dca_execution_unsupported_reason(strategy_profile: str) -> str | None:
return fractional_share_execution_unsupported_reason(
strategy_profile,
strategy_catalog=STRATEGY_CATALOG,
capability_matrix=PLATFORM_CAPABILITY_MATRIX,
)
def dca_compat_mode_enabled(strategy_profile: str) -> bool:
"""True when the strategy wants fractional but the platform lacks it.
The execution layer should convert notional buys to minimum whole-share
(US) or whole-lot (HK) orders instead of skipping the strategy entirely.
"""
return notional_buy_compat_mode_enabled(
strategy_profile,
strategy_catalog=STRATEGY_CATALOG,
capability_matrix=PLATFORM_CAPABILITY_MATRIX,
)
def fractional_buy_execution_enabled(strategy_profile: str) -> bool:
if dca_execution_unsupported_reason(strategy_profile) is not None:
return False
normalized_profile = normalize_profile_name(strategy_profile)
definition = STRATEGY_CATALOG.definitions.get(normalized_profile)
if definition is None:
return False
return definition_requires_fractional_share_execution(definition)
__all__ = (
"FRACTIONAL_BUY_QUANTITY_STEP",
"FRACTIONAL_SHARE_EXECUTION_SKIP_REASON",
"dca_compat_mode_enabled",
"dca_execution_unsupported_reason",
"fractional_buy_execution_enabled",
)