Calls Vs Puts: A Beginner’s Guide to Understanding Options Trading
The financial world can be extremely complex, especially when it comes to options trading. In this blog, we’ll cover the basics of options trading, helping you understand calls and puts, as well as guide you through making your first simulated options trade using Alpaca’s Trading API and Paper Trading environment.
If you’re not set up with Alpaca’s Trading API or Paper Trading, sign up now and connect your trading account! If you already have an account, feel free to follow along and learn more about options trading.
What is Options Trading?
Options are a contract that gives a buyer the right to buy or sell a security or stock at a predetermined price at some point in the future. Options trading is offered by several brokerages, potentially providing access to strategies that can provide stability and protection to your financial portfolio.
When getting started in options trading, you may notice that brokers and institutions have a few different trading levels (often Level 1 to Level 4). Each level builds on top of one another, adding new trading strategies at each level. While higher levels typically have more flexibility and profit potential, they also often come with a greater loss potential. That’s why it’s important to grasp the fundamentals of American-style options before trading at higher levels.
While some traders prefer to have the ability to trade options at every level, many prefer to have only the basics. For the purpose of this blog, we will only be covering Level 1 and Level 2 options trading. Learn more about the different option trading levels available at Alpaca. Other brokers may define Level 1 and Level 2 differently than Alpaca does.
And for those looking to gain an overview of options trading, you can refer to my blogs on how I learned about options trading as a college student.
Overview: Call vs. Put Options
Call and put options, and their different types, are the foundation of options trading. Call options give traders or investors the right to buy a stock at a set price within a given timeframe, while put options provide the right to sell within a given timeframe.
Within Level 1 and Level 2 options trading there are essentially five strategies:
- Covered Calls: Selling a call option on an owned stock to generate premium income.
- Protective Puts: Buying a put option on an owned stock to protect yourself from the loss.
- Cash-Secured Puts: Selling a put option with cash set aside to buy the stock at a lower price if assigned.
- Long Calls: Buying a call option to benefit from a stock price going up.
- Long Puts: Buying a put to benefit from a stock price going down.
These strategies may help traders balance income generation while also potentially protecting them from much of the risk. This makes them a potential choice for novice traders as an opportunity to gain practical experience while potentially maintaining a degree of protection against extensive losses.
Detailed Look: Covered Calls
Now that we know some of the basic strategies, let's dive into how a covered call works.
What Is a Covered Call?
A covered call is an options trading strategy where an investor sells call options on stocks they already own to earn extra income. Essentially, you agree to sell your shares at a set price, the strike price, even if the stock rises, in exchange for receiving a cash premium upfront. If the stock stays below the strike price through expiration, you keep the premium, earning income while holding your shares.
For example, let’s say you agree to sell a covered call for Stock A, which has a current share value of $73, a strike price of $75, a premium of $1, over a timeframe of two weeks. Because options are typically sold in multiples of 100, selling one covered call on Stock A gives you $100 (100 × $1).
If Stock A never hits the strike price in the given timeframe, you may keep your shares and keep the $100 premium. If Stock A increases to $77 per share, you lose your shares, because someone bought them from you, but keep the $100 premium. However, losing the right to sell those shares at the $77 price point means you missed out on the potential growth of the stock, which in this case would have been $200 (($77 - $75) × 100)).
The logic of the person selling a covered call is this: "Even if the stock price rises above a certain level in the future, I’ll give up the right to those profits, but in return, I get to receive some cash upfront." If the stock stays below the strike price or falls, you keep the premium, offering a way to earn guaranteed income now, even if the value of the stock doesn’t rise.
When to Use a Covered Call
Covered calls are particularly useful when:
- Anticipating a sideways or mildly bullish market: If you expect the stock price to remain stable or rise slightly, selling calls can help you earn extra income.
- Earning premium income: Regularly selling call options can provide a steady stream of income from long-term holdings.
- Lowering your cost basis: Premiums received from selling calls can gradually reduce your average cost per share.
Why Covered Calls Are Risky
Covered calls can help balance income generation with limited risk, but there are trade-offs:
- Benefits:
- Steady income: Regular premiums can improve overall returns.
- Minor downside protection: Premiums can offer a small buffer against drops in stock price.
- Limitations:
- Capped upside: If the stock rises above the strike price, your gains could be limited, as you only profit from the option premium.
- Opportunity cost: You may miss out on larger profits if the stock price soars, because you no longer own the rights to sell those shares at the higher price.
Detailed Look: Protective Puts
Now we will dive into what a protective put means in options trading.
What Is a Protective Put?
A protective put is an options strategy that may act as a safety net for your stocks. By buying a put option, you set a minimum sale price, ensuring you can sell your shares at that level, even if the market drops. Think of it as paying a fee now to protect against potentially significant losses later.
Suppose you own 100 shares of Stock A, priced at $73. To protect against a drop, you buy a put option with a $70 strike price, paying a $1 premium per share. This costs $100 (100 × $1).
If Stock A falls to $65, the put lets you sell at $70, capping your loss. Without the put, your potential loss would be $800 (($73 - $65) × 100). With it, your loss is $400: a $300 difference from selling at $70 instead of $73, plus the $100 premium. If Stock A stays at $73 or rises, you may not want to use the put option. Instead, you may want to keep your shares, and you’d lose the $100 premium.
Essentially, this strategy allows you to stay invested in your stocks while having a safety net in place, offering peace of mind during uncertain markets.
When to Use a Protective Put
Investors may use protective puts in situations where they want to mitigate potential losses while still participating in the stock’s upside. Protective puts are particularly useful when:
- You’re expecting volatility: Ideal for times when big price swings are anticipated. Checking the 150-Day Historical Volatilities can help gauge how much risk your target stock has had over the past several months.
- Locking in gains: After a strong rally, buying a put can secure profits while limiting downside.
- Before earnings or news releases: To hedge against potential sudden drops from major announcements.
Why Protective Puts Are Risky
There are also a few benefits and risks that come with using protective puts.
Benefits:
- Downside protection: The put option guarantees that you can sell your stock at the strike price, limiting your potential losses in case the stock price drops.
- Flexibility: While protecting against downside risk, you maintain the ability to benefit from any upside if the stock continues to rise.
Risks:
- Premium expense: The main cost of a protective put is the option premium. The premium paid for this protection may reduce overall returns, especially if the stock remains stable or rises slightly.
- Time decay: As the put option approaches expiration, its value may decline (if not in-the-money), meaning you could lose the premium paid without needing the protection.
Setting Up Basic Algorithms for Covered Calls and Protective Puts
Now that we’ve covered the basics of covered calls and protective puts, we can discuss how to identify potential entry and exit points in options trading using some examples.
Using Data to Identify Entry and Exit Points
To effectively execute covered calls and protective puts, it's crucial to analyze strike prices, implied volatility, and time-to-expiration. These factors can help pinpoint potential entry and exit points. While many traders use charting platforms, you can also adopt a data-driven approach using Python with sources like Yahoo Finance API or Alpaca Trading API. This can help you to automate tracking, optimize strategies, and make informed trading decisions. Note: Prices can also be fetched using Alpaca APIs paid plan.
We will be using Alpaca’s Trading API and Paper Trading environment for the below data and trade examples. If you’re new to Alpaca’s Trading API, here are a few resources you can use before proceeding through the below example:
In the following example, we will show you how to use Yahoo Finance API and Alpaca Trading API to:
- Check an options chain
- Monitor daily highs and lows of underlying stocks
- Display candlestick charts for underlying stocks in your Jupyter notebook
We are using Google Collab as our code environment. Note: We are using Tesla as an example and it should not be considered investment advice.
Step 1: Set Up Your Coding Environment
# import the necessary packages
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
import pandas as pd
import yfinance as yf
import mplfinance as mpf
Step 2: Extract Option Data Using Yahoo Finance API
# Fetch TSLA stock data
tsla = yf.Ticker("TSLA")
# Retrieve available option expiration dates
expiration_dates = tsla.options
print("Available Expiration Dates:", expiration_dates)
# Choose an expiration date to analyze
expiration = expiration_dates[0]
# Retrieve option chain data for the selected expiration date
options_chain = tsla.option_chain(expiration)
# Separate calls and puts data
calls = options_chain.calls
puts = options_chain.puts
# Display the first few rows of calls and puts data
print(calls.head())
print(puts.head())
Step 3: Analyze Daily Highs and Lows for a Stock Using Alpaca API
Note: Make sure to put your API key and Secret API key in their respective spots below.
# Initialize the Alpaca client
api_key = "YOUR PAPER API KEY"
secret_key = "YOUR PAPER API SECRET"
client = StockHistoricalDataClient(api_key, secret_key)
# Define the request for historical data
request_params = StockBarsRequest(
Symbol_or_symbols="TSLA",
timeframe=TimeFrame.Day,
start="2024-09-17", # Adjust the date range as needed
end="2024-10-17"
)
tsla_data = client.get_stock_bars(request_params).df
# Reset index of the dataframe
tsla_data.reset_index(inplace=True)
# Extract daily high (max) and low (min) prices
tsla_daily_max_min = tsla_data[['high', 'low']]
# Print the first few rows to see the data
print(tsla_daily_max_min.head())
Step 4: Generating TSLA Daily Candlestick Chart Using “mplfinance”
# Ensure 'timestamp' is in datetime format
tsla_data['timestamp'] = pd.to_datetime(tsla_data['timestamp'])
# Set 'timestamp' as the index (required for mplfinance)
tsla_data.set_index('timestamp', inplace=True)
# Prepare the data for the candlestick chart
# The required columns are 'Open', 'High', 'Low', 'Close'
candlestick_data = tsla_data[['open', 'high', 'low', 'close']]
# Plot the candlestick chart
mpf.plot(candlestick_data, type='candle', style='charles', title='TSLA Daily Candlestick Chart', ylabel='Price')
This process plots the candlestick chart of “TSLA” between September 17, 2024 to October 17, 2024 as below.
Backtesting Covered Calls and Protective Puts
Before implementing option trading strategies like covered calls and protective puts algorithmically, it's crucial to backtest them. Backtesting is the process of testing your trading strategies against historical data, without risking real money. This allows you to see how your strategies and hypotheses might perform under actual market conditions.
For example, you can simulate buying Tesla (TSLA) shares and then selling call options (covered calls) or buying put options (protective puts). By tracking these simulated trades, you can gauge profitability, risk, and potential pitfalls before trading live.
Popular tools for backtesting include TradingView, which you can connect with your Alpaca paper trading account. While TradingView does not currently support options trading natively, you can use Pine Script—a custom language on TradingView—to build and test your strategies. For more details, check out this demo:
Note: Again, we are using Tesla as an example, and it should not be considered investment advice.
Using Pine Script To Backtest Protective Puts and Covered Calls
With Pine Script, you can write custom code to simulate options strategies, including protective puts. Below is the process for applying a protective put strategy on “TSLA” stock in TradingView.
You can test your strategy against historical data to see how it would have performed. To get started, navigate to the TradingView homepage and click on the “Products” button to access the “Supercharts” page.
On the “Supercharts” page, you can select specific stocks to analyze. In the example below, we chose “TSLA”. In the middle of the screen, you'll find the “Pine Editor” button, which you can use to add your Pine Script.
Copy the following code into the “Pine Editor”. After saving, apply it from the “Indicators” tab:
//@version=5
strategy("Protective Put Example", overlay=true)
// Input settings for backtesting
stock_quantity = input(100, title="Stock Quantity")
put_cost_per_contract = input(3.0, title="Put Cost per Contract")
strike_price = input(230, title="Put Strike Price")
expiry_days = input(30, title="Days Until Expiry")
// Buy the stock at the beginning
strategy.entry("Buy Stock", strategy.long, stock_quantity)
// Simulate buying protective put (subtract put cost)
put_value = (strike_price - close) * stock_quantity / 100
if (close < strike_price)
strategy.exit("Protective Put Activated", "Buy Stock", profit=put_value - put_cost_per_contract * stock_quantity / 100)
After adding your Pine Script, press the Save button. Your strategy can now be found under “Indicators, Metrics, and Strategies”.
At the top of the screen, click on the “Indicators” button. Here, you will find various indicators, metrics, and strategies that you can use.
Select the “Personal” section to locate your custom strategy created using Pine Script.
Once you select it, you will see indicators of your protective puts displayed on your “TSLA” chart.
After your strategy is activated, click on the “Strategy Tester” tab, located next to the “Pine Editor”, to visualize how your strategy would have performed on a specific stock (like TSLA) over time.
Similarly, you can backtest covered call strategies using Pine Script. Follow the same steps: add the script to the Pine Editor, save it, and run it through the Strategy Tester to see potential outcomes.
//@version=5
strategy("Covered Call Example", overlay=true)
// Input settings for backtesting
stock_quantity = input(100, title="Stock Quantity")
call_premium = input(2.5, title="Call Premium per Contract")
strike_price = input(225, title="Call Strike Price")
expiry_days = input(30, title="Days Until Expiry")
// Buy the stock at the beginning
strategy.entry("Buy Stock", strategy.long, stock_quantity)
// Simulate selling covered calls (add call premium)
call_value = (close - strike_price) * stock_quantity / 100
if (close > strike_price)
strategy.exit("Call Option Assigned", "Buy Stock", profit=call_value + call_premium * stock_quantity / 100)
else
strategy.close("Buy Stock")
By using TradingView and Pine Script, you can easily backtest and refine your options strategies, gaining insights and confidence before implementing them live. Experiment with different parameters, track performance, and fine-tune strategies to maximize profitability.
Alpaca Example: Implementing a Covered Call Strategy
Implementing covered calls can help identify optimal opportunities. We can execute covered calls using Alpaca’s Trading API, or we can jump-start trading using Alpaca’s Google Colab notebook. For example, we can demonstrate the security trading with “SPDR S&P 500 ETF Trust (SPY)” with the data being sourced from October 22, 2024. You can find the “SPY” options chains on Alpaca Dashboard or by using the “search” function.
Note: We are using SPY as an example for how to implement a covered call strategy on Alpaca’s Trading API. It should not be considered investment advice.
1. Setting up the Python Environment
You want to make sure that the request actions are imported for this code to work. You can do so by following the code in step 1 below. Also, please note the areas to input your Alpaca API Keys. The trade_client is used for purchasing both stocks and options.
# Please change the following to your own PAPER api key and secret
# You can get them from https://alpaca.markets/
api_key = "YOUR PAPER API KEY"
secret_key = "YOUR PAPER API SECRET"
# Install / Import necessary packages
!python3 -m pip install alpaca-py
import alpaca
from alpaca.trading.client import TradingClient
import json
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
from alpaca.trading.requests import (MarketOrderRequest, GetOrdersRequest)
from alpaca.trading.enums import (OrderSide, OrderType,TimeInForce, QueryOrderStatus)
# We set paper=True to indicate that this is Paper trading, not live trading.
trade_client = TradingClient(api_key=api_key, secret_key=secret_key, paper=True, url_override=trade_api_url)
The implementation of a covered call strategy typically consists of two steps. First, going long on a specific security, in our case SPY. Then, selling call options on that same underlying security.
2. Going long on SPY
We can place an order to buy 100 shares of SPY through Alpaca’s paper trading by running the code below. This limit BUY will be only executed if the market price of SPY reaches to $582. If you already have 100 “SPY” stock, you do not need to run this code.
# Place an order to buy SPY stock.
limit_order_data = LimitOrderRequest(symbol="SPY",
limit_price=582,
qty=100,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY)
limit_order = trade_client.submit_order(order_data=limit_order_data)
3. Selling Call Options:
In a covered call strategy, a potentially profitable scenario is when you sell out-of-the-money (OTM) call options, where the strike price is higher than the current stock price. For example, with SPY trading at $578.615, strike prices like $584 or $590 are ITM.
Further, in this example, we plan to sell call options expiring on Nov. 5 (2 weeks), priced at $4.10.
Note: The option details below can vary, so make sure to change the symbols to match your target options. It will not work if you use option details from a past date.
# Place an order to sell call options on SPY.
call_order_data = LimitOrderRequest(symbol="SPY241105C00590000",
limit_price=4.10,
qty=1,
side=OrderSide.SELL,
time_in_force=TimeInForce.DAY)
call_order = trade_client.submit_order(order_data=call_order_data)
Key factors of this covered call (SPY241105C00590000):
- Underlying Stock: The security we’re trading with (SPY)
- Expiration Date: November 5, 2024 (241105 in YYMMDD format)
- Call or Put: The “C” denotes that it is a call option
- Strike Price: The price at which you agree to sell your SPY shares if the option is exercised (which in this case is $590)
Understanding the order parameters:
- limit_price = 4.10: The minimum price you will accept to sell the call option
- qty = 1: Represents one contract (equivalent to 100 shares of SPY)
- side = OrderSide.Sell: Indicates a sell order for call options
- time_in_force = TimeInForce.DAY: Order remains active until the end of trading day
Need more resources? Watch our video on how to execute covered calls with Alpaca’s Trading API!
Alpaca Example: Implementing a Protective Put Strategy
Implementing protective puts can help shield your portfolio from downside risk. Using Alpaca’s Trading API, you can set up protective puts, or you can get started using Alpaca’s Google Colab notebook.
Key considerations to think about before trading protective puts include:
- Strike Price (Your Safety Net): You may want to pick a strike price just below the current stock level. This acts as your protective floor, limiting how much you can lose if the market takes a dive.
- Watch the Volatility Waves: High volatility typically means bigger risks and bigger swings. Protective puts become essential when the market gets choppy, helping you ride out the storm.
- Choose Your Coverage (Short vs. Long): Need fast, cost-effective protection? It may be better to target a short-term strategy. Want a longer safety cushion? You may want to opt for a longer expiration to stay covered.
We’ll demonstrate this with Tesla (TSLA) based on its stock price on October 25, 2024. The data below is pulled from the “TSLA” options chains on Alpaca Dashboard. Note: We are using Tesla as an example, and it should not be considered investment advice.
Scenario
Let’s say you own 100 shares of TSLA. Due to recent news of a manufacturing issue, you expect that Tesla will have trouble delivering on their production goals, leading to lower earnings and an expected drop in stock price after the Q3 earnings report. To protect against possible losses, you decide to use a protective put strategy.
Therefore, in this scenario, we could choose a strike price of $212.5, which is below the current share price of $217.785. This put option would provide protection if TSLA drops more than 2.4% ((($217.785 - $212.5) / $217.785) * 100) from its current level. Here’s an example of how to set it up using Python:
Note: You want to make sure that you import the necessary packages and set up the environment to run the following work. You can do so by following the code in “1. Setting up the Python Environment” above.
1. Going long on TSLA
We can place an order to buy 100 shares of TSLA through Alpaca's paper trading by running the code below. This limit BUY order will only be executed if the market price of TSLA becomes $217. If you already own 100 shares of TSLA, you can skip this step.
# Place an order to buy SPY stock.
limit_order_data = LimitOrderRequest(symbol="TSLA",
limit_price=275,
qty=100,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY)
limit_order = trade_client.submit_order(order_data=limit_order_data)
2. Buying Put Options
Note: The option details can vary, so change the symbol to match your target options.
# Place an order to buy put options on TSLA.
put_order_data = LimitOrderRequest(symbol="TSLA241025P00212500",
limit_price=5.00,
qty=1,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY)
call_order = trade_client.submit_order(order_data=put_order_data)
Key factors of this protective put (TSLA241025P00212500):
- Underlying Stock: The security we’re trading with (TSLA)
- Expiration Date: October 25, 2024 (241025 in YYMMDD format)
- Call or Put: The “P” denotes that it is a put option
- Strike Price: The price at which you agree to sell your SPY shares if the option is exercised (which in this case is $212.5)
Understanding the order parameters:
- limit_price = 5.00: The maximum price you're willing to pay per contract
- qty = 1: Represents one contract (equivalent to 100 shares of TSLA)
- side = OrderSide.BUY: Indicates a buy order for put options
- time_in_force = TimeInForce.DAY: Order remains active until the end of trading day
Note that we do not have to sell in the protective put process because we're simply adding downside protection to our existing stock position, rather than selling any assets.
Common Risks and Best Practices in Options Trading
Covered calls and protective puts will come with inherent risks, but following best practices can help you manage them effectively.
Managing Risk and Capital
For protective puts, you typically want to monitor premium costs, as they can reduce overall returns. Also, it is a best practice to set clear loss limits and choose strike prices that provide sufficient protection.
With covered calls, be aware of assignment risk—if the stock price exceeds the strike price, you might be forced to sell, capping your gains. Smartly selecting strike prices and expirations can help balance risk and reward.
Avoid Overusing Leverage
Start small. Use manageable positions and slowly increase your exposure as you grow more comfortable. This cautious approach can help you learn and refine your strategies without risking too much capital.
Conclusion and Next Steps
Overall, both covered calls and protective puts are potential strategies for income generation and risk management. Before going live with your strategy, start with paper trading. This can allow you to practice, make adjustments, and build confidence without the potential financial risk. Mastering these basics can prepare you for more advanced options strategies down the line.
Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options before investing in options.
Please note that the content is for informational purposes and is believed to be accurate as of the posting date but may be subject to change. The examples and images above are for illustrative purposes only.
Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.
All investments involve risk and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not assure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.
The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to conduct real transactions in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, "Alpaca") is not authorized to do business.
Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.
This is not an offer, solicitation of an offer, or advice to buy or sell securities or open a brokerage account in any jurisdiction where Alpaca Securities are not registered or licensed, as applicable.