plop | R Documentation |

Calculates portfolio returns or losses by assigning weights

plop(x, wts = NULL, approxim = c(0, 1))

`x` |
a numeric matrix of asset returns or losses |

`wts` |
a numeric vector or matrix containing the portfolio
weights; portfolio value is standardized to 1 on any observation unit;
sum of weights should not exceed 1 (row-wise for matrices); by default
the portfolio is equally weighted over time and across all assets; if a
vector is passed to |

`approxim` |
controls if a first-order approximation for the calculation
of returns or losses is used; default is |

Returns a list with the following elements:

- pl
Weighted portfolio returns or losses

- wts
Portfolio weights

# creating portfolio portfol <- cbind(SP500$price.close, DJI$price.close) returns <- apply(portfol, 2, function(x) diff(log(x))) # defining weights and applying the P&L operator function wts <- c(0.4, 0.6) portret <- plop(returns, wts = wts, approxim = 1) portloss <- plop(-returns, wts = wts, approxim = 1) plot.ts(cbind(portret$pl, portloss$pl))

quarks documentation built on Sept. 1, 2022, 1:06 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.