[Blotter-commits] r1353 - in pkg/quantstrat: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 13 00:53:37 CET 2013
Author: opentrades
Date: 2013-01-13 00:53:37 +0100 (Sun, 13 Jan 2013)
New Revision: 1353
Modified:
pkg/quantstrat/NAMESPACE
pkg/quantstrat/R/orders.R
pkg/quantstrat/R/paramsets.R
pkg/quantstrat/man/apply.paramset.Rd
Log:
- introduced put.orderbook() for better data abstraction
Modified: pkg/quantstrat/NAMESPACE
===================================================================
--- pkg/quantstrat/NAMESPACE 2013-01-12 22:46:57 UTC (rev 1352)
+++ pkg/quantstrat/NAMESPACE 2013-01-12 23:53:37 UTC (rev 1353)
@@ -26,6 +26,7 @@
export(match.names)
export(osMaxPos)
export(osNoOp)
+export(put.orderbook)
export(rm.strat)
export(ruleOrderProc)
export(rulePctEquity)
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2013-01-12 22:46:57 UTC (rev 1352)
+++ pkg/quantstrat/R/orders.R 2013-01-12 23:53:37 UTC (rev 1353)
@@ -17,6 +17,31 @@
return(orders)
}
+#' put a orderbook object in .strategy env
+#' @param portfolio.st string identifying portfolio
+#' @param orderbook orderbook object
+#' @seealso getOrderBook
+#' @concept order book
+#' @export
+
+put.orderbook <- function(portfolio.st, orderbook)
+{
+ strategy.orderbook.st <- paste('order_book', portfolio.st, sep='.')
+ assign(strategy.orderbook.st, orderbook, envir=.strategy)
+}
+
+###############################################################################
+# Blotter: Tools for transaction-oriented trading systems development
+# for R (see http://r-project.org/)
+# Copyright (c) 2008-2011 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
+#
+# $Id$
+#
+###############################################################################
+
#' initialize order container
#'
#' This function sets up the order container by portfolio.
Modified: pkg/quantstrat/R/paramsets.R
===================================================================
--- pkg/quantstrat/R/paramsets.R 2013-01-12 22:46:57 UTC (rev 1352)
+++ pkg/quantstrat/R/paramsets.R 2013-01-12 23:53:37 UTC (rev 1353)
@@ -67,18 +67,18 @@
{
#must.have.args(match.call(), c('portfolio.st', 'cloned.portfolio.st'))
- order.book <- getOrderBook(portfolio.st)
+ orderbook <- getOrderBook(portfolio.st)
i <- 1 # TODO: find index number by name
- names(order.book)[i] <- cloned.portfolio.st
+ names(orderbook)[i] <- cloned.portfolio.st
if(strip.history == TRUE)
{
- for(symbol in names(order.book[[portfolio.st]]))
- order.book[[portfolio.st]][[symbol]] <- order.book[[portfolio.st]][[symbol]][1,]
+ for(symbol in names(orderbook[[portfolio.st]]))
+ orderbook[[portfolio.st]][[symbol]] <- orderbook[[portfolio.st]][[symbol]][1,]
}
- assign(paste("order_book", cloned.portfolio.st, sep='.'), order.book, envir=.strategy)
+ put.orderbook(cloned.portfolio.st, orderbook)
}
### local functions ############################################################
@@ -355,10 +355,8 @@
must.be.paramset(strategy, paramset.label)
portfolio <- getPortfolio(portfolio.st)
+ orderbook <- getOrderBook(portfolio.st)
- order_book.st <- paste('order_book', portfolio.st, sep='.')
- order_book <- get(order_book.st, envir=.strategy)
-
account <- getAccount(account.st)
distributions <- strategy$paramsets[[paramset.label]]$distributions
@@ -385,10 +383,9 @@
put.portfolio(r$portfolio.st, r$portfolio)
r$portfolio <- NULL
- # move order_book from slave returned list into .strategy environment
- full.order_book.st <- paste('order_book', r$portfolio.st, sep='.')
- assign(full.order_book.st, r$order_book, envir=.strategy)
- r$order_book <- NULL
+ # move orderbook from slave returned list into .strategy environment
+ put.orderbook(r$portfolio.st, r$orderbook)
+ r$orderbook <- NULL
if(calc == 'master')
{
@@ -437,10 +434,8 @@
put.portfolio(portfolio.st, portfolio)
put.account(account.st, account)
+ put.orderbook(portfolio.st, orderbook)
- strategy.order_book.st <- paste('order_book', portfolio.st, sep='.')
- assign(strategy.order_book.st, order_book, envir=.strategy)
-
assign(strategy.st, strategy, envir=.strategy)
result <- list()
@@ -462,7 +457,7 @@
result$user.func <- do.call(user.func, user.args)
}
result$portfolio <- getPortfolio(result$portfolio.st)
- result$order_book <- getOrderBook(result$portfolio.st)
+ result$orderbook <- getOrderBook(result$portfolio.st)
return(result)
}
Modified: pkg/quantstrat/man/apply.paramset.Rd
===================================================================
--- pkg/quantstrat/man/apply.paramset.Rd 2013-01-12 22:46:57 UTC (rev 1352)
+++ pkg/quantstrat/man/apply.paramset.Rd 2013-01-12 23:53:37 UTC (rev 1353)
@@ -4,7 +4,7 @@
\usage{
apply.paramset(strategy.st, paramset.label, portfolio.st,
account.st, mktdata, nsamples = 0, user.func = NULL,
- user.args = NULL, calc = "master", verbose = FALSE)
+ user.args = NULL, calc = "slave", verbose = FALSE)
}
\arguments{
\item{strategy}{the name of the strategy object}
@@ -32,7 +32,7 @@
return all portfolios and orderbooks in the .blotter and
.strategy environments resp: less parallelization but
also less data transfer between slave and master; default
- is 'master'}
+ is 'slave'}
\item{verbose}{return full information, in particular the
.blotter environment, default FALSE}
More information about the Blotter-commits
mailing list