Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions application/rebalance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
localize_notification_text as _base_localize_notification_text,
translator_uses_zh as _base_translator_uses_zh,
)
from quant_platform_kit.common.strategy_plugins import attach_strategy_plugin_metadata

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the pinned kit before importing this helper

In the production/Docker path, Dockerfile installs only requirements.txt, which still pins QuantPlatformKit to ceb84a366ed1bf9a53292ff2c73e06b4baac05e2; that pinned quant_platform_kit.common.strategy_plugins does not export attach_strategy_plugin_metadata. Because this import runs while importing application.rebalance_service (and therefore main), the deployed service will fail to start with ImportError before handling any requests unless the QuantPlatformKit pin is bumped to the commit that adds the helper or a compatible fallback is provided.

Useful? React with 👍 / 👎.


_DETAIL_FIELD_SPLIT_RE = re.compile(r"\s+(?=[^\s=::]+[=::])")

Expand Down Expand Up @@ -175,6 +176,10 @@ def run_strategy(
execution_port = runtime.execution_port_factory(trade_context)

def load_plan(*, current_snapshot):
current_snapshot = attach_strategy_plugin_metadata(
current_snapshot,
getattr(config, "strategy_plugin_signals", ()) or (),
)
current_plan = runtime.resolve_rebalance_plan(
indicators=indicators,
snapshot=current_snapshot,
Expand Down
2 changes: 1 addition & 1 deletion application/runtime_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def build_rebalance_runtime(self, *, silent_cycle_notifications: bool = False) -
)

def build_rebalance_config(self, *, strategy_plugin_signals=()) -> LongBridgeRebalanceConfig:
del strategy_plugin_signals
return LongBridgeRebalanceConfig(
limit_sell_discount=self.limit_sell_discount,
limit_buy_premium=self.limit_buy_premium,
Expand All @@ -190,6 +189,7 @@ def build_rebalance_config(self, *, strategy_plugin_signals=()) -> LongBridgeReb
safe_haven_cash_substitute_threshold_usd=self.safe_haven_cash_substitute_threshold_usd,
sleeper=self.sleeper,
extra_notification_lines=(),
strategy_plugin_signals=tuple(strategy_plugin_signals or ()),
)

def load_strategy_plugin_signals(self, raw_mounts):
Expand Down
1 change: 1 addition & 0 deletions application/runtime_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LongBridgeRebalanceConfig:
safe_haven_cash_substitute_threshold_usd: float = 1000.0
sleeper: Callable[[float], None] | None = None
extra_notification_lines: tuple[str, ...] = ()
strategy_plugin_signals: tuple[Any, ...] = ()


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def run_strategy(*, force_run: bool = False, validation_only: bool = False, vali
runtime=composer.build_rebalance_runtime(
silent_cycle_notifications=validation_only,
),
config=composer.build_rebalance_config(),
config=composer.build_rebalance_config(strategy_plugin_signals=strategy_plugin_signals),
)
signal_snapshot = {}
if cycle_result is not None:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flask
gunicorn
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@ceb84a366ed1bf9a53292ff2c73e06b4baac05e2
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@f2ebae8aacd8c70292c5b6115a80c6657e64ad1f
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@86d72631c76f27c668b234704b91241bec8fa9ee
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@5f04e85e89862fdcfa8d90e745340eabdbbe3c86
pandas
requests
pytz
Expand Down