Fix test warnings

This commit is contained in:
Thomas Rijpstra 2025-03-05 20:54:35 +01:00
parent 7e4a880ca9
commit 67db48a2dd
Signed by: thomas
SSH Key Fingerprint: SHA256:sFF5HPNPaaW14qykTkmRi1FGGO0YMUPBenlKOqepUpw
2 changed files with 4 additions and 3 deletions

View File

@ -17,4 +17,4 @@ def var(portfolio, prices, sort="ascending"):
pnl = portfolio.dot(returns.T)
daily_pnl = pnl.sum(axis=0)
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]

View File

@ -25,8 +25,8 @@ def test_calculate_returns(prices, horizon, ascending, expected):
@pytest.mark.parametrize(
"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, 0.9, 0.8, 0.8]}, -10.66666),
({"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, 1.0, 0.8, 0.8]}, -4.0),
],
)
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"),
parse_dates=["date"],
index_col="date",
dayfirst=True,
dtype=float,
)
fx_prices.sort_index(inplace=True, ascending=True)