Exemple #1
0
# Value weighted
stocks_month_vw = cf.prep_monthly_rtn(path, cut, path + '\\Data\\fundamental_mods\\monthly_fund_rtn_val_wt_cut_' + str(0.1) + '.csv', post_2009)

# Inverse value weighted
stocks_month_ivw = cf.prep_monthly_rtn(path, cut, path + '\\Data\\fundamental_mods\\monthly_fund_rtn_inv_val_wt_cut_' + str(0.1) + '.csv', post_2009)

# Clusters; transitive component equal weighted
stocks_month_clu = cf.prep_monthly_rtn(path, cut, path + '\\Data\\fundamental_mods\\monthly_fund_rtn_cluster_cut_' + str(0.1) + '.csv', post_2009)
print(0.25 * int((time.time() - start_time)/15), 'minutes so far...')

# Get Fama-French data
FF, RF = cf.prep_FF_monthly(path)

# Use functions
get_mom_ind = lambda data, signal, wt: cf.get_mom_ind(data, RF, 0, signal, monthly = True, sig_rtn = False, wt = wt)
get_mom_fund = lambda data, signal: cf.get_mom_fund(data, RF, 0, signal, monthly = True, sig_rtn = False)
get_mom_diff = lambda data, signal, wt: cf.get_mom_diff(data, RF, 0, signal, monthly = True, sig_rtn = False, wt = wt)

# VW
ind_mom_rtn1_vw = get_mom_ind(stocks_month_vw, 1, 'vw')
print(0.25 * int((time.time() - start_time)/15), 'minutes so far...')

fund_mom_rtn1_vw, diff_mom_rtn1_vw = get_mom_fund(stocks_month_vw, 1), get_mom_diff(stocks_month_vw, 1, 'vw') 
print(0.25 * int((time.time() - start_time)/15), 'minutes so far...')

ind_mom_rtn6_vw, fund_mom_rtn6_vw, diff_mom_rtn6_vw = get_mom_ind(stocks_month_vw, 6, 'vw'), get_mom_fund(stocks_month_vw, 6), get_mom_diff(stocks_month_vw, 6, 'vw')
print(0.25 * int((time.time() - start_time)/15), 'minutes so far...')

# IVW
ind_mom_rtn1_ivw = get_mom_ind(stocks_month_ivw, 1, 'ivw') 
Exemple #2
0
# Where are the fundamental returns
file = path + '\\Data\\fundamental_mods\\monthly_fund_rtn_inv_val_wt_cut_' + str(
    cut) + '.csv'

# If file isn't none, in which folder should everything be place?
folder = 'fund_inv_val_wt'

# Get the month return data
stocks_month = cf.prep_monthly_rtn(path, cut, file, post_2009)

# Get Fama-French data
FF, RF = cf.prep_FF_monthly(path)

# Use functions
get_mom_ind = lambda delay, signal: cf.get_mom_ind(
    stocks_month, RF, delay, signal, monthly=True)
get_mom_fund = lambda delay, signal: cf.get_mom_fund(
    stocks_month, RF, delay, signal, monthly=True)

# 0-1
ind_mom_rtn0_1, fund_mom_rtn0_1 = get_mom_ind(0, 1), get_mom_fund(0, 1)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')

# 0-3
ind_mom_rtn0_3, fund_mom_rtn0_3 = get_mom_ind(0, 3), get_mom_fund(0, 3)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')

# 1-3
ind_mom_rtn1_3, fund_mom_rtn1_3 = get_mom_ind(1, 3), get_mom_fund(1, 3)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')
Exemple #3
0
# If file isn't none, in which folder should everything be place?
folder = None

# Get the month return data
stocks_month = cf.prep_monthly_rtn(path, cut, file, post_2009)

# Get Fama-French data
FF, RF = cf.prep_FF_monthly(path)

# Get duration
duration = (stocks_month['DATE'].dt.year).max() - (
    stocks_month['DATE'].dt.year).min() + 1

# Use functions
get_mom_ind = lambda signal: cf.get_mom_ind(
    stocks_month, RF, 0, signal, monthly=True, sig_rtn=True)
get_mom_fund = lambda signal: cf.get_mom_fund(
    stocks_month, RF, 0, signal, monthly=True, sig_rtn=True)
get_mom_diff = lambda signal: cf.get_mom_diff(
    stocks_month, RF, 0, signal, monthly=True, sig_rtn=True)

# Get data frame
long_short = pd.DataFrame()

# 0-1
ind_mom_rtn1, ind_MOM1 = get_mom_ind(1)
fund_mom_rtn1, fund_MOM1 = get_mom_fund(1)
diff_mom_rtn1, diff_MOM1 = get_mom_diff(1)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')

# Save results
Exemple #4
0
# Where are the fundamental returns
file = path + '\\Data\\weekly_fundamental_returns_fuller_cut_' + str(
    cut) + '.csv'

# If file isn't none, in which folder should everything be place?
folder = None

# Get the month return data
stocks_week = cf.prep_weekly_rtn(path, cut, file, post_2009)

# Get Fama-French data
FF, RF = cf.prep_FF_weekly(path)

# Use functions
get_mom_ind = lambda delay, signal: cf.get_mom_ind(
    stocks_week, RF, delay, signal, monthly=False)
get_mom_fund = lambda delay, signal: cf.get_mom_fund(
    stocks_week, RF, delay, signal, monthly=False)

# 0-1
ind_mom_rtn0_1, fund_mom_rtn0_1 = get_mom_ind(0, 1), get_mom_fund(0, 1)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')

# 1-1
ind_mom_rtn1_1, fund_mom_rtn1_1 = get_mom_ind(1, 1), get_mom_fund(1, 1)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')

# 0-2
ind_mom_rtn0_2, fund_mom_rtn0_2 = get_mom_ind(0, 2), get_mom_fund(0, 2)
print(0.25 * int((time.time() - start_time) / 15), 'minutes so far...')