@@ -797,10 +797,10 @@ def get_analysis_status(task_id: str) -> TaskStatus:
797797 analysis_summary = record .analysis_summary ,
798798 ),
799799 strategy = ReportStrategy (
800- ideal_buy = str (getattr (record , 'ideal_buy' , None )) if getattr ( record , 'ideal_buy' , None ) is not None else None ,
801- secondary_buy = str (getattr (record , 'secondary_buy' , None )) if getattr ( record , 'secondary_buy' , None ) is not None else None ,
802- stop_loss = str (getattr (record , 'stop_loss' , None )) if getattr ( record , 'stop_loss' , None ) is not None else None ,
803- take_profit = str (getattr (record , 'take_profit' , None )) if getattr ( record , 'take_profit' , None ) is not None else None ,
800+ ideal_buy = _stringify_report_strategy_value (getattr (record , 'ideal_buy' , None )),
801+ secondary_buy = _stringify_report_strategy_value (getattr (record , 'secondary_buy' , None )),
802+ stop_loss = _stringify_report_strategy_value (getattr (record , 'stop_loss' , None )),
803+ take_profit = _stringify_report_strategy_value (getattr (record , 'take_profit' , None )),
804804 ),
805805 ).model_dump ()
806806 return TaskStatus (
@@ -872,6 +872,14 @@ def _load_sync_fundamental_sources(
872872 return None , None
873873
874874
875+ def _stringify_report_strategy_value (value : Any ) -> Optional [str ]:
876+ if value is None :
877+ return None
878+ if isinstance (value , str ):
879+ return value
880+ return str (value )
881+
882+
875883def _build_analysis_report (
876884 report_data : Dict [str , Any ],
877885 query_id : str ,
@@ -932,10 +940,10 @@ def _build_analysis_report(
932940 strategy = None
933941 if strategy_data :
934942 strategy = ReportStrategy (
935- ideal_buy = strategy_data .get ("ideal_buy" ),
936- secondary_buy = strategy_data .get ("secondary_buy" ),
937- stop_loss = strategy_data .get ("stop_loss" ),
938- take_profit = strategy_data .get ("take_profit" )
943+ ideal_buy = _stringify_report_strategy_value ( strategy_data .get ("ideal_buy" ) ),
944+ secondary_buy = _stringify_report_strategy_value ( strategy_data .get ("secondary_buy" ) ),
945+ stop_loss = _stringify_report_strategy_value ( strategy_data .get ("stop_loss" ) ),
946+ take_profit = _stringify_report_strategy_value ( strategy_data .get ("take_profit" ) )
939947 )
940948
941949 extracted_fundamental = extract_fundamental_detail_fields (
0 commit comments