Commit Graph

54 Commits

Author SHA1 Message Date
dtarkent2-sys 7c8d523680 Round 1: import upstream additions (TauricResearch/TradingAgents)
Pure file additions from upstream — zero conflict, zero risk to local
customizations. Cherry-picked individually rather than via merge.

New files:
- tradingagents/llm_clients/model_catalog.py — centralized model registry
- tradingagents/agents/managers/portfolio_manager.py — new PM (paired with
  upstream's risk_manager.py removal, deferred to a later round)
- tradingagents/__init__.py — package init
- tests/test_google_api_key.py
- tests/test_model_validation.py
- tests/test_ticker_symbol_handling.py
- .env.enterprise.example — reference template

Skipped (deferred to later rounds):
- Round 2: bug-fix cherry-picks (yfinance retry, look-ahead bias fix,
  PM-reads-trader fix, indicator normalization, etc.)
- Round 3: feat:add DeepSeek/Qwen/GLM provider support (b0f6058) —
  conflicts with local llm_clients/ customizations, needs careful merge
- Round 4: portfolio manager restructure (b8b2825/318adda) — replaces
  risk_manager.py which has local customizations, needs hand-port

Skipped entirely:
- Docker support (anti-Docker stack)
- Multi-language output (English-only arena)
- GPT-5.4 default flip (would undo a913416 glm-5.1 default)
- azure_client.py (not in arena roster)
- OpenRouter dynamic model selection (not in provider mix)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:20:16 -04:00
dtarkent2-sys 8c48c3cffd WIP: local TradingAgents customizations through 2026-04-13
Bulk commit of accumulated local changes on the dtarkent2-sys fork.
Spans agents, dataflows, llm_clients, graph orchestration, CLI, and
docs. Primary work areas:

- llm_clients/ — multi-LLM client layer (anthropic, google, openai,
  factory, base, validators) for swappable provider support
- dataflows/alpaca_data.py — Alpaca integration alongside existing
  alpha_vantage and y_finance flows
- agents/structured/ — portfolio, scoring, and tier1/2/3 layers
- agents/analysts, researchers, risk_mgmt — local prompt and logic
  customizations
- graph/ — orchestration tweaks (parallel_analysts, propagation,
  reflection, signal_processing, trading_graph)
- alembic scaffolding inherited from prior commit
- chainlit web UI design notes in docs/plans/

This is a single WIP snapshot to preserve work before any upstream
merge. History can be cleaned up with interactive rebase later.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:01:00 -04:00
dtarkent2-sys a913416613 chore: default deep_think_llm + quick_think_llm to glm-5.1:cloud
Switch the default LLM in tradingagents/default_config.py from
nemotron-3-nano:30b-cloud (which was producing low-fidelity
structured output across services) to glm-5.1:cloud. Canonical
values live in .env which is gitignored.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:06:37 -04:00
SharkQuant 2e37bc117d migrate off Railway, update Dockerfile and LLM clients 2026-04-11 22:51:22 -04:00
dtarkent2-sys ae18643103 chore: default model to nemotron-3-nano:30b-cloud
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:50:09 -04:00
dtarkent2-sys ac17d98974 fix: aggressive JSON fallback for LLMs that don't support structured output
- Use SystemMessage forcing JSON-only responses (no markdown)
- Provide concrete example JSON from schema fields
- Better JSON extraction: handles nested braces, code blocks, prose wrappers
- Fixes nemotron/minimax/other Ollama models returning prose instead of JSON

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:39:08 -04:00
dtarkent2-sys 1d3f5e9c86 fix: 10 reliability and observability fixes for trading pipeline
invoke_structured() catches ValidationError with safe defaults, ticker validation
(empty/length), 60s per-LLM-call timeout, event buffer capped at 5000, recursion
limit 50→25, tier 2 low-confidence DataFlags, tier 3 upstream confidence checks,
heartbeat JSON every 15s, data source attribution in all prompts, structured logging
replaces print()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 21:08:01 +00:00
dtarkent2-sys 84f7894768 feat: switch stock data to Alpaca Markets API with yfinance fallback
Alpaca provides 10k calls/min free with 7yr history via IEX feed.
Hybrid approach: Alpaca for price bars, snapshots, sector ETF perf,
and moving averages; yfinance for fundamentals (PE, margins, 13F).

- Add alpaca_data.py: bars, snapshots, MAs, sector ETF perf, news
- Update get_macro_indicators: sector ETF performance via Alpaca
- Update get_sector_rotation: compute relative strength vs SPY
- Update entry timing node: Alpaca MAs from actual bar data
- Add alpaca-py to requirements.txt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:23:58 +00:00
dtarkent2-sys 5e8c81e738 fix: 6 audit issues — missing await, regime range, pct_out scaling, ticker validation, dead code, flag merge
1. app.py: await _update_in_progress (coroutine was silently dropped)
2. models.py + tier1.py: regime_score_adjustment range ±2→±10 (was negligible on 0-100 scale)
3. y_finance.py: pct_out * 100 (was fraction, displayed as percent)
4. app.py: ticker validation accepts dots/hyphens (BRK.B, BF-B)
5. portfolio.py: wire _fetch_peer_basics into theme substitution (was dead code)
6. setup.py: accumulate global_flags across parallel agents (dict.update was dropping them)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:56:38 +00:00
dtarkent2-sys ee80a42971 feat: add regime awareness, smart-money tracking, theme substitution & position replacement
- MacroRegimeOutput: risk_appetite, liquidity_regime, regime_score_adjustment (-2 to +2)
- InstitutionalFlowOutput: 13F holders, insider transactions, short interest trend, smart_money_signal
- Scoring node applies regime adjustment to master score
- Theme Substitution Engine: identifies best expression of theme, ranks peers, flags overlap
- Position Replacement Agent: compares candidate to theme alternatives, flags replacements
- Pipeline: Scoring → Portfolio Analysis → Debate → Decision
- Final decision narrative includes theme context and replacement flags

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:46:03 +00:00
dtarkent2-sys 7ad9e1d1ce feat: rebuild as structured Pydantic equity ranking engine
Replace generic LLM debate system with a tiered, macro-aware equity
ranking pipeline where every agent returns Pydantic structured output
and scoring is deterministic Python — no prose drives downstream decisions.

Architecture: Validation → Tier 1 (Macro+Liquidity parallel) →
Tier 2 (8 agents parallel) → Scoring (Archetype+MasterScore) →
Tier 3 (Bull/Bear debate + Risk + FinalDecision) → END

Master Score: 25% business_quality + 20% macro + 15% institutional_flow
+ 10% valuation + 10% entry_timing + 10% earnings_revisions + 5% backlog
+ 5% crowding. Hard veto gates, confidence penalties, position role
assignment all computed deterministically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 21:30:46 +00:00
dtarkent2-sys 24c90bdd5d Fix crash when LLM requests unsupported indicator (e.g. vwap)
Return error message to LLM instead of crashing the pipeline.
Also list supported indicators in the tool docstring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 17:51:20 +00:00
dtarkent2-sys f8efe0113b Switch LLM models to glm-5:cloud via Ollama
Changed deep_think_llm and quick_think_llm from gpt-5.2/gpt-5-mini
to glm-5:cloud, backend_url to ollama.com/v1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 05:05:33 +00:00
dtarkent2-sys ba39a81e82 Fix parallel research/risk: use async+asyncio.gather instead of ThreadPoolExecutor
Sync ThreadPoolExecutor doesn't truly parallelize inside LangGraph nodes.
Switched to async functions with asyncio.to_thread() + asyncio.gather() —
the same pattern that works for the parallel analyst node.

Result: Research (Bull+Bear) and Risk (Agg+Con+Neu) now run concurrently.
Total analysis time reduced from ~450s to ~280s (~38% faster).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 18:01:54 +00:00
dtarkent2-sys 12e0d507c2 Switch parallel timing logs from logger.info to print for Railway visibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 17:18:46 +00:00
dtarkent2-sys 2484bd89e4 Switch parallel research/risk to sync ThreadPoolExecutor with timing logs
Use sync functions with pool.submit() instead of async+run_in_executor
to avoid potential asyncio event-loop interaction issues with LangGraph.
Added timing logs to diagnose parallelism.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:39:25 +00:00
dtarkent2-sys 7ff05328a8 Fix parallel research/risk: snapshot state to avoid proxy serialization
LangGraph state proxies serialize concurrent dict access, forcing
threads to run sequentially. Fix by snapshotting needed fields into
plain dicts before dispatching to ThreadPoolExecutor — same pattern
used by the working parallel analysts node.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:18:43 +00:00
dtarkent2-sys 3cd0c19b35 Parallelize research & risk debate stages for ~25% faster analysis
Run Bull+Bear researchers concurrently and all 3 risk analysts
(Aggressive/Conservative/Neutral) concurrently instead of sequentially.
With max_debate_rounds=1, there's no back-and-forth so parallel execution
is safe. Sequential mode is completely unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 14:45:59 +00:00
dtarkent2-sys 223879bc04 feat: parallelize analyst agents for ~3x speedup
Run all 4 analysts (Market, Social, News, Fundamentals) concurrently
using asyncio.gather instead of sequentially. Each analyst gets its own
isolated message state and tool-calling loop. Cuts analyst phase from
~8-9 min to ~2-3 min (total analysis from ~11 min to ~4-5 min).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 11:13:16 +00:00
Yijia Xiao 6cd35179fa
chore: clean up dependencies and fix Ollama auth
- Remove unused packages: praw, feedparser, eodhd, akshare, tushare, finnhub
- Fix Ollama requiring API key
2026-02-03 23:08:12 +00:00
Yijia Xiao 102b026d23
refactor: clean up codebase and streamline documentation
- Remove debug prints from vendor routing (interface.py)
- Simplify vendor fallback to only handle rate limits
- Reorder CLI provider menu: OpenAI, Google, Anthropic, xAI, OpenRouter, Ollama
- Remove dead files: local.py, reddit_utils.py, openai.py, google.py, googlenews_utils.py, yfin_utils.py
2026-02-03 22:27:20 +00:00
Yijia Xiao 54cdb146d0
feat: add footer statistics tracking with LangChain callbacks
- Add StatsCallbackHandler for tracking LLM calls, tool calls, and tokens
- Integrate callbacks into TradingAgentsGraph and all LLM clients
- Dynamic agent/report counts based on selected analysts
- Fix report completion counting (tied to agent completion)
2026-02-03 22:27:20 +00:00
Yijia Xiao b06936f420
fix: improve data vendor implementations and tool signatures
- Add get_global_news for Alpha Vantage
- Fix get_insider_transactions signature (remove unused curr_date param)
- Remove unnecessary default params from API calls (sort, limit, tab)
2026-02-03 22:27:20 +00:00
Yijia Xiao 3d040f8da4
feat: add yfinance support to accommodate community request for stability and quota 2026-02-03 22:27:20 +00:00
Yijia Xiao 50961b2477
refactor: rename risky/safe agents to aggressive/conservative 2026-02-03 22:27:20 +00:00
Yijia Xiao a3761bdd66
feat: update Ollama and OpenRouter model options
- Ollama: Add Qwen3 (8B), GPT-OSS (20B), GLM-4.7-Flash (30B)
- OpenRouter: Add NVIDIA Nemotron 3 Nano, Z.AI GLM 4.5 Air
- Add explicit Ollama provider handling in OpenAI client for consistency
2026-02-03 22:27:20 +00:00
Yijia Xiao d4dadb82fc
feat: add multi-provider LLM support with thinking configurations
Models added:
- OpenAI: GPT-5.2, GPT-5.1, GPT-5, GPT-5 Mini, GPT-5 Nano, GPT-4.1
- Anthropic: Claude Opus 4.5/4.1, Claude Sonnet 4.5/4, Claude Haiku 4.5
- Google: Gemini 3 Pro/Flash, Gemini 2.5 Flash/Flash Lite
- xAI: Grok 4, Grok 4.1 Fast (Reasoning/Non-Reasoning)

Configs updated:
- Add unified thinking_level for Gemini (maps to thinking_level for Gemini 3,
  thinking_budget for Gemini 2.5; handles Pro's lack of "minimal" support)
- Add OpenAI reasoning_effort configuration
- Add NormalizedChatGoogleGenerativeAI for consistent response handling

Fixes:
- Fix Bull/Bear researcher display truncation
- Replace ChromaDB with BM25 for memory retrieval
2026-02-03 22:27:20 +00:00
Yijia Xiao 79051580b8
feat: add multi-provider LLM support with factory pattern
- Add tradingagents/llm_clients/ with unified factory pattern
- Support OpenAI, Anthropic, Google, xAI, OpenRouter, Ollama, vLLM
- Replace direct LLM imports in trading_graph.py with create_llm_client()
- Handle provider-specific params (reasoning_effort, thinking_config)
2026-02-03 22:27:20 +00:00
Edward Sun 7bb2941b07 optimized yfin fetching to be much faster 2025-10-06 19:58:01 -07:00
Edward Sun c07dcf026b added fallbacks for tools 2025-10-03 22:40:09 -07:00
luohy15 d23fb539e9 minor fix 2025-09-30 13:27:48 +08:00
luohy15 b01051b9f4 Switch default data vendor
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 12:43:27 +08:00
luohy15 86bc0e793f minor fix 2025-09-27 00:04:59 +08:00
luohy15 6211b1132a Improve Alpha Vantage indicator column parsing with robust mapping
- Replace hardcoded column indices with column name lookup
- Add mapping for all supported indicators to their expected CSV column names
- Handle missing columns gracefully with descriptive error messages
- Strip whitespace from header parsing for reliability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 23:36:36 +08:00
luohy15 8b04ec307f minor fix 2025-09-26 23:25:33 +08:00
luohy15 0ab323c2c6 Add Alpha Vantage API integration as primary data provider
- Replace FinnHub with Alpha Vantage API in README documentation
- Implement comprehensive Alpha Vantage modules:
  - Stock data (daily OHLCV with date filtering)
  - Technical indicators (SMA, EMA, MACD, RSI, Bollinger Bands, ATR)
  - Fundamental data (overview, balance sheet, cashflow, income statement)
  - News and sentiment data with insider transactions
- Update news analyst tools to use ticker-based news search
- Integrate Alpha Vantage vendor methods into interface routing
- Maintain backward compatibility with existing vendor system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 22:57:50 +08:00
luohy15 a6734d71bc WIP 2025-09-26 16:17:50 +08:00
mirza-samad-ahmed-baig f704828f89 Fix: Prevent infinite loops, enable reflection, and improve logging 2025-07-03 17:43:40 +05:00
Yijia Xiao 718df34932
Merge pull request #29 from ZeroAct/save_results
Save results
2025-06-26 00:28:30 -04:00
Max Wong 43aa9c5d09
Local Ollama (#53)
- Fix typo 'Start' 'End'
- Add llama3.1 selection
- Use 'quick_think_llm' model instead of hard-coding GPT
2025-06-26 00:27:01 -04:00
Yijia Xiao 26c5ba5a78
Revert "Docker support and Ollama support (#47)" (#57)
This reverts commit 78ea029a0b.
2025-06-26 00:07:58 -04:00
Geeta Chauhan 78ea029a0b
Docker support and Ollama support (#47)
- Added support for running CLI and Ollama server via Docker
- Introduced tests for local embeddings model and standalone Docker setup
- Enabled conditional Ollama server launch via LLM_PROVIDER
2025-06-25 23:57:05 -04:00
Huijae Lee ee3d499894
Merge branch 'TauricResearch:main' into save_results 2025-06-25 08:43:19 +09:00
Yijia Xiao b575bd0941
Merge pull request #52 from TauricResearch/dev
Merge dev into main. Add support for Anthropic and OpenRouter.
2025-06-23 20:38:14 -04:00
Edward Sun 52284ce13c fixed anthropic support. Anthropic has different format of response when it has tool calls. Explicit handling added 2025-06-21 12:51:34 -07:00
Yijia Xiao c2f897fc67
Merge pull request #43 from AtharvSabde/patch-1
fundamentals_analyst.py (spelling mistake in instruction: Makrdown -> Markdown)
2025-06-19 15:05:08 -04:00
Atharv Sabde 2af7ef3d79
fundamentals_analyst.py(spelling mistake.markdown) 2025-06-19 21:48:16 +05:30
Edward Sun 7eaf4d995f update clear msg bc anthropic needs at least 1 msg in chat call 2025-06-15 23:14:47 -07:00
Edward Sun da84ef43aa main works, cli bugs 2025-06-15 22:20:59 -07:00
Edward Sun 90b23e72f5
Merge pull request #25 from maxer137/main
Add support for other backends, such as OpenRouter and Ollama
2025-06-15 16:06:20 -07:00