Fixes portfolio_model.py tests (#2071)

* fix portfolio tests

* run black on test file

* remove unused argument
This commit is contained in:
montezdesousa
2022-07-12 10:41:59 +01:00
committed by GitHub
parent 72e2e78ad2
commit dfd6d49056
3 changed files with 9 additions and 66 deletions

View File

@@ -1,31 +0,0 @@
,Portfolio,Benchmark
mtd,"TotalHoldings NaN
dtype: float64","Adj Close NaN
dtype: float64"
qtd,"TotalHoldings NaN
dtype: float64","Adj Close NaN
dtype: float64"
ytd,"TotalHoldings 0.759
dtype: float64","Adj Close 0.722
dtype: float64"
3m,"TotalHoldings 0.612
dtype: float64","Adj Close 0.553
dtype: float64"
6m,"TotalHoldings 0.766
dtype: float64","Adj Close 0.718
dtype: float64"
1y,"TotalHoldings 0.59
dtype: float64","Adj Close 0.489
dtype: float64"
3y,"TotalHoldings -1.13
dtype: float64","Adj Close -0.766
dtype: float64"
5y,"TotalHoldings -1.308
dtype: float64","Adj Close -1.483
dtype: float64"
10y,"TotalHoldings -1.308
dtype: float64","Adj Close -1.483
dtype: float64"
all,"TotalHoldings -1.308
dtype: float64","Adj Close -1.483
dtype: float64"
1 Portfolio Benchmark
2 mtd TotalHoldings NaN dtype: float64 Adj Close NaN dtype: float64
3 qtd TotalHoldings NaN dtype: float64 Adj Close NaN dtype: float64
4 ytd TotalHoldings 0.759 dtype: float64 Adj Close 0.722 dtype: float64
5 3m TotalHoldings 0.612 dtype: float64 Adj Close 0.553 dtype: float64
6 6m TotalHoldings 0.766 dtype: float64 Adj Close 0.718 dtype: float64
7 1y TotalHoldings 0.59 dtype: float64 Adj Close 0.489 dtype: float64
8 3y TotalHoldings -1.13 dtype: float64 Adj Close -0.766 dtype: float64
9 5y TotalHoldings -1.308 dtype: float64 Adj Close -1.483 dtype: float64
10 10y TotalHoldings -1.308 dtype: float64 Adj Close -1.483 dtype: float64
11 all TotalHoldings -1.308 dtype: float64 Adj Close -1.483 dtype: float64

View File

@@ -1,31 +0,0 @@
,Portfolio,Benchmark
mtd,"TotalHoldings 1.0
dtype: float64","Adj Close 1.0
dtype: float64"
qtd,"TotalHoldings 1.0
dtype: float64","Adj Close 1.0
dtype: float64"
ytd,"TotalHoldings 0.845
dtype: float64","Adj Close 0.831
dtype: float64"
3m,"TotalHoldings 0.758
dtype: float64","Adj Close 0.702
dtype: float64"
6m,"TotalHoldings 0.851
dtype: float64","Adj Close 0.824
dtype: float64"
1y,"TotalHoldings 0.923
dtype: float64","Adj Close 0.926
dtype: float64"
3y,"TotalHoldings 0.908
dtype: float64","Adj Close 0.799
dtype: float64"
5y,"TotalHoldings 0.882
dtype: float64","Adj Close 0.81
dtype: float64"
10y,"TotalHoldings 0.882
dtype: float64","Adj Close 0.81
dtype: float64"
all,"TotalHoldings 0.882
dtype: float64","Adj Close 0.81
dtype: float64"
1 Portfolio Benchmark
2 mtd TotalHoldings 1.0 dtype: float64 Adj Close 1.0 dtype: float64
3 qtd TotalHoldings 1.0 dtype: float64 Adj Close 1.0 dtype: float64
4 ytd TotalHoldings 0.845 dtype: float64 Adj Close 0.831 dtype: float64
5 3m TotalHoldings 0.758 dtype: float64 Adj Close 0.702 dtype: float64
6 6m TotalHoldings 0.851 dtype: float64 Adj Close 0.824 dtype: float64
7 1y TotalHoldings 0.923 dtype: float64 Adj Close 0.926 dtype: float64
8 3y TotalHoldings 0.908 dtype: float64 Adj Close 0.799 dtype: float64
9 5y TotalHoldings 0.882 dtype: float64 Adj Close 0.81 dtype: float64
10 10y TotalHoldings 0.882 dtype: float64 Adj Close 0.81 dtype: float64
11 all TotalHoldings 0.882 dtype: float64 Adj Close 0.81 dtype: float64

View File

@@ -3,6 +3,7 @@
# IMPORTATION THIRDPARTY
from pathlib import Path
import pandas as pd
import pytest
# IMPORTATION INTERNAL
from openbb_terminal.portfolio import portfolio_model
@@ -27,6 +28,7 @@ benchmark_returns["Date"] = pd.to_datetime(benchmark_returns["Date"])
benchmark_returns = benchmark_returns.set_index("Date")
@pytest.mark.vcr(record_mode="none")
def test_tracking_error(recorder):
result_df, _ = portfolio_model.get_tracking_error(
portfolio_returns, benchmark_returns
@@ -35,6 +37,7 @@ def test_tracking_error(recorder):
recorder.capture(result_df)
@pytest.mark.vcr(record_mode="none")
def test_information_ratio(recorder):
result_df, _ = portfolio_model.get_information_ratio(
portfolio_returns, benchmark_returns
@@ -43,17 +46,19 @@ def test_information_ratio(recorder):
recorder.capture(result_df)
def test_tail_ratio(recorder):
@pytest.mark.vcr(record_mode="none")
def test_tail_ratio():
result_df, _, _ = portfolio_model.get_tail_ratio(
portfolio_returns, benchmark_returns
)
recorder.capture(result_df)
assert isinstance(result_df, pd.DataFrame)
def test_common_sense_ratio(recorder):
@pytest.mark.vcr(record_mode="none")
def test_common_sense_ratio():
result_df = portfolio_model.get_common_sense_ratio(
portfolio_returns, benchmark_returns
)
recorder.capture(result_df)
assert isinstance(result_df, pd.DataFrame)