• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Finance Train

Finance Train

High Quality tutorials for finance, risk, data science

  • Home
  • Data Science
  • CFA® Exam
  • PRM Exam
  • Tutorials
  • Careers
  • Products
  • Login

Options Strategy: Create Long Straddle with R Language

Data Science

This lesson is part 15 of 15 in the course Derivatives with R

The Long Straddle is an options trading strategy that involves going long on a call option and a put option with the same underlying asset, same expiration and same strike price. This strategy tries to gain profits due to volatility in either direction as the strategy wins when the price movement is significant in any direction. In this article we will learn about how to construct a long straddle with R programming language.

The code for implementing the long straddle with R is presented below. We first create a vector of prices using the seq() function in R. For our example, we create a vector with prices ranging from 700 to 950. We chose the strike price to be 850. The call and put options have a premium of 20 and 10 respectively. We calculate the payoffs from the call and the put options and then calculate the payoff from the long straddle strategy with a long position in both call and the put option. We finally plot the strategy payoff using the ggplot library in R.

prices <- seq(700,950,1) # Vector of prices
strike <- 850 # strike price for both put and call 
premium_call <- 20 # option price call
premium_put <- 10  # option price put 
 
# call option payoff at expiration 
intrinsicValuesCall <- prices - strike - premium_call
payoffLongCall <- pmax(-premium_call,intrinsicValues)
 
# put option payoff at expiration
intrinsicValuesPut <- strike - prices - premium_put
payoffLongPut <- pmax(-premium_put,intrinsicValuesPut)
 
# The payoff of the Strategy is the sum of the call and put payoff. Need
# to sum wise element by element between the two vectors
payoff <- rowSums(cbind(payoffLongCall,payoffLongPut))
 
# Make a DataFrame with all the variable to plot it with ggplot
results <- data.frame(cbind(prices,payoffLongCall,payoffLongPut,payoff))
 
ggplot(results, aes(x=prices)) + 
  geom_line(aes(y = payoffLongCall, color = "LongCall")) + 
  geom_line(aes(y = payoffLongPut, color="LongPut"))+
  geom_line(aes(y=payoff, color = 'Payoff')) +
scale_colour_manual("", 
                    breaks = c("LongCall", "LongPut", "Payoff"),
                    values = c("darkred", "darkblue", "darkgreen")) + ylab("Payoff")+
 ggtitle("Long Straddle Payoff")  

The following graph shows the payoff from the long straddle strategy.

Long Straddle Strategy in R

As we can observe in the graph above, the profits from the strategy (green line) are high when any of the stock price moves significantly away from the strike price at expiration. The maximum gain is unlimited in either direction. At the time of expiration, the profit will be the difference between the stock price and the strike price. If at expiration, the stock price is exactly the same as strike price, both options will not be exercised and will expire worthless. The trader’s maximum loss from the strategy will be the premium paid for the two options. The strategy is suitable under high volatility scenarios when trader expects a significant move in the stock price in either direction.

Previous Lesson

‹ Options Strategy: Create Bull Call Spread with R Language

Next Lesson

›

Join Our Facebook Group - Finance, Risk and Data Science

Posts You May Like

How to Improve your Financial Health

CFA® Exam Overview and Guidelines (Updated for 2021)

Changing Themes (Look and Feel) in ggplot2 in R

Coordinates in ggplot2 in R

Facets for ggplot2 Charts in R (Faceting Layer)

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

In this Course

  • Overview of Derivatives with R Tutorial
  • How to Create Futures Continuous Series
  • Exploring Crude Oil (CL) Future Data from Quandl in R
  • R Visualization of Statistical Properties of Future Prices
  • Comparing Futures vs Spot Prices for WTI Crude Oil
  • Different Parties in the Futures Market
  • Creating Term Structure of Futures Contracts Using R
  • Contango and Backwardation
  • Exploring Open Interest for Futures Contracts with R
  • Review of Options Contracts
  • Black Scholes Options Pricing Model in R
  • Binomial Option Pricing Model in R
  • Understanding Options Greeks
  • Options Strategy: Create Bull Call Spread with R Language
  • Options Strategy: Create Long Straddle with R Language

Latest Tutorials

    • Data Visualization with R
    • Derivatives with R
    • Machine Learning in Finance Using Python
    • Credit Risk Modelling in R
    • Quantitative Trading Strategies in R
    • Financial Time Series Analysis in R
    • VaR Mapping
    • Option Valuation
    • Financial Reporting Standards
    • Fraud
Facebook Group

Membership

Unlock full access to Finance Train and see the entire library of member-only content and resources.

Subscribe

Footer

Recent Posts

  • How to Improve your Financial Health
  • CFA® Exam Overview and Guidelines (Updated for 2021)
  • Changing Themes (Look and Feel) in ggplot2 in R
  • Coordinates in ggplot2 in R
  • Facets for ggplot2 Charts in R (Faceting Layer)

Products

  • Level I Authority for CFA® Exam
  • CFA Level I Practice Questions
  • CFA Level I Mock Exam
  • Level II Question Bank for CFA® Exam
  • PRM Exam 1 Practice Question Bank
  • All Products

Quick Links

  • Privacy Policy
  • Contact Us

CFA Institute does not endorse, promote or warrant the accuracy or quality of Finance Train. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.

Copyright © 2021 Finance Train. All rights reserved.

  • About Us
  • Privacy Policy
  • Contact Us