[Blotter-commits] r210 - pkg/blotter/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 28 14:42:32 CET 2010


Author: braverock
Date: 2010-01-28 14:42:31 +0100 (Thu, 28 Jan 2010)
New Revision: 210

Modified:
   pkg/blotter/demo/amzn_test.R
   pkg/blotter/demo/longtrend.R
Log:
- update demos

Modified: pkg/blotter/demo/amzn_test.R
===================================================================
--- pkg/blotter/demo/amzn_test.R	2010-01-27 21:50:29 UTC (rev 209)
+++ pkg/blotter/demo/amzn_test.R	2010-01-28 13:42:31 UTC (rev 210)
@@ -1,16 +1,27 @@
 require(blotter)
 # load the example data
 data("amzn")
+currency("USD")
+stock("amzn",currency="USD",multiplier=1)
 # Initialize the Portfolio
 initPortf("amzn_port",symbols="amzn",initDate="2010-01-14")
+initAcct("amzn_acct",portfolios="amzn_port",initDate="2010-01-14")
 # look at the transactions data
 amzn.trades
 # Add the transactions to the portfolio
 # if you wanted to avoid the contract multiplier warning, you would add an instrument first
 addTxns("amzn_port","amzn",TxnData=amzn.trades,verbose=TRUE)
+
 # update the portfolio stats
 updatePortf("amzn_port",Dates="2010-01-14")
+# getPortfolio("amzn_port")
+
+# update the account P&L
+updateAcct("amzn_acct",Dates="2010-01-14")
+
 # and look at it
-chart.Posn("amzn_port","amzn",Dates="2010-01-14")
+chart.Posn("amzn_port","amzn",Dates="2010-01-14",theme='white')
+
+#and clean up the side effects of the demo
 rm("amzn","amzn.trades")
-rm("portfolio.amzn_port",pos=.blotter)
\ No newline at end of file
+rm("portfolio.amzn_port","account.amzn_acct",pos=.blotter)
\ No newline at end of file

Modified: pkg/blotter/demo/longtrend.R
===================================================================
--- pkg/blotter/demo/longtrend.R	2010-01-27 21:50:29 UTC (rev 209)
+++ pkg/blotter/demo/longtrend.R	2010-01-28 13:42:31 UTC (rev 210)
@@ -99,9 +99,9 @@
     }
 
     # Calculate P&L and resulting equity with blotter
-    portfolio = updatePortf(portfolio, Dates = CurrentDate)
-    account = updateAcct(account, Dates = CurrentDate)
-    account = updateEndEq(account, Dates = CurrentDate)
+    updatePortf(portfolio, Dates = CurrentDate)
+    updateAcct(account, Dates = CurrentDate)
+    updateEndEq(account, Dates = CurrentDate)
 } # End dates loop
 cat('\n')
 # Chart results with quantmod



More information about the Blotter-commits mailing list