Skip to content
Prev 6637 / 15274 Next

Blotter : pbm with P&L calculation

On 09/09/2010 08:21 AM, Fr?d?ric LABORDERIE wrote:
It would be helpful if you provided a reproducible example, so that we 
can help you debug the problem.

I've just committed a new file to the project that should aid you (or 
anyone else) in creating reproducible examples.  The function is 
'extractTxns', and may be found here:

https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/blotter/R/extractTests.R?root=blotter

With the associated calls for setup of the portfolio, and downloading 
data from somewhere, this would even allow us to create a test, if 
warranted.

I suspect that you are crossing directly through a zero position.  In 
this case you will likely encounter problems.  It is generally a good 
idea to close a position before initiating a new position on the other 
side of the market.  Many prime brokers in fact require this, or split 
transactions in the transaction log to create the same effect.

The coding necessary to detect this crossover of a zero position and 
separate the transaction P&L, from experience, is rather painful, and I 
don't know how to vectorize it for performance.

With a reproducible example I'd be happy to work through it, and if 
necessary, work on fixing any problem or providing a workaround.

Regards,

    - Brian