[R-SIG-Finance] Blotter, how to add account transactions

Bos, Roger roger.bos at rothschild.com
Fri May 5 19:36:26 CEST 2017


All,

I have a simple blotter example where I am adding cash, adding a withdrawal, and an interest payment to an account.  It shows up in the account.a object in the .blotter environment, but the actual transactions do not show up in the summary table even after updating the account.  Could anyone point out what I am doing wrong?

$summary
                    Additions Withdrawals Realized.PL Unrealized.PL Interest Gross.Trading.PL
1950-01-01 00:00:00         0           0           0          0.00        0         0.000000
2017-01-03 00:00:00         0           0           0          1.19        0         1.190002
2017-01-03 19:00:00         0           0           0          2.07        0         2.069993
2017-01-04 19:00:00         0           0           0         -0.56        0        -0.559998
2017-01-05 19:00:00         0           0           0          0.83        0         0.830002
2017-01-08 19:00:00         0           0           0         -1.88        0        -1.880005
2017-01-09 19:00:00         0           0           0         -2.13        0        -2.129990
2017-01-10 00:00:00         0           0           4          0.48        0         4.479996
                    Txn.Fees Net.Trading.PL Advisory.Fees Net.Performance End.Eq
1950-01-01 00:00:00        0       0.000000             0        0.000000 166.00
2017-01-03 00:00:00        0       1.190002             0        1.190002 167.19
2017-01-03 19:00:00        0       2.069993             0        2.069993 169.26
2017-01-04 19:00:00        0      -0.559998             0       -0.559998 168.70
2017-01-05 19:00:00        0       0.830002             0        0.830002 169.53
2017-01-08 19:00:00        0      -1.880005             0       -1.880005 167.65
2017-01-09 19:00:00        0      -2.129990             0       -2.129990 165.52
2017-01-10 00:00:00        0       4.479996             0        4.479996 170.00

$Additions
           Additions
1950-01-01         0
2017-01-05      1000

$Withdrawals
           Withdrawals
1950-01-01           0
2017-01-06        1000

$Interest
           Interest
1950-01-01        0
2017-01-07       10

Thanks,

Roger


require(blotter)
require(FinancialInstrument)
require(quantmod)
rm(.blotter)
if(!exists(".instrument")) .instrument <<- new.env()
if(!exists(".blotter")) .blotter <<- new.env()

currency("USD")
symbols = c("IBM")
for(symbol in symbols){ # establish tradable instruments
  stock(symbol, currency="USD", multiplier=1)
}

getSymbols(symbols, from='2017-01-01', to='2017-01-10', src='yahoo', index.class=c("POSIXt","POSIXct"))

initPortf("p", symbols=symbols, currency="USD")

## Trades must be made in date order.
addTxn(Portfolio = "p", Symbol = "IBM", TxnDate = '2017-01-03', TxnQty = 1, TxnPrice = 166, TxnFees = 00)
addTxn("p", "IBM", '2017-01-10', -1, 170, TxnFees = 0)

updatePortf(Portfolio="p",Dates='2017-01')

initAcct(name="a", portfolios="p", initEq=166, currency="USD")

addAcctTxn(Account="a", TxnDate='2017-01-05', TxnType='Additions', Amount=1000)
addAcctTxn(Account="a", TxnDate='2017-01-06', TxnType='Withdrawals', Amount=1000)
addAcctTxn(Account="a", TxnDate='2017-01-07', TxnType='Interest', Amount=10)

updateAcct("a",'2017-01-12')
updateEndEq("a",'2017-01-12')

updateAcct("a")
updateEndEq("a")

getAccount("a")$summary

get("account.a", pos=.blotter)


________________________________

This message and any attachments are for the intended recipient's use only. This message may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately notify the sender by e-mail, delete the message, any attachments and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message or any attachments if you are not the intended recipient.

________________________________

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list