Description Usage Arguments Value Examples
View source: R/plot_metrics_2funds.R
Useful for visualizing the behavior of 2-fund portfolios, e.g. by plotting a measure of growth vs. a measure of volatility.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | plot_metrics_2funds(
metrics = NULL,
formula = mean ~ sd,
tickers = NULL,
...,
points = seq(0, 100, 10),
gains = NULL,
prices = NULL,
benchmark = "SPY",
y.benchmark = benchmark,
x.benchmark = benchmark,
ref.tickers = NULL,
plotly = FALSE,
title = NULL,
base_size = 16,
label_size = 5,
return = "plot"
)
|
metrics |
Data frame with Fund column and column for each metric you
want to plot. Typically the result of a prior call to
|
formula |
Formula specifying what to plot, e.g. |
tickers |
Character vector of ticker symbols, where the first two are are a two-fund pair, the next two are another, and so on. |
... |
Arguments to pass along with |
points |
Numeric vector specifying allocations to include as points on
the curve. Set to |
gains |
Data frame with a date variable named Date and one column of gains for each fund. |
prices |
Data frame with a date variable named Date and one column of prices for each fund. |
benchmark, y.benchmark, x.benchmark |
Character string specifying which
fund to use as benchmark for metrics (if you request |
ref.tickers |
Character vector of ticker symbols to include on the plot. |
plotly |
Logical value for whether to convert the
|
title |
Character string. |
base_size |
Numeric value. |
label_size |
Numeric value. |
return |
Character string specifying what to return. Choices are
|
Depending on return
, a ggplot
object, a data
frame, or a list containing both.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
# Plot mean vs. SD for UPRO/VBLTX, and compare to SPY
plot_metrics_2funds(
formula = mean ~ sd,
tickers = c("UPRO", "VBLTX")
)
# Plot CAGR vs. max drawdown for AAPL/GOOG and FB/TWTR
plot_metrics_2funds(
formula = cagr ~ mdd,
tickers = c("AAPL", "GOOG", "FB", "TWTR")
)
# Plot Sharpe ratio vs. allocation for SPY/TLT
plot_metrics_2funds(
formula = sharpe ~ allocation,
tickers = c("SPY", "TLT")
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.