@@ -247,6 +247,7 @@ class ExecutionCycleResult:
247247 skip_logs : tuple [str , ...]
248248 note_logs : tuple [str , ...]
249249 action_done : bool
250+ dry_run_orders : tuple [dict , ...] = ()
250251
251252
252253DEFAULT_SAFE_HAVEN_CASH_SUBSTITUTE_THRESHOLD_USD = 1000.0
@@ -257,6 +258,13 @@ def _noop_sleep(_seconds):
257258 return None
258259
259260
261+ def _coerce_order_quantity (value ):
262+ try :
263+ return float (str (value ).replace ("," , "" ).strip ())
264+ except (TypeError , ValueError ):
265+ return value
266+
267+
260268def _safe_haven_cash_symbols (* , portfolio : dict , allocation : dict ) -> tuple [str , ...]:
261269 symbols : list [str ] = []
262270 for symbol in allocation .get ("safe_haven_symbols" , ()):
@@ -565,6 +573,7 @@ def execute_rebalance_cycle(
565573 logs : list [str ] = []
566574 skip_logs : list [str ] = []
567575 note_logs : list [str ] = []
576+ dry_run_orders : list [dict ] = []
568577 small_account_cash_note_keys : set [str ] = set ()
569578 action_done = False
570579 sell_submitted = False
@@ -678,6 +687,18 @@ def record_dry_run(symbol, side, quantity, price, *, order_type):
678687 price_text = f"${ price :.2f} " if price is not None else translator ("order_type_market" )
679688 side_key = "side_buy" if str (side ).lower () == "buy" else "side_sell"
680689 order_type_key = "order_type_limit" if order_type == "limit" else "order_type_market"
690+ order_payload = {
691+ "symbol" : str (symbol or "" ).strip ().upper (),
692+ "side" : str (side or "" ).strip ().lower (),
693+ "quantity" : _coerce_order_quantity (quantity ),
694+ "order_type" : str (order_type or "" ).strip ().lower (),
695+ "status" : "dry_run" ,
696+ }
697+ if price is not None :
698+ order_payload ["price" ] = round (float (price ), 4 )
699+ if order_type == "limit" :
700+ order_payload ["limit_price" ] = round (float (price ), 4 )
701+ dry_run_orders .append (order_payload )
681702 message = translator (
682703 "dry_run_order" ,
683704 side = translator (side_key ),
@@ -1110,4 +1131,5 @@ def record_dry_run(symbol, side, quantity, price, *, order_type):
11101131 skip_logs = tuple (skip_logs ),
11111132 note_logs = tuple (note_logs ),
11121133 action_done = action_done ,
1134+ dry_run_orders = tuple (dry_run_orders ),
11131135 )
0 commit comments