Skip to content

Commit c9dedef

Browse files
authored
Merge pull request #36 from OpenSourceAP/Patches
Patches for updated version
2 parents d1e4e4d + 7414552 commit c9dedef

34 files changed

+2029
-1028
lines changed

Portfolios/Code/00_SettingsAndTools.R

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#### GLOBAL SETTINGS
22

3-
quickrun = F # use T if you want to run quickly for testing
4-
quickrunlist = c('DivOmit','realestate','nanalyst')
5-
feed.verbose = F # use T if you want lots of feedback
6-
73
options(dplyr.summarise.inform = FALSE)
84

95
#### PATHS
10-
pathProject = paste0(getwd(), '/')
11-
126
pathPredictors = paste0(pathProject, 'Signals/Data/Predictors/')
137
pathPlacebos = paste0(pathProject, 'Signals/Data/Placebos/')
148
pathCRSPPredictors = paste0(pathProject, 'Signals/Data/CRSPPredictors/')
@@ -21,26 +15,44 @@ pathDataSummary = paste0(pathProject, 'Portfolios/Data/Summary/')
2115

2216
pathResults = paste0(pathProject, 'Results/')
2317

24-
# Create folders if they don't exist
18+
## Create folders if they don't exist
19+
# Portfolios/ paths
2520
dir.create(pathResults)
2621
dir.create(paste0(pathProject, 'Portfolios/Data'))
2722
dir.create(paste0(pathDataPortfolios))
2823
dir.create(paste0(pathDataIntermediate))
29-
dir.create(paste0(pathCRSPPredictors))
24+
25+
# Signals/Data/ paths
26+
dir.create(paste0(pathProject,'Signals/Data/'))
27+
dir.create(paste0(pathPredictors))
28+
dir.create(paste0(pathPlacebos))
29+
dir.create(paste0(pathtemp))
30+
3031

3132
#### PACKAGES
3233
# Check for and potentially install missing packages
3334
install.packages(setdiff(c('tidyverse', 'lubridate', 'readxl', 'writexl', 'pryr', 'fst',
34-
'RPostgres', 'getPass', 'extrafont', 'xtable', 'gridExtra'),
35+
'RPostgres', 'getPass', 'xtable', 'gridExtra',
36+
'ggrepel','data.table'),
3537
rownames(installed.packages())))
3638

39+
# Use the extrafonts package, to get nicer fonts for output figures
40+
# Code issues warnings when not installed but runs nevertheless
41+
# See https://cran.r-project.org/web/packages/extrafont/README.html
42+
if (!'extrafont' %in% rownames(installed.packages())) {
43+
install.packages('extrafont')
44+
extrafont::font_import()
45+
}
46+
47+
3748
options(stringsAsFactors = FALSE)
3849
library(tidyverse)
3950
library(lubridate)
4051
library(readxl)
4152
library(writexl)
4253
library(pryr)
4354
library(fst)
55+
library(data.table) # for handling daily crsp
4456

4557
# for WRDS access
4658
library(RPostgres)
@@ -58,10 +70,17 @@ loadfonts()
5870
library(xtable)
5971
options(xtable.floating = FALSE)
6072
library(gridExtra)
73+
library(ggrepel)
6174

6275
# system dependent settings
6376
dlmethod <- "auto"
64-
optFontFamily = 'Palatino Linotype' # doesn't agree with linux command line
77+
78+
if ('Palatino Linotype' %in% fonts()) {
79+
optFontFamily = 'Palatino Linotype'
80+
} else {
81+
optFontFamily = ''
82+
}
83+
6584
sysinfo <- Sys.info()
6685
if (sysinfo[1] == "Linux") {
6786
dlmethod <- "wget"
@@ -350,7 +369,8 @@ loop_over_strategies = function(
350369
strategylist
351370
, saveportcsv = F
352371
, saveportpath = NA
353-
, saveportNmin = 20
372+
, saveportNmin = 1
373+
, passive_gain = F
354374
){
355375

356376
Nstrat = dim(strategylist)[1]
@@ -387,6 +407,7 @@ loop_over_strategies = function(
387407
, portperiod = strategylist$portperiod[i]
388408
, q_filt = strategylist$q_filt[i]
389409
, filterstr = strategylist$filterstr[i]
410+
, passive_gain = passive_gain
390411
)
391412

392413
}

0 commit comments

Comments
 (0)