R/protective.put.R

Defines functions protective.put

Documented in protective.put

#' Visualization of Protection Selling Strategy (Reverse Operation of Protection Selling Strategy)
#' @description The protective.put() function generates a graph showing the profits and losses of both long and short put options and stock portfolios. The reason for the construction of the strategy is to be bullish on the market, but also worried about the future stock price decline. If the future stock price falls, put options can be executed to compensate for the loss. Its reverse operation is short on the market, but also worries about the future stock price rise. If the future stock price rises, the option fee obtained by short put option can compensate for the loss.
#' @note If there is a mutual occlusion problem in the image, you can run the dev. new () command first. If there are still occlusion problems, you can directly run the protective. put command to call out the source code of the function, and eliminate the occlusion problem by modifying the corresponding graphic parameters.
#' @param K Execution Price of Put Options
#' @param opt The Price of Put Options
#' @param S Current stock price, default value is 42
#' @param position It specifies whether to use a positive strategy to protect the right to sell (multi-selling and underlying stocks at the same time), or a reverse strategy to protect the right to sell (short selling and underlying stocks at the same time).
#' @examples
#' protective.put(K = 40, opt = 5, S = 42)
#' protective.put(K = 40, opt = 5, S = 42, position = "short")
#' @references
#' John C.Hull. Options, Futures, and other Derivatives 9ed
#' @seealso
#' \code{\link{writing.call}}
#' @export
protective.put <- function(K = 40, opt = 5, S = 50, position = "long"){
  if (position != "long" & position != "short")
    stop("position must equal long or short")
  x = seq(K - K/2, K + K/2, 0.01)
  if (position == "long"){
    y1 = x - S
    y2 = ifelse(x <= K, K - x - opt, -opt)
    y = y1 + y2
    plot(x, y, type = "l", ann = FALSE, ylim = c(1.5*min(min(y1, y2), y), 1.5*max(max(y1, y2), y)), col = 2, lty = 1, lwd = 2)
    lines(x, y1, type = "l", col = 3, lty = 1, lwd = 1)
    lines(x, y2, type = "l", col = 4, lty = 1, lwd = 1)
    abline(h = 0, lty = 2)
    title(main = "Protective put Strategy", xlab = "Stock price", ylab = "Payoff", cex.lab = 1)
    legend("bottomright", c("Portfolio payoff", "Payoff from long stock", "Payoff from long put"), col = 2:4, lty = 1, cex = 0.9)
  }
  if (position == "short"){
    y1 = S - x
    y2 = ifelse(x <= K, x - K + opt, opt)
    y = y1 + y2
    plot(x, y, type = "l", ann = FALSE, ylim = c(1.5*min(min(y1, y2), y), 1.5*max(max(y1, y2), y)), col = 2, lty = 1, lwd = 2)
    lines(x, y1, type = "l", col = 3, lty = 1, lwd = 1)
    lines(x, y2, type = "l", col = 4, lty = 1, lwd = 1)
    abline(h = 0, lty = 2)
    title(main = "The reverse of a protective put", xlab = "Stock price", ylab = "Payoff", cex.lab = 1)
    legend("topright", c("Portfolio payoff", "Payoff from short stock", "Payoff from short put"), col = 2:4, lty = 1, cex = 0.9)
  }
}
czxa/FMFE documentation built on Nov. 6, 2019, 4:58 a.m.