Skip to content

Instantly share code, notes, and snippets.

@muxueqz
Forked from anonymous/gist:e87a8e7aceec74b314cb
Last active August 29, 2015 14:23
Show Gist options
  • Save muxueqz/d5cf3a89f6b3a185f4dc to your computer and use it in GitHub Desktop.
Save muxueqz/d5cf3a89f6b3a185f4dc to your computer and use it in GitHub Desktop.
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