Skip to content

Commit

Permalink
Adds Short Strangle Strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCatarino committed Jul 26, 2023
1 parent 1834e50 commit 507205d
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p><span class="new-term">Short Strangle</span> is an Options trading strategy that consists of simultaneously selling an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date. By doing so, the trader is essentially betting that the underlying asset will remain relatively stable and not experience significant price movements before the Options' expiration.</p>
<p>Compared to a <a href='/docs/v2/writing-algorithms/trading-and-orders/option-strategies/short-straddle'>short straddle</a>, the net debit of a short strangle is lower since OTM Options are cheaper. Additionally, the winning range of a short straddle is wider and the strike spread is wider.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<p>Follow these steps to implement the short strangle strategy:</p>

<ol>
<li>In the <code>Initialize</code> method, set the start date, end date, cash, and <a href="/docs/v2/writing-algorithms/universes/equity-options">Option universe</a>.</li>
<div class="section-example-container">
<pre class="csharp">private Symbol _symbol;

public override void Initialize()
{
SetStartDate(2017, 4, 1);
SetEndDate(2017, 4, 30);
SetCash(100000);

var option = AddOption("GOOG");
_symbol = option.Symbol;
option.SetFilter(-5, 5, 0, 30);
}</pre>
<pre class="python">def Initialize(self) -&gt; None:
self.SetStartDate(2017, 4, 1)
self.SetEndDate(2017, 4, 30)
self.SetCash(100000)

option = self.AddOption("GOOG")
self.symbol = option.Symbol
option.SetFilter(-5, 5, 0, 30)</pre>
</div>

<li>In the <code>OnData</code> method, select the expiration date and strike prices of the contracts in the strategy legs.</li>
<div class="section-example-container">
<pre class="csharp">public override void OnData(Slice slice)
{
if (Portfolio.Invested ||
!slice.OptionChains.TryGetValue(_symbol, out var chain))
{
return;
}

// Find options with the farthest expiry
var expiry = chain.Max(contract =&gt; contract.Expiry);
var contracts = chain.Where(contract =&gt; contract.Expiry == expiry).ToList();

// Order the OTM calls by strike to find the nearest to ATM
var callContracts = contracts
.Where(contract =&gt; contract.Right == OptionRight.Call &amp;&amp;
contract.Strike &gt; chain.Underlying.Price)
.OrderBy(contract =&gt; contract.Strike).ToArray();
if (callContracts.Length == 0) return;

// Order the OTM puts by strike to find the nearest to ATM
var putContracts = contracts
.Where(contract =&gt; contract.Right == OptionRight.Put &amp;&amp;
contract.Strike &lt; chain.Underlying.Price)
.OrderByDescending(contract =&gt; contract.Strike).ToArray();
if (putContracts.Length == 0) return;

var callStrike = callContracts[0].Strike;
var putStrike = putContracts[0].Strike;
}</pre>
<pre class="python">def OnData(self, slice: Slice) -&gt; None:
if self.Portfolio.Invested:
return

chain = slice.OptionChains.get(self.symbol)
if not chain:
return

# Find options with the farthest expiry
expiry = max([x.Expiry for x in chain])
contracts = [contract for contract in chain if contract.Expiry == expiry]

# Order the OTM calls by strike to find the nearest to ATM
call_contracts = sorted([contract for contract in contracts
if contract.Right == OptionRight.Call and
contract.Strike > chain.Underlying.Price],
key=lambda x: x.Strike)
if not call_contracts:
return

# Order the OTM puts by strike to find the nearest to ATM
put_contracts = sorted([contract for contract in contracts
if contract.Right == OptionRight.Put and
contract.Strike < chain.Underlying.Price],
key=lambda x: x.Strike, reverse=True)
if not put_contracts:
return

call_strike = call_contracts[0].Strike
put_strike = put_contracts[0].Strike</pre>
</div>

<li>In the <code>OnData</code> method, call the <code>OptionStrategies.Strangle</code> method and then submit the order.</li>
<div class="section-example-container">
<pre class="csharp">var shortStrangle = OptionStrategies.ShortStrangle(_symbol, callStrike, putStrike, expiry);
Buy(shortStrangle, 1);</pre>
<pre class="python">short_strangle = OptionStrategies.ShortStrangle(self.symbol, call_strike, put_strike, expiry)
self.Buy(short_strangle, 1)</pre>
</div>

<?
$methodNames = array("Buy");
include(DOCS_RESOURCES."/trading-and-orders/option-strategy-extra-args.php");
?>
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<p>The payoff of the strategy is</p>
$$
\begin{array}{rcll}
C^{OTM}_T &amp; = &amp; (S_T - K^{C})^{+}\\
P^{OTM}_T &amp; = &amp; (K^{P} - S_T)^{+}\\
P_T &amp; = &amp; (-C^{OTM}_T - P^{OTM}_T + C^{OTM}_0 + P^{OTM}_0)\times m - fee
\end{array}
$$
$$
\begin{array}{rcll}
\textrm{where} &amp; C^{OTM}_T &amp; = &amp; \textrm{OTM call value at time T}\\
&amp; P^{OTM}_T &amp; = &amp; \textrm{OTM put value at time T}\\
&amp; S_T &amp; = &amp; \textrm{Underlying asset price at time T}\\
&amp; K^{C} &amp; = &amp; \textrm{OTM call strike price}\\
&amp; K^{P} &amp; = &amp; \textrm{OTM put strike price}\\
&amp; P_T &amp; = &amp; \textrm{Payout total at time T}\\
&amp; C^{OTM}_0 &amp; = &amp; \textrm{OTM call value at position opening (debit paid)}\\
&amp; P^{OTM}_0 &amp; = &amp; \textrm{OTM put value at position opening (debit paid)}\\
&amp; m &amp; = &amp; \textrm{Contract multiplier}\\
&amp; T &amp; = &amp; \textrm{Time of expiration}
\end{array}
$$
<br>
<p>The following chart shows the payoff at expiration:</p>
<!--img class="docs-image" src="https://cdn.quantconnect.com/tutorials/i/Tutorial04-short-strangle.png" alt="short strangle strategy payoff"-->

<p>The maximum profit $C^{OTM}_0 + P^{OTM}_0$. It occurs when the underlying price at expiration remains within the range of the strike prices. In this case, both Options expire worthless.</p>
<p>The maximum loss is unlimited if the underlying price rises to infinity or substantial, $C^{OTM}_0 + P^{OTM}_0 - K^{P}$, if it drops to zero at expiration.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<p>The following table shows the price details of the assets in the algorithm at Option expiration (2017-04-22):</p>

<table class="table qc-table" id="payoff-table">
<thead>
<tr><th>Asset</th><th>Price ($)</th><th>Strike ($)</th></tr>
</thead>
<tbody>
<tr><td>Call</td><td>8.00</td><td>835.00</td></tr>
<tr><td>Put</td><td>7.40</td><td>832.50</td></tr>
<tr><td>Underlying Equity at expiration</td><td>843.19</td><td>-</td></tr>
</tbody>
</table>

<style>
#payoff-table td:nth-child(2),
#payoff-table th:nth-child(2),
#payoff-table td:nth-child(3),
#payoff-table th:nth-child(3) {
text-align: right;
}
</style>

<p>Therefore, the payoff is</p>

$$
\begin{array}{rcll}
C^{OTM}_T &amp; = &amp; (S_T - K^{C})^{+}\\
&amp; = &amp; (843.19-835.00)^{+}\\
&amp; = &amp; 8.19\\
P^{OTM}_T &amp; = &amp; (K^{P} - S_T)^{+}\\
&amp; = &amp; (832.50-843.19)^{+}\\
&amp; = &amp; 0\\
P_T &amp; = &amp; (-C^{OTM}_T - P^{OTM}_T + C^{OTM}_0 + P^{OTM}_0)\times m - fee\\
&amp; = &amp; (-8.19-0+8.00+7.40)\times100-2.00\times2\\
&amp; = &amp; 719
\end{array}
$$<br>

<p>So, the strategy gains $719.</p>

<?
$optionStrategyName = "a short straddle";
$pythonBacktestHash = "dbae86c4e62f2be4b1d7b03230253526" ;
$csharpBacktestHash = "50ec754950edc4d94d0b441d86540989" ;
include(DOCS_RESOURCES."/trading-and-orders/option-strategy-embedded-backtest.php");
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "metadata",
"values": {
"description": "A Short Strangle is an Options trading strategy that consists of simultaneously selling an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date.",
"keywords": "Short Strangle Options trading strategy, out-the-money call, out-the-money put, profit from stable and not experience significant movements in the underlying stock, short straddle, contracts in the strategy legs, Strategy Payoff, maximum loss is unlimited",
"og:description": "A Short Strangle is an Options trading strategy that consists of simultaneously selling an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date.",
"og:title": "Short Strangle - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Short Strangle - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/trading-and-orders/option-strategies/short-strangle.png"
}
}

0 comments on commit 507205d

Please sign in to comment.