From noreply at r-forge.r-project.org Wed Jan 7 14:23:01 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 14:23:01 +0100 (CET) Subject: [Blotter-commits] r1665 - in pkg/quantstrat: . R Message-ID: <20150107132301.782521852A7@r-forge.r-project.org> Author: braverock Date: 2015-01-07 14:23:01 +0100 (Wed, 07 Jan 2015) New Revision: 1665 Modified: pkg/quantstrat/DESCRIPTION pkg/quantstrat/R/applyStrategy.rebalancing.R pkg/quantstrat/R/indicators.R pkg/quantstrat/R/initialize.R pkg/quantstrat/R/match.names.R pkg/quantstrat/R/orders.R pkg/quantstrat/R/osFUNs.R pkg/quantstrat/R/parameters.R pkg/quantstrat/R/paramsets.R pkg/quantstrat/R/rebalance.rules.R pkg/quantstrat/R/ruleOrderProc.R pkg/quantstrat/R/ruleRevoke.R pkg/quantstrat/R/ruleSignal.R pkg/quantstrat/R/rules.R pkg/quantstrat/R/signals.R pkg/quantstrat/R/strategy.R pkg/quantstrat/R/tradeGraphs.R pkg/quantstrat/R/tradeOrderStats.R pkg/quantstrat/R/utils.R pkg/quantstrat/R/walk.forward.R pkg/quantstrat/R/wrapup.R Log: - update Copyright to 2015 Modified: pkg/quantstrat/DESCRIPTION =================================================================== --- pkg/quantstrat/DESCRIPTION 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/DESCRIPTION 2015-01-07 13:23:01 UTC (rev 1665) @@ -1,7 +1,7 @@ Package: quantstrat Type: Package Title: Quantitative Strategy Model Framework -Version: 0.9.1664 +Version: 0.9.1665 Date: $Date$ Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme Depends: @@ -26,4 +26,5 @@ Michael Guan, Jeffrey A. Ryan, Garrett See LazyLoad: yes License: GPL-3 +Copyright: (c) 2009-2015 ByteCompile: TRUE Modified: pkg/quantstrat/R/applyStrategy.rebalancing.R =================================================================== --- pkg/quantstrat/R/applyStrategy.rebalancing.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/applyStrategy.rebalancing.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -198,7 +198,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/indicators.R =================================================================== --- pkg/quantstrat/R/indicators.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/indicators.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -213,7 +213,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/initialize.R =================================================================== --- pkg/quantstrat/R/initialize.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/initialize.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -217,12 +217,12 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING # -# $Id: initialize.R 1561 2013-11-01 15:51:45Z bodanker $ +# $Id$ # ############################################################################### Modified: pkg/quantstrat/R/match.names.R =================================================================== --- pkg/quantstrat/R/match.names.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/match.names.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -41,7 +41,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/orders.R =================================================================== --- pkg/quantstrat/R/orders.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/orders.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -527,7 +527,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/osFUNs.R =================================================================== --- pkg/quantstrat/R/osFUNs.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/osFUNs.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -238,7 +238,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/parameters.R =================================================================== --- pkg/quantstrat/R/parameters.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/parameters.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -1,7 +1,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/paramsets.R =================================================================== --- pkg/quantstrat/R/paramsets.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/paramsets.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -1,7 +1,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/rebalance.rules.R =================================================================== --- pkg/quantstrat/R/rebalance.rules.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/rebalance.rules.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -108,7 +108,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/ruleOrderProc.R =================================================================== --- pkg/quantstrat/R/ruleOrderProc.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/ruleOrderProc.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -456,7 +456,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/ruleRevoke.R =================================================================== --- pkg/quantstrat/R/ruleRevoke.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/ruleRevoke.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -43,7 +43,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2012 +# Copyright (c) 2009-2015 # Niklas Kolster, Jan Humme # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/ruleSignal.R =================================================================== --- pkg/quantstrat/R/ruleSignal.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/ruleSignal.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -251,7 +251,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/rules.R =================================================================== --- pkg/quantstrat/R/rules.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/rules.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -699,7 +699,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/signals.R =================================================================== --- pkg/quantstrat/R/signals.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/signals.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -946,7 +946,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/strategy.R =================================================================== --- pkg/quantstrat/R/strategy.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/strategy.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -300,12 +300,12 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING # -# $Id: strategy.R 1594 2014-03-29 20:39:45Z braverock $ +# $Id$ # ############################################################################### Modified: pkg/quantstrat/R/tradeGraphs.R =================================================================== --- pkg/quantstrat/R/tradeGraphs.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/tradeGraphs.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -69,7 +69,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, Garrett See, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/tradeOrderStats.R =================================================================== --- pkg/quantstrat/R/tradeOrderStats.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/tradeOrderStats.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -54,7 +54,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/utils.R =================================================================== --- pkg/quantstrat/R/utils.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/utils.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -93,7 +93,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # Modified: pkg/quantstrat/R/walk.forward.R =================================================================== --- pkg/quantstrat/R/walk.forward.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/walk.forward.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -1,7 +1,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) Modified: pkg/quantstrat/R/wrapup.R =================================================================== --- pkg/quantstrat/R/wrapup.R 2014-12-31 14:38:01 UTC (rev 1664) +++ pkg/quantstrat/R/wrapup.R 2015-01-07 13:23:01 UTC (rev 1665) @@ -148,7 +148,7 @@ ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, Garrett See, and Joshua Ulrich # # This library is distributed under the terms of the GNU Public License (GPL) From noreply at r-forge.r-project.org Wed Jan 7 14:26:09 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 14:26:09 +0100 (CET) Subject: [Blotter-commits] r1666 - in pkg/blotter: . R Message-ID: <20150107132609.E198418615C@r-forge.r-project.org> Author: braverock Date: 2015-01-07 14:26:09 +0100 (Wed, 07 Jan 2015) New Revision: 1666 Modified: pkg/blotter/DESCRIPTION pkg/blotter/R/PortfReturns.R pkg/blotter/R/addPortfInstr.R pkg/blotter/R/addTxn.R pkg/blotter/R/calcPortfWgt.R pkg/blotter/R/calcPosAvgCost.R pkg/blotter/R/calcTxnAvgCost.R pkg/blotter/R/calcTxnValue.R pkg/blotter/R/chart.ME.R pkg/blotter/R/chart.Posn.R pkg/blotter/R/chart.Reconcile.R pkg/blotter/R/chart.Spread.R pkg/blotter/R/extractTests.R pkg/blotter/R/getAccount.R pkg/blotter/R/getByPortf.R pkg/blotter/R/getBySymbol.R pkg/blotter/R/getEndEq.R pkg/blotter/R/getPortfAcct.R pkg/blotter/R/getPortfolio.R pkg/blotter/R/getPos.R pkg/blotter/R/getPosAvgCost.R pkg/blotter/R/getPosQty.R pkg/blotter/R/getTxn.R pkg/blotter/R/initAcct.R pkg/blotter/R/initPortf.R pkg/blotter/R/initPosPL.R pkg/blotter/R/initSummary.R pkg/blotter/R/initTxn.R pkg/blotter/R/perTradeStats.R pkg/blotter/R/put.account.R pkg/blotter/R/put.portfolio.R pkg/blotter/R/tradeStats.R pkg/blotter/R/updateAcct.R pkg/blotter/R/updateEndEq.R pkg/blotter/R/updatePortf.R pkg/blotter/R/updatePosPL.R Log: - update Copyright to 2015 Modified: pkg/blotter/DESCRIPTION =================================================================== --- pkg/blotter/DESCRIPTION 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/DESCRIPTION 2015-01-07 13:26:09 UTC (rev 1666) @@ -2,7 +2,7 @@ Type: Package Title: Tools for transaction-oriented trading systems development. -Version: 0.9.1644 +Version: 0.9.1666 Date: $Date$ Author: Peter Carl, Brian G. Peterson Maintainer: Brian G. Peterson @@ -26,5 +26,5 @@ Contributors: Daniel Cegielka, Dirk Eddelbuettel, Jan Humme, Lance Levenson, Ben McCann, Jeff Ryan, Garrett See, Joshua Ulrich, Wolfgang Wu URL: https://r-forge.r-project.org/projects/blotter/ -Copyright: (c) 2008-2014 +Copyright: (c) 2008-2015 ByteCompile: TRUE Modified: pkg/blotter/R/PortfReturns.R =================================================================== --- pkg/blotter/R/PortfReturns.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/PortfReturns.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -72,7 +72,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/addPortfInstr.R =================================================================== --- pkg/blotter/R/addPortfInstr.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/addPortfInstr.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -24,7 +24,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/addTxn.R =================================================================== --- pkg/blotter/R/addTxn.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/addTxn.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -320,7 +320,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/calcPortfWgt.R =================================================================== --- pkg/blotter/R/calcPortfWgt.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/calcPortfWgt.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -43,7 +43,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/calcPosAvgCost.R =================================================================== --- pkg/blotter/R/calcPosAvgCost.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/calcPosAvgCost.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -27,7 +27,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/calcTxnAvgCost.R =================================================================== --- pkg/blotter/R/calcTxnAvgCost.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/calcTxnAvgCost.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -13,7 +13,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/calcTxnValue.R =================================================================== --- pkg/blotter/R/calcTxnValue.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/calcTxnValue.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -14,7 +14,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/chart.ME.R =================================================================== --- pkg/blotter/R/chart.ME.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/chart.ME.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -100,7 +100,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/chart.Posn.R =================================================================== --- pkg/blotter/R/chart.Posn.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/chart.Posn.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -94,7 +94,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/chart.Reconcile.R =================================================================== --- pkg/blotter/R/chart.Reconcile.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/chart.Reconcile.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -162,7 +162,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/chart.Spread.R =================================================================== --- pkg/blotter/R/chart.Spread.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/chart.Spread.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -87,7 +87,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/extractTests.R =================================================================== --- pkg/blotter/R/extractTests.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/extractTests.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -56,7 +56,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getAccount.R =================================================================== --- pkg/blotter/R/getAccount.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getAccount.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -51,7 +51,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getByPortf.R =================================================================== --- pkg/blotter/R/getByPortf.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getByPortf.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -56,7 +56,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getBySymbol.R =================================================================== --- pkg/blotter/R/getBySymbol.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getBySymbol.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -55,7 +55,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getEndEq.R =================================================================== --- pkg/blotter/R/getEndEq.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getEndEq.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -18,7 +18,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getPortfAcct.R =================================================================== --- pkg/blotter/R/getPortfAcct.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getPortfAcct.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -23,7 +23,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getPortfolio.R =================================================================== --- pkg/blotter/R/getPortfolio.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getPortfolio.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -83,7 +83,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getPos.R =================================================================== --- pkg/blotter/R/getPos.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getPos.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -27,7 +27,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getPosAvgCost.R =================================================================== --- pkg/blotter/R/getPosAvgCost.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getPosAvgCost.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -17,7 +17,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getPosQty.R =================================================================== --- pkg/blotter/R/getPosQty.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getPosQty.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -31,7 +31,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/getTxn.R =================================================================== --- pkg/blotter/R/getTxn.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/getTxn.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -26,7 +26,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/initAcct.R =================================================================== --- pkg/blotter/R/initAcct.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/initAcct.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -83,7 +83,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/initPortf.R =================================================================== --- pkg/blotter/R/initPortf.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/initPortf.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -98,7 +98,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/initPosPL.R =================================================================== --- pkg/blotter/R/initPosPL.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/initPosPL.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -21,7 +21,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/initSummary.R =================================================================== --- pkg/blotter/R/initSummary.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/initSummary.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -13,7 +13,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/initTxn.R =================================================================== --- pkg/blotter/R/initTxn.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/initTxn.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -19,7 +19,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/perTradeStats.R =================================================================== --- pkg/blotter/R/perTradeStats.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/perTradeStats.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -300,7 +300,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/put.account.R =================================================================== --- pkg/blotter/R/put.account.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/put.account.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -14,7 +14,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/put.portfolio.R =================================================================== --- pkg/blotter/R/put.portfolio.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/put.portfolio.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -14,7 +14,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/tradeStats.R =================================================================== --- pkg/blotter/R/tradeStats.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/tradeStats.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -431,7 +431,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/updateAcct.R =================================================================== --- pkg/blotter/R/updateAcct.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/updateAcct.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -162,7 +162,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/updateEndEq.R =================================================================== --- pkg/blotter/R/updateEndEq.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/updateEndEq.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -45,7 +45,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/updatePortf.R =================================================================== --- pkg/blotter/R/updatePortf.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/updatePortf.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -124,7 +124,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING Modified: pkg/blotter/R/updatePosPL.R =================================================================== --- pkg/blotter/R/updatePosPL.R 2015-01-07 13:23:01 UTC (rev 1665) +++ pkg/blotter/R/updatePosPL.R 2015-01-07 13:26:09 UTC (rev 1666) @@ -254,7 +254,7 @@ ############################################################################### # Blotter: Tools for transaction-oriented trading systems development # for R (see http://r-project.org/) -# Copyright (c) 2008-2014 Peter Carl and Brian G. Peterson +# Copyright (c) 2008-2015 Peter Carl and Brian G. Peterson # # This library is distributed under the terms of the GNU Public License (GPL) # for full details see the file COPYING From noreply at r-forge.r-project.org Wed Jan 7 19:12:45 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 19:12:45 +0100 (CET) Subject: [Blotter-commits] r1667 - pkg/quantstrat/demo Message-ID: <20150107181245.36410184F4D@r-forge.r-project.org> Author: michaelguan326 Date: 2015-01-07 19:12:44 +0100 (Wed, 07 Jan 2015) New Revision: 1667 Added: pkg/quantstrat/demo/signal.RSI.R pkg/quantstrat/demo/signal.SMA.R Log: - add signal demos Added: pkg/quantstrat/demo/signal.RSI.R =================================================================== --- pkg/quantstrat/demo/signal.RSI.R (rev 0) +++ pkg/quantstrat/demo/signal.RSI.R 2015-01-07 18:12:44 UTC (rev 1667) @@ -0,0 +1,96 @@ +# Work Flow: +# Example Code 2 for Running Signal Analysis in Quantstrat. +# System: A simple RSI strategy for evaluating signals. +# Author: Michael Guan +########################################################################### +rm(list=ls()) + +# Load Packages: +require(iterators) +require(quantstrat) + +suppressWarnings(rm("order_book.RSI",pos=.strategy)) +suppressWarnings(rm("account.RSI","portfolio.RSI",pos=.blotter)) +suppressWarnings(rm("account.st","portfolio.st","stock.str","stratRSI","initDate","initEq",'start_t','end_t')) + +#Parameters +n=2 + +#Data +currency("USD") +currency("EUR") +symbols = c("XLF", "XLP") +for(symbol in symbols){ # establish trade-able instruments + stock(symbol, currency="USD",multiplier=1) + getSymbols(symbol,src='yahoo') +} + +# Initialize Account, Portfolio, Strategy +stratRSI <- strategy("RSI") + +initDate='1997-12-31' +initEq=100000 +port.st<-'RSI' #use a string here for easier changing of parameters and re-trying + +initPortf(port.st, symbols=symbols, initDate=initDate) +initAcct(port.st, portfolios=port.st, initDate=initDate,initEq=initEq) +initOrders(portfolio=port.st, initDate=initDate) +for(symbol in symbols){ addPosLimit(port.st, symbol, initDate, 300, 3 ) } #set max pos + +# Indicator +stratRSI <- add.indicator(strategy = stratRSI, name = "RSI", arguments = list(price = quote(getPrice(mktdata)),n=n), label="RSI") + +# There are two signals: +# The first is when RSI is greater than 90 +stratRSI <- add.signal(strategy = stratRSI, name="sigThreshold",arguments = list(threshold=70, column="RSI",relationship="gt", cross=TRUE),label="RSI.gt.70") +# The second is when RSI is less than 10 +stratRSI <- add.signal(strategy = stratRSI, name="sigThreshold",arguments = list(threshold=30, column="RSI",relationship="lt",cross=TRUE),label="RSI.lt.30") + +######################################################################### +#Signal Analysis + +#Entry Signal colname Label +signal.label = 'RSI.lt.30' + +.n = seq(2,10,1) + +strategy.st<-add.distribution(stratRSI, + paramset.label = 'RSI', + component.type = 'indicator', + component.label = 'RSI', + variable = list(n = .n), + label = 'nRSI') + + +# Run Study +results =apply.paramset.signal.analysis(strategy.st, + paramset.label='RSI', + port.st, + sigcol = signal.label, + sigval = 1, + on='days', + forward.days=10, + cum.sum=TRUE, + include.day.of.signal=F, + obj.fun=signal.obj.slope, + decreasing=T, + mktdata=NULL, + verbose=TRUE) + + +# Plot Paramset Combined Barchart [Subset list to plot a sub portion if too large] +plot.signals(results$sigret.by.asset$XLF, rows=2, columns = 5) + +# Distributional Box Plot via gamlss +distributional.boxplot(results$sigret.by.asset$XLF$paramset.2) + + + + + + + + + + + Added: pkg/quantstrat/demo/signal.SMA.R =================================================================== --- pkg/quantstrat/demo/signal.SMA.R (rev 0) +++ pkg/quantstrat/demo/signal.SMA.R 2015-01-07 18:12:44 UTC (rev 1667) @@ -0,0 +1,173 @@ +# Work Flow: +# Example Code 1 for Running Signal Analysis in Quantstrat. +# System: A simple moving average strategy for evaluating signal +# Author: Michael Guan +########################################################################### +# Load Packages: +rm(list=ls()) +require(iterators) +require(quantstrat) + +########################################################################### +# Configure Date Time Settings +ttz<-Sys.getenv('TZ') +Sys.setenv(TZ='UTC') + +suppressWarnings(rm("order_book.macross",pos=.strategy)) +suppressWarnings(rm("account.macross","portfolio.macross",pos=.blotter)) +suppressWarnings(rm("account.st","portfolio.st","stock.str","strategy.st",'start_t','end_t')) + +if(isTRUE(options('in_test')$in_test)){ + # use test dates + initDate="2011-01-01" + endDate="2012-12-31" +} else { + # use demo defaults + initDate="1999-12-31" + endDate=Sys.Date() +} + +########################################################################### +# Data +stock.str=c('XLY','XLF','XLP','XLI','RTH','XLV','XLK','XLE','IYT') +currency('USD') +stock(stock.str,currency='USD',multiplier=1) +getSymbols(stock.str,from=initDate,to=endDate,src = 'yahoo') +for(i in stock.str) + assign(i, adjustOHLC(get(i),use.Adjusted=TRUE)) + +########################################################################### +# Account, Portfolio, Strategy Initialization +initEq=1000000 +portfolio.st='macross' +account.st='macross' +initPortf(portfolio.st,symbols=stock.str, initDate=initDate) +initAcct(account.st,portfolios=portfolio.st, initDate=initDate,initEq=initEq) +initOrders(portfolio=portfolio.st,initDate=initDate) + +strategy.st<- strategy(portfolio.st) + + +#Indicator +strategy.st <- add.indicator(strategy = strategy.st, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=50),label= "ma50" ) +strategy.st <- add.indicator(strategy = strategy.st, name = "SMA", arguments = list(x=quote(Cl(mktdata)[,1]), n=200),label= "ma200") + +#Signals +strategy.st <- add.signal(strategy = strategy.st,name="sigCrossover",arguments = list(columns=c("ma50","ma200"), relationship="gte"), label="ma50.gt.ma200") +strategy.st <- add.signal(strategy = strategy.st,name="sigCrossover",arguments = list(column=c("ma50","ma200"),relationship="lt"), label="ma50.lt.ma200") + +########################################################################### + +# Signal Column Label to Analyze +signal.label = 'ma50.gt.ma200' + +# Desired Parameter Pool +.FastSMA = seq(1,5,1) +.SlowSMA = seq(5,20,5) + +strategy.st<-add.distribution(strategy.st, + paramset.label = 'SMA', + component.type = 'indicator', + component.label = 'ma50', + variable = list(n = .FastSMA), + label = 'nFAST') + +strategy.st<-add.distribution(strategy.st, + paramset.label = 'SMA', + component.type = 'indicator', + component.label = 'ma200', + variable = list(n = .SlowSMA), + label = 'nSLOW') + +# Constraint: nFast < nSlow +strategy.st<-add.distribution.constraint(strategy.st, + paramset.label = 'SMA', + distribution.label.1 = 'nFAST', + distribution.label.2 = 'nSLOW', + operator = '<', + label = 'SMA') + + +# Daily Signal With Post Daily Return Analysis +results =apply.paramset.signal.analysis(strategy.st, + paramset.label='SMA', + portfolio.st, + sigcol = signal.label, + sigval = 1, + on=NULL, + forward.days=50, + cum.sum=TRUE, + include.day.of.signal=F, + obj.fun=signal.obj.slope, + decreasing=T) + +distributional.boxplot(signal=results$sigret.by.asset$IYT$paramset.5.20, + x.val=seq(1, 50, 5),val=10,ylim=c(-20, 20), + xlim=c(0, 50),mai=c(1,1,0.3,0.5),h=0) + +plot.signals(results$sigret.by.asset$XLE, rows=5, columns = 4) +beanplot.signals(results$sigret.by.asset$XLE, rows=5, columns = 4) +plot.signal.path(results$sigret.by.asset$IYT$paramset.5.20) + + +# Daily Signal With Post Weekly Return Analysis +results.w =apply.paramset.signal.analysis(strategy.st, + paramset.label='SMA', + portfolio.st, + sigcol = signal.label, + sigval = 1, + on='weeks', + forward.days=10, + cum.sum=TRUE, + include.day.of.signal=F, + obj.fun=signal.obj.slope, + decreasing=T) + +distributional.boxplot(signal=results.w$sigret.by.asset$IYT$paramset.5.20, + x.val=seq(1, 10, 2),val=10,ylim=c(-20, 20), + xlim=c(0, 10),mai=c(1,1,0.3,0.5),h=0) + +plot.signals(results.w$sigret.by.asset$XLE, rows=5, columns = 4) +beanplot.signals(results.w$sigret.by.asset$XLE, rows=5, columns = 4) + + +# Daily Signal With Post Monthly Return Analysis +results.m =apply.paramset.signal.analysis(strategy.st, + paramset.label='SMA', + portfolio.st, + sigcol = signal.label, + sigval = 1, + on='months', + forward.days=5, + cum.sum=TRUE, + include.day.of.signal=F, + obj.fun=signal.obj.slope, + decreasing=T) + +distributional.boxplot(signal=results.m$sigret.by.asset$IYT$paramset.5.20, + x.val=seq(1, 5, 1),val=10,ylim=c(-30, 30), + xlim=c(0, 5),mai=c(1,1,0.3,0.5),h=0) + +plot.signals(results.m$sigret.by.asset$XLE, rows=5, columns = 4) +beanplot.signals(results.m$sigret.by.asset$XLE, rows=5, columns = 4) + + + + +############################################################################### +# R (http://r-project.org/) Quantitative Strategy Model Framework +# +# Copyright (c) 2009-2012 +# Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, +# Jeffrey Ryan, Joshua Ulrich, and Garrett See +# +# This library is distributed under the terms of the GNU Public License (GPL) +# for full details see the file COPYING +# +############################################################################### + +##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### +# book = getOrderBook(port) +# stats = tradeStats(port) +# rets = PortfReturns(acct) +################################################################ \ No newline at end of file From noreply at r-forge.r-project.org Tue Jan 13 19:28:06 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 13 Jan 2015 19:28:06 +0100 (CET) Subject: [Blotter-commits] r1668 - in pkg/quantstrat: demo sandbox/backtest_musings Message-ID: <20150113182806.814601878B7@r-forge.r-project.org> Author: braverock Date: 2015-01-13 19:28:06 +0100 (Tue, 13 Jan 2015) New Revision: 1668 Modified: pkg/quantstrat/demo/00Index 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 backtest paper Modified: pkg/quantstrat/demo/00Index =================================================================== --- pkg/quantstrat/demo/00Index 2015-01-07 18:12:44 UTC (rev 1667) +++ pkg/quantstrat/demo/00Index 2015-01-13 18:28:06 UTC (rev 1668) @@ -27,4 +27,5 @@ luxor.sample.tradeGraphs.sma.R Jaekle & Tomasini; sample 3D SMA graph luxor.sample.tradeGraphs.timespan.R Jaekle & Tomasini; sample 3D timespan graph signal.SMA.R SMA Cross Strategy with Signal Analysis Example; See maCross.R -signal.RSI.R RSI Cross Strategy with Signal Analysis Example; See rsi.R \ No newline at end of file +signal.RSI.R RSI Cross Strategy with Signal Analysis Example; See rsi.R + Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-07 18:12:44 UTC (rev 1667) +++ pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-13 18:28:06 UTC (rev 1668) @@ -1,112 +1,136 @@ - at book{Aronson2006, - author_sort = "Aronson, David", - author = "David Aronson", - year = "2006", - month = "Nov", - publisher = "Wiley", - title = "Evidence-Based Technical Analysis: Applying the Scientific Method and Statistical Inference to Trading Signals" +% This file was created with JabRef 2.10. +% Encoding: UTF-8 + + + at Book{Aronson2006, + Title = {Evidence-Based Technical Analysis: Applying the Scientific Method and Statistical Inference to Trading Signals}, + Author = {David Aronson}, + Publisher = {Wiley}, + Year = {2006}, + Month = {Nov}, + + Author_sort = {Aronson, David} } - at article{Bailey2014deSharpe, - title={The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality}, - author={Bailey, David H and {L{\'o}pez de Prado}, Marcos}, - journal={Journal of Portfolio Management, Forthcoming}, - year={2014}, - url={http://www.davidhbailey.com/dhbpapers/deflated-sharpe.pdf} + at 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}, + Journal = {Notices of the AMS}, + Year = {2014}, + Number = {5}, + Pages = {458--471}, + Volume = {61} } - at article{Bailey2014drawdown, - title={Drawdown-Based Stop-Outs and the 'Triple Penance' Rule}, - author={Bailey, David H and {L{\'o}pez de Prado}, Marcos}, - journal={Journal of Risk}, - year={forthcoming, 2014}, - url={http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2201302} + at Article{Bailey2014probability, + Title = {The probability of backtest overfitting}, + Author = {Bailey, David H and Borwein, Jonathan M and L{\'o}pez de Prado, Marcos and Zhu, Qiji Jim}, + Year = {2014}, + + Url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2326253} } - at 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}, - journal={Notices of the AMS}, - volume={61}, - number={5}, - pages={458--471}, - year={2014} + at Article{Bailey2014drawdown, + Title = {Drawdown-Based Stop-Outs and the 'Triple Penance' Rule}, + Author = {Bailey, David H and {L{\'o}pez de Prado}, Marcos}, + Journal = {Journal of Risk}, + Year = {forthcoming, 2014}, + + Url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2201302} } - at article{Bailey2014probability, - title={The probability of backtest overfitting}, - author={Bailey, David H and Borwein, Jonathan M and L{\'o}pez de Prado, Marcos and Zhu, Qiji Jim}, - year={2014}, - url={http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2326253} + at Article{Bailey2014deSharpe, + Title = {The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality}, + Author = {Bailey, David H and {L{\'o}pez de Prado}, Marcos}, + Journal = {Journal of Portfolio Management, Forthcoming}, + Year = {2014}, + + Url = {http://www.davidhbailey.com/dhbpapers/deflated-sharpe.pdf} } - at article{baquero2005, - title={Survival, look-ahead bias, and persistence in hedge fund performance}, - author={Baquero, Guillermo and Ter Horst, Jenke and Verbeek, Marno}, - journal={Journal of Financial and Quantitative Analysis}, - volume={40}, - number={03}, - pages={493--517}, - year={2005}, - publisher={Cambridge Univ Press}, - url= {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=371051} + at Article{baquero2005, + Title = {Survival, look-ahead bias, and persistence in hedge fund performance}, + Author = {Baquero, Guillermo and Ter Horst, Jenke and Verbeek, Marno}, + Journal = {Journal of Financial and Quantitative Analysis}, + Year = {2005}, + Number = {03}, + Pages = {493--517}, + Volume = {40}, + + Publisher = {Cambridge Univ Press}, + Url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=371051} } - at book{Box1987, - title={Empirical model-building and response surfaces.}, - author={Box, George E.P. and Draper, Norman R.}, - year={1987}, - publisher={John Wiley \& Sons} + at Book{Box1987, + Title = {Empirical model-building and response surfaces.}, + Author = {Box, George E.P. and Draper, Norman R.}, + Publisher = {John Wiley \& Sons}, + Year = {1987} } - at article{Burns2006, - title={Random Portfolios for Evaluating Trading Strategies}, - author={Burns, Patrick}, - year={2006}, - url={http://www.burns-stat.com/pages/Working/evalstrat.pdf} + at Article{Burns2006, + Title = {Random Portfolios for Evaluating Trading Strategies}, + Author = {Burns, Patrick}, + Year = {2006}, + + Url = {http://www.burns-stat.com/pages/Working/evalstrat.pdf} } - at book{Carroll2011, - title={The skeptic's dictionary}, - subtitle = { a collection of strange beliefs, amusing deceptions, and dangerous delusions}, - author={Carroll, Robert}, - year={2011}, - publisher={John Wiley \& Sons}, - url={http://skepdic.com/adhoc.html} + at Book{Carroll2011, + Title = {The skeptic's dictionary}, + Author = {Carroll, Robert}, + Publisher = {John Wiley \& Sons}, + Year = {2011}, + + Subtitle = { a collection of strange beliefs, amusing deceptions, and dangerous delusions}, + Url = {http://skepdic.com/adhoc.html} } - at article{Diedesch2014, - author={Diedesch, Josh}, - year={2014}, - journal={Chief Investment Officer}, - title ={2014 Forty Under Forty}, - publisher = {California State Teachers\' Retirement System}, - url={http://www.ai-cio.com/Forty_Under_Forty_2014.aspx?page=9} + at Article{Diedesch2014, + Title = {2014 Forty Under Forty}, + Author = {Diedesch, Josh}, + Journal = {Chief Investment Officer}, + Year = {2014}, + + Publisher = {California State Teachers\' Retirement System}, + Url = {http://www.ai-cio.com/Forty_Under_Forty_2014.aspx?page=9} } - @Book{Feynman1965, - title={The Feynman Lectures on Physics}, - author={Feynman, Richard P and Leighton, Robert B and Sands, Matthew and Hafner, EM}, - volume={1-3}, - year={1965} + Title = {The Feynman Lectures on Physics}, + Author = {Feynman, Richard P and Leighton, Robert B and Sands, Matthew and Hafner, EM}, + Year = {1965}, + Volume = {1-3} } @Book{Fitschen2013, - author = {Fitschen, Keith}, - publisher = {John Wiley \& Sons, Inc.}, - year = {2013}, - title = {Building Reliable Trading Systems}, - subtitle = {Tradable Strategies That Perform as They Backtest and Meet Your Risk-Reward Goals} + Title = {Building Reliable Trading Systems}, + Author = {Fitschen, Keith}, + Publisher = {John Wiley \& Sons, Inc.}, + Year = {2013}, + + Subtitle = {Tradable Strategies That Perform as They Backtest and Meet Your Risk-Reward Goals} } - at book{Hastie2009, - title={The elements of statistical learning: Data mining, inference, and prediction. Second Edition}, - author={Hastie, Trevor and Tibshirani, Robert and Friedman, Jerome}, - year={2009}, - publisher={Springer} + at Misc{Fox2011, + Title = {Multivariate Linear Models in R}, + + Author = {Fox, John and Weisberg, Sanford}, + Year = {2011}, + + __markedentry = {[brian:]}, + Owner = {brian}, + Publisher = {An Appendix to An R Companion to Applied Regression, Sage, Thousand Oaks, CA,}, + Timestamp = {2015.01.13} } + at Manual{parma2014, + Title = {parma: portfolio allocation and risk management applications.}, + Author = {Alexios Ghalanos and Bernhard Pfaff}, + Note = {R package version 1.5-1.}, + Year = {2014} +} + @Article{Hansen2005, Title = {A Test for Superior Predictive Ability}, Author = {Hansen,Peter R.}, @@ -114,111 +138,171 @@ Year = {2005} } - at article{Harvey2013backtesting, - title={Backtesting}, - author={Harvey, Campbell R. and Liu, Yan}, - journal={SSRN}, - url={http://ssrn.com/abstract=2345489}, - year={2013} + at Article{Harvey2014, + Title = {Evaluating Trading Strategies}, + Author = {Harvey, Campbell R. and Liu, Yan}, + Journal = {SSRN}, + Year = {2014}, + + Url = {http://ssrn.com/abstract=2474755} } - at article{Harvey2014, - title={Evaluating Trading Strategies}, - author={Harvey, Campbell R. and Liu, Yan}, - journal={SSRN}, - url={http://ssrn.com/abstract=2474755}, - year={2014} + at Article{Harvey2013backtesting, + Title = {Backtesting}, + Author = {Harvey, Campbell R. and Liu, Yan}, + Journal = {SSRN}, + Year = {2013}, + + Url = {http://ssrn.com/abstract=2345489} } - at article{Harvey2013multiple, - title={Multiple Testing in Economics}, - author={Harvey, Campbell R. and Liu, Yan}, - journal={SSRN}, - url={http://ssrn.com/abstract=2358214}, - year={2013} + at Article{Harvey2013multiple, + Title = {Multiple Testing in Economics}, + Author = {Harvey, Campbell R. and Liu, Yan}, + Journal = {SSRN}, + Year = {2013}, + + Url = {http://ssrn.com/abstract=2358214} } - at book{Horowitz2014, - title={The Hard Thing about Hard Things}, - subtitle={Building a Business when There are No Easy Answers}, - author={Horowitz, Ben}, - year={2014}, - publisher={HarperCollins} + at Book{Hastie2009, + Title = {The elements of statistical learning: Data mining, inference, and prediction. Second Edition}, + Author = {Hastie, Trevor and Tibshirani, Robert and Friedman, Jerome}, + Publisher = {Springer}, + Year = {2009} } - at book{Kestner2003, - title={Quantitative trading strategies: {H}arnessing the power of quantitative techniques to create a winning trading program}, - author={Kestner, Lars}, - year={2003}, - publisher={McGraw-Hill} + at Book{Horowitz2014, + Title = {The Hard Thing about Hard Things}, + Author = {Horowitz, Ben}, + Publisher = {HarperCollins}, + Year = {2014}, + + Subtitle = {Building a Business when There are No Easy Answers} } + at Book{Ilmanen2011, + Title = {Expected returns: an investor's guide to harvesting market rewards}, + Author = {Ilmanen, Antti}, + Publisher = {John Wiley \& Sons}, + Year = {2011} +} + + at Book{Kestner2003, + Title = {Quantitative trading strategies: {H}arnessing the power of quantitative techniques to create a winning trading program}, + Author = {Kestner, Lars}, + Publisher = {McGraw-Hill}, + Year = {2003} +} + @Book{Kuhn2013, Title = {Applied predictive modeling}, Author = {Kuhn, Max and Johnson, Kjell}, Publisher = {Springer}, Year = {2013}, - url = {http://appliedpredictivemodeling.com/} + + Url = {http://appliedpredictivemodeling.com/} } - at misc{mistakes2011, - author={Martha K. Smith}, - author_sort={Smith, Martha}, - title={Common ~~ misteaks ~~ mistakes in using statistics: Spotting and Avoiding Them - Data Snooping}, - url = {https://www.ma.utexas.edu/users/mks/statmistakes/datasnooping.html}, - accessed = {2014-09-23} + at Article{Levy2006, + Title = {A systems approach to conduct an effective literature review in support of information systems research}, + Author = {Levy, Yair and Ellis, Timothy J}, + Journal = {Informing Science: International Journal of an Emerging Transdiscipline}, + Year = {2006}, + Number = {1}, + Pages = {181--212}, + Volume = {9}, + + __markedentry = {[brian:6]}, + Owner = {brian}, + Publisher = {Informing Science Institute}, + Timestamp = {2015.01.13}, + Url = {http://inform.nu/Articles/Vol9/V9p181-212Levy99.pdf} } - at book{Pardo2008, - title={The evaluation and optimization of trading strategies, second edition}, - author_sort = "Pardo, Robert", - author = "Robert Pardo", - year = "2008", - month = "Feb", - year={2011}, - publisher={John Wiley \& Sons} + at Book{Pardo2008, + Title = {The evaluation and optimization of trading strategies, second edition}, + Author = {Robert Pardo}, + Publisher = {John Wiley \& Sons}, + Year = {2008}, + Month = {Feb}, + + Author_sort = {Pardo, Robert} } + at Article{Peterson2015, + Title = {Developing \& Backtesting Systematic Trading Strategies }, + Author = {Peterson, Brian G}, + Year = {2015}, + + Url = {http://goo.gl/na4u5d} +} + @Manual{perfa2014, - title = {PerformanceAnalytics: Econometric tools for performance and risk analysis}, - author = {Brian G. Peterson and Peter Carl}, - year = {2014}, - subtitle = {R package version 1.4.3541}, - url = {http://CRAN.R-project.org/package=PerformanceAnalytics}, + Title = {PerformanceAnalytics: Econometric tools for performance and risk analysis}, + Author = {Brian G. Peterson and Peter Carl}, + Year = {2015}, + + Subtitle = {R package version 1.4.3541}, + Url = {http://CRAN.R-project.org/package=PerformanceAnalytics} } @Manual{porta2014, - title = {PortfolioAnalytics: Portfolio Analysis, including Numerical Methods for Optimization of Portfolios}, - author = {Brian G. Peterson and Peter Carl and Ross Bennett and Kris Boudt}, - year = {2014}, - subtitle = {R package version 0.9.0}, - url={http://r-forge.r-project.org/projects/returnanalytics/} + Title = {PortfolioAnalytics: Portfolio Analysis, including Numerical Methods for Optimization of Portfolios}, + Author = {Brian G. Peterson and Peter Carl and Ross Bennett and Kris Boudt}, + Year = {2015}, + + Subtitle = {R package version 0.9.3581}, + Url = {http://r-forge.r-project.org/projects/returnanalytics/} } @Manual{quantstrat2014, - title = {quantstrat: Quantitative Strategy Model Framework}, - author = {Brian G. Peterson and Joshua Ulrich and Jan Humme and Peter Carl }, - year = {2014}, - subtitle = {R package version 0.9.1632}, - url = {http://r-forge.r-project.org/projects/blotter/} + Title = {quantstrat: Quantitative Strategy Model Framework}, + Author = {Brian G. Peterson and Joshua Ulrich and Jan Humme and Peter Carl }, + Year = {2015}, + + Subtitle = {R package version 0.9.1667}, + Url = {http://r-forge.r-project.org/projects/blotter/} } - at article{Racine2009, - title={Data-driven model evaluation: a test for revealed performance}, - author={Racine, Jeffrey S and Parmeter, Christopher F}, - journal={Mac Master University}, - year={2009}, - url={https://editorialexpress.com/cgi-bin/conference/download.cgi?db_name=FEMES09&paper_id=152} + at Manual{R2014, + Title = {R: A Language and Environment for Statistical Computing}, + + Address = {Vienna, Austria}, + Author = {{R Core Team}}, + Organization = {R Foundation for Statistical Computing}, + Year = {2014}, + + Url = {http://www.R-project.org/} } - at article{Ripley2004, - title={Selecting amongst large classes of models}, - author={Ripley, Brian D}, - journal={Methods and models in statistics: In honor of Professor John Nelder, FRS}, - pages={155--170}, - year={2004} + at Article{Racine2009, + Title = {Data-driven model evaluation: a test for revealed performance}, + Author = {Racine, Jeffrey S and Parmeter, Christopher F}, + Journal = {Mac Master University}, + Year = {2009}, + + Url = {https://editorialexpress.com/cgi-bin/conference/download.cgi?db_name=FEMES09&paper_id=152} } + at Article{Ripley2004, + Title = {Selecting amongst large classes of models}, + Author = {Ripley, Brian D}, + Journal = {Methods and models in statistics: In honor of Professor John Nelder, FRS}, + Year = {2004}, + Pages = {155--170} +} + + at Misc{mistakes2011, + Title = {Common ~~ misteaks ~~ mistakes in using statistics: Spotting and Avoiding Them - Data Snooping}, + + Author = {Martha K. Smith}, + + Accessed = {2014-09-23}, + Author_sort = {Smith, Martha}, + Url = {https://www.ma.utexas.edu/users/mks/statmistakes/datasnooping.html} +} + @Article{Sullivan1999, Title = {Data snooping, technical trading rule performance, and the bootstrap}, Author = {Sullivan, Ryan and Timmermann, Allan and White, Halbert}, @@ -227,49 +311,63 @@ Number = {5}, Pages = {1647-1691}, Volume = {54} - } - at misc{Tomasini2009, - author_sort = "Tomasini, Emilio \& Jaekle, Urban", - author = "Emilio Tomasini and Urban Jaekle", - year = "2009", - month = "Dec", - volume = "1", - title = "Trading Systems: A New Approach to System Development and -Portfolio Optimisation ", - title_sort = "Trading Systems A New Approach to System Development -and Portfolio Optimisation" + at Misc{Tomasini2009, + Title = {Trading Systems: A New Approach to System Development and +Portfolio Optimisation }, + + Author = {Emilio Tomasini and Urban Jaekle}, + Month = {Dec}, + Year = {2009}, + + Author_sort = {Tomasini, Emilio \& Jaekle, Urban}, + Title_sort = {Trading Systems A New Approach to System Development +and Portfolio Optimisation}, + Volume = {1} } - at article{Tukey1962, - title={The future of data analysis}, - author={Tukey, John W}, - journal={The Annals of Mathematical Statistics}, - pages={1--67}, - year={1962}, - publisher={JSTOR}, - url={http://projecteuclid.org/euclid.aoms/1177704711} + at Article{Tukey1962, + Title = {The future of data analysis}, + Author = {Tukey, John W}, + Journal = {The Annals of Mathematical Statistics}, + Year = {1962}, + Pages = {1--67}, + + Publisher = {JSTOR}, + Url = {http://projecteuclid.org/euclid.aoms/1177704711} } - at book{Vince2009, - title={The leverage space trading model}, - subtitle={Reconciling portfolio management strategies and economic theory}, - author={Vince, Ralph}, - volume={425}, - year={2009}, - publisher={John Wiley and Sons} + at Book{Vince2009, + Title = {The leverage space trading model}, + Author = {Vince, Ralph}, + Publisher = {John Wiley and Sons}, + Year = {2009}, + Volume = {425}, + + Subtitle = {Reconciling portfolio management strategies and economic theory} } - at misc{White2000, - title={System and method for testing prediction models and/or entities}, - author={Halbert L. White}, - authorsort ={White, Halbert L.}, - url={http://www.google.com/patents/US6088676}, - year={2000}, - month=jul # "~11", - publisher={Google Patents}, - note={US Patent 6,088,676} + at Misc{White2000, + Title = {System and method for testing prediction models and/or entities}, + + Author = {Halbert L. White}, + Month = jul # {~11}, + Note = {US Patent 6,088,676}, + Year = {2000}, + + Authorsort = {White, Halbert L.}, + Publisher = {Google Patents}, + Url = {http://www.google.com/patents/US6088676} } + at Misc{Rmarkdown, + Title = {R Markdown ? Dynamic Documents for R}, + Author = {Yihui Xie}, + + Owner = {brian}, + Timestamp = {2015.01.13}, + Url = {http://rmarkdown.rstudio.com/} +} + Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2015-01-07 18:12:44 UTC (rev 1667) +++ pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2015-01-13 18:28:06 UTC (rev 1668) @@ -291,15 +291,17 @@ plain erroneous idea. The faster an untestable idea can be set aside for more verifiable ideas, the better. -\newthought{Proceeding without a hypothesis risks ruin.} Many strategists -will still try to skip robust hypotheses in favor of sloppy ones such -as "I hypothesize that this strategy idea will make money". While the value -of testing a more rigorous hypothesis should be clear, it may be more -difficult to see the risks imposed by having no hypothesis or a sloppy or -incomplete hypothesis. An incomplete or otherwise deficient hypothesis at this -stage will create a strong desire to "refine" the hypothesis later by adding -new explanatory statements. This is called an "ad hoc hypothesis", where -new hypotheses are piled on top of old to better "explain" observation. +\newthought{Proceeding without a hypothesis risks ruin.} ^[*A big computer, +a complex algorithm and a long time does not equal science. - Robert Gentleman*] +Many strategists will still try to skip robust hypotheses in favor of sloppy +ones such as "I hypothesize that this strategy idea will make money". + +While the value of testing a more rigorous hypothesis should be clear, it may +be more difficult to see the risks imposed by having no hypothesis or a sloppy +or incomplete hypothesis. An incomplete or otherwise deficient hypothesis at +this stage will create a strong desire to "refine" the hypothesis later by +adding new explanatory statements. This is called an "ad hoc hypothesis", +where new hypotheses are piled on top of old to better "explain" observation. (@Carroll2011 , p. 7 or online; see also "rule burden", below) Engaging in the creation of ad hoc hypotheses risks ruin, as the in sample (IS) explanatory power of the model will seem to go up, while the @@ -1430,7 +1432,7 @@ - *techniques for backing out from weights to capital to order sizes* ___ -# Probability of Overfitting ^[*A big computer, a complex algorithm and a long time does not equal science. - Robert Gentleman*] +# Probability of Overfitting ^[*We should recognize the reality that any simulated (backtest) performance presented to us likely overstates future prospects. By how much? -Antti Ilmanen* [- at Ilmanen2011] p. 112 ] \newthought{This entire paper has been devoted to avoiding overfitting.} At the end of the modeling process, we still need to evaluate how likely @@ -1626,11 +1628,14 @@ as those of Brian Peterson, and do not necessarily reflect the opinions or policies of DV Trading or DV Asset Management. -?2014 Brian G. Peterson +?2014-2015 Brian G. Peterson \includegraphics[width=1.75cm]{cc-by-nc-sa} *Please do not distribute this draft without permission.* + +The most recently published version of this document may be found at \url{http://goo.gl/na4u5d} + \newpage ___ Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Wed Jan 14 00:03:12 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 14 Jan 2015 00:03:12 +0100 (CET) Subject: [Blotter-commits] r1669 - in pkg/quantstrat: . R Message-ID: <20150113230312.D6280187831@r-forge.r-project.org> Author: bodanker Date: 2015-01-14 00:03:12 +0100 (Wed, 14 Jan 2015) New Revision: 1669 Modified: pkg/quantstrat/DESCRIPTION pkg/quantstrat/R/paramsets.R Log: - Fix bug #5776 (again); thanks to Aylon for the report http://stackoverflow.com/q/27912302/271616 Modified: pkg/quantstrat/DESCRIPTION =================================================================== --- pkg/quantstrat/DESCRIPTION 2015-01-13 18:28:06 UTC (rev 1668) +++ pkg/quantstrat/DESCRIPTION 2015-01-13 23:03:12 UTC (rev 1669) @@ -1,7 +1,7 @@ Package: quantstrat Type: Package Title: Quantitative Strategy Model Framework -Version: 0.9.1665 +Version: 0.9.1669 Date: $Date$ Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme Depends: Modified: pkg/quantstrat/R/paramsets.R =================================================================== --- pkg/quantstrat/R/paramsets.R 2015-01-13 18:28:06 UTC (rev 1668) +++ pkg/quantstrat/R/paramsets.R 2015-01-13 23:03:12 UTC (rev 1669) @@ -198,9 +198,9 @@ if(strategy$rules[[component.type]][[index]]$label == component.label) { if(variable.name %in% c('timespan')) - strategy$rules[[component.type]][[index]][[variable.name]] <- as.character(param.combo[[param.label]]) + strategy$rules[[component.type]][[index]][[variable.name]] <- as.character(param.combo[,param.label]) else - strategy$rules[[component.type]][[index]]$arguments[[variable.name]] <- param.combo[[param.label]] + strategy$rules[[component.type]][[index]]$arguments[[variable.name]] <- param.combo[,param.label] found <- TRUE break From noreply at r-forge.r-project.org Fri Jan 16 15:37:55 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 16 Jan 2015 15:37:55 +0100 (CET) Subject: [Blotter-commits] r1670 - pkg/quantstrat/sandbox/backtest_musings Message-ID: <20150116143755.F0D9E1872EB@r-forge.r-project.org> Author: braverock Date: 2015-01-16 15:37:55 +0100 (Fri, 16 Jan 2015) New Revision: 1670 Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf Log: - minor updates to backtest paper Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-13 23:03:12 UTC (rev 1669) +++ pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-16 14:37:55 UTC (rev 1670) @@ -61,6 +61,20 @@ Url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=371051} } + at Article{Barnes2010, + Title = {Publish your computer code: it is good enough}, + Author = {Barnes, Nick}, + Journal = {Nature}, + Year = {2010}, + Number = {7317}, + Pages = {753--753}, + Volume = {467}, + Owner = {brian}, + Publisher = {Nature Publishing Group}, + Timestamp = {2015.01.14}, + Url = {http://www.nature.com/news/2010/101013/full/467753a.html} +} + @Book{Box1987, Title = {Empirical model-building and response surfaces.}, Author = {Box, George E.P. and Draper, Norman R.}, @@ -96,6 +110,19 @@ Url = {http://www.ai-cio.com/Forty_Under_Forty_2014.aspx?page=9} } + at Article{Dudler2014, + Title = {Risk Adjusted Time Series Momentum}, + Author = {Dudler, Martin and Gmuer, Bruno and Malamud, Semyon}, + Journal = {Available at SSRN 2457647}, + Year = {2014}, + + __markedentry = {[brian:6]}, + Abstract = {We introduce a new class of momentum strategies that are based on the long-term averages of risk-adjusted returns and test these strategies on a universe of 64 liquid futures contracts. We show that this risk adjusted momentum strategy outperforms the time series momentum strategy of Ooi, Moskowitz and Pedersen (2012) for almost all combinations of holding- and look-back periods. We construct measures of momentum-specific volatility (risk), (both within and across asset classes) and show that these volatility measures can be used both for risk management and it momentum timing. We find that momentum risk management significantly increases Sharpe ratios, but at the same time leads to more pronounced negative skewness and tail risk; by contrast, combining risk management with momentum timing practically eliminates the negative skewness of momentum returns and significantly reduces tail risk. In addition, momentum risk management leads to a much lower exposure to market, value, and momentum factors. As a result, risk-managed momentum returns offer much higher diversification benefits than the standard momentum returns.}, + Owner = {brian}, + Timestamp = {2015.01.15}, + Url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2457647} +} + @Book{Feynman1965, Title = {The Feynman Lectures on Physics}, Author = {Feynman, Richard P and Leighton, Robert B and Sands, Matthew and Hafner, EM}, @@ -117,8 +144,6 @@ Author = {Fox, John and Weisberg, Sanford}, Year = {2011}, - - __markedentry = {[brian:]}, Owner = {brian}, Publisher = {An Appendix to An R Companion to Applied Regression, Sage, Thousand Oaks, CA,}, Timestamp = {2015.01.13} @@ -188,6 +213,20 @@ Year = {2011} } + at Article{Ince2012, + Title = {The case for open computer programs}, + Author = {Ince, Darrel C and Hatton, Leslie and Graham-Cumming, John}, + Journal = {Nature}, + Year = {2012}, + Number = {7386}, + Pages = {485--488}, + Volume = {482}, + Owner = {brian}, + Publisher = {Nature Publishing Group}, + Timestamp = {2015.01.14}, + Url = {http://www.nature.com/nature/journal/v482/n7386/pdf/nature10836.pdf} +} + @Book{Kestner2003, Title = {Quantitative trading strategies: {H}arnessing the power of quantitative techniques to create a winning trading program}, Author = {Kestner, Lars}, @@ -212,8 +251,6 @@ Number = {1}, Pages = {181--212}, Volume = {9}, - - __markedentry = {[brian:6]}, Owner = {brian}, Publisher = {Informing Science Institute}, Timestamp = {2015.01.13}, @@ -230,6 +267,20 @@ Author_sort = {Pardo, Robert} } + at Article{Peng2011, + Title = {Reproducible research in computational science}, + Author = {Peng, Roger D}, + Journal = {Science (New York, Ny)}, + Year = {2011}, + Number = {6060}, + Pages = {1226}, + Volume = {334}, + Owner = {brian}, + Publisher = {NIH Public Access}, + Timestamp = {2015.01.14}, + Url = {http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3383002/} +} + @Article{Peterson2015, Title = {Developing \& Backtesting Systematic Trading Strategies }, Author = {Peterson, Brian G}, @@ -348,6 +399,17 @@ Subtitle = {Reconciling portfolio management strategies and economic theory} } + at Article{Vlaeminck2013, + Title = {Research Data Management in Economic Journals}, + Author = {Sven Vlaeminck}, + Journal = {American Economic Review, Open Economics}, + Year = {2013}, + + Owner = {brian}, + Timestamp = {2015.01.14}, + Url = {http://openeconomics.net/resources/data-policies-of-economic-journals/} +} + @Misc{White2000, Title = {System and method for testing prediction models and/or entities}, @@ -365,9 +427,22 @@ Title = {R Markdown ? Dynamic Documents for R}, Author = {Yihui Xie}, + Year = {2014}, Owner = {brian}, Timestamp = {2015.01.13}, Url = {http://rmarkdown.rstudio.com/} } + at Article{Economist2013, + Title = {Unreliable Research: Trouble at the lab}, + Journal = {Economist}, + Year = {2013}, + + Month = {Oct 19}, + + Owner = {brian}, + Timestamp = {2015.01.14}, + Url = {http://www.economist.com/news/briefing/21588057-scientists-think-science-self-correcting-alarming-degree-it-not-trouble} +} + Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Sat Jan 17 18:38:17 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 17 Jan 2015 18:38:17 +0100 (CET) Subject: [Blotter-commits] r1671 - pkg/quantstrat/demo Message-ID: <20150117173817.51EBD1873C9@r-forge.r-project.org> Author: bodanker Date: 2015-01-17 18:38:17 +0100 (Sat, 17 Jan 2015) New Revision: 1671 Modified: pkg/quantstrat/demo/signal.RSI.R pkg/quantstrat/demo/signal.SMA.R Log: - Remove rm(list=ls()), add copyright, update copyright date Modified: pkg/quantstrat/demo/signal.RSI.R =================================================================== --- pkg/quantstrat/demo/signal.RSI.R 2015-01-16 14:37:55 UTC (rev 1670) +++ pkg/quantstrat/demo/signal.RSI.R 2015-01-17 17:38:17 UTC (rev 1671) @@ -3,7 +3,6 @@ # System: A simple RSI strategy for evaluating signals. # Author: Michael Guan ########################################################################### -rm(list=ls()) # Load Packages: require(iterators) @@ -84,13 +83,15 @@ # Distributional Box Plot via gamlss distributional.boxplot(results$sigret.by.asset$XLF$paramset.2) +############################################################################### +# R (http://r-project.org/) Quantitative Strategy Model Framework +# +# Copyright (c) 2009-2015 +# Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, +# Jeffrey Ryan, Joshua Ulrich, and Garrett See +# +# This library is distributed under the terms of the GNU Public License (GPL) +# for full details see the file COPYING +# +############################################################################### - - - - - - - - - Modified: pkg/quantstrat/demo/signal.SMA.R =================================================================== --- pkg/quantstrat/demo/signal.SMA.R 2015-01-16 14:37:55 UTC (rev 1670) +++ pkg/quantstrat/demo/signal.SMA.R 2015-01-17 17:38:17 UTC (rev 1671) @@ -3,8 +3,8 @@ # System: A simple moving average strategy for evaluating signal # Author: Michael Guan ########################################################################### + # Load Packages: -rm(list=ls()) require(iterators) require(quantstrat) @@ -151,13 +151,10 @@ plot.signals(results.m$sigret.by.asset$XLE, rows=5, columns = 4) beanplot.signals(results.m$sigret.by.asset$XLE, rows=5, columns = 4) - - - ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework # -# Copyright (c) 2009-2012 +# Copyright (c) 2009-2015 # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, # Jeffrey Ryan, Joshua Ulrich, and Garrett See # @@ -170,4 +167,4 @@ # book = getOrderBook(port) # stats = tradeStats(port) # rets = PortfReturns(acct) -################################################################ \ No newline at end of file +################################################################ From noreply at r-forge.r-project.org Tue Jan 20 00:30:42 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 20 Jan 2015 00:30:42 +0100 (CET) Subject: [Blotter-commits] r1672 - pkg/quantstrat/sandbox/backtest_musings Message-ID: <20150119233042.A06D3187887@r-forge.r-project.org> Author: braverock Date: 2015-01-20 00:30:42 +0100 (Tue, 20 Jan 2015) New Revision: 1672 Added: pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd pkg/quantstrat/sandbox/backtest_musings/research_replication.pdf Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib Log: - add essay on replicating research Added: pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd (rev 0) +++ pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd 2015-01-19 23:30:42 UTC (rev 1672) @@ -0,0 +1,501 @@ +--- +title: "Research Replication" +author: "Brian G. Peterson" +bibliography: stat_process.bib +date: "`r format(Sys.time(), '%B %d, %Y')`" +output: pdf_document +--- + +___________ + +This essay provides a process and supporting framework to help in replicating +the research of others. Analysis of new trading system hypotheses often starts +when an analyst or their management reads an interesting paper which provides +the seed of a new idea. To fully understand and make use of the ideas in the +paper, the analyst needs to first replicate the paper, since most papers do not +publish data and code. + +After replicating the paper, the results need to be analyzed to determine +whether the model or results are credible, and how the analysis of the paper can +be improved. Only after replication is complete, and the analyst has formulated +an opinion on the quality and applicability of the research to be done, can s/he +move on to creating a backtest for a new strategy incorporating or based on the +models or techniques in the paper. + +Throughout this document, we will refer to the "original research" or "source +paper" interchangeably, though the research to be replicated may be part of a +book chapter, or a blog post, or a web page. With practice, after a number of +replications of this type are completed, some of the steps in this process may +be curtailed or skipped altogether. We believe that the complete process has +value as the reproducibility and clarity of thinking of the research will make +the deliverables more reusable and useful over time. + +Try to go through the entire process at a publication-quality level, as you may +choose to publish part or all of your replication work at a later point. You +should write in your own words, in order to better develop a deeper understanding +of the source material. If you must quote, make sure to properly cite the +quotation, as even unintentional or accidental plagiarism can have serious +consequences. Any portion of the replication may be edited as you progress +through the project; do not consider it to be a completed document until the +entire project is finished. ^[Thanks to David Matteson for his additions to this +process.] + +___________ + +# Summarize the Paper + +One of the first main steps is to be able to summarize the paper in a structured +document which should be 2-3 pages long, devoting no more than one paragraph +to each main point. The goal of the summary stage is to make certain that the +paper and its research context are understood. + +The *pr?cis* model of formal summary is useful in this regard. +Introduction, 2-5 main points, conclusion. +Similar forms are the classic "five paragraph essay". + +*Why so formal?* The concise summary provides a road map for the following stages. +The goal of such a short, formal, summary is to organize your thinking in a +structured way which will make replication easier. The summary will help to +uncover logical errors or omissions (either in the reader or the paper) much +earlier in the process. It will allow you to identify early where you need more +information, and where you will be likely to have difficulties with your +research. + +Candidates for main points are key assertions or findings, major contributions, +summary of the main technique(s) used, etc. Each of the main points should +describe how the paper supports its points, including what methods, tests, or +arguments are made. + +The concise pr?cis model is 4-6 declarative sentences. The analyst should +strive to follow the concise model in the introductory paragraph of the paper +summary. The introductory paragraph should have the following sentences: + + 1. a single introductory sentence describing + - the title, authors, and journal the paper appeared in + - an appropriate verb such as *assert, argue, deny, demonstrate, disprove, + examine, prove, refute* + - a **that** object clause that describes the thesis of the work + 1. one sentence for each major point in the paper + - choosing *no more* than five points + - each sentence should describe the technique or claim + - and the claimed result of applying the concept + 1. one sentence that ties it all together: what the reader should be + expected to take away from the paper + +The rest of the pr?cis document will devote one paragraph to each major point +from the introduction, using the structure: + + 1. a declarative sentence which restates and paraphrases the technique or + claim to be covered in this paragraph + 1. two to four sentences describing + - the main methods, tests, or arguments + - formulas (with appropriate citation) when they add necessary precision + - results from this portion of the paper + 1. one sentence which summarizes any take away conclusions about the idea + being described + +The summary document will then conclude with a single paragraph which ties +together all the main points, and describes the relevance of the work to the +analyst's research interests. + + +___________ + +# Describe the Hypothesis + +At this next stage, the analyst should work to expand the understanding of the +hypothesis or hypotheses which are to be tested. The hypotheses presented by the +source paper need extraction, enumeration, and expansion. Expected tests for +the hypotheses also need to be considered and specified in this stage. + +A hypothesis statement includes: + +- what is being analyzed (the subject), +- the dependent variable(s) (the output/result/prediction) +- the independent variables (inputs into the model) +- the anticipated possible outcomes, including direction or comparison +- address *how you will validate or refute each hypothesis* + +The pr?cis form of structured paragraphs (containing the points above) may be +useful in stating the hypotheses, or a less regimented hypothesis/test pairing +may be more appropriate. Some judgement will be required at this stage both in +extracting hypotheses, and in describing the hypotheses and their tests. + +___________ + +# Literature Review + +After summarizing the paper, and extracting the hypotheses, it is time to +move on to a *literature review*.[@Levy2006] A literature review is a formal +summary of the literature covering the idea that you are researching. It serves +to make certain that you are looking at relevant work, and to keep formal notes +on the relevant papers. + +We recommend again following the pr?cis model: + + 1. the bibliographic entry for the paper + 1. a single sentence describing the thesis of the work + 1. two to four sentences covering the main points or findings of the paper + 1. a summary sentence describing this paper's relevance and relation to the + current research project + +It is not necessary or desirable to gain deep understanding of every +paper you will review during the course of your replication research. The main +goal is rather to understand the framework that your research goal fits into, +and develop resources for deeper understanding when that is required. + +## organization of the literature review +The analyst will need to decide on an organizational scheme for the literature +review. There are two models which you will return to; which model is appropriate +will depend both on how the replication is to proceed, and how the analyst's +internal organizational structure is envisioned. + +The first model is the *annotated bibliography*. It is organized alphabetically, +by author, containing the bibliographic entry plus the paragraph of summary as +described above. Methodologically, it has an advantage that all the material +for the annotated bibliography may be stored in the reference manager software, +and a template may be used to construct the annotated bibliography automatically +from all the reference notations in the replication research report. The +annotated bibliography has the disadvantage that it has no other organization, +so keeping track of multiple references for importance or topic can be very +difficult. + +The second model organizes the literature review by key topic. The top level +for this organization of the literature review should be the two to four main +topics of the paper being replicated. It may further be organized into +sub-topics or techniques, as appropriate for the research project. The +advantage of this model is that it allows the analyst to rapidly locate key +references on a topic or idea or technique, along with their summaries. The +potential disadvantage is that it is very specific to this research project, +and may be less useful in the future for additional research. This risk is +usually offset by the topic-based organization, which allows papers to be +quickly located by topic. + +## key references of the paper being replicated + +The literature review should start with the key references of the paper you are +trying to replicate. It should have become clear while reading and summarizing +the paper which papers provided starting material or key techniques for this +paper. These papers should be located and summarized in a single paragraph +each, as described above. + +## finding similar work + +Other papers which should be included in the literature review are similar work. +Resources like Google Scholar will automatically recommend similar papers, and +even order them by number of papers that reference the paper in the results. +The analyst will want to make sure that they at least review a few papers which +are at the top of a literature search on the key topics. + +## references with implementation hints + +Finally, the literature review is not complete without including implementation +references that cover the key analytical techniques to be used in the +replication. These should be as hands-on as possible. For example, a paper +to be replicated which includes a complex multivariate linear model may include +a reference to *Multivariate Linear Models in R*[@Fox2011]. The paragraph +describing this reference can focus on the specific chapter or technique of +interest, aiding the analyst in collecting their thoughts, and aiding any +readers to find the relevant material. + +___________ + +# Data + +The paper to be replicated will have described the data which was used in the +paper. Summarize this information in your replication report. Pay particular +attention to data sources, time-frames, and specific instruments. If a data +vendor is mentioned, be sure to note this in your report. This constitutes the +*original source data* which you are trying to replicate. + +In rare cases, the original source data will be published exactly online. It +may be from some earlier paper, or it may be in the "supplementary materials" +included online at the journal publisher or author's website. If you can find +this data, it will save you a lot of time. In most cases, the original source +data will not be available. + +If the source paper did not specifically list the data as private or confidential, +and time allows, you may wish to contact the primary author of the source paper +via email and (politely) request the data. If the author provides the data, make +sure to thank the author and properly cite this in your report. + +When you do not have the original source data, you must locate data that is as +close as possible to the source data. We recommend working in the following +order: + + 1. see what data vendors you have access to at your organization + 1. check and see if you have access to any data vendors that were listed in + the original paper + 1. if you don't have access to the precise data vendors, or the paper does not + state which vendor was used, then make a list of possible sources by + subsetting your list of available sources + 1. determine what symbols will need to be requested from each vendor + 1. if your vendors do not have all the data you need, determine if you can get + enough representative data to proceed, or if you need to try another + approach + +Once you've located the data, you need to download it. Keep notes on the +process, the vendor, and all of the symbols. This will aid you later if you +come back to this research, or want to extend the data. + +If you can download the data directly in *R*, the code to so should be included +in your replication report, though you may comment it or mark it to not be run +given the time that downloading takes. Store all of the data for your +replication with the project archive. + +If possible, get data that copies the time-frame used in the original paper, in +addition to the specific instruments. In addition, make a data request all the +way to the current date. This "newer" data should be reserved as a validation +set, it can be used for many tests of out of sample deterioration and overfitting. + +Once you have the data, you need to get it into *R* if you were not able to +download it directly into your analytical environment. Code for loading the +data, labeling it, converting it to **xts**, etc. should be included in your +replication report. Add citations for all packages that you use. + +Some attention should be given in your report to the checks that you do for +data quality. For example: + +- is the data complete? are there gaps in it? +- do you have all the instruments from the source paper? +- do you have the same time-frames? +- can you validate that your data looks like the source data by quickly + replicating any charts or graphs from the paper? +- do you need to do any data cleaning for outliers? +- was any data cleaning mechanism described in the source paper? + +Document all the steps that you take with the data in your replication report, +and keep the code for manipulating the data in the replication report as well. + +Managing data is a critical step to any quantitative research project. The more +information on finding, acquiring, loading, manipulating, and cleaning the data +you can include as you do the work, the better. + +___________ + +# Building the Model + +Replicating a paper will involve several of the same steps as those you would +follow to build a backtest. [see e.g. @Peterson2015] It also involves steps +unique to paper replication. + +## replicating key analytical techniques + +The summary of the paper identified the key analytical techniques used in paper. +You will replicate or build these first after you have data to work with. If you +are lucky, the modeling technique will already exist in *R*, and needs only to +be applied to your data. + +It is more likely that you will need to write code to replicate one or more key +techniques from the paper. This will likely be both the hardest part of the +replication, and the part most likely to contain errors. + +As you work, keep your code in your replication report, with your discussion and +analysis of the results. Rmarkdown contains many features for generation and +inclusion of charts and tables, so your code should directly generate its outputs. + +## validate results as you work + +At each stage, check to see if you get the same results as the paper. Strive to +match, or be close, to every number that the paper publishes, either in the main +text or in supplemental materials and appendices. If you can't match, or aren't +close, figure out why. Document divergences and the process you are going +through as you write code and check your results. + +Occasionally, the paper will not contain enough information to understand +precisely how the authors implemented the finer details of the technique. As +you work, clearly document key assumptions or guesses that you make to try to +replicate the technique or analysis. Often, your first (or second ...) attempt +will not get the desired result. Leave the attempt in the replication report, +and make another attempt. Eventually, you can usually get close to what you see +in the source paper. The "failed" attempts can also be valuable, showing +alternative interpretations, and robustness of the methodology. This type of +breadth is important if you later move on to using the techniques in a new +strategy backtest. + +Rarely, you will not be able to replicate one of the techniques in the paper. It +may not matter, if you get through enough of the rest of the paper to form +conclusions about the work as a whole. + +In even more rare cases, you will implement the technique, and get results that +are contradictory to the ones published in the paper. *Now what do you do?* + +We recommend a series of analytical steps in this case: + +- carefully check your work for bugs, reversed signs, etc. This is the most + likely cause. +- can you replicate results from a different paper that is the source of the + technique? +- can you independently validate the math? +- can data differences or data cleaning/manipulation difference explain the + divergence of results? + +If, after carefully checking your work, and validating against other data, if +possible, you are certain that you have correctly implemented the technique, +but the results still don't match, document this too. Add as much detail (and +code!) about the checks you performed, things that you tested, and conclusions +that you have drawn as you can to your replication report. Sometimes failure +or contradicting the paper is the most important result that you could reach, +saving you from implementing a bad or non-robust technique in a strategy. + +Additional validation beyond replication of the paper's techniques is always +valuable. If you identified hypotheses in your paper summary, now is the time +to write code to test those hypotheses. If the model you have built has model +fit or calibration statistics, you should include the output of these tests or +statistics. + +## choosing a strategy model + +If the paper presents a trading or investment strategy, you must choose the +model which you will use to replicate it. In our experience, there are three +main models which you will encounter: + +1. **signal based strategy**: This model implements one or more indicators, + signals, and rules to create a trading strategy. This type of model is + best replicated in *quantstrat*[@quantstrat2014] in **R**. +1. **portfolio strategy**: This model implements some method of choosing, + constructing a portfolio in, and rebalancing a portfolio of instruments. + This type of model will likely use packages such as *Portfolioanalytics* + [@porta2014] or *parma*[@parma2014]. +1. **pricing strategy**: This type of paper may or may not implement a trading + strategy at all, or may use a strategy only as an example of the application + of the pricing methodology. Needed **R** packages will depend on the exact + model to be replicated. + +It is also possible to use different methods in the replication than the source +used. Sometimes, this will be in addition to a rote replication; in other cases +it may be used as a replacement. For example, many "trading strategy"" papers +will describe a technique whereby they generate signals based on some indicator, +but then "go long" or "go short" by constructing a portfolio containing the +desired instruments, ignoring transaction costs, and often ignoring timing (and +introducing look-ahead bias). Real trading strategies don't work this way: +transaction costs exist, execution is not instant, etc. The analyst may choose +to replicate the paper using a complete indicator, signal, and trading rules +model which will naturally make the replication more realistic (and thus +potentially more useful) rather than blindly replicating the method used in the +source material. + +___________ + +# Extending the Analysis + +Once the analyst has replicated the key techniques and findings from the paper, +there is often great value in extending the analysis. In this phase, the +analyst is working to tie it all together, validate that the conclusions of the +paper are valid, and lay the groundwork for future work. + +## summary statistics + +Every piece of backtesting software (including *quantstrat* and *PortfolioAnalytics*) +has summary statistics that will be shown time and time again. It makes sense +to present these summary statistics in your replication. Some of them will +almost certainly have been presented by the authors of the original paper, so +this will further confirm the results of your replication. Others will not have +been reported, and will provide an interesting point of comparison, which may +warrant some commentary in the replication report. + +## more data + +One of the most obvious places to extend and validate the analysis in the source +paper is by adding more data. Three categories suggest themselves: + +1. **more recent data, same instruments** : + The extension of the replication analysis to more recent data should + **always** be part of a replication report. It provides a very clear and + simple test of out of sample deterioration, overfitting, or selection bias. + +1. **similar instruments** : + once the code is done to replicate the paper's techniques and methods, + extension to similar instruments is very straightforward. This type of + analysis should help the analyst understand selection biases, and begin to + draw some conclusions about the general applicability of the analysis. + +1. **different asset classes** : + extending the analysis to other asset classes is the furthest from pure + replication. This type of analysis will often be saved for later work on + the ideas contained in the source paper. + + +## similar techniques + +It is quite likely that the Literature Review uncovered similar techniques to +those used in the source paper. When such similar techniques are readily +available in **R**, the analyst should strive to apply them to the data used for +the replication. Typically, it is not worth spending a lot of time on this. +Exceptions usually include when a paper claims to have improved a technique, +but does an incomplete job of reporting results for the original (theoretically +deficient) technique. + +## probability of overfitting + + at Peterson2015 discusses multiple techniques for detecting biases and overfitting. +Most replication reports should contain results of appropriate tests. Specific +categories to pay attention to in most cases include selection biases, +look-ahead bias, and out of sample deterioration. + + +___________ +# Computing Appendix + +This essay focuses on replicating published research using *R* [@R2014]. We +recommend building a replication report template in *Rmarkdown/knitr* [@Rmarkdown] (or +*Sweave* [@Sweave2002] if you are already proficient with it) which you will +expand as you work through the replication. The main advantage of this approach +is that you have a living, compilable document which will track the progress of +your research. You can edit and fill it in during the course of the replication, +compiling the document as you proceed. We additionally recommend the use of +a reference manager such as [*jabref*](http://jabref.sourceforge.net/). Similar +reproducible research processes exist in other languages or environments (e.g. +[Beaker](http://beakernotebook.com/index), [mendeley](http://www.mendeley.com/), +[STATA do-files](http://www.lse.ac.uk/geographyAndEnvironment/whosWho/profiles/neumayer/replicationdatasets.aspx), +[iPython notebooks in *python*](http://ipython.org/notebook.html), etc.) but we +have assumed that the reader is using *R* and associated tools. + +\newpage + +One good way to structure all this work in **R** is to create a package for the +replication project. A further advantage of the package structure is that it can +be stored in a version control system such as [*bitbucket*](https://bitbucket.org/) . + + +| File/Directory | description | +| --------------:|:----------------------------------------------------------- | +| DESCRIPTION | defines a package name, and any `Depends` directives | +| *vignettes/* | directory to hold Rmarkdown `.Rmd` and `.bib` files | +| *data/* | directory will hold the data after it has been downloaded | +| *R/* | will hold any `.R` files containing functions used by the analysis | +| *demo/* | holds script files called infrequently for things like downloading data | +| *inst/doc/* | holds a copy of the source paper, and possibly related papers | +| *man/* | documentation auto generated by *roxygen* | +| NAMESPACE | auto generated by *roxygen* | + + + +Reproducibility of research has gained attention in recent years, with prominent +papers in journals such as *Science*[@Peng2011] and *Nature*[@Barnes2010, @Ince2012]. +Finance and Economics have entries in @Vlaeminck2013 or the *Economist* +[@Economist2013], among others. + +Following good computing practices even for routine research is always good +policy, and will be useful if work is submitted for publication ,reviewed by peers, +management, or even "only" your future self. + +___________ + +# Acknowledgements + +I would like to thank my team for thoughtful comments and questions, +and David Matteson at Cornell University for his insightful comments on an early +draft of this paper. All remaining errors or omissions should be attributed to +the author. All views expressed in this paper are to be viewed as those of Brian +Peterson, and do not necessarily reflect the opinions or policies of DV Trading. + +?2015 Brian G. Peterson + +![](cc-by-nc-sa.pdf) + +\newpage + +___________ + +# References \ No newline at end of file Added: pkg/quantstrat/sandbox/backtest_musings/research_replication.pdf =================================================================== (Binary files differ) Property changes on: pkg/quantstrat/sandbox/backtest_musings/research_replication.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-17 17:38:17 UTC (rev 1671) +++ pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-19 23:30:42 UTC (rev 1672) @@ -115,8 +115,6 @@ Author = {Dudler, Martin and Gmuer, Bruno and Malamud, Semyon}, Journal = {Available at SSRN 2457647}, Year = {2014}, - - __markedentry = {[brian:6]}, Abstract = {We introduce a new class of momentum strategies that are based on the long-term averages of risk-adjusted returns and test these strategies on a universe of 64 liquid futures contracts. We show that this risk adjusted momentum strategy outperforms the time series momentum strategy of Ooi, Moskowitz and Pedersen (2012) for almost all combinations of holding- and look-back periods. We construct measures of momentum-specific volatility (risk), (both within and across asset classes) and show that these volatility measures can be used both for risk management and it momentum timing. We find that momentum risk management significantly increases Sharpe ratios, but at the same time leads to more pronounced negative skewness and tail risk; by contrast, combining risk management with momentum timing practically eliminates the negative skewness of momentum returns and significantly reduces tail risk. In addition, momentum risk management leads to a much lower exposure to market, value, and momentum factors. As a result, risk-managed momentum returns offer much higher diversification benefits than the standard momentum returns.}, Owner = {brian}, Timestamp = {2015.01.15}, @@ -243,6 +241,19 @@ Url = {http://appliedpredictivemodeling.com/} } + at InProceedings{Sweave2002, + Title = {Sweave: Dynamic Generation of Statistical Reports Using Literate Data Analysis}, + Author = {Friedrich Leisch}, + Booktitle = {Compstat 2002 --- Proceedings in Computational Statistics}, + Year = {2002}, + Editor = {Wolfgang H{\"a}rdle and Bernd R{\"o}nz}, + Note = {ISBN 3-7908-1517-9}, + Pages = {575--580}, + Publisher = {Physica Verlag, Heidelberg}, + + Url = {http://www.stat.uni-muenchen.de/~leisch/Sweave} +} + @Article{Levy2006, Title = {A systems approach to conduct an effective literature review in support of information systems research}, Author = {Levy, Yair and Ellis, Timothy J}, @@ -281,9 +292,10 @@ Url = {http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3383002/} } - at Article{Peterson2015, - Title = {Developing \& Backtesting Systematic Trading Strategies }, + at TechReport{Peterson2015, + Title = {Developing \& Backtesting Systematic Trading Strategies}, Author = {Peterson, Brian G}, + Institution = {DV Trading}, Year = {2015}, Url = {http://goo.gl/na4u5d} @@ -365,16 +377,14 @@ } @Misc{Tomasini2009, - Title = {Trading Systems: A New Approach to System Development and -Portfolio Optimisation }, + Title = {Trading Systems: A New Approach to System Development and Portfolio Optimisation }, Author = {Emilio Tomasini and Urban Jaekle}, Month = {Dec}, Year = {2009}, Author_sort = {Tomasini, Emilio \& Jaekle, Urban}, - Title_sort = {Trading Systems A New Approach to System Development -and Portfolio Optimisation}, + Title_sort = {Trading Systems A New Approach to System Development and Portfolio Optimisation}, Volume = {1} } From noreply at r-forge.r-project.org Wed Jan 21 12:22:28 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 21 Jan 2015 12:22:28 +0100 (CET) Subject: [Blotter-commits] r1673 - in pkg/quantstrat: . R demo man Message-ID: <20150121112228.A64EE1858F3@r-forge.r-project.org> Author: michaelguan326 Date: 2015-01-21 12:22:28 +0100 (Wed, 21 Jan 2015) New Revision: 1673 Modified: pkg/quantstrat/NAMESPACE pkg/quantstrat/R/signals.R pkg/quantstrat/demo/signal.RSI.R pkg/quantstrat/demo/signal.SMA.R pkg/quantstrat/man/ruleOrderProc.Rd Log: Exported necessary functions to make Signal Analysis demos work. Modified: pkg/quantstrat/NAMESPACE =================================================================== --- pkg/quantstrat/NAMESPACE 2015-01-19 23:30:42 UTC (rev 1672) +++ pkg/quantstrat/NAMESPACE 2015-01-21 11:22:28 UTC (rev 1673) @@ -1,6 +1,5 @@ # Generated by roxygen2 (4.0.2): do not edit by hand -S3method(plot,signal.path) export(add.distribution) export(add.distribution.constraint) export(add.indicator) @@ -11,14 +10,17 @@ export(addPosLimit) export(apply.paramset) export(apply.paramset.signal.analysis) +export(applyIndicatorSignals) export(applyIndicators) export(applyRules) export(applySignals) export(applyStrategy) export(applyStrategy.rebalancing) +export(beanplot.signals) export(chart.forward) export(chart.forward.training) export(delete.paramset) +export(distributional.boxplot) export(enable.rule) export(get.orderbook) export(get.strategy) @@ -34,6 +36,7 @@ export(match.names) export(osMaxPos) export(osNoOp) +export(post.signal.returns) export(put.orderbook) export(put.strategy) export(rm.strat) @@ -48,6 +51,10 @@ export(sigPeak) export(sigThreshold) export(sigTimestamp) +export(signal.generate.statistics) +export(signal.obj.slope) +export(signal.path.plot) +export(signal.plot) export(strategy) export(tradeGraphs) export(tradeOrderStats) Modified: pkg/quantstrat/R/signals.R =================================================================== --- pkg/quantstrat/R/signals.R 2015-01-19 23:30:42 UTC (rev 1672) +++ pkg/quantstrat/R/signals.R 2015-01-21 11:22:28 UTC (rev 1673) @@ -522,6 +522,7 @@ #' \code{\link{apply.paramset.signal.analysis}} #' \code{\link{applyIndicators}} #' \code{\link{applySignals}} +#' @export applyIndicatorSignals<-function(strategy, portfolio, mktdata, sigcol, ...){ @@ -560,6 +561,7 @@ #' @return objective function values #' @seealso #' \code{\link{apply.paramset.signal.analysis}} +#' @export signal.generate.statistics<-function(post.ret, obj.fun=NULL, decreasing=TRUE){ if(is.null(obj.fun)) stop("Must define an objective function for signal sorting.") @@ -597,6 +599,7 @@ #' @return \code{matrix} of post signal price changes; rows = nth signal, column = nth period since signal #' @seealso #' \code{\link{apply.paramset.signal.analysis}} +#' @export post.signal.returns<-function(signals,sigval,on=NULL,forward.days,cum.sum=TRUE, include.day.of.signal=FALSE,mktdata=NULL){ @@ -750,6 +753,7 @@ #' @return Single Objective Value #' @seealso #' \code{\link{apply.paramset.signal.analysis}} +#' @export signal.obj.slope<-function(x){ mu = colMeans(x) @@ -779,10 +783,9 @@ #' @param h the y-value(s) for horizontal line(s). #' @param hlinecol A specification for the default plotting color. See section ?Color Specification?. #' @author Michael Guan -#' @return plot -#' +#' @export -plot.signals<-function(signals,rows=NULL,columns=NULL,mai = c(0.1,0.4,0.2,0.1), mgp = c(1,1,0), +signal.plot<-function(signals,rows=NULL,columns=NULL,mai = c(0.1,0.4,0.2,0.1), mgp = c(1,1,0), xlab='',ylab='',cex.main=0.6,xaxt='n',cex.axis=0.5,h=0,hlinecol='red',...){ if(is.null(signals)) stop('No signals to plot') @@ -825,6 +828,7 @@ #' @param hlinecol A specification for the default plotting color. See section ?Color Specification?. #' @author Michael Guan #' @return plot +#' @export beanplot.signals<-function(signals,rows=NULL,columns=NULL,mai = c(0.1,0.4,0.2,0.1), mgp = c(1,1,0), xlab='',ylab='',cex.main=0.6,xaxt='n',cex.axis=0.5, @@ -863,6 +867,7 @@ #' @param h the y-value(s) for horizontal line(s). #' @author Michael Guan #' @return plot +#' @export distributional.boxplot<-function(signal,x.val=seq(1, 50, 5),val=10,ylim=c(-5, 5), xlim=c(0, 50),mai=c(1,1,0.3,0.5),h=0,...){ @@ -913,10 +918,10 @@ #' @examples #' \dontrun{ #' # signalAnalysisExample1.R -#' plot.signal.path(results$sigret.by.asset$RTH$paramset.1.5[1:10,]) +#' plot.signal.path(results$sigret.by.asset$RTH$paramset.1.5[1:10,])s #' } #' @export -plot.signal.path<-function(data,main='Cumulative Return Paths'){ +signal.path.plot<-function(data,main='Cumulative Return Paths'){ require(rCharts) #TODO: Need to wrap around If statement require(reshape2) data = t(data) Modified: pkg/quantstrat/demo/signal.RSI.R =================================================================== --- pkg/quantstrat/demo/signal.RSI.R 2015-01-19 23:30:42 UTC (rev 1672) +++ pkg/quantstrat/demo/signal.RSI.R 2015-01-21 11:22:28 UTC (rev 1673) @@ -18,7 +18,7 @@ #Data currency("USD") currency("EUR") -symbols = c("XLF", "XLP") +symbols = c("SPY") for(symbol in symbols){ # establish trade-able instruments stock(symbol, currency="USD",multiplier=1) getSymbols(symbol,src='yahoo') @@ -67,7 +67,7 @@ port.st, sigcol = signal.label, sigval = 1, - on='days', + on=NULL, forward.days=10, cum.sum=TRUE, include.day.of.signal=F, @@ -78,10 +78,10 @@ # Plot Paramset Combined Barchart [Subset list to plot a sub portion if too large] -plot.signals(results$sigret.by.asset$XLF, rows=2, columns = 5) +signal.plot(results$sigret.by.asset$SPY, rows=2, columns = 5) # Distributional Box Plot via gamlss -distributional.boxplot(results$sigret.by.asset$XLF$paramset.2) +distributional.boxplot(results$sigret.by.asset$SPY$paramset.2) ############################################################################### # R (http://r-project.org/) Quantitative Strategy Model Framework Modified: pkg/quantstrat/demo/signal.SMA.R =================================================================== --- pkg/quantstrat/demo/signal.SMA.R 2015-01-19 23:30:42 UTC (rev 1672) +++ pkg/quantstrat/demo/signal.SMA.R 2015-01-21 11:22:28 UTC (rev 1673) @@ -105,9 +105,9 @@ x.val=seq(1, 50, 5),val=10,ylim=c(-20, 20), xlim=c(0, 50),mai=c(1,1,0.3,0.5),h=0) -plot.signals(results$sigret.by.asset$XLE, rows=5, columns = 4) +signal.plot(results$sigret.by.asset$XLE, rows=5, columns = 4) beanplot.signals(results$sigret.by.asset$XLE, rows=5, columns = 4) -plot.signal.path(results$sigret.by.asset$IYT$paramset.5.20) +signal.path.plot(results$sigret.by.asset$IYT$paramset.5.20) # Daily Signal With Post Weekly Return Analysis Modified: pkg/quantstrat/man/ruleOrderProc.Rd =================================================================== --- pkg/quantstrat/man/ruleOrderProc.Rd 2015-01-19 23:30:42 UTC (rev 1672) +++ pkg/quantstrat/man/ruleOrderProc.Rd 2015-01-21 11:22:28 UTC (rev 1673) @@ -5,9 +5,6 @@ \usage{ ruleOrderProc(portfolio, symbol, mktdata, timestamp = NULL, ordertype = NULL, ..., slippageFUN = NULL) - -ruleOrderProc(portfolio, symbol, mktdata, timestamp = NULL, - ordertype = NULL, ..., slippageFUN = NULL) } \arguments{ \item{portfolio}{text name of the portfolio to associate the order book with} @@ -23,31 +20,12 @@ \item{...}{any other passthru parameters} \item{slippageFUN}{default NULL, not yet implemented} - -\item{portfolio}{text name of the portfolio to associate the order book with} - -\item{symbol}{identfier of the instrument to find orders for. The name of any associated price objects (xts prices, usually OHLC or BBO) should match these} - -\item{mktdata}{an xts object containing market data. depending on indicators, may need to be in OHLCV or BBO formats, default NULL} - -\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be processed on} - -\item{ordertype}{one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL} - -\item{...}{any other passthru parameters} - -\item{slippageFUN}{default NULL, not yet implemented} } \description{ The ruleOrderProc function is effectively the default fill simulator for quantstrat. This function is meant to be sufficient for backtesting most strategies, but would need to be replaced for production use. It provides the interface for taking the order book and determining when orders become trades. - -The ruleOrderProc function is effectively the default fill simulator for quantstrat. -This function is meant to be sufficient for backtesting most strategies, -but would need to be replaced for production use. It provides the interface -for taking the order book and determining when orders become trades. } \details{ In this version, in contrast with an earlier version, @@ -71,28 +49,6 @@ We would like to model slippage here via \code{slippageFUN}. Code contributions, suggestions, and requests appreciated. - -In this version, in contrast with an earlier version, -this function will allow a transaction to cross your current -position through zero. The accounting rules for realizing gains in such cases -are quite complicated, so blotter will split this transaction into two transactions. -Many brokers will break, revise, or split such transactions for the same reason. - -This function would need to be revised or replaced for connection to a live trading infrastructure. -In a production mode, you would replace the \code{\link{addOrder}} function -with a custom function to connect to your market infrastructure. -In that case, you might need to add additional code to your strategy, -or overload functions for checking position. - -Note that this function is called by default in the 'orders' slot of the -\code{\link{applyRules}} processing. If you have defined another order -processing rule, it will \emph{replace} this function. If you want your -custom order rule and ruleOrderProc to both be called, you will need -explicitly add a rule to call ruleOrderProc either before or after your -custom order processing function. - -We would like to model slippage here via \code{slippageFUN}. Code contributions, suggestions, -and requests appreciated. } \seealso{ add.rule @@ -104,16 +60,6 @@ addOrder updateOrders - -add.rule - -applyRules - -getOrderBook - -addOrder - -updateOrders } \concept{ fill simulator @@ -127,17 +73,5 @@ This function is meant to be sufficient for backtesting many/most strategies, but would need to be replaced for production use. It provides the interface for taking the order book and determining when orders become trades. - -fill simulator - -orders - -backtest - -fills - -This function is meant to be sufficient for backtesting many/most strategies, -but would need to be replaced for production use. It provides the interface -for taking the order book and determining when orders become trades. } From noreply at r-forge.r-project.org Wed Jan 21 14:40:31 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 21 Jan 2015 14:40:31 +0100 (CET) Subject: [Blotter-commits] r1674 - pkg/quantstrat/R Message-ID: <20150121134031.2FB0E186902@r-forge.r-project.org> Author: bodanker Date: 2015-01-21 14:40:30 +0100 (Wed, 21 Jan 2015) New Revision: 1674 Modified: pkg/quantstrat/R/signals.R Log: - Fix typo Modified: pkg/quantstrat/R/signals.R =================================================================== --- pkg/quantstrat/R/signals.R 2015-01-21 11:22:28 UTC (rev 1673) +++ pkg/quantstrat/R/signals.R 2015-01-21 13:40:30 UTC (rev 1674) @@ -918,7 +918,7 @@ #' @examples #' \dontrun{ #' # signalAnalysisExample1.R -#' plot.signal.path(results$sigret.by.asset$RTH$paramset.1.5[1:10,])s +#' plot.signal.path(results$sigret.by.asset$RTH$paramset.1.5[1:10,]) #' } #' @export signal.path.plot<-function(data,main='Cumulative Return Paths'){ From noreply at r-forge.r-project.org Fri Jan 30 13:55:52 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 30 Jan 2015 13:55:52 +0100 (CET) Subject: [Blotter-commits] r1675 - pkg/quantstrat/sandbox/backtest_musings Message-ID: <20150130125552.46AFD18785F@r-forge.r-project.org> Author: braverock Date: 2015-01-30 13:55:51 +0100 (Fri, 30 Jan 2015) New Revision: 1675 Modified: pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd pkg/quantstrat/sandbox/backtest_musings/research_replication.pdf 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: - added more references and commentary Modified: pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd 2015-01-21 13:40:30 UTC (rev 1674) +++ pkg/quantstrat/sandbox/backtest_musings/research_replication.Rmd 2015-01-30 12:55:51 UTC (rev 1675) @@ -472,13 +472,13 @@ Reproducibility of research has gained attention in recent years, with prominent -papers in journals such as *Science*[@Peng2011] and *Nature*[@Barnes2010, @Ince2012]. -Finance and Economics have entries in @Vlaeminck2013 or the *Economist* -[@Economist2013], among others. +papers in journals such as *Science*[@Peng2011], *Nature*[@Barnes2010, @Ince2012] +, and *PLOSOne*[@Ioannidis2005, @Moonesinghe2007]. Finance and Economics have +entries in @Vlaeminck2013 or the *Economist*[@Economist2013], among others. -Following good computing practices even for routine research is always good -policy, and will be useful if work is submitted for publication ,reviewed by peers, -management, or even "only" your future self. +Following good citation and computing practices even for routine research is +always good policy, and will be particularly useful if work is submitted for +publication, reviewed by peers, management, or even "only" your future self. ___________ Modified: pkg/quantstrat/sandbox/backtest_musings/research_replication.pdf =================================================================== (Binary files differ) Modified: pkg/quantstrat/sandbox/backtest_musings/stat_process.bib =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-21 13:40:30 UTC (rev 1674) +++ pkg/quantstrat/sandbox/backtest_musings/stat_process.bib 2015-01-30 12:55:51 UTC (rev 1675) @@ -225,6 +225,22 @@ Url = {http://www.nature.com/nature/journal/v482/n7386/pdf/nature10836.pdf} } + at Article{Ioannidis2005, + Title = {Why most published research findings are false}, + Author = {Ioannidis, John PA}, + Journal = {PLoS medicine}, + Year = {2005}, + Number = {8}, + Pages = {e124}, + Volume = {2}, + + __markedentry = {[brian:6]}, + Owner = {brian}, + Publisher = {Public Library of Science}, + Timestamp = {2015.01.29}, + Url = {http://journals.plos.org/plosmedicine/article?id=10.1371/journal.pmed.0020124#s6} +} + @Book{Kestner2003, Title = {Quantitative trading strategies: {H}arnessing the power of quantitative techniques to create a winning trading program}, Author = {Kestner, Lars}, @@ -268,6 +284,22 @@ Url = {http://inform.nu/Articles/Vol9/V9p181-212Levy99.pdf} } + at Article{Moonesinghe2007, + Title = {Most published research findings are false, but a little replication goes a long way}, + Author = {Moonesinghe, Ramal and Khoury, Muin J and Janssens, A Cecile JW}, + Journal = {PLoS medicine}, + Year = {2007}, + Number = {2}, + Pages = {e28}, + Volume = {4}, + + __markedentry = {[brian:]}, + Owner = {brian}, + Publisher = {Public Library of Science}, + Timestamp = {2015.01.29}, + Url = {http://journals.plos.org/plosmedicine/article?id=info:doi/10.1371/journal.pmed.0040028} +} + @Book{Pardo2008, Title = {The evaluation and optimization of trading strategies, second edition}, Author = {Robert Pardo}, Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd =================================================================== --- pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2015-01-21 13:40:30 UTC (rev 1674) +++ pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.Rmd 2015-01-30 12:55:51 UTC (rev 1675) @@ -21,7 +21,6 @@ # Constraints, Benchmarks, and Objectives ^[*Essentially, all models are wrong, but some are useful*. - George Box[- at Box1987] ] - It is important to understand what you are trying to achieve *before* you set out to achieve it. Modified: pkg/quantstrat/sandbox/backtest_musings/strat_dev_process.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Fri Jan 30 23:33:50 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 30 Jan 2015 23:33:50 +0100 (CET) Subject: [Blotter-commits] r1676 - pkg/FinancialInstrument/R Message-ID: <20150130223350.98715183BCE@r-forge.r-project.org> Author: braverock Date: 2015-01-30 23:33:50 +0100 (Fri, 30 Jan 2015) New Revision: 1676 Modified: pkg/FinancialInstrument/R/load.instruments.R Log: - update getSymbols.FI to allow a vector for use_identifier and rbind the results Modified: pkg/FinancialInstrument/R/load.instruments.R =================================================================== --- pkg/FinancialInstrument/R/load.instruments.R 2015-01-30 12:55:51 UTC (rev 1675) +++ pkg/FinancialInstrument/R/load.instruments.R 2015-01-30 22:33:50 UTC (rev 1676) @@ -287,45 +287,124 @@ #' } #' @export getSymbols.FI <- function(Symbols, - from=getOption("getSymbols.FI.from", "2010-01-01"), - to=getOption("getSymbols.FI.to", Sys.Date()), - ..., - dir=getOption("getSymbols.FI.dir", ""), - return.class=getOption("getSymbols.FI.return.class", - "xts"), - extension=getOption("getSymbols.FI.extension", "rda"), - split_method=getOption("getSymbols.FI.split_method", - c("days", "common")), - use_identifier=getOption("getSymbols.FI.use_identifier", - NA), - date_format=getOption("getSymbols.FI.date_format"), - verbose=getOption("getSymbols.FI.verbose", TRUE), - days_to_omit=getOption("getSymbols.FI.days_to_omit", - c("Saturday", "Sunday")), - indexTZ=getOption("getSymbols.FI.indexTZ", NA) - ) + from=getOption("getSymbols.FI.from", "2010-01-01"), + to=getOption("getSymbols.FI.to", Sys.Date()), + ..., + dir=getOption("getSymbols.FI.dir", ""), + return.class=getOption("getSymbols.FI.return.class", + "xts"), + extension=getOption("getSymbols.FI.extension", "rda"), + split_method=getOption("getSymbols.FI.split_method", + c("days", "common")), + use_identifier=getOption("getSymbols.FI.use_identifier", + NA), + date_format=getOption("getSymbols.FI.date_format"), + verbose=getOption("getSymbols.FI.verbose", TRUE), + days_to_omit=getOption("getSymbols.FI.days_to_omit", + c("Saturday", "Sunday")), + indexTZ=getOption("getSymbols.FI.indexTZ", NA) +) { - if (is.null(date_format)) date_format <- "%Y.%m.%d" - if (is.null(days_to_omit)) days_to_omit <- 'NULL' - this.env <- environment() - for(var in names(list(...))) { - assign(var,list(...)[[var]], this.env) + if (is.null(date_format)) date_format <- "%Y.%m.%d" + if (is.null(days_to_omit)) days_to_omit <- 'NULL' + this.env <- environment() + for(var in names(list(...))) { + assign(var,list(...)[[var]], this.env) + } + + #The body of the following function comes from Dominik's answer here: + #browseURL("http://stackoverflow.com/questions/7224938/can-i-rbind-be-parallelized-in-r") + #it does what do.call(rbind, lst) would do, but faster and with less memory usage + do.call.rbind <- function(lst) { + while(length(lst) > 1) { + idxlst <- seq(from=1, to=length(lst), by=2) + + lst <- lapply(idxlst, function(i) { + if(i==length(lst)) { return(lst[[i]]) } + + return(rbind(lst[[i]], lst[[i+1]])) + }) } - - #The body of the following function comes from Dominik's answer here: - #browseURL("http://stackoverflow.com/questions/7224938/can-i-rbind-be-parallelized-in-r") - #it does what do.call(rbind, lst) would do, but faster and with less memory usage - do.call.rbind <- function(lst) { - while(length(lst) > 1) { - idxlst <- seq(from=1, to=length(lst), by=2) - - lst <- lapply(idxlst, function(i) { - if(i==length(lst)) { return(lst[[i]]) } - - return(rbind(lst[[i]], lst[[i+1]])) - }) - } - lst[[1]] + lst[[1]] + } + + # Find out if user provided a value for each formal + if (hasArg.from <- hasArg(from)) .from <- from + if (hasArg.to <- hasArg(to)) .to <- to + if (hasArg.dir <- hasArg(dir)) .dir <- dir + if (hasArg.return.class <- hasArg(return.class)) + .return.class <- return.class + if (hasArg.extension <- hasArg(extension)) .extension <- extension + if (hasArg.split_method <- hasArg(split_method)) + .split_method <- split_method + if (hasArg.use_identifier <- hasArg(use_identifier)) + .use_identifier <- use_identifier + if (hasArg.date_format <- hasArg(date_format)) .date_format <- date_format + if (hasArg.verbose <- hasArg(verbose)) .verbose <- verbose + if (hasArg.days_to_omit <- hasArg(days_to_omit)) + .days_to_omit <- days_to_omit + if (hasArg.indexTZ <- hasArg(indexTZ)) .indexTZ <- indexTZ + + #importDefaults("getSymbols.FI") + + # Now get the values for each formal that we'll use if not provided + # by the user and not found in the SymbolLookup table + default.from <- from + default.to <- to + default.dir <- dir + default.return.class <- return.class + default.extension <- extension + default.split_method <- split_method[1] + default.use_identifier <- use_identifier + default.date_format <- date_format + default.verbose <- verbose + default.days_to_omit <- days_to_omit + default.indexTZ <- indexTZ + + # quantmod:::getSymbols will provide auto.assign and env + # so the next 2 if statements should always be TRUE + auto.assign <- if(hasArg(auto.assign)) {auto.assign} else TRUE + env <- if(hasArg(env)) {env} else .GlobalEnv + + # make an argument matching function to sort out which values to use for each arg + pickArg <- function(x, Symbol) { + if(get(paste('hasArg', x, sep="."))) { + get(paste(".", x, sep="")) + } else if(!is.null(SymbolLookup[[Symbol]][[x]])) { + SymbolLookup[[Symbol]][[x]] + } else get(paste("default", x, sep=".")) + } + + SymbolLookup <- getSymbolLookup() + fr <- NULL + datl <- lapply(1:length(Symbols), function(i) { + #FIXME? Should nothing be saved if there are errors with any of + # the Symbols (current behavior)? Or, if auto.assign == TRUE, should + # we assign the data as we get it instead of making a list of data and + # assigning at the end. + from <- pickArg("from", Symbols[[i]]) + to <- pickArg("to", Symbols[[i]]) + dir <- pickArg("dir", Symbols[[i]]) + return.class <- pickArg("return.class", Symbols[[i]]) + extension <- pickArg('extension', Symbols[[i]]) + split_method <- pickArg('split_method', Symbols[[i]]) + use_identifier <- pickArg('use_identifier', Symbols[[i]]) + date_format <- pickArg('date_format', Symbols[[i]]) + verbose <- pickArg('verbose', Symbols[[i]]) + days_to_omit <- pickArg('days_to_omit', Symbols[[i]]) + indexTZ <- pickArg('indexTZ', Symbols[[i]]) + # if 'dir' is actually the 'base_dir' then we'll paste the instrument name (Symbol) to the end of it. + # First, find out what the instrument name is + instr_str <- NA + if(!is.na(use_identifier[1])) { + tmp_instr <- try(getInstrument(Symbols[[i]], silent=FALSE)) + if (inherits(tmp_instr,'try-error') || !is.instrument(tmp_instr)) + stop("must define instrument first to call with 'use_identifier'") + if (!use_identifier[1]=='primary_id') { + instr_str <- make.names(tmp_instr$identifiers[use_identifier]) + instr_str <- instr_str[!is.null(instr_str)] + } else instr_str <- make.names(tmp_instr[[use_identifier]]) + if (length(instr_str) == 0L) stop("Could not find instrument. Try with use_identifier=NA") } # Find out if user provided a value for each formal @@ -361,139 +440,96 @@ default.days_to_omit <- days_to_omit default.indexTZ <- indexTZ - # quantmod:::getSymbols will provide auto.assign and env - # so the next 2 if statements should always be TRUE - auto.assign <- if(hasArg(auto.assign)) {auto.assign} else TRUE - env <- if(hasArg(env)) {env} else .GlobalEnv - - # make an argument matching function to sort out which values to use for each arg - pickArg <- function(x, Symbol) { - if(get(paste('hasArg', x, sep="."))) { - get(paste(".", x, sep="")) - } else if(!is.null(SymbolLookup[[Symbol]][[x]])) { - SymbolLookup[[Symbol]][[x]] - } else get(paste("default", x, sep=".")) + tmpr<-list() + tmp <- list() + dirstr<-paste(dirs, collapse=' ') + if(!length(dirs)==1) warning(paste0('multiple directories ',dirstr,' referenced, merge may be messy.')) + for(dir in dirs) { + if(!dir=="" && !file.exists(dir)) { + if (verbose) cat("\ndirectory ",dir," does not exist, skipping\n") + } else { + if(verbose) cat("loading ",Symbols[[i]],".....\n") + switch(split_method[1], + days={ + StartDate <- as.Date(from) + EndDate <- as.Date(to) + date.vec <- as.Date(StartDate:EndDate) + date.vec <- date.vec[!weekdays(date.vec) %in% days_to_omit] + date.vec <- format(date.vec, format=date_format) + sym.files <- paste(date.vec, Symbol, extension, sep=".") + if (dir != "") sym.files <- file.path(dir, sym.files) + dl <- lapply(sym.files, function(fp) { + sf <- strsplit(fp, "/")[[1]] + sf <- sf[length(sf)] + if (verbose) cat("Reading ", sf, "...") + if(!file.exists(fp)) { + if (verbose) cat(" failed. File not found in ", dir, " ... skipping\n") + } else { + if (verbose) cat(' done.\n') + local.name <- load(fp) + dat <- get(local.name) + if (!is.na(indexTZ) && !is.null(dat)) indexTZ(dat) <- indexTZ + dat + } + }) + if (verbose) cat('rbinding data ... ') + fr <- do.call.rbind(dl) + }, + common = , { + sym.file <- paste(Symbol,extension,sep=".") + if(dir != "") sym.file <- file.path(dir, sym.file) + if(!file.exists(sym.file)) { + if (verbose) cat("file ",paste(Symbol,extension,sep='.')," does not exist in ",dir,"....skipping\n") + } else { + #fr <- read.csv(sym.file) + local.name <- load(sym.file) + dat <- get(local.name) + if (!is.na(indexTZ) && !is.null(dat)) indexTZ(dat) <- indexTZ + assign('fr', dat) + if(verbose) cat("done.\n") + #if(!is.xts(fr)) fr <- xts(fr[,-1],as.Date(fr[,1],origin='1970-01-01'),src='rda',updated=Sys.time()) + } + } # end 'common'/default method (same as getSymbols.rda) + ) # end split_method switch + fr <- convert.time.series(fr=fr,return.class=return.class) + Symbols[[i]] <-make.names(Symbols[[i]]) + #tmp <- list() + tmp[[Symbols[[i]]]] <- fr + if(!dir==dirs[1]) tmp[[Symbols[[i]]]] <- rbind(tmp[[Symbols[[i]]]],fr) + } # end Symbols else } - - SymbolLookup <- getSymbolLookup() - fr <- NULL - datl <- lapply(1:length(Symbols), function(i) { - #FIXME? Should nothing be saved if there are errors with any of - # the Symbols (current behavior)? Or, if auto.assign == TRUE, should - # we assign the data as we get it instead of making a list of data and - # assigning at the end. - from <- pickArg("from", Symbols[[i]]) - to <- pickArg("to", Symbols[[i]]) - dir <- pickArg("dir", Symbols[[i]]) - return.class <- pickArg("return.class", Symbols[[i]]) - extension <- pickArg('extension', Symbols[[i]]) - split_method <- pickArg('split_method', Symbols[[i]]) - use_identifier <- pickArg('use_identifier', Symbols[[i]]) - date_format <- pickArg('date_format', Symbols[[i]]) - verbose <- pickArg('verbose', Symbols[[i]]) - days_to_omit <- pickArg('days_to_omit', Symbols[[i]]) - indexTZ <- pickArg('indexTZ', Symbols[[i]]) - # if 'dir' is actually the 'base_dir' then we'll paste the instrument name (Symbol) to the end of it. - # First, find out what the instrument name is - instr_str <- NA - if(!is.na(use_identifier)) { - tmp_instr <- try(getInstrument(Symbols[[i]], silent=FALSE)) - if (inherits(tmp_instr,'try-error') || !is.instrument(tmp_instr)) - stop("must define instrument first to call with 'use_identifier'") - if (!use_identifier=='primary_id') { - instr_str<-make.names(tmp_instr$identifiers[[use_identifier]]) - } else instr_str <- make.names(tmp_instr[[use_identifier]]) - if (length(instr_str) == 0L) stop("Could not find instrument. Try with use_identifier=NA") - } - Symbol <- ifelse(is.na(instr_str), make.names(Symbols[[i]]), instr_str) - ndc<-nchar(dir) - if(substr(dir,ndc,ndc)=='/') dir <- substr(dir,1,ndc-1) #remove trailing forward slash - dir <- paste(dir, Symbol, sep="/") - - if(!dir=="" && !file.exists(dir)) { - if (verbose) cat("\ndirectory ",dir," does not exist, skipping\n") - } else { - if(verbose) cat("loading ",Symbols[[i]],".....\n") - switch(split_method[1], - days={ - StartDate <- as.Date(from) - EndDate <- as.Date(to) - date.vec <- as.Date(StartDate:EndDate) - date.vec <- date.vec[!weekdays(date.vec) %in% days_to_omit] - date.vec <- format(date.vec, format=date_format) - sym.files <- paste(date.vec, Symbol, extension, sep=".") - if (dir != "") sym.files <- file.path(dir, sym.files) - dl <- lapply(sym.files, function(fp) { - sf <- strsplit(fp, "/")[[1]] - sf <- sf[length(sf)] - if (verbose) cat("Reading ", sf, "...") - if(!file.exists(fp)) { - if (verbose) cat(" failed. File not found in ", dir, " ... skipping\n") - } else { - if (verbose) cat(' done.\n') - local.name <- load(fp) - dat <- get(local.name) - if (!is.na(indexTZ) && !is.null(dat)) indexTZ(dat) <- indexTZ - dat - } - }) - if (verbose) cat('rbinding data ... ') - fr <- do.call.rbind(dl) - }, - common = , { - sym.file <- paste(Symbol,extension,sep=".") - if(dir != "") sym.file <- file.path(dir, sym.file) - if(!file.exists(sym.file)) { - if (verbose) cat("file ",paste(Symbol,extension,sep='.')," does not exist in ",dir,"....skipping\n") - } else { - #fr <- read.csv(sym.file) - local.name <- load(sym.file) - dat <- get(local.name) - if (!is.na(indexTZ) && !is.null(dat)) indexTZ(dat) <- indexTZ - assign('fr', dat) - if(verbose) cat("done.\n") - #if(!is.xts(fr)) fr <- xts(fr[,-1],as.Date(fr[,1],origin='1970-01-01'),src='rda',updated=Sys.time()) - } - } # end 'common'/default method (same as getSymbols.rda) - ) # end split_method switch - fr <- convert.time.series(fr=fr,return.class=return.class) - Symbols[[i]] <-make.names(Symbols[[i]]) - tmp <- list() - tmp[[Symbols[[i]]]] <- fr - if(verbose) cat("done.\n") - tmp - } - }) #end loop over Symbols - - if (length(Filter("+", lapply(datl, length))) == 0) { - warning("No data found.") - return(NULL) + if(verbose) cat("done.\n") + tmp + }) #end lapply loop over Symbols + + if (length(Filter("+", lapply(datl, length))) == 0) { + warning("No data found.") + return(NULL) + } + + datl.names <- do.call(c, lapply(datl, names)) + missing <- Symbols[!Symbols %in% datl.names] + if (length(missing) > 0) warning('No data found for ', paste(missing, collapse=" ")) + if(auto.assign) { + #invisible(lapply(datl, function(x) if (length(x) > 0) assign(names(x), x[[1]], pos=env))) + out <- Filter(function(x) length(x) > 0, datl) + invisible(lapply(out, function(x) assign(names(x), x[[1]], pos=env))) + return(datl.names) + } else { + #NOTE: Currently, NULLs aren't filtered out. If there are data for any Symbol, + # the returned list will have an element for each symbol requested even if some don't contain data. + out <- lapply(datl, function(x) { + if (length(x) > 0) x[[1]] + }) + if (length(out) == 1) + return(out[[1]]) + else { + names(out) <- Symbols + return(out) } - - datl.names <- do.call(c, lapply(datl, names)) - missing <- Symbols[!Symbols %in% datl.names] - if (length(missing) > 0) warning('No data found for ', paste(missing, collapse=" ")) - if(auto.assign) { - #invisible(lapply(datl, function(x) if (length(x) > 0) assign(names(x), x[[1]], pos=env))) - out <- Filter(function(x) length(x) > 0, datl) - invisible(lapply(out, function(x) assign(names(x), x[[1]], pos=env))) - return(datl.names) - } else { - #NOTE: Currently, NULLs aren't filtered out. If there are data for any Symbol, - # the returned list will have an element for each symbol requested even if some don't contain data. - out <- lapply(datl, function(x) { - if (length(x) > 0) x[[1]] - }) - if (length(out) == 1) - return(out[[1]]) - else { - names(out) <- Symbols - return(out) - } - } + } } - #' currency metadata to be used by \code{\link{load.instruments}} #' #' @name currencies