twofunds_graph {stocks} | R Documentation |
Graph One Performance Metric vs. Another for Two-Fund Portfolios as Allocation Varies
Description
Useful for visualizing performance of two-fund portfolios, typically by plotting a measure of growth vs. a measure of volatility. First two investments are used as the first two-fund pair, next two as the second two-fund pair, and so on.
Usage
twofunds_graph(tickers = NULL, intercepts = NULL, slopes = NULL, ...,
benchmark.tickers = NULL, reference.tickers = NULL,
tickers.gains = NULL, benchmark.gains = NULL, reference.gains = NULL,
step.data = 0.0025, step.points = 0.1, x.metric = "sd",
y.metric = "mean", tickerlabel.offsets = NULL, reflabel.offsets = NULL,
add.plot = FALSE, colors = NULL, lty = NULL, plot.list = NULL,
points.list = NULL, text.list = NULL, pdf.list = NULL,
bmp.list = NULL, jpeg.list = NULL, png.list = NULL, tiff.list = NULL)
Arguments
tickers |
Character vector of ticker symbols that Yahoo! Finance recognizes, if you want to download data on the fly. |
intercepts |
Numeric vector of values to add to daily gains for each ticker. |
slopes |
Numeric vector of values to multiply daily gains for each ticker by. Slopes are multiplied prior to adding intercepts. |
... |
Arguments to pass along with |
benchmark.tickers |
Character vector of length 1 or 2 indicating ticker
symbols for benchmark indexes. Only used if |
reference.tickers |
Character vector of ticker symbols to include on graph as data points for comparative purposes. |
tickers.gains |
Numeric matrix of gains, where each column has gains for a particular fund. |
benchmark.gains |
Numeric vector or matrix of gains for 1 or 2 benchmark
indexes. Only used if |
reference.gains |
Numeric vector or matrix of gains for funds to include on graph as data points for comparative purposes. |
step.data |
Numeric value specifying allocation increments for plotting curves. |
step.points |
Numeric value specifying allocation increments for adding
data points on top of curves. Set to |
x.metric |
Character string specifying x-axis performance metric. Choices are:
|
y.metric |
Same as |
tickerlabel.offsets |
Either a numeric vector of length 2 giving the x- and y-axis offsets for all ticker labels, or a 2-column matrix where each row gives the x- and y-axis offsets for a ticker. |
reflabel.offsets |
Either a numeric vector of length 2 giving the x- and y-axis offsets for all reference ticker labels, or a 2-column matrix where each row gives the x- and y-axis offsets for a reference ticker. |
add.plot |
Logical value for whether to add plot data to current plot frame rather than open a new one. |
colors |
Character vector of colors for each curve. |
lty |
Numeric vector specifying line types for each curve. |
plot.list |
List of arguments to pass to |
points.list |
List of arguments to pass to
|
text.list |
List of arguments to pass to |
pdf.list |
List of arguments to pass to |
bmp.list |
List of arguments to pass to |
jpeg.list |
List of arguments to pass to |
png.list |
List of arguments to pass to |
tiff.list |
List of arguments to pass to |
Value
In addition to the graph, a list containing:
List named
portfolio.xy
where each element is a two-column matrix of x- and y-axis values for a fund pair.Numeric vector named
means
with mean gains for each fund.Numeric matrix named
corr.matrix
with a correlation matrix for gains for each fund.
References
Ryan, J.A. and Ulrich, J.M. (2017) quantmod: Quantitative Financial Modelling Framework. R package version 0.4-12, https://CRAN.R-project.org/package=quantmod.
Examples
## Not run:
# Plot mean vs. SD for UPRO/VBLTX portfolio, and compare to VFINX and BRK-B
fig1 <- twofunds_graph(tickers = c("UPRO", "VBLTX"),
reference.tickers = c("VFINX", "BRK-B"))
# Same funds, but annualized growth vs. maximum drawdown
fig2 <- twofunds_graph(tickers = c("UPRO", "VBLTX"),
reference.tickers = c("VFINX", "BRK-B"),
x.metric = "mdd", y.metric = "cagr")
## End(Not run)