[R-SIG-Finance] bug in updatePortf

kidA jbherman at gmail.com
Sun Feb 5 16:57:06 CET 2012


ALSO: If I call updatePortf with "Dates=paste(startDate,endDate,"::"))" the
p$summary table has all the roles corresponding to intraday PnL, but those
rows have incorrect Long/Short/Net/Gross values which only account for the
exposure of the individual transactions. Note the Long.Value of 1020304 on
2008-09-30 11:27:38.586 that "skips a beat" on the next row (which comes
from a different symbols posPL table) only to return on the next common end
of day price stamp at 2008-10-01 1020648. *So PnLs are complete, while
exposures are not reliable.*

> p$summary['2008-09-28/2008-10-8']
                        Long.Value Short.Value Net.Value Gross.Value
Period.Realized.PL Period.Unrealized.PL Gross.Trading.PL  Txn.Fees
Net.Trading.PL
2008-09-29 00:00:00.000          0           0         0           0              
0.00                    0             0.00     0.000          0.000
2008-09-30 00:00:00.000          0           0         0           0              
0.00                    0             0.00     0.000          0.000
2008-09-30 11:27:38.586    1020304           0   1020304     1020304              
0.00                20984         20984.00 -1498.980      19485.020
2008-09-30 15:03:12.137          0    -1011574  -1011574     1011574              
0.00               -14062        -14062.00 -1496.268     -15558.268
2008-10-01 00:00:00.000    1020648     -971168     49480     1991816              
0.00                40750         40750.00     0.000      40750.000
2008-10-01 16:00:00.000          0           0         0           0          
17471.59               -26344         -8872.41 -1470.061     -10342.471
2008-10-02 00:00:00.000     968016           0    968016      968016              
0.00               -52632        -52632.00     0.000     -52632.000
2008-10-03 00:00:00.000     972832           0    972832      972832              
0.00                 4816          4816.00     0.000       4816.000
2008-10-06 00:00:00.000     928456           0    928456      928456              
0.00               -44376        -44376.00     0.000     -44376.000
2008-10-06 16:00:00.000          0           0         0           0         
-78081.12                70864         -7217.12 -1381.858      -8598.978
2008-10-07 00:00:00.000          0           0         0           0              
0.00                    0             0.00     0.000          0.000
2008-10-08 00:00:00.000          0           0         0           0              
0.00                    0             0.00     0.000          0.000
> p$symbols$`A-US`$txn
                        Txn.Qty Txn.Price Txn.Value Txn.Avg.Cost Pos.Qty
Pos.Avg.Cost Gross.Txn.Realized.PL  Txn.Fees Net.Txn.Realized.PL Con.Mult
1950-01-01 00:00:00.000       0    0.0000       0.0       0.0000       0        
0.00                  0.00     0.000                0.00        0
2008-09-30 11:27:38.586   34400   29.0500  999320.0      29.0500   34400       
29.05                  0.00 -1498.980            -1498.98        1
2008-10-06 16:00:00.000  -34400   26.7802 -921238.9      26.7802       0        
0.00             -78081.12 -1381.858           -79462.98        1
> p$symbols$`AAPL-US`$txn
                        Txn.Qty Txn.Price Txn.Value Txn.Avg.Cost Pos.Qty
Pos.Avg.Cost Gross.Txn.Realized.PL  Txn.Fees Net.Txn.Realized.PL Con.Mult
1950-01-01 00:00:00.000       0    0.0000       0.0       0.0000       0        
0.00                  0.00     0.000               0.000        0
2008-09-30 15:03:12.137   -8900  112.0800 -997512.0     112.0800   -8900      
112.08                  0.00 -1496.268           -1496.268        1
2008-10-01 16:00:00.000    8900  110.1169  980040.4     110.1169       0        
0.00              17471.59 -1470.061           16001.529        1
> p$symbols$`A-US`$posPL['2008-09-28/2008-10-8']
                        Pos.Qty Con.Mult Ccy.Mult Pos.Value Pos.Avg.Cost
Txn.Value Period.Realized.PL Period.Unrealized.PL Gross.Trading.PL  Txn.Fees
Net.Trading.PL
2008-09-29 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000         
0.000
2008-09-30 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000         
0.000
2008-09-30 11:27:38.586   34400        1        1   1020304        29.05 
999320.0               0.00                20984         20984.00 -1498.980     
19485.020
2008-10-01 00:00:00.000   34400        1        1   1020648         0.00      
0.0               0.00                  344           344.00     0.000       
344.000
2008-10-02 00:00:00.000   34400        1        1    968016         0.00      
0.0               0.00               -52632        -52632.00     0.000    
-52632.000
2008-10-03 00:00:00.000   34400        1        1    972832         0.00      
0.0               0.00                 4816          4816.00     0.000      
4816.000
2008-10-06 00:00:00.000   34400        1        1    928456         0.00      
0.0               0.00               -44376        -44376.00     0.000    
-44376.000
2008-10-06 16:00:00.000       0        1        1         0         0.00
-921238.9          -78081.12                70864         -7217.12 -1381.858     
-8598.978
2008-10-07 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000         
0.000
2008-10-08 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000         
0.000
> p$symbols$`AAPL-US`$posPL['2008-09-28/2008-10-8']
                        Pos.Qty Con.Mult Ccy.Mult Pos.Value Pos.Avg.Cost
Txn.Value Period.Realized.PL Period.Unrealized.PL Gross.Trading.PL  Txn.Fees
Net.Trading.PL
2008-09-29 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-09-30 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-09-30 15:03:12.137   -8900        1        1  -1011574       112.08
-997512.0               0.00               -14062        -14062.00 -1496.268     
-15558.27
2008-10-01 00:00:00.000   -8900        1        1   -971168         0.00      
0.0               0.00                40406         40406.00     0.000      
40406.00
2008-10-01 16:00:00.000       0        1        1         0         0.00 
980040.4           17471.59               -26344         -8872.41 -1470.061     
-10342.47
2008-10-02 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-10-03 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-10-06 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-10-07 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
2008-10-08 00:00:00.000       0        1        1         0         0.00      
0.0               0.00                    0             0.00     0.000          
0.00
> 


--
View this message in context: http://r.789695.n4.nabble.com/bug-in-updatePortf-tp4359010p4359140.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list