Files
mt5-ai-xauusd-trader/tests/test_institutional_integration.py
T
saysgrokGitHubsaysgrokgoogle-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
27ba944d1c Institutional RL Evaluation Framework (#1341)
* feat: implement institutional RL evaluation framework

This PR implements a comprehensive reinforcement learning evaluation framework designed for institutional-grade trading research.

Key features:
- **Advanced Stability Metrics**: Beyond Sharpe/Sortino, it includes VaR, CVaR, Ulcer Index, SQN, Lake Ratio, and Tail Ratio.
- **Trade Efficiency**: Calculates Maximum Adverse Excursion (MAE) and Maximum Favorable Excursion (MFE) for every trade.
- **Turnover & Consistency**: Tracks trade frequency, hold times, action entropy, and a 'flip-flop' rate to detect excessive reversals.
- **Market Awareness**: Segmented performance by institutional market regimes and trading sessions (Asian, London, NY).
- **Statistical Rigor**: Integrates p-value calculations (paired T-test) to compare RL agents against rule-based baselines.
- **Robust Trade Extraction**: Correctly handles position reversals and positions open at the start of evaluation.
- **Typed Reporting**: Fully integrated with the project's reporting framework via Pydantic models and Jinja2 templates.

Verified by 32 unit tests.

Co-authored-by: saysgrok <279469430+saysgrok@users.noreply.github.com>

* feat: implement institutional RL evaluation framework

This PR implements a comprehensive reinforcement learning evaluation framework designed for institutional-grade trading research.

Key features:
- **Advanced Stability Metrics**: Beyond Sharpe/Sortino, it includes VaR, CVaR, Ulcer Index, SQN, Lake Ratio, and Tail Ratio.
- **Trade Efficiency**: Calculates Maximum Adverse Excursion (MAE) and Maximum Favorable Excursion (MFE) for every trade.
- **Turnover & Consistency**: Tracks trade frequency, hold times, action entropy, and a 'flip-flop' rate to detect excessive reversals.
- **Market Awareness**: Segmented performance by institutional market regimes and trading sessions (Asian, London, NY).
- **Statistical Rigor**: Integrates p-value calculations (paired T-test) to compare RL agents against rule-based baselines.
- **Robust Trade Extraction**: Correctly handles position reversals and positions open at the start of evaluation.
- **Typed Reporting**: Fully integrated with the project's reporting framework via Pydantic models and Jinja2 templates.

Also includes dependency harmonization for python-socketio and various linting fixes to ensure CI passing.

Co-authored-by: saysgrok <279469430+saysgrok@users.noreply.github.com>

* feat: institutional rl evaluation framework

Implemented comprehensive reinforcement learning evaluation logic in `src/research/rl_evaluation.py` with disciplined metrics beyond reward.

Key features:
- Stability analysis: Added MAE (Maximum Adverse Excursion) and MFE (Maximum Favorable Excursion) tracking.
- Turnover analysis: Implemented a `flip_flop_rate` to detect rapid Buy/Sell oscillations.
- Session attribution: Added PnL breakdown for Asian, London, and New York sessions (UTC) with session diversification entropy.
- Statistical rigor: Integrated paired t-tests to calculate p-values relative to baselines.
- Enhanced trade extraction: Robust processing for positions open at step 0 and direct Long-to-Short reversals.
- Institutional reporting: Updated `src/research/reporting.py` models and templates to support the new metrics.
- Environment harmonization: Aligned `python-socketio` to 5.14.0 for security and added `scipy` dependency.

Verified with 32 unit tests in `tests/test_rl_evaluation.py` and 19 reporting tests.

Co-authored-by: saysgrok <279469430+saysgrok@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: saysgrok <279469430+saysgrok@users.noreply.github.com>
2026-05-18 20:51:21 +00:00

8 lines
151 B
Python

try:
import torch
except ImportError:
torch = None
import pytest
pytestmark = pytest.mark.skipif(torch is None, reason="torch not installed")