[Blotter-commits] r268 - in pkg/quantstrat: R demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 26 15:17:24 CET 2010


Author: braverock
Date: 2010-02-26 15:17:24 +0100 (Fri, 26 Feb 2010)
New Revision: 268

Modified:
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/demo/simplestrat.R
Log:
- fix updateOrderMatrix fn

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2010-02-26 13:56:01 UTC (rev 267)
+++ pkg/quantstrat/R/orders.R	2010-02-26 14:17:24 UTC (rev 268)
@@ -235,7 +235,7 @@
 updateOrderMatrix<-function(portfolio, symbol, updatedorders){
     orderbook <- getOrderBook(portfolio)
 
-    orderbook[[portfolio]][[symbol]][index(updatedorders)]<-updatedorders
+    orderbook[[portfolio]][[symbol]][index(updatedorders),]<-updatedorders
     
     # assign order book back into place (do we need a non-exported "put" function?)
     assign(paste("order_book",portfolio,sep='.'),orderbook,envir=.strategy)
@@ -403,7 +403,7 @@
                     if(!is.null(txnprice)){
                         addTxn(Portfolio=portfolio, Symbol=symbol, TxnDate=txntime, TxnQty=as.numeric(procorders[ii,]$Order.Qty), TxnPrice=txnprice ,...=...)
                         procorders[ii,]$Order.Status<-'closed'
-                        procorders[ii,]$Order.StatusTime<-timestamp
+                        procorders[ii,]$Order.StatusTime<-as.character(timestamp)
                     }
                 } #end loop over open orders       
             } # end higher frequency processing

Modified: pkg/quantstrat/demo/simplestrat.R
===================================================================
--- pkg/quantstrat/demo/simplestrat.R	2010-02-26 13:56:01 UTC (rev 267)
+++ pkg/quantstrat/demo/simplestrat.R	2010-02-26 14:17:24 UTC (rev 268)
@@ -18,7 +18,7 @@
 
 s <- strategy("simplestrat")
 #s <- add.indicator(strategy = s, name = "SMA", arguments = list(x = quote(Cl(mktdata)), n=10), label="SMA10")
-s <- add.indicator(strategy = s, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), sd = 2,maType=quote(SMA)))
+s <- add.indicator(strategy = s, name = "BBands", arguments = list(HLC = quote(HLC(mktdata)), sd = 2, n=20, maType=quote(SMA)))
 
 
 #if you wanted to manually apply a signal function for demonstration
@@ -47,7 +47,7 @@
 end_t-start_t
 updatePortf(Portfolio='simplestrat',Dates=paste('::',as.Date(Sys.time()),sep=''))
 chart.Posn(Portfolio='simplestrat',Symbol='IBM',theme='white')
-plot(addBBands(on=1,sd=2,n=10))
+plot(addBBands(on=1,sd=2,n=20))
 ###############################################################################
 # R (http://r-project.org/) Quantitative Strategy Model Framework
 #



More information about the Blotter-commits mailing list