Write Covered Call Strategy in Python

Share on Facebook0Tweet about this on Twitter0Share on LinkedIn2Share on Google+0

Introduction

Traders in the derivative market often exercise one of the following: Call option or Put Option.

“Call option” is a financial contract between a buyer and seller, whereby the buyer has the right, but not the obligation, to buy an agreed quantity of a financial instrument from the seller of the option at a certain time for a certain price (the strike price). The “Pull Option” serves the opposite.

In a “Covered Call”, the seller of the call options owns the corresponding amount of the underlying instrument.

A Covered Call is an income generating option strategy which involves two legs:

  • Buying a stock
  • Selling an Out of the money (OTM) call option

If the call is sold simultaneously along with the stock purchase, the strategy is referred to as a “buy-write” strategy.

In a Covered Call, the trader holds a neutral to a bullish outlook. Covered Call is a net debit transaction because you pay for the stock and receive a small premium for the call option sold.

The idea of this blog post is to elaborate on the covered call strategy by an example, and to plot its payoff using Python. The post also highlights “Calendar Call” as it is a modification of the Covered Call strategy.

Let us take an example straight away to understand the working of a Covered Call, its payoff, and the risk involved in the strategy.

 Covered Call Strategy example:

SBI stock is trading at Rs. 189 on April 29th, 2015.
Leg 1: Buy 100 shares of the stock for Rs. 189
Leg 2: Sell the 195 strike May 26th 2015 Call for Rs.6.30, Lot size – 100 shares

The amount paid to take these two positions equals – Stock price paid minus call premium received, i.e. Rs. 18,900 (Stock purchase) – Rs. 630 (Premium received) = Rs. 18,270

If the stock price rises above the call strike of 195, it will be exercised, and the stock will be sold. However, the strategy will make a profit because you are covered by the stock you own.

Say, the stock price at expiration is Rs. 200. The profit made is given by

If the stock falls below the initial stock purchase price, your long position is in loss, but you have some cushion from the call premium received by selling the call.

Say, the stock falls and is at Rs. 180 on expiration. The loss incurred is given by

One can employ the Covered Call strategy by selling calls on a monthly basis, and thus generating monthly income by way of premiums.

The Risk-Reward Profile for Covered Call is as given below:
1. Maximum Risk – (Stock price paid – call premium received)
2. Maximum Reward – (Call strike – stock price paid) + call premium received
3. Breakeven – (Stock price paid – call premium received)

Python code for Covered Call Payoff chart

Below is the code for Long Stock, Short Call and Covered call payoff chart in Python.

We use the matplotlib library to plot the charts. We first create an empty figure and add a subplot to it. Then we remove the top & the right border, and move the X-axis at the center. Using the plt.plot function we plot payoffs for Long stock, Short Call, and the Covered Call. Finally, we add the Title, labels, and the legend in the chart.

Long Stock, Short Call and Covered call payoff chart in Python.

 

Calendar Call Strategy

Calendar Call is a variation of a Covered Call strategy, where the long stock position is substituted with a long-term long call option instead.

The Calendar Call strategy involves two legs:

  • Buying a long-term expiration call with a near the money strike price and
  • Selling a short-term call option with the same strike price

With a Calendar Call, the outlook of the trader is neutral to bullish. This is a net debit transaction because calls bought will be more expensive than the calls sold, which have less time value. The Calendar Call like the Covered Call can be an income generating strategy by way of selling short-term calls on a monthly basis.

Let us take an example of a Calendar Call to understand its payoff, and the risk involved in the strategy.

Example:

XYZ stock is trading at Rs. 187 on May 2nd, 2015, with historical volatility at 40% and risk-free rate of 8%.

Leg 1: Buy the 190 strike July 28th 2015 Call for Rs.20.70, Lot size – 100 shares

Leg 2: Sell the 190 strike May 26th 2015 Call for Rs.7.50, Lot size – 100 shares

1st Scenario: At May expiration the stock falls to Rs.180

Long call is worth approximately Rs.8.80; loss of Rs.11.90

Short calls expire worthless, and we pocket the profit of Rs.7.50

Total position – loss of Rs.4.40

2nd Scenario: At May expiration the stock rises to Rs.205

In this case the stock has risen above the strike price. The short call will get exercised. The price of the long call is approximately Rs.23.60; profit of 2.90.

Sell long call for a profit of Rs.2.90

Keep short call premium of Rs.7.50

Short call expires at Rs.15 ITM. Buy stock at Rs.205; Sell stock at Rs.190 – loss of Rs.15

Hence total position – loss of Rs.4.60

The Risk-Reward Profile for Calendar Call is as given below:

  • Maximum Risk – Limited to the net debit paid
  • Maximum Reward – (Value of the long call at the time of the short call expiration, when the stock price is at the strike price) minus (net debit)

Python code for Calendar Call Payoff chart

Below is the code for Short Call, Long Call Premium, and the Calendar call payoff.

 

Short Call, Long Call Premium, and the Calendar call payoff.

We use the matplotlib library to plot the charts. We first create an empty figure and add a subplot to it. Then we remove the top & the right border, and move the X-axis at the center. Using the plt.plot function we plot payoffs for Short Call, Long Call Premium, and the Calendar Call. Finally, we add the Title, labels, and the legend in the chart.

If you liked what you read, please give us feedback in the comments section below. For more such strategies and python codes, go through our blogs section. If you are looking for python codes to build technical indicators like Moving Average or Ease of Movement, you will find it here.  Incase you are wondering what makes Python most preferred language for Algorithmic Traders, we have a cool infographic about it.

If you are a coder or a tech professional looking to start your own automated trading desk. Learn automated trading from live Interactive lectures by daily-practitioners. Executive Programme in Algorithmic Trading covers training modules like Statistics & Econometrics, Financial Computing & Technology, and Algorithmic & Quantitative Trading.Enroll now!

 

Share on Facebook0Tweet about this on Twitter0Share on LinkedIn2Share on Google+0

Leave a Reply

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