-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1834e50
commit 507205d
Showing
5 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...orithms/22 Trading and Orders/07 Option Strategies/25 Short Strangle/01 Introduction.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
103 changes: 103 additions & 0 deletions
103
...rithms/22 Trading and Orders/07 Option Strategies/25 Short Strangle/02 Implementation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) -> 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 => contract.Expiry); | ||
var contracts = chain.Where(contract => contract.Expiry == expiry).ToList(); | ||
|
||
// Order the OTM calls by strike to find the nearest to ATM | ||
var callContracts = contracts | ||
.Where(contract => contract.Right == OptionRight.Call && | ||
contract.Strike > chain.Underlying.Price) | ||
.OrderBy(contract => 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 => contract.Right == OptionRight.Put && | ||
contract.Strike < chain.Underlying.Price) | ||
.OrderByDescending(contract => 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) -> 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> |
34 changes: 34 additions & 0 deletions
34
...thms/22 Trading and Orders/07 Option Strategies/25 Short Strangle/03 Strategy Payoff.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 & = & (S_T - K^{C})^{+}\\ | ||
P^{OTM}_T & = & (K^{P} - S_T)^{+}\\ | ||
P_T & = & (-C^{OTM}_T - P^{OTM}_T + C^{OTM}_0 + P^{OTM}_0)\times m - fee | ||
\end{array} | ||
$$ | ||
$$ | ||
\begin{array}{rcll} | ||
\textrm{where} & C^{OTM}_T & = & \textrm{OTM call value at time T}\\ | ||
& P^{OTM}_T & = & \textrm{OTM put value at time T}\\ | ||
& S_T & = & \textrm{Underlying asset price at time T}\\ | ||
& K^{C} & = & \textrm{OTM call strike price}\\ | ||
& K^{P} & = & \textrm{OTM put strike price}\\ | ||
& P_T & = & \textrm{Payout total at time T}\\ | ||
& C^{OTM}_0 & = & \textrm{OTM call value at position opening (debit paid)}\\ | ||
& P^{OTM}_0 & = & \textrm{OTM put value at position opening (debit paid)}\\ | ||
& m & = & \textrm{Contract multiplier}\\ | ||
& T & = & \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> |
52 changes: 52 additions & 0 deletions
52
...ng Algorithms/22 Trading and Orders/07 Option Strategies/25 Short Strangle/99 Example.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 & = & (S_T - K^{C})^{+}\\ | ||
& = & (843.19-835.00)^{+}\\ | ||
& = & 8.19\\ | ||
P^{OTM}_T & = & (K^{P} - S_T)^{+}\\ | ||
& = & (832.50-843.19)^{+}\\ | ||
& = & 0\\ | ||
P_T & = & (-C^{OTM}_T - P^{OTM}_T + C^{OTM}_0 + P^{OTM}_0)\times m - fee\\ | ||
& = & (-8.19-0+8.00+7.40)\times100-2.00\times2\\ | ||
& = & 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"); | ||
?> |
12 changes: 12 additions & 0 deletions
12
...ing Algorithms/22 Trading and Orders/07 Option Strategies/25 Short Strangle/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |