-
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
1a5622a
commit a8a5356
Showing
5 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...g Algorithms/22 Trading and Orders/07 Option Strategies/18 Naked Put/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 @@ | ||
<p>A <span class="new-term">Naked Put</span>, also known as an <span class="new-term">uncovered put</span>, involves the sale of put Options without having a corresponding short position in the underlying security. It is called "naked" because the seller does not have any cover or protection in the form of a short position in the underlying asset, which exposes them to potentially unlimited risk. Naked puts aim to profit from the Option premium by selling puts. At any time for American Options or at expiration for European Options, if the stock moves above the strike price, you keep the premium. If the underlying price moves below the strike, the Option buyer can <a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/option-exercise-orders'>exercise the Options contract</a>, which means you need sell the underlying at market price to fulfill your obligation to buy it at the strike price and keep the premium.</p> |
80 changes: 80 additions & 0 deletions
80
... Algorithms/22 Trading and Orders/07 Option Strategies/18 Naked Put/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,80 @@ | ||
<p>Follow these steps to implement the naked put strategy:</p> | ||
|
||
<ol> | ||
<li>In the <code>Initialize</code> method, set the start date, end date, starting cash, and <a href="/docs/v2/writing-algorithms/universes/equity-options">Options universe</a>.</li> | ||
<div class="section-example-container"> | ||
<pre class="csharp">private Symbol _put, _symbol; | ||
|
||
public override void Initialize() | ||
{ | ||
SetStartDate(2014, 1, 1); | ||
SetEndDate(2014, 3, 1); | ||
SetCash(100000); | ||
|
||
var option = AddOption("IBM"); | ||
_symbol = option.Symbol; | ||
option.SetFilter(-3, 3, 0, 31); | ||
}</pre> | ||
<pre class="python">def Initialize(self) -> None: | ||
self.SetStartDate(2014, 1, 1) | ||
self.SetEndDate(2014, 3, 1) | ||
self.SetCash(100000) | ||
|
||
option = self.AddOption("IBM") | ||
self.symbol = option.Symbol | ||
self.put = None | ||
|
||
option.SetFilter(-3, 3, 0, 31)</pre> | ||
</div> | ||
|
||
<li>In the <code>OnData</code> method, select the Option contract.</li> | ||
<div class="section-example-container"> | ||
<pre class="csharp">public override void OnData(Slice slice) | ||
{ | ||
if (_put != null && Portfolio[_put].Invested) return; | ||
|
||
if (!slice.OptionChains.TryGetValue(_symbol, out var chain)) return; | ||
|
||
// Find ATM put with the farthest expiry | ||
var expiry = chain.Max(x => x.Expiry); | ||
var atmCall = chain | ||
.Where(x => x.Right == OptionRight.Call && x.Expiry == expiry) | ||
.OrderBy(x => Math.Abs(x.Strike - chain.Underlying.Price)) | ||
.FirstOrDefault();</pre> | ||
<pre class="python">def OnData(self, slice: Slice) -> None: | ||
if self.put and self.Portfolio[self.put].Invested: | ||
return | ||
|
||
chain = slice.OptionChains.get(self.symbol) | ||
if not chain: | ||
return | ||
|
||
# Find ATM put with the farthest expiry | ||
expiry = max([x.Expiry for x in chain]) | ||
put_contracts = sorted([x for x in chain | ||
if x.Right == OptionRight.Call and x.Expiry == expiry], | ||
key=lambda x: abs(chain.Underlying.Price - x.Strike)) | ||
|
||
if not put_contracts: | ||
return | ||
|
||
atm_put = put_contracts[0]</pre> | ||
</div> | ||
|
||
<li>In the <code>OnData</code> method, call the <code>OptionStrategies.NakedPut</code> method and then submit the order.</li> | ||
<div class="section-example-container"> | ||
<pre class="csharp">var nakedCall = OptionStrategies.NakedPut(_symbol, atmCall.Strike, expiry); | ||
Buy(nakedCall, 1); | ||
|
||
_put = atmCall.Symbol;</pre> | ||
<pre class="python">naked_put = OptionStrategies.NakedPut(self.symbol, atm_put.Strike, expiry) | ||
self.Buy(naked_put, 1) | ||
|
||
self.put = atm_put.Symbol</pre> | ||
</div> | ||
|
||
<? | ||
$methodNames = array("Buy"); | ||
include(DOCS_RESOURCES."/trading-and-orders/option-strategy-extra-args.php"); | ||
?> | ||
</ol> |
30 changes: 30 additions & 0 deletions
30
...lgorithms/22 Trading and Orders/07 Option Strategies/18 Naked Put/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,30 @@ | ||
<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} | ||
P^{K}_T & = & (K - S_T)^{+}\\ | ||
P_T & = & (P^{K}_0 - P^{K}_T)\times m - fee | ||
\end{array} | ||
$$ | ||
$$ | ||
\begin{array}{rcll} | ||
\textrm{where} & P^{K}_T & = & \textrm{Put value at time T}\\ | ||
& S_T & = & \textrm{Underlying asset price at time T}\\ | ||
& K & = & \textrm{Put strike price}\\ | ||
& P_T & = & \textrm{Payout total at time T}\\ | ||
& P^{K}_0 & = & \textrm{Put price when the trade opened (credit received)}\\ | ||
& 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/Tutorial01-naked-put.png" alt="naked put strategy payoff"--> | ||
<p>The maximum profit is $P^{K}_0$, which occurs when the underlying price is at or above the strike price of the put at expiration.</p> | ||
<p>The maximum loss is $K - P^{K}_0$ which ocurrs when the underlying price drops to zero.</p> | ||
<p>If the Option is American Option, there is risk of early assignment on the sold contract.</p> |
47 changes: 47 additions & 0 deletions
47
03 Writing Algorithms/22 Trading and Orders/07 Option Strategies/18 Naked Put/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,47 @@ | ||
<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:</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>Put</td><td>1.37</td><td>185.00</td></tr> | ||
<tr><td>Underlying Equity at expiration</td><td>190.01</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} | ||
P^{K}_T & = & (K - S_T)^{+}\\ | ||
& = & (185 - 190.01)^{+}\\ | ||
& = & 0.0\\ | ||
P_T & = & (P^{K}_0 - P^{K}_T)\times m - fee\\ | ||
& = & (1.37 - 0.0)\times m - fee\\ | ||
& = & 1.37 \times 100 - 1\\ | ||
& = & 136 | ||
\end{array} | ||
$$ | ||
<br> | ||
<p>So, the strategy gains $136.</p> | ||
|
||
<? | ||
$optionStrategyName = "a naked put"; | ||
$pythonBacktestHash = "f81ecd25b7db05a4174cfdea6277a46b" ; | ||
$csharpBacktestHash = "e3654011cfc55607efdb6cabba7bb2ef" ; | ||
include(DOCS_RESOURCES."/trading-and-orders/option-strategy-embedded-backtest.php"); | ||
?> |
12 changes: 12 additions & 0 deletions
12
03 Writing Algorithms/22 Trading and Orders/07 Option Strategies/18 Naked Put/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 Naked Put, also known as an uncovered put, involves the sale of put Options without having a corresponding short position in the underlying security.", | ||
"keywords": "naked put, profit from the Option premium, Strategy Payoff, risk of early assignment, option strategy", | ||
"og:description": "A Naked Put, also known as an uncovered put, involves the sale of put Options without having a corresponding short position in the underlying security.", | ||
"og:title": "Naked Put - Documentation QuantConnect.com", | ||
"og:type": "website", | ||
"og:site_name": "Naked Put - QuantConnect.com", | ||
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/trading-and-orders/option-strategies/naked-put.png" | ||
} | ||
} |