Description Usage Arguments Details Value See Also Examples
The function toymkt
is used to create toy market objects.
1 2 3 |
price |
A |
R |
Simple returns of the assets (same format as |
benchmark.weight |
Portfolio weights of the benchmark (same format as |
initial.weight |
a numeric vector of initial benchmark weights. All entries of |
buy.and.hold |
If |
The function toymkt
is used to create toy market objects from prices, returns and/or benchmark weights. The universe consists of (say) n assets. For each asset, we have a time series of returns. A benchmark portfolio is given by a fixed set of portfolio weights, and we want to study the performances of portfolios with respect to this benchmark. The portfolio weights of the benchmark are called the benchmark weights.
If buy.and.hold
is TRUE
, the toy market is an idealized market where the benchmark is a buy-and-hold portfolio. In this case all data in the output is derived from price
and initial.weight
, or R
and initial.weight
. If buy.and.hold
is TRUE
, initial.weight
is not given but benchmark.weight
is given, the first row of benchmark.weight
will be used as the initial weight vector.
In the case buy.and.hold
is FALSE
the benchmark portfolio can be quite arbitrary. It is defined in terms of the beginning benchmark weights for each period and the returns for each asset.
A list containing the following components:
growth |
a |
R |
a |
r |
a |
benchmark.weight |
a |
n |
number of assets in the market. |
buy.and.hold |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # We use the EuStockMarkets dataset in the datasets package
data(EuStockMarkets)
# Example 1: Minimal specifications
# The market will be equal-weighted initially.
market <- toymkt(price = EuStockMarkets)
print(market)
plot(market) # several plots
# Example 2: Generate a market from simulated log-normal returns.
n.periods <- 60
n.stocks <- 5
mu <- 0
sigma <- 0.1
R <- matrix(0, nrow = n.periods, ncol = n.stocks)
for (j in 1:n.stocks) {
R[, j] <- exp(rnorm(n.periods, mean = mu, sd = sigma)) - 1
}
initial.weight <- c(0.1, 0.2, 0.3, 0.2, 0.2) # specify initial weights
market <- toymkt(R = R, initial.weight = initial.weight,
buy.and.hold = TRUE)
plot(market)
|
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Warning message:
In toymkt(price = EuStockMarkets) :
Since initial.weight is not given, the benchmark is assumed to be equal-weighted initially.
There are 4 assets:
DAX SMI CAC FTSE
The benchmark is buy-and-hold.
Other information (use $):
growth R r benchmark.weight n buy.and.hold
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.