from tradingagents.graph.xau_graph import XAUTradingGraph from tradingagents.xau_config import XAU_CONFIG from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() def run_xau_analysis(): """ Run the XAU trading-analysis workflow for a predetermined asset and date. Initializes the XAU trading graph with debug enabled and the module configuration, executes a propagation for the hard-coded asset ticker "GC=F" on "2024-05-10", and prints any generated macro and positioning analyst reports followed by the final trade decision. On failure, prints an error message and the exception traceback. """ print("Initializing XAU Trading System...") # Initialize the specialized XAU graph with its config xau_system = XAUTradingGraph(debug=True, config=XAU_CONFIG) # Define the asset and date for analysis # "GC=F" is the Yahoo Finance ticker for Gold futures. # The system will use this for price data but analyze "XAU" conceptually. asset_ticker = "GC=F" trade_date = "2024-05-10" print(f"Running analysis for asset: {asset_ticker} (Gold) on date: {trade_date}") # Propagate the state through the graph to get a decision try: final_state, decision = xau_system.propagate(asset_ticker, trade_date) print("\n" + "="*80) print("XAU Trading Analysis Complete") print("="*80) # Print the reports generated by the new agents if final_state.get("xau_macro_report"): print("\n--- Macro Analyst Report ---") print(final_state["xau_macro_report"]) if final_state.get("xau_positioning_report"): print("\n--- Positioning Analyst Report ---") print(final_state["xau_positioning_report"]) print("\n--- Final Trade Decision ---") print(decision) print("="*80) except Exception as e: print(f"\nAn error occurred during XAU analysis: {e}") import traceback traceback.print_exc() if __name__ == "__main__": run_xau_analysis()