66
77from us_equity_strategies .cash_only_equity import (
88 build_portfolio_inputs_from_snapshot ,
9+ resolve_weight_translation_equity ,
910)
1011from quant_platform_kit .strategy_contracts import (
1112 PositionTarget ,
@@ -464,6 +465,7 @@ def _normalize_to_value_target_decision(
464465 * ,
465466 portfolio_inputs ,
466467 runtime_metadata : Mapping [str , Any ] | None = None ,
468+ cash_only_execution : bool = True ,
467469) -> tuple [StrategyDecision , ValueTargetExecutionAnnotations | None ]:
468470 target_mode = resolve_decision_target_mode (decision )
469471 no_execute = "no_execute" in set (decision .risk_flags )
@@ -472,18 +474,30 @@ def _normalize_to_value_target_decision(
472474 return decision , None
473475
474476 if target_mode == "weight" and not no_execute :
475- total_equity = float (portfolio_inputs .total_equity )
476- if total_equity <= 0.0 :
477+ total_equity , block_execution , deleverage_mode = resolve_weight_translation_equity (
478+ portfolio_inputs ,
479+ cash_only_execution = cash_only_execution ,
480+ )
481+ if block_execution :
477482 return _build_zero_equity_value_decision (
478483 decision ,
479484 ), _build_weight_translation_annotations (
480485 decision ,
481- total_equity = total_equity ,
486+ total_equity = float ( portfolio_inputs . total_equity ) ,
482487 liquid_cash = float (portfolio_inputs .liquid_cash ),
483488 runtime_metadata = runtime_metadata ,
484489 )
490+ decision_for_translation = decision
491+ if deleverage_mode :
492+ decision_for_translation = replace (
493+ decision ,
494+ diagnostics = {
495+ ** dict (decision .diagnostics ),
496+ "cash_only_deleverage_mode" : True ,
497+ },
498+ )
485499 translated = translate_decision_to_target_mode (
486- decision ,
500+ decision_for_translation ,
487501 target_mode = "value" ,
488502 total_equity = total_equity ,
489503 )
@@ -652,6 +666,7 @@ def map_strategy_decision_to_plan(
652666 decision ,
653667 portfolio_inputs = portfolio_inputs ,
654668 runtime_metadata = runtime_metadata ,
669+ cash_only_execution = cash_only_execution ,
655670 )
656671 annotations = normalized_annotations
657672 if annotations is None :
0 commit comments