[R-SIG-Finance] Another blotter test case
Wolfgang Wu
wobwu22 at yahoo.de
Fri Dec 24 10:35:05 CET 2010
I am still bumping into problems trying to implement some of our trading
strategies using blotter. So here is another one that seems to go wrong using
r511.
library(blotter)
dateRange <- as.Date(as.Date('2010-01-02'):as.Date('2010-01-05'))
currency('USD')
stock('ABC', currency='USD')
ABC <- xts(102:105, order.by=dateRange)
colnames(ABC) = "Close"
initPortf('portA', symbols="ABC", initDate='2010-01-01');
initAcct('accA',portfolios='portA', initDate='2010-01-01', initEq=100);
addTxn("portA", Symbol='ABC', TxnDate='2010-01-02', TxnPrice=102, TxnQty =1,
TxnFees=0, verbose=TRUE)
updatePortf('portA', Dates = dateRange)
updateAcct('accA', Dates = dateRange)
updateEndEq('accA', Dates = dateRange)
#Equity wrong?
getAccount('accA')
I get the following result with the End.Eq staying at 101 where I am expecting
it to increase as the stock increases in value.
$portfolios
$portfolios$portA
Long.Value Short.Value Net.Value Gross.Value Realized.PL
2010-01-01 0 0 0 0 0
2010-01-02 102 0 102 102 0
2010-01-03 103 0 103 103 0
2010-01-04 104 0 104 104 0
2010-01-05 105 0 105 105 0
Unrealized.PL Gross.Trading.PL Txn.Fees Net.Trading.PL
2010-01-01 0 0 0 0
2010-01-02 0 0 0 0
2010-01-03 1 1 0 1
2010-01-04 1 1 0 1
2010-01-05 1 1 0 1
$summary
Additions Withdrawals Realized.PL Unrealized.PL Int.Income
2010-01-01 0 0 0 0 0
2010-01-02 0 0 0 0 0
2010-01-03 0 0 0 1 0
2010-01-04 0 0 0 1 0
2010-01-05 0 0 0 1 0
Gross.Trading.PL Txn.Fees Net.Trading.PL Advisory.Fees
2010-01-01 0 0 0 0
2010-01-02 0 0 0 0
2010-01-03 1 0 1 0
2010-01-04 1 0 1 0
2010-01-05 1 0 1 0
Net.Performance End.Eq
2010-01-01 0 100
2010-01-02 0 100
2010-01-03 1 101
2010-01-04 1 101
2010-01-05 1 101
attr(,"currency")
[1] "USD"
attr(,"initEq")
[1] 100
attr(,"class")
[1] "portfolio_account" "account"
Regards, Wolfgang Wu
More information about the R-SIG-Finance
mailing list