Lab 6
Team C'est La Vie - Ziqin, Ruiyang, Hanut and Tim
Introduction
Collecting yfinance
Downloading yfinance-0.1.63.tar.gz (26 kB)
Requirement already satisfied: pandas>=0.24 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from yfinance) (1.2.5)
Requirement already satisfied: numpy>=1.15 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from yfinance) (1.19.5)
Requirement already satisfied: requests>=2.20 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from yfinance) (2.26.0)
Collecting multitasking>=0.0.7
Downloading multitasking-0.0.9.tar.gz (8.1 kB)
Requirement already satisfied: lxml>=4.5.1 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from yfinance) (4.6.3)
Requirement already satisfied: python-dateutil>=2.7.3 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from pandas>=0.24->yfinance) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from pandas>=0.24->yfinance) (2021.1)
Requirement already satisfied: six>=1.5 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas>=0.24->yfinance) (1.16.0)
Requirement already satisfied: idna<4,>=2.5 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from requests>=2.20->yfinance) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->yfinance) (1.26.7)
Requirement already satisfied: certifi>=2017.4.17 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->yfinance) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests>=2.20->yfinance) (2.0.6)
Building wheels for collected packages: yfinance, multitasking
Building wheel for yfinance (setup.py) ... done
Created wheel for yfinance: filename=yfinance-0.1.63-py2.py3-none-any.whl size=23918 sha256=8ecf626a6b3402599d1ecd116b1f8fbe91098abe68f727def5ca697fa6fbc1f1
Stored in directory: /tmp/pip-ephem-wheel-cache-knbhvcl5/wheels/fe/87/8b/7ec24486e001d3926537f5f7801f57a74d181be25b11157983
Building wheel for multitasking (setup.py) ... done
Created wheel for multitasking: filename=multitasking-0.0.9-py3-none-any.whl size=8375 sha256=5d10a4564401473f772124d3fd312e1821b5007061f634a8a6e8af1f2d2e301f
Stored in directory: /tmp/pip-ephem-wheel-cache-knbhvcl5/wheels/ae/25/47/4d68431a7ec1b6c4b5233365934b74c1d4e665bf5f968d363a
Successfully built yfinance multitasking
Installing collected packages: multitasking, yfinance
Successfully installed multitasking-0.0.9 yfinance-0.1.63
[*********************100%***********************] 1 of 1 completed
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 4819 entries, 2000-12-01 to 2020-01-30
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Open 4819 non-null float64
1 High 4819 non-null float64
2 Low 4819 non-null float64
3 Close 4819 non-null float64
4 Adj Close 4819 non-null float64
5 Volume 4819 non-null int64
dtypes: float64(5), int64(1)
memory usage: 263.5 KB
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4819 entries, 0 to 4818
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 4819 non-null datetime64[ns]
1 Open 4819 non-null float64
2 High 4819 non-null float64
3 Low 4819 non-null float64
4 Close 4819 non-null float64
5 Adj Close 4819 non-null float64
6 Volume 4819 non-null int64
dtypes: datetime64[ns](1), float64(5), int64(1)
memory usage: 263.7 KB
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4819 entries, 0 to 4818
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 4819 non-null datetime64[ns]
1 Adj Close 4819 non-null float64
2 Volume 4819 non-null int64
dtypes: datetime64[ns](1), float64(1), int64(1)
memory usage: 113.1 KB
SPY Returns Test
Average December return: 0.00032347123207658173
Average January return: 0.00017295862358590982
Median December return: 0.0005613111317387398
Median January return: 0.0009899095543648428
Difference in mean return:
-0.015051260849067192
p value is 0.845551257889439
The difference in mean return is not significantly different (fail to reject H0)
SPY Volatility Test
Difference in mean return volatility:
0.5641207395593373
p value is 0.7163508355033023
The difference in mean return volatility is not significantly different (fail to reject H0)
SPY Volume Test
Difference in volume:
1176374835.2531166
p value is 0.0620201958662138
The difference in mean Volume is not significantly different (fail to reject H0)
Summary: Since the p value for the return, volume and annualized volatility of return are all greater than our chosen alpha, we fail to reject our null hypothesis that the difference in return, volume and annualized volatility of return in December and January is not statistically different.
Comparison with China's SSE Composite Index
Since we could not reject the null hypothesis for SPY in the U.S., we decided to analyze the China's SSE Composite Index similarly to see if the January Effect exists in China, where Christmas is not an official holiday.
[*********************100%***********************] 1 of 1 completed
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 4638 entries, 2000-12-01 to 2020-01-23
Data columns (total 6 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Open 4638 non-null float64
1 High 4638 non-null float64
2 Low 4638 non-null float64
3 Close 4638 non-null float64
4 Adj Close 4638 non-null float64
5 Volume 4638 non-null int64
dtypes: float64(5), int64(1)
memory usage: 253.6 KB
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4638 entries, 0 to 4637
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Date 4638 non-null datetime64[ns]
1 Open 4638 non-null float64
2 High 4638 non-null float64
3 Low 4638 non-null float64
4 Close 4638 non-null float64
5 Adj Close 4638 non-null float64
6 Volume 4638 non-null int64
dtypes: datetime64[ns](1), float64(5), int64(1)
memory usage: 253.8 KB
SSE Return Test
China Average December return: 0.0011857048150169752
China Average January return: -0.0004149025522141868
China Median December return: 0.0006669669582203275
China Average January return: 0.00129636246592435
China Difference in mean return:
-0.16006073672311621
p value is 0.16548844753746467
The difference in mean return is not significantly different (fail to reject H0)
SSE Volatility Test
China Difference in mean return volatility:
3.8880171977119127
p value is 0.013796683609565737
The difference in mean return volatility is significantly different (reject H0)
SSE Volume Test
China difference in volume:
514985.54502662446
p value is 0.49115584773222076
China the difference in mean Volume is not significantly different (fail to reject H0)
Summary: Since the p value for the return and volume are greater than our chosen alpha, we fail to reject our null hypothesis. However, for annualized volatility of return, we see that the p value is smaller than alpha, which means we can reject our null hypothesis that the annualized volatility of return in January is greater than that of December.
Conclusion
USA versus China
US-China difference in returns:
8.040637073101977e-05
p value is nan
The US-China difference in mean returns is not significantly different (fail to reject H0)