Skip to content

Instantly share code, notes, and snippets.

###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
############################################################
## Using Genetic Algorithms in Quantitative Trading
##
## thertrader@gmail.com - Mar 2014
############################################################
library(PerformanceAnalytics)
library(rgenoud)
library(quantmod)
library(TTR)
#######################################################
# Evaluating Quandl Data Quality
#
# thertrader@gmail.com - Nov 2013
#######################################################
library(quantmod)
library(Quandl)
library(Rbbg)
library(XML)
###############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
This Shiny application is designed to help analysing trading strategies. It is an ongoing project that I improve when time allows. Feel free to get in touch should you have any suggestion.
*How to use the App as it is?
The App uses as input several csv files (one for each strategy). Each file has two columns: date and daily return. There is an example of such a file in the Github repository. The code is essentially made of 3 files.
-ui.R: controls the layout and appearance of the app
-server.R: contains the instructions needed to build the app. You can load as much strategies as you want as long as the corresponding csv file has the right format (see below).
-shinyStrategyGeneral.R: loads the required packages and launches the app
put ui.R and server.R file in a separate directory
In the server.R file change the inputPath, inputFile and keepColumns parameters to match your setting. The first two are self explanatory the third one is a list of column names within the csv file. Keep only date and daily return
@rterbush
rterbush / e1071.R
Last active August 29, 2015 14:07 — forked from ivannp/e1071.R
svmComputeOneForecast = function(
id,
data,
response,
startPoints,
endPoints,
len,
history=500,
trace=FALSE,
kernel="radial",
@rterbush
rterbush / armaSearch.R
Last active August 29, 2015 14:07 — forked from ivannp/armaSearch.R
armaSearch = function(
xx,
minOrder=c(0,0),
maxOrder=c(5,5),
trace=FALSE )
{
bestAic = 1e9
len = NROW( xx )
for( p in minOrder[1]:maxOrder[1] ) for( q in minOrder[2]:maxOrder[2] )
{
@rterbush
rterbush / garchAuto.R
Last active August 29, 2015 14:08 — forked from ivannp/garchAuto.R
garchAutoTryFit = function(
ll,
data,
trace=FALSE,
forecast.length=1,
with.forecast=TRUE,
ic="AIC",
garch.model="garch" )
{
formula = as.formula( paste( sep="",
@rterbush
rterbush / gys.r
Last active August 29, 2015 14:08 — forked from ivannp/gys.r
#' Saves symbols (from an environment) to a specified directory
#'
#' The files (one per symbol) are saved in \code{dir}. The file name
#' is the symbol itself, and the file extension is RData.
#'
#' @param symbols The symbols
#' @param dir The destination folder (file system directory). It must exist.
#' @param env The environment containing the symbols
#'
#' @examples