TradingAgents/main.py

34 lines
1.3 KiB
Python
Raw Normal View History

from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Create a custom config
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "google" # Use a different model
config["backend_url"] = "https://generativelanguage.googleapis.com/v1" # Use a different backend
config["deep_think_llm"] = "gemini-2.0-flash" # Use a different model
config["quick_think_llm"] = "gemini-2.0-flash" # Use a different model
config["max_debate_rounds"] = 1 # Increase debate rounds
# Configure data vendors (default uses Alpha Vantage for real-time data)
config["data_vendors"] = {
"core_stock_apis": "alpha_vantage", # Options: alpha_vantage, yahoo_finance, local
"technical_indicators": "alpha_vantage", # Options: alpha_vantage, yahoo_finance, local
"fundamental_data": "alpha_vantage", # Options: alpha_vantage, openai, local
"news_data": "alpha_vantage", # Options: alpha_vantage, openai, google, local
}
# Initialize with custom config
ta = TradingAgentsGraph(debug=True, config=config)
# forward propagate
_, decision = ta.propagate("NVDA", "2024-05-10")
print(decision)
# Memorize mistakes and reflect
# ta.reflect_and_remember(1000) # parameter is the position returns