On 09/01/2014 01:00 PM, domodo wrote:
[Joshua] Ulrich,thanks for your reply.

I found the reason why equity are always zero. the argument 'initDate' in
initPortf and initAcct should be earlier than market data's start date,in
this case, the start date is '2012-01-18 09:15:00',so argument 'initDate' in
initPortf and initAcct should at least be '2012-01-18 09:14:00' or earlier.
Having replace both of the value of initDate with  '2012-01-18 09:14:00', I
got the result of txns as below:

head(txns)
                     Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost
Net.Txn.Realized.PL
2012-01-18 09:14:00       0       0.0    0.000         0          0.0
0.000
2012-01-18 09:35:00       8    2580.0 -309.600   6192000       2580.0
-309.600
2012-01-18 09:43:00      -8    2582.0 -309.840  -6196800       2582.0
4490.160
2012-01-18 09:54:00       8    2580.8 -309.696   6193920       2580.8
-309.696
2012-01-18 09:57:00      -8    2575.8 -309.096  -6181920       2575.8
-12309.096
2012-01-18 09:58:00       8    2581.8 -309.816   6196320       2581.8
-309.816

all transactions are OK,except the first transaction. why it occurs ? I
tried to run the codes in debug mode line-by-line,but couldn't find the
reason.

The first row is there only as an initialization row. You need a starting point (an empty portfolio) or none of the math makes sense.

PS:
I couldn't find the reason why argument 'initDate' in initPortf and
initAcct must be earlier than market data's start date/time in help
documents.


I don't know why it should be unclear that initDate must be before the first transaction.

The documentation currently describes initDate as:

initDate: A date prior to the first close price given,
          used to contain initial account equity and initial position

I suppose we can try to make this more clear and say that it must be prior to the first *transaction* and that you need to have initDate before the market data you wish to use to mark the portfolio.


As with the initial state of the portfolio, above, where you start with nothing. Portfolio accounting is about marking the portfolio with realized and unrealized differences. There must be a starting point. You have to create the portfolio and account *before* you can put transactions in it. Transactions have to occur in order or you need to go back and reassess what happened.

Regards,

Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to