Question: Based on the program (underneath) to test the January effect, write a Python program to test week-day effect. import numpy as np import scipy as

Based on the program (underneath) to test the January effect, write a Python program to test week-day effect.

import numpy as np import scipy as sp import pandas as pd from datetime import datetime from matplotlib.finance import quotes_historical_yahoo_ochl as getData ticker='IBM' begdate=(1962,1,1) enddate=(2016,12,31) x =getData(ticker, begdate, enddate,asobject=True, adjusted=True) logret = sp.log(x.aclose[1:]/x.aclose[:-1]) date=[] d0=x.date for i in range(0,sp.size(logret)): t1=''.join([d0[i].strftime("%Y"),d0[i].strftime("%m"),"01"]) date.append(datetime.strptime(t1,"%Y%m%d"))

y=pd.DataFrame(logret,date,columns=['logret']) retM=y.groupby(y.index).sum() ret_Jan=retM[retM.index.month==1] ret_others=retM[retM.index.month!=1] print(sp.stats.ttest_ind(ret_Jan.values,ret_others.values))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!