Fix test warnings
This commit is contained in:
parent
7e4a880ca9
commit
67db48a2dd
|
|
@ -17,4 +17,4 @@ def var(portfolio, prices, sort="ascending"):
|
||||||
pnl = portfolio.dot(returns.T)
|
pnl = portfolio.dot(returns.T)
|
||||||
daily_pnl = pnl.sum(axis=0)
|
daily_pnl = pnl.sum(axis=0)
|
||||||
daily_pnl_asc = daily_pnl.sort_values(ascending=True)
|
daily_pnl_asc = daily_pnl.sort_values(ascending=True)
|
||||||
return 0.4 * daily_pnl_asc[1] + 0.6 * daily_pnl_asc[2]
|
return 0.4 * daily_pnl_asc.iloc[1] + 0.6 * daily_pnl_asc.iloc[2]
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ def test_calculate_returns(prices, horizon, ascending, expected):
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"portfolio, prices, expected",
|
"portfolio, prices, expected",
|
||||||
[
|
[
|
||||||
({"FX-1": [100.00]}, {"FX-1": [1, 1.1, 0.9, 0.8]}, -6.909090),
|
({"FX-1": [100.00]}, {"FX-1": [1, 1.1, 1.0, 0.9, 0.8]}, -9.454545),
|
||||||
({"FX-1": [100.00]}, {"FX-1": [1, 0.9, 0.8, 0.8]}, -10.66666),
|
({"FX-1": [100.00]}, {"FX-1": [1, 0.9, 1.0, 0.8, 0.8]}, -4.0),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_var(portfolio, prices, expected):
|
def test_var(portfolio, prices, expected):
|
||||||
|
|
@ -39,6 +39,7 @@ def test_end_to_end():
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "var_fx_prices.csv"),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "var_fx_prices.csv"),
|
||||||
parse_dates=["date"],
|
parse_dates=["date"],
|
||||||
index_col="date",
|
index_col="date",
|
||||||
|
dayfirst=True,
|
||||||
dtype=float,
|
dtype=float,
|
||||||
)
|
)
|
||||||
fx_prices.sort_index(inplace=True, ascending=True)
|
fx_prices.sort_index(inplace=True, ascending=True)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue