Skip to content

Commit

Permalink
Repository cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeeli committed Dec 7, 2018
1 parent 95b2383 commit 9bae1fa
Show file tree
Hide file tree
Showing 26 changed files with 29 additions and 46 deletions.
33 changes: 1 addition & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
# R files
.RData

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# knitr and R markdown default cache directories
/*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
rsconnect/

WRDS_pwd.txt
crsp.msf.csv
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Short-term Momentum trading strategy

Short-term momentum trading strategy implemented for the lecture "Systematic risk premia strategies traded at hedge funds" at University of Zurich, FS 2018.

---

## Overview

* Implementation in R
* In accordance to paper:

+ Monthly pricing data from the Center for Research in Security Prices (CRSP)

+ Sample starts in July, 1963 and ends in December, 2016
+ All common shares traded on NYSE, AMEX, and Nasdaq
Measure short-term momentum using the return over the previous month: 𝑀𝑂𝑀_(𝑖,𝑡) = 𝑟_(𝑖,𝑡−1)

+ Measure short-term turnover using previous month volume and number of shares outstanding data: 𝑇𝑂_(𝑖,𝑡) = 𝑉𝑂𝐿_(𝑖,𝑡−1) / 𝑆𝐻𝑅𝑂𝑈𝑇_(𝑖,𝑡−1)

+ Portfolios are value-weighted by market capitalization and rebalanced at the end of each month

## Results

![Main findings (excess returns)](./results/main_findings_table.png)

![Cumulative performance of strategies](./results/strategies_performance.png)
11 changes: 5 additions & 6 deletions backtest/backtest.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ for (month in 1:n.months) {
turnover <- turnover[idx.intersect]
marketCap <- marketCap[idx.intersect]

####################
# double sorts

# value-weighted returns in each decile
Expand All @@ -138,7 +137,7 @@ for (month in 1:n.months) {
return(weightedMean(rets, caps))
}, n.rows, n.columns)

# value-weighted returns in each decile
# value-weighted excess returns in each decile
ts.deciles.rets.ex[ , , month] <- doublesort.conditional.colbreaks(rets.ex, turnover, momentum, breakpoints.mom, function(rets) {
caps <- mwnd.marketCap[month, which(stock.names %in% names(rets))]
return(weightedMean(rets, caps))
Expand Down Expand Up @@ -227,9 +226,9 @@ plot.data <- melt(plot.data.wide, id.vars=c('date'))

ggplot(data=plot.data, aes(x=date, group=variable)) +
geom_line(aes(y=value, colour=variable)) +
labs(y="cumulative excess returns", x="") +
labs(y="Dollar value of investment", x="") +
scale_x_date(date_breaks='48 months', labels=date_format("%m.%Y")) +
scale_y_continuous(labels=function(x) paste0(x*100, '%'), breaks=seq(-100, 100, by=2)) +
scale_y_continuous(labels=function(x) x*100, breaks=seq(-100, 100, by=2)) +
scale_colour_manual('', values=c('low.turnover'='red', 'high.turnover'='black', 'combo'='green', 'market'='blue'),
labels=c('Short-term reversal', 'Short-term momentum', '50:50 combo', 'FF market')) +
theme_hc() +
Expand All @@ -245,9 +244,9 @@ plot.data <- melt(plot.data.wide, id.vars=c('date'))

ggplot(data=plot.data, aes(x=date, group=variable)) +
geom_line(aes(y=value, colour=variable)) +
labs(y="cumulative excess returns", x="") +
labs(y="Dollar value of investment", x="") +
scale_x_date(date_breaks='48 months', labels=date_format("%m.%Y")) +
scale_y_continuous(labels=function(x) paste0(x*100, '%'), breaks=seq(-100, 100, by=2)) +
scale_y_continuous(labels=function(x) x*100, breaks=seq(-100, 100, by=2)) +
scale_colour_manual('', values=c('low.turnover'='red', 'high.turnover'='black', 'combo'='green', 'market'='blue'),
labels=c('Short-term reversal', 'Short-term momentum', '50:50 combo', 'FF market')) +
theme_hc() +
Expand Down
Binary file removed backtest/doublesort 1x10 average count.xlsx
Binary file not shown.
Binary file removed backtest/doublesort 1x10 average market cap.xlsx
Binary file not shown.
Binary file removed backtest/doublesort 1x10 average returns styled.xlsx
Binary file not shown.
Binary file removed backtest/doublesort 1x10 average returns.xlsx
Binary file not shown.
Binary file removed backtest/doublesort 1x10 statistics.xlsx
Binary file not shown.
Binary file removed backtest/doublesort paper styled.xlsx
Binary file not shown.
8 changes: 0 additions & 8 deletions backtest/doublesort.test.R

This file was deleted.

Binary file removed backtest/strategies performance 20y.pdf
Binary file not shown.
Binary file removed backtest/strategies performance.pdf
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added results/doublesort paper styled.xlsx
Binary file not shown.
Binary file added results/main_findings_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added results/strategies performance 20y.pdf
Binary file not shown.
Binary file added results/strategies performance.pdf
Binary file not shown.
Binary file added results/strategies_performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9bae1fa

Please sign in to comment.