TradingAgents/tests/portfolio
ahmet guzererler 02cbaecf62
feat: Add macro scanner feedback loop and lessons memory (#124)
* feat: add macro scanner feedback loop and lessons memory

- Implements `LessonStore` to persist JSON screening lessons
- Adds `selection_reflector.py` to fetch performance and news, and generate LLM lessons
- Adds `memory_loader.py` to filter negative lessons into `FinancialSituationMemory`
- Integrates a rejection gate in `candidate_prioritizer.py` based on past negative lessons
- Adds `reflect` command to CLI

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

* feat: update macro scanner feedback loop for dual-lesson output (Trend DNA)

- Update `selection_reflector.py` to calculate exact terminal returns, `mfe_pct`, `mae_pct`, and `days_to_peak`.
- Update LLM prompt to generate distinct `screening_advice` and `exit_advice`.
- Update `lesson_store` tests to reflect new schema.
- Update `memory_loader.py` to use `screening_advice` for negative selection filtering.
- Update `micro_summary_agent.py` to inject `exit_advice` into PM context for current holdings.
- Update `cli/main.py` default horizons to `30,90` and print dual-advice columns.

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

* fix: resolve bugs in macro scanner feedback loop

- Address Key mismatch (stock_return_pct vs terminal_return_pct)
- Fix missing persistence of mfe_pct and mae_pct
- Use create_report_store() instead of raw ReportStore() in load_scan_candidates
- Clean up unused imports in fetch_news_summary
- Ensure default horizons match code in cli description
- Create isolated `_local_safe_pct` to remove cross-module dependency

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

* fix: address PR 124 feedback on macro scanner memory feedback loop

- Use `l.get('screening_advice')` gracefully in `memory_loader` to prevent KeyErrors.
- Properly instantiate `selection_memory` inside the graph in `portfolio_setup.py` and pass it to the prioriziation rejection gate.

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

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
2026-03-26 23:44:44 +01:00
..
__init__.py feat: portfolio manager data foundation — docs, SQL migration, and module scaffolding 2026-03-20 10:40:48 +00:00
conftest.py feat: complete portfolio data foundation — psycopg2 client, repository, tests 2026-03-20 14:06:50 +01:00
test_candidate_prioritizer.py feat: Portfolio Manager Phases 2-5 — risk evaluation, candidate prioritization, LLM agents, trade executor 2026-03-20 14:38:48 +00:00
test_candidate_prioritizer_memory.py feat: Add macro scanner feedback loop and lessons memory (#124) 2026-03-26 23:44:44 +01:00
test_config.py test: add edge case for sum constraints validation 2026-03-21 08:22:53 +00:00
test_lesson_store.py feat: Add macro scanner feedback loop and lessons memory (#124) 2026-03-26 23:44:44 +01:00
test_models.py Add stop_loss and take_profit fields to Trade entries in database, API, and UI 2026-03-23 21:12:01 +00:00
test_report_store.py Fix JSON serialization of LangChain message objects in ReportStore 2026-03-23 19:37:41 +00:00
test_repository.py feat: add portfolio risk metrics module and LangChain agent tools 2026-03-20 14:42:43 +00:00
test_risk_evaluator.py feat: Portfolio Manager Phases 2-5 — risk evaluation, candidate prioritization, LLM agents, trade executor 2026-03-20 14:38:48 +00:00
test_risk_metrics.py feat: add portfolio risk metrics module and LangChain agent tools 2026-03-20 14:42:43 +00:00
test_selection_reflector.py feat: Add macro scanner feedback loop and lessons memory (#124) 2026-03-26 23:44:44 +01:00
test_trade_executor.py Add stop_loss and take_profit fields to Trade entries in database, API, and UI 2026-03-23 21:12:01 +00:00