| portfolio_returns | R Documentation |
Computes the portfolio simple return series by applying (lagged) portfolio weights to next-period asset returns, optionally net of proportional costs.
portfolio_returns(weights, prices, cost_bps = 0)
weights |
A data.frame/data.table of portfolio weights on rebalance dates:
first column |
prices |
A data.frame/data.table of adjusted prices at the same cadence:
first column |
cost_bps |
One-way proportional cost per side in basis points (e.g., |
CASH support: if weights contains a column named "CASH" (case-insensitive)
but prices has no matching column, a synthetic flat price series is added
internally (price = 1 \Rightarrow return = 0). In that case the function does not
re-normalise the non-CASH weights; the row is treated as a complete budget
(symbols + CASH = 1).
The function carries forward the latest available weights to each return row via the usual one-period decision lag. Transaction cost handling is conservative: if a turnover helper is not available, costs are skipped.
A data.table with columns Date and ret (portfolio simple return).
PortfolioTesteR::panel_returns_simple
data(sample_prices_weekly)
mom12 <- PortfolioTesteR::calc_momentum(sample_prices_weekly, 12)
sel10 <- PortfolioTesteR::filter_top_n(mom12, 10)
w_eq <- PortfolioTesteR::weight_equally(sel10)
pr <- portfolio_returns(w_eq, sample_prices_weekly, cost_bps = 0)
head(pr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.