5656 build_strategy_plugin_alert_context_label as build_email_alert_context_label ,
5757 publish_strategy_plugin_email_alerts ,
5858)
59+ from quant_platform_kit .notifications .strategy_plugin_sms import (
60+ StrategyPluginSmsAlertMarkerStore ,
61+ publish_strategy_plugin_sms_alerts ,
62+ )
5963from quant_platform_kit .strategy_contracts import build_strategy_evaluation_inputs
6064from runtime_config_support import PlatformRuntimeSettings , load_platform_runtime_settings
6165from strategy_runtime import load_strategy_runtime
@@ -238,6 +242,35 @@ def build_strategy_plugin_alert_store(
238242 )
239243
240244
245+ def build_strategy_plugin_sms_alert_store (
246+ settings : PlatformRuntimeSettings ,
247+ * ,
248+ env_reader : Callable [[str , str | None ], str | None ] = os .getenv ,
249+ ):
250+ explicit_gcs_uri = env_reader ("STRATEGY_PLUGIN_ALERT_STATE_GCS_URI" , None )
251+ report_gcs_uri = env_reader ("EXECUTION_REPORT_GCS_URI" , None )
252+ state_bucket = env_reader ("FIRSTRADE_GCS_STATE_BUCKET" , None )
253+ state_prefix = env_reader ("FIRSTRADE_STATE_PREFIX" , "firstrade-platform" ) or "firstrade-platform"
254+ state_gcs_uri = f"gs://{ state_bucket } /{ state_prefix } " if state_bucket else None
255+ return StrategyPluginSmsAlertMarkerStore (
256+ local_dir = env_reader ("STRATEGY_PLUGIN_ALERT_STATE_DIR" , None ) or "/tmp/quant_strategy_plugin_alerts" ,
257+ gcs_prefix_uri = explicit_gcs_uri or report_gcs_uri or state_gcs_uri ,
258+ gcp_project_id = settings .project_id ,
259+ )
260+
261+
262+ class StrategyPluginAlertPublishResults :
263+ def __init__ (self , * , email_result , sms_result ):
264+ self .email_result = email_result
265+ self .sms_result = sms_result
266+
267+ def to_report_fields (self ) -> dict [str , Any ]:
268+ fields : dict [str , Any ] = {}
269+ fields .update (self .email_result .to_report_fields ())
270+ fields .update (self .sms_result .to_report_fields ())
271+ return fields
272+
273+
241274def publish_strategy_plugin_alerts (
242275 signals ,
243276 * ,
@@ -246,7 +279,7 @@ def publish_strategy_plugin_alerts(
246279 log_message : Callable [..., Any ] = print ,
247280 env_reader : Callable [[str , str | None ], str | None ] = os .getenv ,
248281):
249- return publish_strategy_plugin_email_alerts (
282+ email_result = publish_strategy_plugin_email_alerts (
250283 signals ,
251284 email_settings = settings ,
252285 translator = translator ,
@@ -255,6 +288,16 @@ def publish_strategy_plugin_alerts(
255288 alert_store = build_strategy_plugin_alert_store (settings , env_reader = env_reader ),
256289 log_message = log_message ,
257290 )
291+ sms_result = publish_strategy_plugin_sms_alerts (
292+ signals ,
293+ sms_settings = settings ,
294+ translator = translator ,
295+ strategy_label = settings .strategy_profile ,
296+ context_label = build_strategy_plugin_alert_context_label (settings ),
297+ alert_store = build_strategy_plugin_sms_alert_store (settings , env_reader = env_reader ),
298+ log_message = log_message ,
299+ )
300+ return StrategyPluginAlertPublishResults (email_result = email_result , sms_result = sms_result )
258301
259302
260303def _runtime_metadata_with_execution_policy (
@@ -385,6 +428,11 @@ def run_strategy_cycle(
385428 "strategy_plugin_alert_email_skipped_count" : 0 ,
386429 "strategy_plugin_alert_email_failed_count" : 0 ,
387430 "strategy_plugin_alert_email_deliveries" : [],
431+ "strategy_plugin_alert_sms_attempted_count" : 0 ,
432+ "strategy_plugin_alert_sms_sent_count" : 0 ,
433+ "strategy_plugin_alert_sms_skipped_count" : 0 ,
434+ "strategy_plugin_alert_sms_failed_count" : 0 ,
435+ "strategy_plugin_alert_sms_deliveries" : [],
388436 }
389437 return attach_strategy_plugin_result (
390438 result ,
@@ -489,6 +537,11 @@ def run_strategy_cycle(
489537 "strategy_plugin_alert_email_skipped_count" : 0 ,
490538 "strategy_plugin_alert_email_failed_count" : 0 ,
491539 "strategy_plugin_alert_email_deliveries" : [],
540+ "strategy_plugin_alert_sms_attempted_count" : 0 ,
541+ "strategy_plugin_alert_sms_sent_count" : 0 ,
542+ "strategy_plugin_alert_sms_skipped_count" : 0 ,
543+ "strategy_plugin_alert_sms_failed_count" : 0 ,
544+ "strategy_plugin_alert_sms_deliveries" : [],
492545 }
493546 )
494547 if strategy_plugin_alert_email_error :
0 commit comments