Commit Graph

255 Commits

Author SHA1 Message Date
google-labs-jules[bot] 811459b38f Add tests for `extract_content_string` error handling in `cli/main.py`
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 14:53:45 +00:00
google-labs-jules[bot] bdaf188b33 Fix Finnhub API error handling and add coverage
Extracted the API request logic in `finnhub_news.py` to a private `_fetch_company_news_data` helper to properly catch `Exception` and return an empty list without violating the `str` return type of the main `get_company_news` function. Explicitly allows `ThirdPartyTimeoutError` to propagate to preserve timeout behavior.

Added corresponding tests to mock generic API exceptions and invalid response types. Retained the test verifying fallback behavior for invalid numeric values within `get_insider_transactions`.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 14:51:29 +00:00
google-labs-jules[bot] 177d35ede5 🧪 Fix VIX trend logic and add extensive tests for macro regime short history edge cases
- Fixed `_signal_vix_trend` to correctly return neutral for insufficient history (`< 21`).
- Added `test_short_history_is_neutral` to `TestSignalVixTrend`.
- Extended coverage for short history and edge cases in `TestSignalCreditSpread`, `TestSignalYieldCurve`, `TestSignalMarketBreadth`, and `TestSignalSectorRotation`.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 14:48:20 +00:00
google-labs-jules[bot] 7ab7cd7591 perf: lazy load json parsing in PortfolioSnapshot
This commit optimizes `PortfolioSnapshot` instantiation when loaded from the DB or JSON dictionaries by removing the immediate `json.loads(holdings_snapshot)` parsing inside the `from_dict` constructor. Instead, it overrides `__getattribute__` to implement a lazy-loading pattern, where the `holdings_snapshot` string is only parsed into a Python dictionary the very first time the field is accessed.

    This optimization ensures that parsing large JSON payloads doesn't block the instantiation of snapshots, which is particularly beneficial in workflows that load a large historical series of snapshots but never access their `holdings_snapshot` field.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:32:52 +00:00
google-labs-jules[bot] 77694d49c9 Refactor classify_macro_regime into helper functions
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:31:07 +00:00
google-labs-jules[bot] a7f5f67f94 🧪 [testing improvement] Add unit tests for _clean_dataframe in stockstats_utils
Added tests to verify the dataframe cleaning logic in stockstats_utils.
Tests cover lowercasing of columns, handling non-string columns, and ensuring original dataframe is not mutated.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:30:52 +00:00
google-labs-jules[bot] 3bed14e5c1 🧹 fix: remove unused imports from agent_utils.py
Removed re-exported tool imports from `tradingagents/agents/utils/agent_utils.py` to declutter the file and prevent unnecessary dependency loading. Updated all downstream modules (tests, analysts, scanners, and the trading graph) to import the required tools directly from their respective source files in `tradingagents/agents/utils/`.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:30:43 +00:00
google-labs-jules[bot] 644ce57b9c test: add tests and parsing logic for text formats in _extract_top_sectors
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:28:35 +00:00
google-labs-jules[bot] 1129c0cd21 Refactor interface.py to remove unused imports in alpha_vantage.py
The file `tradingagents/dataflows/alpha_vantage.py` previously acted as an aggregator but did not use the imports it defined, leading to linter warnings (ruff). The dependencies in `tradingagents/dataflows/interface.py` were refactored to import directly from the specialized modules instead. This safely allowed removing all unused imports from `alpha_vantage.py`, improving code health and module clarity without affecting functionality.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:27:10 +00:00
google-labs-jules[bot] 0a53060ce9 Refactor `get_indicator` function in `alpha_vantage_indicator.py`
This change refactors the large monolithic `get_indicator` function by extracting large mapping dictionaries out of the function scope as constants and separating API fetching logic and CSV parsing logic into private helper functions. This drastically improves the maintainability and readability of `alpha_vantage_indicator.py` without introducing any behavioral changes.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:26:02 +00:00
google-labs-jules[bot] ab86ccb3a7 test: add tests for _fmt_pct in macro regime
Added `TestFmtPct` class to `tests/unit/test_macro_regime.py` to test the `_fmt_pct` function from `tradingagents.dataflows.macro_regime`.
The test covers `None`, positive, negative, and zero values.
Also updated `_fmt_pct` implementation to match the requested `+.1f` formatting.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:24:45 +00:00
google-labs-jules[bot] 86d1afc0fd 🧹 Remove unused import 'Path' from trading_graph.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:24:12 +00:00
google-labs-jules[bot] b9c4cf2859 Remove unused Annotated import from interface.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:23:52 +00:00
google-labs-jules[bot] 433af4d1e4 Add edge case test for short history in _signal_vix_trend
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:23:47 +00:00
google-labs-jules[bot] 9a6e8c5c7c Add edge case tests for _find_col in ttm_analysis
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:23:16 +00:00
google-labs-jules[bot] bb7d22d3a3 🧪 Add tests for _extract_article_data in yfinance_news.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:23:12 +00:00
google-labs-jules[bot] 369bc02ef5 🧹 Remove unused imports in trading_graph.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:22:55 +00:00
google-labs-jules[bot] 2663661be9 test: add edge case for sum constraints validation
Adds an edge case test in `test_config.py` to verify that `min_cash_pct` + `max_position_pct` can be exactly `1.0` without raising a `ValueError`.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:22:53 +00:00
google-labs-jules[bot] 404edc56b7 🧹 remove unused import _make_api_request from finnhub_scanner.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:22:49 +00:00
google-labs-jules[bot] 0955568391 refactor: remove unused imports in risk manager
Removed unused `import json` and `import time` from `tradingagents/agents/managers/risk_manager.py` to improve code health and cleanliness. Also removed unused variable `company_name`. Tested to ensure no functionality is affected.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:22:14 +00:00
google-labs-jules[bot] f82a810c3b Remove unused pandas import and clean up finnhub_stock.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 08:21:43 +00:00
copilot-swe-agent[bot] 33b61910e3 Address code review: clarify token estimation descriptions
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/94532c4f-3d37-464e-9a74-3c2e9899a532
2026-03-21 02:35:26 +00:00
copilot-swe-agent[bot] ada257ac3e Update portfolio flow diagram, add token estimation per model, add CLI/test commands to README
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/94532c4f-3d37-464e-9a74-3c2e9899a532
2026-03-21 02:34:23 +00:00
copilot-swe-agent[bot] 59acce14a9 Initial plan 2026-03-21 02:23:53 +00:00
ahmet guzererler 5799bb3f00
Merge pull request #42 from aguzererler/feat/portfolio-cli
feat: Portfolio Manager Auto and Check CLI Commands
2026-03-21 03:21:00 +01:00
Ahmet Guzererler 1d589c0621 feat(portfolio): add end-to-end auto and check-portfolio commands 2026-03-21 03:18:20 +01:00
Ahmet Guzererler d7a932bc83 feat(portfolio): integrate portfolio manager into cli, add pm command 2026-03-21 03:10:06 +01:00
ahmet guzererler 69e6bee34b
Merge pull request #40 from aguzererler/fix/remove-unused-timedelta-import-16675261317014341937
🧹 Remove unused `timedelta` import in finnhub_indicators.py
2026-03-21 02:56:10 +01:00
ahmet guzererler 5fed2ff3c0
Merge pull request #41 from aguzererler/testing/memory-tokenization-5207856762792060376
🧪 Add tests for memory tokenization
2026-03-21 02:55:53 +01:00
google-labs-jules[bot] 3b9eef380d test: add unit tests for _tokenize in FinancialSituationMemory
Adds comprehensive tests for `_tokenize` method inside
`tradingagents/agents/utils/memory.py` focusing on regex behavior
`\b\w+\b` with case mixing, punctuation, edges (empty string),
numbers, underscores, quoting, and hyphenation strings.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:54:23 +00:00
google-labs-jules[bot] 5fa0fe3178 🧹 Remove unused `timedelta` import in finnhub_indicators.py
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:54:05 +00:00
ahmet guzererler 3e90f13bf5
Merge pull request #39 from aguzererler/chore/remove-unused-json-import-11845664957182921108
🧹 chore: remove unused json import in research_manager.py
2026-03-21 02:53:14 +01:00
google-labs-jules[bot] 8bc92344f8 🧹 chore: remove unused json import in research_manager.py
Removed the unused `import json` line from `tradingagents/agents/managers/research_manager.py` to improve code health and maintainability.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:52:39 +00:00
ahmet guzererler 25457930ae
Merge pull request #36 from aguzererler/fix-unused-imports-utils-14929046510086826793
🧹 Remove unused imports in utils.py
2026-03-21 02:39:50 +01:00
ahmet guzererler 2becf7fca4
Merge pull request #37 from aguzererler/fix-max-positions-validation-test-9122767223538480688
🧪 Add comprehensive unit tests for portfolio config validation
2026-03-21 02:36:49 +01:00
ahmet guzererler 279081d3c7
Merge pull request #38 from aguzererler/perf-optimize-json-extraction-regex-3266597981569245080
 Pre-compile regex in JSON extraction utility
2026-03-21 02:36:33 +01:00
google-labs-jules[bot] 646fe40754 perf: pre-compile regex patterns in extract_json util
Compile THINK_PATTERN and FENCE_PATTERN at the module level to improve
the performance of extract_json by avoiding redundant regex compilation
during function calls.

Measured a ~5% performance improvement in an isolated benchmark.
- Baseline: 51.98 us/call
- Optimized: 49.26 us/call

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:34:43 +00:00
google-labs-jules[bot] a14de62f1e 🧪 Add comprehensive unit tests for portfolio config validation
Implemented `tests/portfolio/test_config.py` to test the `validate_config` function in `tradingagents/portfolio/config.py`.

Key improvements:
- Added `test_validate_config_max_positions_invalid` to verify `max_positions` boundary conditions (0, -1).
- Added happy path test `test_validate_config_valid`.
- Added tests for `max_position_pct`, `max_sector_pct`, `min_cash_pct`, and `default_budget` validation.
- Verified that tests correctly catch bugs by temporarily disabling validation logic.

These tests ensure the portfolio manager configuration is robustly validated before use.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:34:31 +00:00
google-labs-jules[bot] 13e5534043 chore: remove unused imports `os` and `json` from `tradingagents/dataflows/utils.py`
Identified by `ruff check`, these imports were not being used in the module. Removing them improves code health and maintainability.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 01:34:15 +00:00
ahmet guzererler c3954c966d
Merge pull request #34 from aguzererler/copilot/refactor-agent-workflows-and-risk-metrics
feat: portfolio risk metrics computation + LangChain agent tools
2026-03-21 02:31:57 +01:00
ahmet guzererler 9d8566f878
Merge branch 'main' into copilot/refactor-agent-workflows-and-risk-metrics 2026-03-21 02:30:18 +01:00
ahmet guzererler 9f72dbaea5
Merge pull request #33 from aguzererler/copilot/extend-portfolio-manager-implementation 2026-03-20 17:30:42 +01:00
copilot-swe-agent[bot] 96a2c79cb3 Implement Portfolio Manager Phases 2-5: risk evaluation, candidate prioritization, holding reviewer agent, PM decision agent, trade executor, and portfolio graph orchestration
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-20 14:44:22 +00:00
copilot-swe-agent[bot] 066460a501 feat: add portfolio risk metrics module and LangChain agent tools
- tradingagents/portfolio/risk_metrics.py: pure-Python computation of
  Sharpe, Sortino, VaR, max drawdown, beta, sector concentration from
  PortfolioSnapshot NAV history — no LLM, no external dependencies
- tradingagents/portfolio/__init__.py: export compute_risk_metrics
- tradingagents/agents/utils/portfolio_tools.py: 4 LangChain tools
  wrapping Holding.enrich, Portfolio.enrich, ReportStore APIs, and
  compute_risk_metrics so agents can access portfolio data without
  reimplementing computations
- tests/portfolio/test_risk_metrics.py: 48 tests for risk metrics
- tests/unit/test_portfolio_tools.py: 19 tests for portfolio tools
- tests/portfolio/test_repository.py: fix pre-existing import error

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-20 14:42:43 +00:00
copilot-swe-agent[bot] 1444e8438c feat: Portfolio Manager Phases 2-5 — risk evaluation, candidate prioritization, LLM agents, trade executor
- tradingagents/portfolio/risk_evaluator.py: pure-Python risk metrics
  (log returns, Sharpe, Sortino, VaR, max drawdown, beta, sector
  concentration, portfolio/holding aggregation, constraint checking)
- tradingagents/portfolio/candidate_prioritizer.py: conviction × thesis ×
  diversification × held_penalty scoring; sorted candidate ranking
- tradingagents/portfolio/trade_executor.py: executes BUY/SELL decisions
  (SELLs first), pre-flight constraint checks, EOD snapshot
- tradingagents/agents/portfolio/holding_reviewer.py: LLM agent using
  run_tool_loop() — reviews all holdings, outputs HOLD/SELL JSON
- tradingagents/agents/portfolio/pm_decision_agent.py: pure-reasoning LLM
  agent (no tools) — produces structured BUY/SELL/HOLD decision JSON
- tradingagents/portfolio/portfolio_states.py: PortfolioManagerState
  (MessagesState + Annotated _last_value reducers)
- tradingagents/graph/portfolio_setup.py: PortfolioGraphSetup — sequential
  6-node workflow with factory-pattern non-LLM nodes
- tradingagents/graph/portfolio_graph.py: PortfolioGraph — mirrors
  ScannerGraph pattern with mid/deep_think LLM tiers
- tests/portfolio/test_risk_evaluator.py: 28 tests (pure Python)
- tests/portfolio/test_candidate_prioritizer.py: 10 tests (pure Python)
- tests/portfolio/test_trade_executor.py: 10 tests (MagicMock repo)
- tradingagents/portfolio/__init__.py: exports new symbols

All 93 tests pass (4 integration skipped, no regressions).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-20 14:38:48 +00:00
copilot-swe-agent[bot] c94c3373b2 Initial plan for portfolio manager phases 2-5
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-20 14:27:37 +00:00
copilot-swe-agent[bot] 94c4a2e43d Initial plan 2026-03-20 14:27:11 +00:00
copilot-swe-agent[bot] 766e60234e Initial plan 2026-03-20 14:20:24 +00:00
ahmet guzererler 3e9322ae4b
Merge pull request #32 from aguzererler/copilot/create-data-foundation-layer
feat: implement Portfolio models, ReportStore, tests; fix SQL constraint & document float decision
2026-03-20 14:07:15 +01:00
Ahmet Guzererler a17e5f3707 feat: complete portfolio data foundation — psycopg2 client, repository, tests
Replace supabase-py stubs with working psycopg2 implementation using
Supabase pooler connection string. Implement full business logic in
repository (avg cost basis, cash accounting, trade recording, snapshots).
Add 12 unit tests + 4 integration tests (51 total portfolio tests pass).
Fix cash_pct bug in models.py, update docs for psycopg2 + pooler pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 14:06:50 +01:00