@@ -42,11 +42,52 @@ def test_maps_semiconductor_strategy_decision_to_execution_plan(self):
4242 strategy_profile = "semiconductor_rotation_income" ,
4343 )
4444
45- self .assertEqual (plan ["strategy_assets" ], ("SOXL" , "SOXX" , "BOXX" , "QQQI" , "SPYI" ))
46- self .assertEqual (plan ["limit_order_symbols" ], ("SOXL" , "SOXX" , "QQQI" , "SPYI" ))
47- self .assertEqual (plan ["portfolio_rows" ], (("SOXL" , "SOXX" ), ("QQQI" , "SPYI" ), ("BOXX" ,)))
48- self .assertEqual (plan ["targets" ]["BOXX" ], 15000.0 )
49- self .assertEqual (plan ["threshold_value" ], 500.0 )
45+ self .assertEqual (plan ["allocation" ]["target_mode" ], "value" )
46+ self .assertEqual (plan ["allocation" ]["strategy_symbols" ], ("SOXL" , "SOXX" , "BOXX" , "QQQI" , "SPYI" ))
47+ self .assertEqual (plan ["allocation" ]["targets" ]["BOXX" ], 15000.0 )
48+ self .assertEqual (plan ["portfolio" ]["portfolio_rows" ], (("SOXL" , "SOXX" ), ("QQQI" , "SPYI" ), ("BOXX" ,)))
49+ self .assertEqual (plan ["portfolio" ]["sellable_quantities" ]["BOXX" ], 50 )
50+ self .assertEqual (plan ["execution" ]["trade_threshold_value" ], 500.0 )
51+ self .assertEqual (plan ["execution" ]["investable_cash" ], 9000.0 )
52+ self .assertNotIn ("strategy_assets" , plan )
53+ self .assertNotIn ("targets" , plan )
54+ self .assertNotIn ("threshold_value" , plan )
55+
56+ def test_prefers_normalized_execution_annotations_when_present (self ):
57+ decision = StrategyDecision (
58+ positions = (PositionTarget (symbol = "SOXL" , target_value = 30000.0 ),),
59+ diagnostics = {
60+ "execution_annotations" : {
61+ "trade_threshold_value" : 250.0 ,
62+ "signal_display" : "signal" ,
63+ "status_display" : "risk-on" ,
64+ "deploy_ratio_text" : "60.0%" ,
65+ "income_ratio_text" : "10.0%" ,
66+ "income_locked_ratio_text" : "10.0%" ,
67+ "active_risk_asset" : "SOXL" ,
68+ "investable_cash" : 9000.0 ,
69+ "current_min_trade" : 100.0 ,
70+ }
71+ },
72+ )
73+ account_state = {
74+ "available_cash" : 10000.0 ,
75+ "market_values" : {"SOXL" : 0.0 },
76+ "quantities" : {"SOXL" : 0 },
77+ "sellable_quantities" : {"SOXL" : 0 },
78+ "total_strategy_equity" : 50000.0 ,
79+ }
80+
81+ plan = map_strategy_decision_to_plan (
82+ decision ,
83+ account_state = account_state ,
84+ strategy_profile = "semiconductor_rotation_income" ,
85+ )
86+
87+ self .assertEqual (plan ["execution" ]["trade_threshold_value" ], 250.0 )
88+ self .assertEqual (plan ["execution" ]["status_display" ], "risk-on" )
89+ self .assertEqual (plan ["execution" ]["signal_display" ], "signal" )
90+ self .assertEqual (plan ["execution" ]["investable_cash" ], 9000.0 )
5091
5192
5293if __name__ == "__main__" :
0 commit comments