[Blotter-commits] r1657 - in pkg/quantstrat: . R man sandbox/backtest_musings
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Nov 29 14:39:24 CET 2014
Author: braverock
Date: 2014-11-29 14:39:24 +0100 (Sat, 29 Nov 2014)
New Revision: 1657
Modified:
pkg/quantstrat/DESCRIPTION
pkg/quantstrat/NAMESPACE
pkg/quantstrat/R/parameters.R
pkg/quantstrat/man/applyParameter.Rd
pkg/quantstrat/man/getParameterTable.Rd
pkg/quantstrat/man/paramConstraint.Rd
pkg/quantstrat/man/setParameterConstraint.Rd
pkg/quantstrat/man/setParameterDistribution.Rd
pkg/quantstrat/sandbox/backtest_musings/gamlss.png
pkg/quantstrat/sandbox/backtest_musings/stat_process.bib
pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd
pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf
Log:
- update roxygen docs
- deprecate old applyParameter code
- update backtest paper
Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/DESCRIPTION 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,12 +1,12 @@
Package: quantstrat
Type: Package
Title: Quantitative Strategy Model Framework
-Version: 0.9.1648
+Version: 0.9.1657
Date: $Date$
Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
Depends:
xts(>= 0.8-2),TTR(>= 0.2),
- blotter(>= 0.7.2),
+ blotter(>= 0.9),
FinancialInstrument(>= 0.12.5),
foreach(>= 1.4.0)
Suggests:
Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/NAMESPACE 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,4 +1,4 @@
-# Generated by hand: do not edit with roxygen2
+# Generated by roxygen2 (4.0.2): do not edit by hand
export(add.distribution)
export(add.distribution.constraint)
@@ -10,7 +10,6 @@
export(addPosLimit)
export(apply.paramset)
export(applyIndicators)
-export(applyParameter)
export(applyRules)
export(applySignals)
export(applyStrategy)
@@ -23,7 +22,6 @@
export(get.strategy)
export(getOrderBook)
export(getOrders)
-export(getParameterTable)
export(getPosLimit)
export(getStrategy)
export(initOrders)
@@ -42,8 +40,6 @@
export(ruleRevoke)
export(ruleSignal)
export(save.strategy)
-export(setParameterConstraint)
-export(setParameterDistribution)
export(sigComparison)
export(sigCrossover)
export(sigFormula)
Modified: pkg/quantstrat/R/parameters.R
===================================================================
--- pkg/quantstrat/R/parameters.R 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/R/parameters.R 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,83 +1,3 @@
-## add parameters to strategy objects: ALPHA CODE USE WITH CARE
-#add.parameter <-
-# function (strategy,
-# type = c('indicator','signal'),
-# add.to.name,
-# method = c('lookup','lookup.range','calc'),
-# arguments = NULL,
-# label = NULL,
-# ...,
-# store=FALSE)
-#{
-# if(!is.strategy(strategy)) stop("You must pass in a strategy object to manipulate")
-# # perhaps I should add parameters and parameter.args as arguments to the constructors...
-#
-# tmp.param<-list()
-#
-# type=type[1] #this should probably come out eventually
-#
-# method = method[1] #only use the first if the user didn't specify, or over-specified
-#
-# if(is.null(label)) {
-# label<-method
-# }
-# tmp.param$label <- label
-# tmp.param$method <- method
-# tmp.param$call <- match.call()
-# tmp.param$arguments <- arguments
-# class(tmp.param)<-'quantstrat.parameter'
-#
-# switch(type,
-# indicator = {type='indicators'},
-# signal = {type='signals'},
-# rule = {type='rules'}) #NOTE rules not supported yet, since they need a rule type too
-#
-# # need to think about how to create a 'parameters' list, and whether
-# # it should be at the strategy level or lower down, on the individual
-# # signal/indicator/rule
-#
-# if(!is.list(strategy[[type]][[add.to.name]]$parameters)){
-# strategy[[type]][[add.to.name]]$parameters <- list()
-# }
-# strategy[[type]][[add.to.name]][['parameters']][[method]] <- tmp.param
-#
-# if (store) assign(strategy$name,strategy,envir=as.environment(.strategy))
-# else return(strategy)
-#}
-#
-#
-## add parameters to strategy objects: ALPHA CODE USE WITH CARE
-#paramLookup <- function(strategy, symbol , type, name, parameter, ...) {
-# # should take in a strategy and parameter object, and return an argument list for 'symbol'
-# #as.pairlist(paramTable[,symbol]
-# paramTable<-get(paste(strategy,type,name,'table',pos=.strategy))
-# as.pairlist(paramTable[,symbol])
-#}
-#
-## add parameters to strategy objects: ALPHA CODE USE WITH CARE
-#add.paramLookupTable <- function(strategy, type, name, paramTable){
-# assign(paste(strategy,type,name,'table',pos=.strategy),paramTable)
-#}
-#
-## get parameterized arguments list out of the strategy environment
-#getParams <- function (strategy, symbol, type, name)
-#{
-#
-# params <- strategy[[type]][[name]]$parameters
-# param.ret<-list()
-# for (param in params) {
-# switch(param$method,
-# lookup = {param.ret<-c(param.ret,paramLookup(strategy,symbol,parameter=param))},
-# lookup.range = {},
-# calc = {},
-# {warning("parameter method",param$method,'not recognized for',type,name); next()}
-# )
-# }
-# # return an arguments list back to the 'apply*' fn
-# return(param.ret)
-#}
-
-
###############################################################################
# R (http://r-project.org/) Quantitative Strategy Model Framework
#
@@ -136,7 +56,7 @@
#retrieve the needed parameters and existing values after add*
-#' Extract the parameter structure from a strategy object.
+#' Extract the parameter structure from a strategy object. (deprecated)
#'
#' Users can use this function to extract the parameters used in a strategy, and use the output as a reminder/ cheatsheet
#' when they create the parameter distribution or parameter constraints. But it's not required to run to specify the distribution or constraints of parameters.
@@ -156,7 +76,6 @@
#' }
#' @param strategy The strategy object.
#' @author Yu Chen
-#' @export
getParameterTable<-function (strategy) #,staticSwitch)
{
@@ -235,19 +154,9 @@
return(paramPack)
}
-#
-#
-#getParameterInfo<-function(paramStructure){
-# paramInfo<-list()
-# for(paraLine in paramStructure){
-# paraInfo[[1]]<-paraLine$paramType
-# }
-#}
-#getParameterMatrix<-function(paraStructure){
-#
-#}
-#' Function used to create an object that contains the distribution of parameters to be generated from, before testing parameters of a strategy.
+
+#' Function used to create an object that contains the distribution of parameters to be generated from, before testing parameters of a strategy. (deprecated)
#'
#'
#' Each call to the function will set/update the distribution of ONE parameter in the 'parameter distribution object' that is associated with a specific strategy.
@@ -279,7 +188,6 @@
#' @param psindex A number specify the index within the parameter distribution object, it is used to make change/ repalce a parameter distribution in the object.
#' @return The returned object is a structure contains the distribution of parameters, if the input argument 'paramDist' is provided, the function update the input paramDist object and return the updated one. When specify the distribution of several parameters, usually the first returned object is passed to the next several call of the function as input argument 'paramDist'. See example.
#' @author Yu Chen
-#' @export
setParameterDistribution<-function(paramDist=NULL, strategy, component.type, component.label, distribution=NULL, weight, label, psindex=NULL) #All is needed, set to illegal values
{
missing.msg <- ': missing in call to setParameterDistribution'
@@ -336,7 +244,7 @@
return(paramDist)
}
-#' Generate parameter sets for a specific strategy, test the strategy on each set of parameters, output result package.
+#' Generate parameter sets for a specific strategy, test the strategy on each set of parameters, output result package. (deprecated)
#'
#' The function do several things in one call, to test different parameters on a strategy. It generates parameter sets based on specified distribution (a defined parameter distribution object generated by setParameterDistribution function) and constraints (A defined parameter constraint object generated by setParameterConstraint function),
#' apply the generated parameter sets to the specified strategy and return the results package, put the generated portfolio objects and account objects in .blotter environment.
@@ -392,11 +300,13 @@
#' @seealso \code{\link{setParameterDistribution}}, \code{\link{setParameterConstraint}}
#'
#' @author Yu Chen
-#' @export
applyParameter<-function(strategy,portfolios,parameterPool,parameterConstraints,method,sampleSize,verbose=FALSE,...)
{
+ .Deprecated("apply.paramsets","The original parameter code in applyParameter hase been deprecated. Use apply.paramsets instead.")
+
#need to create combination of distribution values in each slot of the parameterPool
+
initialPortf<-.getPortfolio(portfolios)
symbols<-ls(initialPortf$symbols)
@@ -720,13 +630,11 @@
}
-#for(pname in names(as.list(ss$blotter))){
-# assign(paste(pname,'p',23,sep='.'),get(paste('ss$blotter$',pname,sep='')),envir=as.environment(.blotter))
-#}
-
-#' Internal function used in applyParameter function for process constraints on relationship between two parameter values. Basicly is the same as sigComparison function in signal.R written by Brian, with minor change.
+#' Internal function used in applyParameter function for process constraints on relationship between two parameter values. (deprecated)
#'
+#' Basically is the same as sigComparison function in signal.R written by Brian, with minor change.
+#'
#' Currently, this function compares two columns.
#' Patches to compare an arbitrary number of columns would be gladly accepted.
#'
@@ -781,7 +689,7 @@
}
-#' Function to construct parameter constraint object.
+#' Function to construct parameter constraint object. (deprecated)
#'
#' Function to construct parameter constraint object. The returned value will be one of the inputs to the applyParameter function.
#'
@@ -802,7 +710,6 @@
#' @param relationship relationship between the 1st parameter and 2nd one. ('gt' means 1st parameter > 2nd parameter).
#' @return The returned object is a structure contains the constraints on pairs of parameters, if the input argument 'paramConstraintObj' is provided, the function update the input paramConstraintObj object and return the updated one. When specify the constraints of several pairs of parameters, usually the first returned object is passed to the next several call of the function as input argument 'paramConstraintObj'. See example.
#' @author Yu Chen
-#' @export
setParameterConstraint<-function(paramConstraintObj=list(),constraintLabel,paramList,relationship)
{
if(!hasArg(paramConstraintObj) || !exists(as.character(substitute(paramConstraintObj))))
Modified: pkg/quantstrat/man/applyParameter.Rd
===================================================================
--- pkg/quantstrat/man/applyParameter.Rd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/man/applyParameter.Rd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{applyParameter}
\alias{applyParameter}
-\title{Generate parameter sets for a specific strategy, test the strategy on each set of parameters, output result package.}
+\title{Generate parameter sets for a specific strategy, test the strategy on each set of parameters, output result package. (deprecated)}
\usage{
applyParameter(strategy, portfolios, parameterPool, parameterConstraints,
method, sampleSize, verbose = FALSE, ...)
Modified: pkg/quantstrat/man/getParameterTable.Rd
===================================================================
--- pkg/quantstrat/man/getParameterTable.Rd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/man/getParameterTable.Rd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{getParameterTable}
\alias{getParameterTable}
-\title{Extract the parameter structure from a strategy object.}
+\title{Extract the parameter structure from a strategy object. (deprecated)}
\usage{
getParameterTable(strategy)
}
Modified: pkg/quantstrat/man/paramConstraint.Rd
===================================================================
--- pkg/quantstrat/man/paramConstraint.Rd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/man/paramConstraint.Rd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{paramConstraint}
\alias{paramConstraint}
-\title{Internal function used in applyParameter function for process constraints on relationship between two parameter values. Basicly is the same as sigComparison function in signal.R written by Brian, with minor change.}
+\title{Internal function used in applyParameter function for process constraints on relationship between two parameter values. (deprecated)}
\usage{
paramConstraint(label, data = mktdata, columns, relationship = c("gt", "lt",
"eq", "gte", "lte", "op"))
@@ -16,10 +16,12 @@
\item{relationship}{one of c("gt","lt","eq","gte","lte","op") or reasonable alternatives}
}
\description{
+Basically is the same as sigComparison function in signal.R written by Brian, with minor change.
+}
+\details{
Currently, this function compares two columns.
Patches to compare an arbitrary number of columns would be gladly accepted.
-}
-\details{
+
Comparison will be applied from the first to the second column in the \code{columns} vector.
Relationship 'op' means 'opposite' side. Reasonable attempt will be made to match.
Modified: pkg/quantstrat/man/setParameterConstraint.Rd
===================================================================
--- pkg/quantstrat/man/setParameterConstraint.Rd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/man/setParameterConstraint.Rd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{setParameterConstraint}
\alias{setParameterConstraint}
-\title{Function to construct parameter constraint object.}
+\title{Function to construct parameter constraint object. (deprecated)}
\usage{
setParameterConstraint(paramConstraintObj = list(), constraintLabel,
paramList, relationship)
Modified: pkg/quantstrat/man/setParameterDistribution.Rd
===================================================================
--- pkg/quantstrat/man/setParameterDistribution.Rd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/man/setParameterDistribution.Rd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -1,7 +1,7 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{setParameterDistribution}
\alias{setParameterDistribution}
-\title{Function used to create an object that contains the distribution of parameters to be generated from, before testing parameters of a strategy.}
+\title{Function used to create an object that contains the distribution of parameters to be generated from, before testing parameters of a strategy. (deprecated)}
\usage{
setParameterDistribution(paramDist = NULL, strategy, component.type,
component.label, distribution = NULL, weight, label, psindex = NULL)
Modified: pkg/quantstrat/sandbox/backtest_musings/gamlss.png
===================================================================
(Binary files differ)
Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib
===================================================================
--- pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2014-11-29 13:39:24 UTC (rev 1657)
@@ -25,7 +25,7 @@
@article{Bailey2014pm,
title={Pseudomathematics and financial charlatanism: The effects of backtest {O}ver fitting on out-of-sample performance},
- author={Bailey, David H and Borwein, Jonathan M and L{\'o}pez de Prado, Marcos and Zhu, Qiji Jim},
+ author={Bailey, David H and Borwein, Jonathan M and {L{\'o}pez de Prado}, Marcos and Zhu, Qiji Jim},
journal={Notices of the AMS},
volume={61},
number={5},
Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd
===================================================================
--- pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2014-11-28 01:07:57 UTC (rev 1656)
+++ pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2014-11-29 13:39:24 UTC (rev 1657)
@@ -14,7 +14,7 @@
footer: Copyright 2014 Brian G. Peterson CC-BY-NC-SA. Please do not distribute this draft without permission.
copyright: Copyright 2014 Brian G. Peterson CC-BY-NC-SA. Please do not distribute this draft without permission.
-abstract: Analysts and portfolio managers face many challenges in developing new systematic trading systems. This paper provides a detailed, repeatable process to aid in evaluating new ideas, developing those ideas into testable hypotheses, measuring results in comparable ways, and avoiding and measuring the ever-present risks of over-fitting. ^[ *Back-testing. I hate it –- it's just optimizing over history. You never see a bad back-test. Ever. In any strategy.* - Josh Diedesch [- at Diedesch2014] ]
+abstract: Analysts and portfolio managers face many challenges in developing new systematic trading systems. This paper provides a detailed, repeatable process to aid in evaluating new ideas, developing those ideas into testable hypotheses, measuring results in comparable ways, and avoiding and measuring the ever-present risks of over-fitting. ^[ *Back-testing. I hate it –- it's just optimizing over history. You never see a bad back-test. Ever. In any strategy.* - Josh Diedesch[- at Diedesch2014] ]
---
___
@@ -147,7 +147,7 @@
*SharpeRatio*'s, *FactorAnalytics*, and more are well
represented in **R**.
-## Choosing an Objective {#objectives} ^[*When measuring results against objectives, start by making sure the objectives are correct.* - Ben @Horowitz2014]
+## Choosing an Objective ^[*When measuring results against objectives, start by making sure the objectives are correct.* - Ben @Horowitz2014]
In strategy creation, it is very dangerous to start without a clear
objective.
@@ -597,7 +597,6 @@
\begin{marginfigure}
\includegraphics{gamlss}
-\caption{source:gamlss}
\end{marginfigure}
The signals generated by the backtest(s) are also able to be empirically
@@ -632,15 +631,15 @@
signals, holding period, etc.) to the process you are evaluating, to ensure
that you are really looking at comparable things.
-In the analysis of signal processes, since every signal is a prediction, is
-where we can begin to fully apply the literature on model specification
-and testing of predictions. From the simplest available methods such
-as mean squared model error or kernel distance from an ideal process,
-through extensive evaluation as suggested for BIC, effective number of
-parameters, and cross validation of @Hastie2009, and including time series
-specific models such as the data driven approach "revealed performance"
-approach of @Racine2009, all available tools from the forecasting literature
-should be considered for evaluating proposed signal processes.
+Because every signal is a prediction, when analysing of signal processes, we
+can begin to fully apply the literature on model specification and testing of
+predictions. From the simplest available methods such as mean squared model
+error or kernel distance from an ideal process, through extensive evaluation
+as suggested for BIC, effective number of parameters, and cross validation of
+ at Hastie2009, and including time series specific models such as the data driven
+approach "revealed performance" approach of @Racine2009, all available tools
+from the forecasting literature should be considered for evaluating proposed
+signal processes.
It should be clear that evaluating the signal generating process offers
multiple opportunities to re-evaluate assumptions about the method of
@@ -655,11 +654,15 @@
information about the instruments you are examining. If not, stop and go back
and reexamine your hypotheses. Assuming that you do have both a theoretical
and empirical basis on which to proceed, it is time to define the
-strategy's trading rules.
+strategy's trading rules.
Much of the work involved in evaluating "technical trading rules" described
in the literature is really an evaluation of signal processes, described
-in depth above.
+in depth above. Rules should refine the way the strategy 'listens' to signals,
+producing path-dependent actions based on the current state of the market,
+your portfolio, and the indicators and signals. Separate from whether a
+signal has predictive power or not, as described above, evaluation of rules
+is an evaluation of the actions taken in response to the rule.
## entry rules
@@ -1579,7 +1582,7 @@
[@Bailey2014probability, p.17]
- prior remarks about overlapping periods, parameter autocorrelation, and *i.i.d.* assumptions apply here as well
-- @harvey2013backtesting , @harvey2014 , @harvey2013multiple look at Type I vs Type II error in evaluating
+- @Harvey2013backtesting , @Harvey2014 , @Harvey2013multiple look at Type I vs Type II error in evaluating
backtests and look at appropriate haircuts based on this.
Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf
===================================================================
(Binary files differ)
More information about the Blotter-commits
mailing list