forked from cmf-team/importance-sampling-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
22 lines (20 loc) · 807 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
import pandas as pd
from data import stocks_returns
def test_stocks_returns():
assets = ['APPL']
weights = [1.]
returns = stocks_returns(assets, weights, from_date='09/02/2022', to_date='09/07/2022')
test_returns = pd.Series(
data=[-0.0136, -0.0082, 0.0093],
index=pd.to_datetime(['09/02/2022', '09/06/2022', '09/07/2022']),
)
assert np.allclose(returns, test_returns, atol=0.0001)
assets = ['APPL', 'GOOGL']
weights = [0.3, 0.7]
returns = stocks_returns(assets, weights, from_date='09/02/2022', to_date='09/07/2022')
test_returns = pd.Series(
data=[-0.0158, -0.0091, 0.0188],
index=pd.to_datetime(['09/02/2022', '09/06/2022', '09/07/2022']),
)
assert np.allclose(returns, test_returns, atol=0.0001)