Skip to content

Commit

Permalink
Renames Strangle to Long Strangle
Browse files Browse the repository at this point in the history
Converge to the code of Short Strangle
  • Loading branch information
AlexCatarino committed Jul 26, 2023
1 parent 507205d commit 9425d6b
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<p>The following chart shows the payoff at expiration:</p>
<img class="docs-image" src="https://cdn.quantconnect.com/tutorials/i/Tutorial03-long-straddle.png" alt="Strategy payoff decomposition and analysis of long straddle">

<p>The maximum profit is unlimited if the underlying price rises to infinity at expiration.</p>
<p>The maximum profit is unlimited if the underlying price rises to infinity or substantial, $K^{P} - C^{OTM}_0 - P^{OTM}_0$, if it drops to zero at expiration.</p>
<p>The maximum loss is the net debit paid, $C^{ATM}_0 + P^{ATM}_0$. It occurs when the underlying price is the same at expiration as it was when you opened the trade. In this case, both Options expire worthless.</p>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<p><span class="new-term">Long Strangle</span> is an Options trading strategy that consists of simultaneously buying an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date. This strategy aims to profit from volatile movements in the underlying stock, either positive or negative.</p>
<p>Compared to a <a href='/docs/v2/writing-algorithms/trading-and-orders/option-strategies/straddle'>long straddle</a>, the net debit of a long strangle is lower since OTM Options are cheaper. Additionally, the losing range of a long straddle is wider and the strike spread is wider.</p>
<p>Compared to a <a href='/docs/v2/writing-algorithms/trading-and-orders/option-strategies/long-straddle'>long straddle</a>, the net debit of a long strangle is lower since OTM Options are cheaper. Additionally, the losing range of a long 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 long 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 longStrangle = OptionStrategies.Strangle(_symbol, callStrike, putStrike, expiry);
Buy(longStrangle, 1);</pre>
<pre class="python">long_strangle = OptionStrategies.Strangle(self.symbol, call_strike, put_strike, expiry)
self.Buy(long_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
Expand Up @@ -31,5 +31,4 @@
<img class="docs-image" src="https://cdn.quantconnect.com/tutorials/i/Tutorial04-long-strangle.png" alt="long strangle strategy payoff">

<p>The maximum profit is unlimited if the underlying price rises to infinity at expiration.</p>
<p>The maximum loss is the net debit paid, $C^{OTM}_0 + P^{OTM}_0$. It occurs when the underlying price at expiration is the same as when you opened the trade. In this case, both Options expire worthless.</p>

<p>The maximum loss is the net debit paid, $C^{OTM}_0 + P^{OTM}_0$. It occurs when the underlying price at expiration is the same as when you opened the trade. In this case, both Options expire worthless.</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.80</td><td>835.00</td></tr>
<tr><td>Put</td><td>9.50</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.80-9.50)\times100-2.00\times2\\
&amp; = &amp; -1013
\end{array}
$$<br>

<p>So, the strategy losses $1,013.</p>

<?
$optionStrategyName = "a long straddle";
$pythonBacktestHash = "2803b574abb88853879060ba5224b026" ;
$csharpBacktestHash = "126b5aeb4be7a8bc2e15e10f54ee4894" ;
include(DOCS_RESOURCES."/trading-and-orders/option-strategy-embedded-backtest.php");
?>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "A Long Strangle consists of simultaneously buying an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date.",
"keywords": "Long Strangle Options trading strategy, out-the-money call, out-the-money put, profit from volatile movements in the underlying stock, long straddle, contracts in the strategy legs, Strategy Payoff, maximum profit is unlimited",
"og:description": "A Long Strangle consists of simultaneously buying an OTM put and an OTM call, where both contracts have the same underlying asset and expiration date.",
"og:title": "Strangle - Documentation QuantConnect.com",
"og:title": "Long Strangle - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Strangle - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/trading-and-orders/option-strategies/strangle.png"
"og:site_name": "Long Strangle - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/trading-and-orders/option-strategies/long-strangle.png"
}
}
}

This file was deleted.

This file was deleted.

0 comments on commit 9425d6b

Please sign in to comment.