fix: CI coverage enforcement, real avg_holding_days, vectorize _datetime_to_int

- Add --cov and --cov-fail-under=50 to CI pytest command
- Replace hardcoded avg_holding_days=5.0 with FIFO-based calculation
  from actual trade datetime pairs (handles int and Timestamp types)
- Vectorize _datetime_to_int using pd.to_datetime().strftime()
  instead of Python for-loop (~100-200x faster on large arrays)
- Add 3 new test cases: weighted holding days, no datetime fallback,
  only-buys edge case
This commit is contained in:
Justin Gu
2026-06-11 01:44:39 +08:00
parent b4f63c85a6
commit 06b2617ebc
4 changed files with 141 additions and 19 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- run: pip install -e ".[dev]"
- run: python -m pytest tests/unit/ -v --tb=short
- run: python -m pytest tests/unit/ -v --tb=short --cov src/easy_tdx --cov-fail-under=50
- run: ruff check src/ tests/
- run: ruff format --check src/ tests/