[R-SIG-Finance] Convert Daily PnL to Returns
Brian G. Peterson
brian at braverock.com
Fri May 15 19:12:38 CEST 2009
Oops, my code line is wrong. Sorry.
I wasn't thinking clearly about what you said. You need to add the
capital number to the series.
if you have $1000, and your PnL series is in $, then you would do
cumsum(PnL)+1000
to create your wealth index from which you can calculate returns.
if the capital changes, you have to take into account the addition or
withdrawal from the capital account in your series.
Sorry for the confusion,
- Brian
Brian G. Peterson wrote:
> Convert them to a wealth index. Add 1 to your first PnL number, and
> cumsum. This creates a fake "price series" that can then be turned
> into a return series for all the other analysis you need to do.
>
> if 'PnL' is your data variable:
>
> cumsum(PnL+1)
>
> Regards,
>
> - Brian
>
> Subhrangshu Nandi wrote:
>> I'm using R to optimize our portfolio. However, I do not have a return
>> series, as required in most of the portfolio optimization packages. I
>> have
>> daily PnLs (regular profit/loss numbers) of several products. In
>> order to be
>> able to use PerformanceAnalytics or RMetrics, how should I about
>> converting
>> them to returns? Also, my objective of optimizing the portfolio is to
>> maximize the return, constrained on some risk parameter like
>> VAR/CVAR/etc
>> and then decide how much to trade each product.
>>
>> Any headstart in solving this problem will be helpful.
>>
>> Thanks a lot,
>> -Nandi
>>
>
>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list