Skip to content
Prev 5858 / 15274 Next

Error in Blotter's Longtrend Demo

I am trying to reproduce the longtrend example in the current blotter package.
Loading required package: blotter
Loading required package: FinancialInstrument
The demo breaks after the for loop with the error: object 'ConMult' not found. 
Is this a known issue or am I doing something wrong?

I have compared my R settings with Brian's examples in http://ethos.braverock.com/brian/longtrend/sessioninfo.txt
My xts and zoo package seem to be newer than the ones in the example settings. Is this causing the problem? 

Maybe someone can point me to the right direction.

My current setup is the following:
_                            
platform       i386-pc-mingw32              
arch           i386                         
os             mingw32                      
system         i386, mingw32                
status                                      
major          2                            
minor          10.1                         
year           2009                         
month          12                           
day            14                           
svn rev        50720                        
language       R                            
version.string R version 2.10.1 (2009-12-14)
R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] PerformanceAnalytics_1.0.2 blotter_0.4                FinancialInstrument_0.0.2  quantmod_0.3-14            TTR_0.20-1                
[6] Defaults_1.1-1             xts_0.7-1                  zoo_1.6-3                 

loaded via a namespace (and not attached):
[1] grid_2.10.1    lattice_0.18-3 tools_2.10.1  



And here is the code snippet of the demo('longtrend') that is breaking:
+     # browser()
+     CurrentDate=time(GSPC)[i]
+     cat(".")
+     equity = getEndEq(ltaccount, CurrentDate)
+ 
+     ClosePrice = as.numeric(Ad(GSPC[i,]))
+     Posn = getPosQty(ltportfolio, Symbol='GSPC', Date=CurrentDate)
+     UnitSize = as.numeric(trunc(equity/ClosePrice))
+ 
+     # Position Entry (assume fill at close)
+     if( Posn == 0 ) { 
+     # No position, so test to initiate Long position
+         if( as.numeric(Ad(GSPC[i,])) > as.numeric(GSPC[i,'SMA10m']) ) { 
+             cat('\n')
+             # Store trade with blotter
+             addTxn(ltportfolio, Symbol='GSPC', TxnDate=CurrentDate, TxnPrice=ClosePrice, TxnQty = UnitSize , TxnFees=0, verbose=verbose)
+         } 
+     } else {
+     # Have a position, so check exit
+         if( as.numeric(Ad(GSPC[i,]))  <  as.numeric(GSPC[i,'SMA10m'])) { 
+             cat('\n')
+             # Store trade with blotter
+             addTxn(ltportfolio, Symbol='GSPC', TxnDate=CurrentDate, TxnPrice=ClosePrice, TxnQty = -Posn , TxnFees=0, verbose=verbose)
+         } 
+     }
+ 
+     # Calculate P&L and resulting equity with blotter
+     updatePortf(ltportfolio, Dates = CurrentDate)
+     updateAcct(ltaccount, Dates = CurrentDate)
+     updateEndEq(ltaccount, Dates = CurrentDate)
+ } # End dates loop
.
[1] "1998-10-30 GSPC 91 @ 1098.67"
Error: object 'ConMult' not found
In addition: There were 15 warnings (use warnings() to see them)

Thanks for your help!

Regards,

 Wolfgang Wu


_______________________________
?gt ?ber einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com