-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy path30_PredictorAltPorts.R
137 lines (100 loc) · 3.13 KB
/
30_PredictorAltPorts.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# ==== ENVIRONMENT AND DATA ====
crspinfo = read.fst(
paste0(pathProject,'Portfolios/Data/Intermediate/crspminfo.fst')
) %>% # me, screens,
setDT()
crspret = read.fst(
paste0(pathProject,'Portfolios/Data/Intermediate/crspmret.fst')
) %>% # returns
setDT()
# SELECT SIGNALS
strategylist0 <- alldocumentation %>% filter(Cat.Signal == "Predictor")
strategylist0 <- ifquickrun()
#### ALT HOLDING PERIODS ####
holdperlist <- c(1, 3, 6, 12)
for (i in seq(1, length(holdperlist))) {
print(paste0(
"Running portperiod = ",
holdperlist[i],
" ======================================="
))
port <- loop_over_strategies(
strategylist0 %>% mutate(portperiod = holdperlist[i])
)
checkport(port, c("signalname"))
writestandard(
port,
pathDataPortfolios,
paste0("PredictorAltPorts_HoldPer_", holdperlist[i], ".csv")
)
} # for i
#### ALT LIQUIDITY ADJUSTMENTS ####
print("CheckLiq: ME > NYSE 20 pct =========================================")
## ME > NYSE 20th pct
# create ME screen
# customscreen is used on the signal df, which is then lagged, so no look ahead here
port <- loop_over_strategies(
strategylist0 %>% mutate(filterstr = "me > me_nyse20")
)
checkport(port, c("signalname"))
writestandard(
port,
pathDataPortfolios, "PredictorAltPorts_LiqScreen_ME_gt_NYSE20pct.csv"
)
## Price > 5
print("CheckLiq: Price > 5 =========================================")
port <- loop_over_strategies(
strategylist0 %>% mutate(filterstr = "abs(prc) > 5")
)
writestandard(
port,
pathDataPortfolios, "PredictorAltPorts_LiqScreen_Price_gt_5.csv"
)
## NYSE only
print("CheckLiq: NYSE only =========================================")
port <- loop_over_strategies(
strategylist0 %>% mutate(filterstr = "exchcd==1")
)
checkport(port, c("signalname"))
writestandard(
port,
pathDataPortfolios, "PredictorAltPorts_LiqScreen_NYSEonly.csv"
)
## VW
print("CheckLiq: VW force =========================================")
port <- loop_over_strategies(
strategylist0 %>% mutate(sweight = "VW")
)
checkport(port, c("signalname"))
writestandard(
port,
pathDataPortfolios, "PredictorAltPorts_LiqScreen_VWforce.csv"
)
#### ALT QUANTILES ####
## DECILE SORTS
strategylistcts = strategylist0 %>% filter(Cat.Form == 'continuous')
# OP stock weighting
port <- loop_over_strategies(
strategylistcts %>% mutate(q_cut = 0.1)
)
checkport(port, c("signalname", "port"))
writestandard(port, pathDataPortfolios, "PredictorAltPorts_Deciles.csv")
# force value weighting
port <- loop_over_strategies(
strategylistcts %>% mutate(q_cut = 0.1, sweight = 'VW')
)
checkport(port, c("signalname", "port"))
writestandard(port, pathDataPortfolios, "PredictorAltPorts_DecilesVW.csv")
## QUINTILE SORTS
# OP stock weighting
port <- loop_over_strategies(
strategylistcts %>% mutate(q_cut = 0.2)
)
checkport(port, c("signalname", "port"))
writestandard(port, pathDataPortfolios, "PredictorAltPorts_Quintiles.csv")
# force value weighting
port <- loop_over_strategies(
strategylistcts %>% mutate(q_cut = 0.2, sweight = 'VW')
)
checkport(port, c("signalname", "port"))
writestandard(port, pathDataPortfolios, "PredictorAltPorts_QuintilesVW.csv")