corrected return calc test, writing sortino tests
This commit is contained in:
parent
db8377f0ef
commit
c4e1d8b586
@ -3,8 +3,8 @@ import datetime
|
|||||||
import pytest
|
import pytest
|
||||||
from pyfacts import (
|
from pyfacts import (
|
||||||
AllFrequencies,
|
AllFrequencies,
|
||||||
PyfactsOptions,
|
|
||||||
Frequency,
|
Frequency,
|
||||||
|
PyfactsOptions,
|
||||||
TimeSeries,
|
TimeSeries,
|
||||||
create_date_series,
|
create_date_series,
|
||||||
)
|
)
|
||||||
@ -248,7 +248,7 @@ class TestReturns:
|
|||||||
with pytest.raises(DateNotFoundError):
|
with pytest.raises(DateNotFoundError):
|
||||||
ts.calculate_returns("2020-04-04", return_period_unit="days", return_period_value=90, as_on_match="exact")
|
ts.calculate_returns("2020-04-04", return_period_unit="days", return_period_value=90, as_on_match="exact")
|
||||||
with pytest.raises(DateNotFoundError):
|
with pytest.raises(DateNotFoundError):
|
||||||
ts.calculate_returns("2020-04-04", return_period_unit="months", return_period_value=3, prior_match="exact")
|
ts.calculate_returns("2020-04-08", return_period_unit="months", return_period_value=1, prior_match="exact")
|
||||||
|
|
||||||
def test_date_formats(self, create_test_data):
|
def test_date_formats(self, create_test_data):
|
||||||
ts_data = create_test_data(AllFrequencies.D, skip_weekends=True)
|
ts_data = create_test_data(AllFrequencies.D, skip_weekends=True)
|
||||||
|
@ -106,18 +106,16 @@ class TestSortino:
|
|||||||
)
|
)
|
||||||
assert round(sortino_ratio, 4) == 1.2564
|
assert round(sortino_ratio, 4) == 1.2564
|
||||||
|
|
||||||
# def test_sharpe_weekly_freq(self, create_test_data):
|
def test_sortino_weekly_freq(self, create_test_data):
|
||||||
# data = create_test_data(num=261, frequency=pft.AllFrequencies.W, mu=0.6, sigma=0.7)
|
data = create_test_data(num=500, frequency=pft.AllFrequencies.W, mu=0.12, sigma=0.06)
|
||||||
# ts = pft.TimeSeries(data, "W")
|
ts = pft.TimeSeries(data, "W")
|
||||||
# sharpe_ratio = pft.sharpe_ratio(
|
sortino = pft.sortino_ratio(
|
||||||
# ts,
|
ts,
|
||||||
# risk_free_rate=0.052,
|
risk_free_rate=0.06,
|
||||||
# from_date="2017-01-08",
|
return_period_unit="years",
|
||||||
# to_date="2021-12-31",
|
return_period_value=1,
|
||||||
# return_period_unit="days",
|
)
|
||||||
# return_period_value=7,
|
assert round(sortino, 4) == -5.5233
|
||||||
# )
|
|
||||||
# assert round(sharpe_ratio, 4) == 0.4533
|
|
||||||
|
|
||||||
# sharpe_ratio = pft.sharpe_ratio(
|
# sharpe_ratio = pft.sharpe_ratio(
|
||||||
# ts,
|
# ts,
|
||||||
|
Loading…
Reference in New Issue
Block a user