2025-06-05 03:08:28 -07:00
|
|
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
|
|
|
|
from tradingagents.default_config import DEFAULT_CONFIG
|
|
|
|
|
|
2025-09-26 23:58:51 +08:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
# Load environment variables from .env file
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
2025-06-26 00:07:58 -04:00
|
|
|
# Create a custom config
|
|
|
|
|
config = DEFAULT_CONFIG.copy()
|
2025-09-30 11:11:05 +08:00
|
|
|
config["deep_think_llm"] = "gpt-4o-mini" # Use a different model
|
|
|
|
|
config["quick_think_llm"] = "gpt-4o-mini" # Use a different model
|
2025-06-26 00:07:58 -04:00
|
|
|
config["max_debate_rounds"] = 1 # Increase debate rounds
|
2025-06-05 03:08:28 -07:00
|
|
|
|
2025-09-30 11:11:05 +08:00
|
|
|
# Configure data vendors (default uses yfinance and alpha_vantage)
|
2025-09-26 23:52:26 +08:00
|
|
|
config["data_vendors"] = {
|
2025-09-30 11:11:05 +08:00
|
|
|
"core_stock_apis": "yfinance", # Options: yfinance, alpha_vantage, local
|
|
|
|
|
"technical_indicators": "yfinance", # Options: yfinance, alpha_vantage, local
|
|
|
|
|
"fundamental_data": "alpha_vantage", # Options: openai, alpha_vantage, local
|
|
|
|
|
"news_data": "alpha_vantage", # Options: openai, alpha_vantage, google, local
|
2025-09-26 23:52:26 +08:00
|
|
|
}
|
|
|
|
|
|
2025-06-26 00:07:58 -04:00
|
|
|
# Initialize with custom config
|
|
|
|
|
ta = TradingAgentsGraph(debug=True, config=config)
|
2025-06-05 03:08:28 -07:00
|
|
|
|
2025-06-26 00:07:58 -04:00
|
|
|
# forward propagate
|
|
|
|
|
_, decision = ta.propagate("NVDA", "2024-05-10")
|
|
|
|
|
print(decision)
|
2025-06-05 03:08:28 -07:00
|
|
|
|
2025-06-26 00:07:58 -04:00
|
|
|
# Memorize mistakes and reflect
|
|
|
|
|
# ta.reflect_and_remember(1000) # parameter is the position returns
|