mirror of
https://github.com/farcasclaudiu/TradingAgents.git
synced 2026-06-22 05:01:20 +03:00
4cbd4b086f
Long analyses can take many minutes; a crash or interruption forced users to re-run from scratch and re-pay every LLM call. This adds an opt-in checkpoint layer backed by per-ticker SQLite databases so the graph resumes from the last successful node. How to use: - CLI: tradingagents analyze --checkpoint - CLI: tradingagents analyze --clear-checkpoints - Python: config["checkpoint_enabled"] = True Lifecycle: - propagate() recompiles the graph with a SqliteSaver when enabled and injects a deterministic thread_id derived from ticker+date so the same ticker+date resumes while a different date starts fresh. - On successful completion the per-thread checkpoint rows are cleared. - The context manager is closed in a try/finally so a crash never leaks the SQLite connection or leaves the graph in checkpoint mode. Storage: ~/.tradingagents/cache/checkpoints/<TICKER>.db (override via TRADINGAGENTS_CACHE_DIR). The checkpointer module is new (tradingagents/graph/checkpointer.py) and the GraphSetup now returns the uncompiled workflow so it can be recompiled with a saver when needed. Adds langgraph-checkpoint-sqlite>=2.0.0 dependency. 3 new tests verify the crash/resume cycle and that a different date starts fresh.
42 lines
2.0 KiB
Python
42 lines
2.0 KiB
Python
import os
|
|
|
|
_TRADINGAGENTS_HOME = os.path.join(os.path.expanduser("~"), ".tradingagents")
|
|
|
|
DEFAULT_CONFIG = {
|
|
"project_dir": os.path.abspath(os.path.join(os.path.dirname(__file__), ".")),
|
|
"results_dir": os.getenv("TRADINGAGENTS_RESULTS_DIR", os.path.join(_TRADINGAGENTS_HOME, "logs")),
|
|
"data_cache_dir": os.getenv("TRADINGAGENTS_CACHE_DIR", os.path.join(_TRADINGAGENTS_HOME, "cache")),
|
|
"memory_log_path": os.getenv("TRADINGAGENTS_MEMORY_LOG_PATH", os.path.join(_TRADINGAGENTS_HOME, "memory", "trading_memory.md")),
|
|
# LLM settings
|
|
"llm_provider": "openai",
|
|
"deep_think_llm": "gpt-5.4",
|
|
"quick_think_llm": "gpt-5.4-mini",
|
|
"backend_url": "https://api.openai.com/v1",
|
|
# Provider-specific thinking configuration
|
|
"google_thinking_level": None, # "high", "minimal", etc.
|
|
"openai_reasoning_effort": None, # "medium", "high", "low"
|
|
"anthropic_effort": None, # "high", "medium", "low"
|
|
# Checkpoint/resume: when True, LangGraph saves state after each node
|
|
# so a crashed run can resume from the last successful step.
|
|
"checkpoint_enabled": False,
|
|
# Output language for analyst reports and final decision
|
|
# Internal agent debate stays in English for reasoning quality
|
|
"output_language": "English",
|
|
# Debate and discussion settings
|
|
"max_debate_rounds": 1,
|
|
"max_risk_discuss_rounds": 1,
|
|
"max_recur_limit": 100,
|
|
# Data vendor configuration
|
|
# Category-level configuration (default for all tools in category)
|
|
"data_vendors": {
|
|
"core_stock_apis": "yfinance", # Options: alpha_vantage, yfinance
|
|
"technical_indicators": "yfinance", # Options: alpha_vantage, yfinance
|
|
"fundamental_data": "yfinance", # Options: alpha_vantage, yfinance
|
|
"news_data": "yfinance", # Options: alpha_vantage, yfinance
|
|
},
|
|
# Tool-level configuration (takes precedence over category-level)
|
|
"tool_vendors": {
|
|
# Example: "get_stock_data": "alpha_vantage", # Override category default
|
|
},
|
|
}
|