Trading Strategies Performance Report with R and Knitr

October 18, 2013

(This article was first published on The R Trader » R, and kindly contributed to R-bloggers)

I’ve been looking for template reports using R and Knitr for a while but I didn’t find anything that suits my needs so far. I therefore decided to create them myself.

What I like to see about trading strategies are basic performance charts (daily, monthly and yearly), some basic trading statistics and above all most recent performance figures to track potential strategy decay. I also want all of the information to be displayed on a single page. All this already exists obviously but not within a synthetic report like the one I present here. Therefore some custom formatting was required.

The input necessary to create this report is a simple 2 columns csv file with daily date and return. The output is a good looking pdf file (see image below).

I created a GistGitHub repository with 3 files:

  • performanceReportREADME.txt: it contains the usual disclaimer
  • performanceReportWithKnitr.R: This is the main R function that creates the charts and the input for LaTeX tables
  • performanceReport_AssetAllocation.Rnw: This file calls the R function above and generates the pdf report.

Any comments welcome


To leave a comment for the author, please follow the link and comment on their blog: The R Trader » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)