mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-07 12:07:43 +00:00
08a08fa5b0
New test infrastructure:
1. pytest + pytest-cov installed
- requirements.txt updated
- pytest.ini configured
- .coveragerc for coverage
2. Test suite created (97 tests):
- test_backtest_engine.py (32 tests)
* BacktestMetrics: IC, Sharpe, Drawdown, Win Rate
* FactorBacktester: run_backtest, JSON export
* Edge cases: NaN, empty, insufficient data
- test_results_db.py (33 tests)
* ResultsDatabase: CRUD operations
* Queries: get_top_factors, get_aggregate_stats
* Database cleanup
- test_risk_management.py (32 tests)
* CorrelationAnalyzer: Matrix, uncorrelated factors
* PortfolioOptimizer: Mean-Variance, Risk Parity
* AdvancedRiskManager: Limit checks
3. Fixtures (conftest.py):
- 22 reusable test fixtures
- Mock data for all scenarios
- Sample factors, returns, equity curves
4. Coverage: 98.77% (target: >80%)
- BacktestMetrics: 100%
- FactorBacktester: 100%
- ResultsDatabase: 95.92%
- CorrelationAnalyzer: 100%
- PortfolioOptimizer: 100%
- AdvancedRiskManager: 100%
5. Documentation:
- test/backtesting/README.md
- How to run tests
- Generate coverage reports
Run tests:
pytest test/backtesting/ -v
Coverage report:
pytest test/backtesting/ --cov=rdagent/components/backtesting --cov-report=html
56 lines
876 B
INI
56 lines
876 B
INI
[run]
|
|
# Source code to measure
|
|
source = rdagent/components/backtesting
|
|
|
|
# Omit patterns
|
|
omit =
|
|
*/tests/*
|
|
*/test_*
|
|
*/__pycache__/*
|
|
*/conftest.py
|
|
*/site-packages/*
|
|
|
|
# Branch coverage
|
|
branch = True
|
|
|
|
# Parallel execution support
|
|
parallel = True
|
|
|
|
[report]
|
|
# Precision for coverage percentages
|
|
precision = 2
|
|
|
|
# Exclude patterns
|
|
exclude_lines =
|
|
pragma: no cover
|
|
def __repr__
|
|
raise AssertionError
|
|
raise NotImplementedError
|
|
if __name__ == .__main__.:
|
|
if TYPE_CHECKING:
|
|
@abstractmethod
|
|
|
|
# Show missing lines
|
|
show_missing = True
|
|
|
|
# Skip covered files in report
|
|
skip_covered = False
|
|
|
|
# Fail under threshold
|
|
fail_under = 80
|
|
|
|
[html]
|
|
# HTML report directory
|
|
directory = htmlcov
|
|
|
|
# Title for HTML report
|
|
title = PREDIX Backtesting Coverage Report
|
|
|
|
[xml]
|
|
# XML output file
|
|
output = coverage.xml
|
|
|
|
[json]
|
|
# JSON output file
|
|
output = coverage.json
|