This is a question about the realized PL of the transactions in the amzn_test
demo of the blotter
R package. The transactions are a sequence of 7 trades that open and close positions intraday. A call to getTxns('amzn_port', 'amzn')
returns
Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost Net.Txn.Realized.PL
2010-01-14 00:00:00 0 0.00 0 0 0.00 0
2010-01-14 10:18:50 -400 127.49 0 -50996 127.49 50996
2010-01-14 10:18:53 400 127.49 0 50996 127.49 0
...
Why is Net.Txn.Realized.PL
non-zero for the opening transaction and zero for the closing transaction? With daily transactions, the realized P&L would be non-zero on the day of the closing transaction.
I am running blotter
0.9.1666 on 64-bit Windows.
Thanks for your patience.
This looks like a bug in
addTxns
because the net realized P&L looks reasonable if you calladdTxn
for each row inamzn.trades
.I'll investigate and report back once I've found/fixed the bug.
This is now fixed in revision 1693. Here's the patch: