feat: add sortino, directional_accuracy metrics and PyTorch loss functions#46
Merged
Conversation
…tions - Add sortino() and directional_accuracy() to fynance/features/metrics.py with helper _annual_downside_volatility(); both exported in __all__ - Add fynance/models/loss/ submodule: BaseLoss, SharpeLoss, SortinoLoss, DirectionalAccuracyLoss — pure torch ops, gradient-flow tested - Export new loss classes from fynance/models/__init__.py - 24 new tests (6 metric + 18 loss); ruff clean; full suite 249 passed
…it, models, backtest)
|
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sortino()anddirectional_accuracy()tofynance/features/metrics.pywith shared helper_annual_downside_volatility; both exported in__all__fynance/models/loss/submodule:BaseLoss,SharpeLoss,SortinoLoss,DirectionalAccuracyLoss— pure torch ops, differentiable,rf/periodprecomputed,std(correction=0)for Sharpe consistency with numpy metricfynance/models/__init__.pyTest plan
pytest fynance/tests/features/test_metrics.py::test_sortinopytest fynance/tests/features/test_metrics.py::test_directional_accuracypytest fynance/tests/models/test_loss.pypytest --doctest-modules fynance/models/loss/pytest -q(full suite)ruff check fynance/