Skip to content

Commit

Permalink
增加自然日测试案例
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou-JiaJun committed Jun 28, 2022
1 parent 458eb59 commit 728e2c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions rqrisk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .risk import Risk
from .utils import DAILY, WEEKLY, MONTHLY, YEARLY
from .utils import DAILY, WEEKLY, MONTHLY, YEARLY, NATURAL_DAILY

__all__ = [
"Risk",
"DAILY",
"WEEKLY",
"MONTHLY",
"YEARLY"
"YEARLY",
"NATURAL_DAILY"
]
13 changes: 12 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np

import rqrisk
from rqrisk import DAILY, WEEKLY, MONTHLY
from rqrisk import DAILY, WEEKLY, MONTHLY, NATURAL_DAILY


# Simple benchmark, no drawdown
Expand Down Expand Up @@ -231,3 +231,14 @@ def _assert(returns, benchmark, desired_max_dd, desired_excess_max_dd):

_assert(volatile_returns, zero_benchmark, 0.10899999999999994, 0.10899999999999994)
_assert(volatile_returns, volatile_benchmark, 0.10899999999999994, 0.20000000000000007)


def test_natural_daily():
""" 测试自然日 """
r = _r(volatile_returns, volatile_benchmark, 0, NATURAL_DAILY)
assert_almost_equal(r.annual_return, -0.41377394067925255)
assert_almost_equal(r.benchmark_annual_return, 92.86171734511149)
assert_almost_equal(r.alpha, 62.31947511024051)
assert_almost_equal(r.information_ratio, 97.92626812366308)
assert_almost_equal(r.sharpe, -0.23942084288518412)

0 comments on commit 728e2c5

Please sign in to comment.