Commit Graph

65 Commits

Author SHA1 Message Date
ahmet guzererler e0b882ed75
Merge pull request #75 from aguzererler/optimize-sell-batching-17320376887335337420
 Batch database writes for portfolio SELL operations
2026-03-21 23:02:52 +01:00
ahmet guzererler 442b38dff4
Merge pull request #69 from aguzererler/copilot/review-financial-tools-implementation
Financial tools analysis doc and fix YoY revenue growth off-by-one
2026-03-21 22:41:55 +01:00
google-labs-jules[bot] 1ed46937d7 perf(portfolio): batch database writes during bulk SELL executions
Replaces the O(N) database operations in the `TradeExecutor`'s
`execute_decisions` SELL loop with a single `batch_remove_holdings`
call to the repository. The new repository method calculates updates
in memory, resolves duplicate operations on the same ticker, and issues
the updates via newly implemented `psycopg2.extras.execute_batch`
routines on the `SupabaseClient`.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 20:06:45 +00:00
copilot-swe-agent[bot] 92ebc13ce4 Add API consumption estimation module and CLI command
- New tradingagents/api_usage.py: Pre-run estimation of API calls per vendor
  for analyze, scan, and pipeline commands. Includes Alpha Vantage tier
  assessment (free: 25/day vs premium: 75/min).
- New CLI command: `estimate-api [analyze|scan|pipeline|all]`
- Enhanced observability: RunLogger.summary() now includes vendor_methods
  breakdown (vendor → method → call count)
- Enhanced CLI output: All 3 command summaries (analyze, scan, pipeline)
  now show per-vendor breakdown and Alpha Vantage assessment after runs
- 32 new tests in tests/unit/test_api_usage.py

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/bb80e772-3e03-420e-bb0e-76cfdde14a04
2026-03-21 17:25:26 +00:00
copilot-swe-agent[bot] a8ccff31a0 Add YoY edge case tests for 5 and 4 quarter scenarios
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/b594017b-ed84-4786-9b81-200a78eb5d76
2026-03-21 16:59:03 +00:00
copilot-swe-agent[bot] 3d76acf17d Add financial tools analysis doc and fix YoY revenue growth bug in TTM analysis
- Create docs/FINANCIAL_TOOLS_ANALYSIS.md with comprehensive 4-point analysis:
  1. Implementation accuracy review for all indicators and metrics
  2. Library assessment (stockstats vs TA-Lib vs pandas-ta)
  3. Alpha Vantage debate (local calc vs API-fetched)
  4. Data flow & API mapping for every financial tool
- Fix off-by-one in ttm_analysis.py: YoY revenue used quarterly[-4]
  (3 quarters back) instead of quarterly[-5] (4 quarters = 1 year back)
- Add test_revenue_yoy_is_four_quarters_back test to validate the fix

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/b594017b-ed84-4786-9b81-200a78eb5d76
2026-03-21 16:57:21 +00:00
google-labs-jules[bot] c8465af163 🧪 Resolve PRs #56, #58, and #60
- Added edge case test for `_find_col` in `tests/unit/test_ttm_analysis.py` (from PR #56).
- Enhanced `_clean_dataframe` in `tradingagents/dataflows/stockstats_utils.py` to parse dates, drop invalid rows, fill price gaps, and lowercase columns (combining PRs #58 and #60).
- Expanded the test suite in `tests/unit/test_stockstats_utils.py` to cover the new `_clean_dataframe` functionality.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 16:51:49 +00:00
ahmet guzererler 2ec8a17216
Merge pull request #54 from aguzererler/test-macro-regime-fmt-pct-18208719821293052000
🧪 Add tests for `_fmt_pct` in macro regime
2026-03-21 17:36:20 +01:00
ahmet guzererler 7b9510a99b
Merge pull request #61 from aguzererler/fix/agent-utils-unused-imports-948671579039994874
🧹 fix: remove unused imports from agent_utils.py
2026-03-21 17:35:19 +01:00
ahmet guzererler 86a0f5d9b7
Merge pull request #59 from aguzererler/testing/industry-deep-dive-parsing-12762969703991793840
🧪 test: add tests and parsing logic for text formats in _extract_top_sectors
2026-03-21 17:34:47 +01:00
ahmet guzererler cce5755b30
Merge pull request #62 from aguzererler/test-stockstats-utils-15966200471023157106
🧪 [testing improvement] Add unit tests for _clean_dataframe in stockstats_utils
2026-03-21 17:29:41 +01:00
ahmet guzererler b0424a36d7
Merge pull request #66 from aguzererler/jules-17548469684748509551-99819dec
🧪 [Fix Finnhub API error handling and add coverage]
2026-03-21 17:27:49 +01:00
ahmet guzererler 0dc6236e20
Merge pull request #67 from aguzererler/testing/cli-extract-content-string-6775172434327225745
🧪 [Testing Improvement] Add tests for `extract_content_string` in `cli/main.py`
2026-03-21 17:27:21 +01:00
ahmet guzererler 5c91aa8bb3
Merge pull request #50 from aguzererler/test-ttm-analysis-find-col-8347777247783205733
🧪 Add unit tests for _find_col in ttm_analysis
2026-03-21 17:26:22 +01:00
ahmet guzererler e5dcfb0e25
Merge pull request #49 from aguzererler/test-extract-article-data-17131555993247333235
🧪 Improve test coverage for `_extract_article_data`
2026-03-21 17:25:19 +01:00
ahmet guzererler 319feac087
Merge pull request #65 from aguzererler/testing-macro-regime-edge-cases-7674628334263228754
🧪 Fix VIX trend logic and add extensive tests for macro regime short history edge cases
2026-03-21 17:23:38 +01:00
ahmet guzererler 0313cc629e
Merge pull request #47 from aguzererler/fix/test-config-sum-constraints-edge-case-6454385375638160819
🧪 test: add edge case for portfolio config sum constraints
2026-03-21 17:20:25 +01:00
google-labs-jules[bot] 6f052fffea 🧪 Implement robust tool call parsing and unit tests
- Replaced potentially unsafe or missing tool call parsing logic with `ast.literal_eval` in `cli/main.py`.
- Created a new `parse_tool_call` helper to handle fallback parsing for LLM tool calls formatted as strings.
- Added comprehensive unit tests in `tests/unit/test_cli_main_tools.py` verifying behavior for valid strings, `ValueError`, `SyntaxError`, dicts, and objects.

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-21 14:56:12 +00:00
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] 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] 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] 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] 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] 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
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
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
ahmet guzererler 9d8566f878
Merge branch 'main' into copilot/refactor-agent-workflows-and-risk-metrics 2026-03-21 02:30:18 +01: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
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
copilot-swe-agent[bot] aa4dcdeb80 feat: implement Portfolio models, ReportStore, and tests; fix SQL constraint
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-20 11:16:39 +00:00
copilot-swe-agent[bot] f1cabe7a4a feat: portfolio manager data foundation — docs, SQL migration, and module scaffolding
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-20 10:40:48 +00:00
Copilot 179e55f264
fix(tests): complete PR #26 — enforce socket isolation in unit tier and add test suite reference doc (#30)
* Initial plan

* fix(tests): complete PR #26 — move integration tests to tests/integration/ and fix 4 failing unit tests

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

* docs: create docs/testing.md — comprehensive test suite reference with 5 Mermaid flowcharts

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-19 17:41:25 +01:00
ahmet guzererler d92fd9cab1
feat: NotebookLM sync with date-specific sources and consolidation (#28) 2026-03-19 15:39:25 +01:00
Ahmet Guzererler 57c9b3ecaa refactor(tests): consolidate live-API tests into integration/, move mocked tests to unit/
- Replaced 7 duplicate live-API test files in tests/ root with:
  - tests/integration/test_scanner_live.py — consolidated scanner + yfinance + vendor fallback tests (marked @pytest.mark.integration, excluded from default run)
  - tests/e2e/test_llm_e2e.py — LLM e2e test extracted from test_scanner_comprehensive
  - tests/unit/test_industry_deep_dive.py — mocked _extract_top_sectors + run_tool_loop tests
  - tests/unit/test_scanner_fallback.py — mocked AV failover tests
- Removed record_mode hardcode from integration/conftest.py (VCR.py cannot intercept curl_cffi used by yfinance; integration tests run live against real APIs on demand)

Deleted: test_scanner_tools, test_scanner_end_to_end, test_scanner_complete_e2e,
         test_scanner_final, test_scanner_comprehensive, test_scanner_fallback,
         test_industry_deep_dive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 14:24:52 +01:00
Ahmet Guzererler 8c9183cf10 Add integration and unit tests for scanner routing, TTM analysis, vendor fail-fast, and yfinance data layer
- Implement integration tests for scanner vendor routing, ensuring correct routing to Alpha Vantage and fallback to yfinance.
- Create comprehensive unit tests for TTM analysis, covering metrics computation and report formatting.
- Introduce fail-fast vendor routing tests to verify immediate failure for methods not in FALLBACK_ALLOWED.
- Develop extensive integration tests for the yfinance data layer, mocking external calls to validate functionality across various financial data retrieval methods.
2026-03-19 13:51:57 +01:00
ahmet guzererler a90f14c086
feat: unified report paths, structured observability logging, and memory system update (#22)
* gitignore

* feat: unify report paths under reports/daily/{date}/ hierarchy

All generated artifacts now land under a single reports/ tree:
- reports/daily/{date}/market/ for scan results (was results/macro_scan/)
- reports/daily/{date}/{TICKER}/ for per-ticker analysis (was reports/{TICKER}_{timestamp}/)
- reports/daily/{date}/{TICKER}/eval/ for eval logs (was eval_results/{TICKER}/...)

Adds tradingagents/report_paths.py with centralized path helpers used by
CLI commands, trading graph, and pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: structured observability logging for LLM, tool, and vendor calls

Add RunLogger (tradingagents/observability.py) that emits JSON-lines events
for every LLM call (model, agent, tokens in/out, latency), tool invocation
(tool name, args, success, latency), data vendor call (method, vendor,
success/failure, latency), and report save.

Integration points:
- route_to_vendor: log_vendor_call() on every try/catch
- run_tool_loop: log_tool_call() on every tool invoke
- ScannerGraph: new callbacks param, passes RunLogger.callback to all LLM tiers
- pipeline/macro_bridge: picks up RunLogger from thread-local, passes to TradingAgentsGraph
- cli/main.py: one RunLogger per command (analyze/scan/pipeline), write_log()
  at end, summary line printed to console

Log files co-located with reports:
  reports/daily/{date}/{TICKER}/run_log.jsonl   (analyze)
  reports/daily/{date}/market/run_log.jsonl     (scan)
  reports/daily/{date}/run_log.jsonl            (pipeline)

Also fix test_long_response_no_nudge: update "A"*600 → "A"*2100 to match
MIN_REPORT_LENGTH=2000 threshold set in an earlier commit.

Update memory system context files (ARCHITECTURE, COMPONENTS, CONVENTIONS,
GLOSSARY, CURRENT_STATE) to document observability and report path systems.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 09:06:40 +01:00
Copilot 3b6e399563
Resolve merge conflicts after PR #18 merge into main (#19)
* feat: add extract_json() utility for robust LLM JSON parsing

Handles DeepSeek R1 <think> blocks, markdown code fences, and
preamble/postamble text that LLMs wrap around JSON output.
Applied to macro_synthesis, macro_bridge, and CLI scan output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: opt-in vendor fallback — fail-fast by default (ADR 011)

Silent cross-vendor fallback corrupts signal quality when data contracts
differ (e.g., AV news has sentiment scores yfinance lacks). Only methods
with fungible data contracts (OHLCV, indices, sector/industry perf,
market movers) now get fallback. All others raise immediately.

- Add FALLBACK_ALLOWED whitelist to interface.py
- Rewrite route_to_vendor() with fail-fast/fallback branching
- Improve error messages with method name, vendors tried, and exception chaining
- Add 11 new tests in test_vendor_failfast.py
- Update ADRs 002 (superseded), 008, 010; create ADR 011

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Initial plan

* fix: address PR #18 review findings - type safety, import ordering, EOF newline

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

* fix: add inline comments explaining combined ValueError catch in json_utils.py

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

---------

Co-authored-by: Ahmet Guzererler <guzererler@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-18 14:38:48 +01:00
ahmet guzererler fa8a0d56fb
feat: opt-in vendor fallback — fail-fast by default (#18)
* feat: add extract_json() utility for robust LLM JSON parsing

Handles DeepSeek R1 <think> blocks, markdown code fences, and
preamble/postamble text that LLMs wrap around JSON output.
Applied to macro_synthesis, macro_bridge, and CLI scan output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: opt-in vendor fallback — fail-fast by default (ADR 011)

Silent cross-vendor fallback corrupts signal quality when data contracts
differ (e.g., AV news has sentiment scores yfinance lacks). Only methods
with fungible data contracts (OHLCV, indices, sector/industry perf,
market movers) now get fallback. All others raise immediately.

- Add FALLBACK_ALLOWED whitelist to interface.py
- Rewrite route_to_vendor() with fail-fast/fallback branching
- Improve error messages with method name, vendors tried, and exception chaining
- Add 11 new tests in test_vendor_failfast.py
- Update ADRs 002 (superseded), 008, 010; create ADR 011

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 14:25:38 +01:00
Ahmet Guzererler b50bc30217 Merge branch 'claude/objective-galileo': test fixes and plans
- fix: resolve 12 pre-existing test failures across 5 test files
  (callable() check, env var isolation, integration markers, stale assertions)
- docs: add implementation plans 011 (opt-in fallback) and 012 (test fixes)
- chore: unblock docs/agent/plans/ from .gitignore

Full offline suite: 388 passed, 70 deselected, 0 failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 12:16:02 +01:00
Copilot d5fb0fdd94
Resolve merge conflicts after PR #16 merge into main (#17)
* Initial plan

* feat: Finnhub integration layer with review fixes — 100 offline tests, vendor routing, evaluation report

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

* review: extract _MAX_ERROR_LEN constant for error message truncation

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

* re-review: fix version downgrade (0.2.0→0.2.1), extract _safe_fmt helper for earnings formatting

Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-18 11:38:44 +01:00
ahmet guzererler 26cd4c8b78
feat: Finnhub integration layer, 141 tests, and vendor evaluation report (#16)
* feat: add Finnhub integration layer, tests, and evaluation report

Adds a complete Finnhub data vendor integration as a supplementary
source alongside Alpha Vantage — zero changes to existing functionality.

New dataflow modules:
- finnhub_common.py: exception hierarchy, thread-safe rate limiter (60/min), _make_api_request
- finnhub_stock.py: get_stock_candles, get_quote
- finnhub_fundamentals.py: get_company_profile, get_financial_statements, get_basic_financials
- finnhub_news.py: get_company_news, get_market_news, get_insider_transactions
- finnhub_scanner.py: market movers (S&P 500 basket workaround), indices, sectors, topic news
- finnhub_indicators.py: SMA, EMA, MACD, RSI, BBANDS, ATR via /indicator endpoint
- finnhub.py: facade re-exporting all public functions

New tests:
- test_finnhub_integration.py: 100 offline (mocked HTTP) tests — all passing
- test_finnhub_live_integration.py: 41 live integration tests — skip gracefully when FINNHUB_API_KEY unset

Evaluation report (docs/finnhub_evaluation.md):
- Full coverage matrix vs Alpha Vantage across 5 data categories
- Free tier viability analysis (60 calls/min)
- Unique capabilities: earnings calendar, economic calendar, XBRL as-filed filings
- Recommendation: add as supplementary vendor for calendar data only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: mark paid-tier Finnhub endpoints; update evaluation with live results

Live testing with free-tier key confirmed:
- /quote, /stock/profile2, /stock/metric, /company-news, /news,
  /stock/insider-transactions → all free tier (27 live tests PASS)
- /stock/candle, /financials-reported, /indicator → paid tier HTTP 403
  (14 tests now properly skipped with @pytest.mark.paid_tier)

Also:
- Register 'integration' and 'paid_tier' markers in pyproject.toml
- Update docs/finnhub_evaluation.md with confirmed endpoint availability table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: wire Finnhub into routing layer — insider txns, calendars, fallback

Changes:
- interface.py: Finnhub added as third vendor (alongside yfinance + AV)
  - get_insider_transactions: Finnhub primary (free, + MSPR bonus signal)
  - get_market_indices/sector_performance/topic_news: Finnhub added as option
  - Fallback catch extended: (AlphaVantageError, FinnhubError, ConnectionError, TimeoutError)
  - New calendar_data category with get_earnings_calendar + get_economic_calendar
- finnhub_scanner.py: added get_earnings_calendar_finnhub, get_economic_calendar_finnhub
  (FOMC/CPI/NFP/GDP events + earnings beats — unique, not in AV at any tier)
- finnhub.py: re-exports new calendar functions
- scanner_tools.py: @tool wrappers for get_earnings_calendar, get_economic_calendar
- default_config.py: tool_vendors["get_insider_transactions"]="finnhub",
  calendar_data vendor category defaulting to "finnhub"
- .env.example: FINNHUB_API_KEY documented
- docs/agent/decisions/010-finnhub-vendor-integration.md: ADR for this decision

All 173 offline tests pass. ADR 002 constraints respected throughout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 11:28:43 +01:00
Ahmet Guzererler cf636232aa fix: resolve 12 pre-existing test failures across 5 test files
Root causes fixed:
- test_config_wiring.py: `callable()` returns False on LangChain @tool
  objects — replaced with `hasattr(x, "invoke")` check
- test_env_override.py: `load_dotenv()` in default_config.py re-reads
  .env on importlib.reload(), leaking user's TRADINGAGENTS_* env vars
  into isolation tests — mock env vars before reload
- test_scanner_comprehensive.py: LLM-calling test was not marked
  @pytest.mark.integration — added marker so offline runs skip it
- test_scanner_fallback.py: assertions used stale `_output_files` list
  from a previous run when output dir already existed — clear dir in
  setUp; also fixed tool-availability check using hasattr(x, "invoke")
- test_scanner_graph.py: output-file path assertions used hardcoded
  date string instead of fixture date; graph node assertions checked
  for removed node names

Full offline suite: 388 passed, 70 deselected, 0 failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 11:11:00 +01:00
Ahmet Guzererler 5b6d3a0c3f test: mark paid-tier Finnhub endpoints; update evaluation with live results
Live testing with free-tier key confirmed:
- /quote, /stock/profile2, /stock/metric, /company-news, /news,
  /stock/insider-transactions → all free tier (27 live tests PASS)
- /stock/candle, /financials-reported, /indicator → paid tier HTTP 403
  (14 tests now properly skipped with @pytest.mark.paid_tier)

Also:
- Register 'integration' and 'paid_tier' markers in pyproject.toml
- Update docs/finnhub_evaluation.md with confirmed endpoint availability table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 08:57:00 +01:00