Created
June 25, 2015 02:26
-
-
Save anonymous/e87a8e7aceec74b314cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year_input = raw_input('Please enter a 4-digit year: ') | |
mylist = [] | |
with open('F-F_Research_Data_Factors_daily.txt') as fh: | |
lines = fh.readlines() | |
slicedline = lines[6:-2] | |
header = lines[5].split() | |
for element in slicedline: | |
yearstr.mkt.smb.hml.rf = element.split() | |
if year_input == yearstr[:4]: | |
print 'available factors: {0}'.format(header) | |
factor_input = raw_input('please enter a Fama-French factor: ') | |
else: | |
exit('1st arg must be 4-digit year between 1926 and 2012') | |
if factor_input in header: | |
len_list = len(mylist) | |
sumlist = sum([float(y) for y in mylist]) | |
print '{0} values, avg {1}'.format(len_list,sumlist/len_list) | |
else: | |
print '2nd arg must be one of the four factors {0}'. format(header) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment