<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Profit diagram &#8211; The Financial Hacker</title>
	<atom:link href="https://financial-hacker.com/tag/profit-diagram/feed/" rel="self" type="application/rss+xml" />
	<link>https://financial-hacker.com</link>
	<description>A new view on algorithmic trading</description>
	<lastBuildDate>Wed, 19 Dec 2018 09:49:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://financial-hacker.com/wp-content/uploads/2017/07/cropped-mask-32x32.jpg</url>
	<title>Profit diagram &#8211; The Financial Hacker</title>
	<link>https://financial-hacker.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Algorithmic Options Trading 2</title>
		<link>https://financial-hacker.com/algorithmic-options-trading-2/</link>
					<comments>https://financial-hacker.com/algorithmic-options-trading-2/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Sat, 17 Jun 2017 23:00:22 +0000</pubDate>
				<category><![CDATA[Introductory]]></category>
		<category><![CDATA[System Development]]></category>
		<category><![CDATA[Binary options]]></category>
		<category><![CDATA[Black-Scholes Formula]]></category>
		<category><![CDATA[Butterfly]]></category>
		<category><![CDATA[Call]]></category>
		<category><![CDATA[Condor]]></category>
		<category><![CDATA[Options]]></category>
		<category><![CDATA[Profit diagram]]></category>
		<category><![CDATA[Put]]></category>
		<category><![CDATA[Strangle]]></category>
		<guid isPermaLink="false">http://www.financial-hacker.com/?p=2298</guid>

					<description><![CDATA[In this second part of the Algorithmic Options trading series we&#8217;ll look more closely into option returns. Especially into combining different option types for getting user-tailored profit and risk curves. Option traders know combinations with funny names like &#8220;Iron Condor&#8221; or &#8220;Butterfly&#8221;, but you&#8217;re not limited to them. With some tricks you can create artificial &#8230; <a href="https://financial-hacker.com/algorithmic-options-trading-2/" class="more-link">Continue reading<span class="screen-reader-text"> "Algorithmic Options Trading 2"</span></a>]]></description>
										<content:encoded><![CDATA[<p>In this second part of the <a href="http://www.financial-hacker.com/algorithmic-options-trading/">Algorithmic Options trading</a> series we&#8217;ll look more closely into option returns. Especially into combining different option types for getting user-tailored profit and risk curves. Option traders know combinations with funny names like &#8220;Iron Condor&#8221; or &#8220;Butterfly&#8221;, but you&#8217;re not limited to them. With some tricks you can create artificial financial instruments of any desired property &#8211; for instance &#8220;<a href="http://www.financial-hacker.com/binary-options-scam-or-opportunity/" target="_blank" rel="noopener">Binary Options</a>&#8221; with more than 100% payout factor.<span id="more-2298"></span></p>
<p>The <strong>profit diagram</strong> of an option is its profit or loss at or before expiration in dependence of the price of the underlying. Let&#8217;s assume that we know that the price of a certain asset will rise in the next months. So we buy a call option on that asset. Our profit diagram then looks like this:</p>
<figure id="attachment_2488" aria-describedby="caption-attachment-2488" style="width: 423px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s.png"><img fetchpriority="high" decoding="async" class="wp-image-2488" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s-768x466.png 768w" sizes="(max-width: 423px) 85vw, 423px" /></a><figcaption id="caption-attachment-2488" class="wp-caption-text">AAPL call at strike 144</figcaption></figure>
<p>This is the potential return when buying a current (June 2017) AAPL call option with 4 months expiration time. We have to pay $668 premium for that option. The current AAPL price is $144, and that&#8217;s also our strike price. The blue line is our profit or loss, dependent on the AAPL price at expiration. The option will expire out of the money when AAPL stays below $144, so we&#8217;ll then lose the premium. We&#8217;ll still lose a part of the premium if the option expires only slightly in the money. The break even point is at about $151. And if AAPL floats even higher at expiration time, we can collect huge profits of a multiple of the premium. So buying a call option means an unlimited profit chance at a limited risk. You can not lose more than the premium.</p>
<p>The green line in the diagram is the theoretical option value after 2 months, at half the expiration time. It is approximated with a finite difference method or calculated with the Black-Scholes formula, dependent on option type. The real option price is normally close to that theoretical value. So we can see that we could already sell the option with a profit after two months when the AAPL price is then above $148.</p>
<p>By the way, this option profit diagram resembles the response function of a Rectified Linear Unit in a <a href="http://www.financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/" target="_blank" rel="noopener">neural network</a>. So we can speculate that when a billion option traders permanently sell and buy large numbers of options, when the underlying price depends on option demand, and when profits are always reinvested in new options, the option market becomes a huge neural net. Some day artificial intelligence might emerge and the options start buying and selling themselves&#8230;</p>
<h3>Option combos</h3>
<p>Now let&#8217;s assume we know for sure that the AAPL price will move in the next time, but we do not know if it will rise or fall. For making profit in both cases, we just buy a call and a put option, both with the strike at the current price of $144:</p>
<figure id="attachment_2490" aria-describedby="caption-attachment-2490" style="width: 423px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s3.png"><img decoding="async" class="wp-image-2490" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s3.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s3.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s3-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s3-768x466.png 768w" sizes="(max-width: 423px) 85vw, 423px" /></a><figcaption id="caption-attachment-2490" class="wp-caption-text">1 call at 144 + 1 put at 144</figcaption></figure>
<p>We can see that a call and a put option with the same parameters don&#8217;t cancel out each other! The resulting profit diagram is just the sum of the profit diagrams of the single options. For both options we have to pay a $1310 total premium. If the AAPL price stays inside the $131 &#8211; $157 range, we lose. If it ends up outside this range, we win. If it ends up outside by a wide margin, we win big.</p>
<p>Now suppose we think an asset won&#8217;t be very volatile in the next time and its price will stay inside a range. We&#8217;ll then sell the two options instead of buying them. Selling instead of buying just turns the above profit diagram upside down. And we can already see the problem with that: The profit is now limited and the risk unlimited.</p>
<p>For fixing this, we need to add some more options to the combination:</p>
<figure id="attachment_2493" aria-describedby="caption-attachment-2493" style="width: 423px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s4.png"><img decoding="async" class="wp-image-2493" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s4.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s4.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s4-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s4-768x466.png 768w" sizes="(max-width: 423px) 85vw, 423px" /></a><figcaption id="caption-attachment-2493" class="wp-caption-text">1 call at 139 + 1 call at 149 &#8211; 2 calls at 144</figcaption></figure>
<p>For this profit diagram we&#8217;ve used 4 options. We bought one call at a strike $5 below the current price, another call at a strike $5 above the current price, and we sold short two calls with the strike at the current price. For the two long options we paid $1400 premium, and for the two short options we got $1340. This leaves us with $60 total premium cost, and a chance of up to $440 profit when the price stays inside the $140 &#8211; $148 range. This option combo, for whatever reason, got the name &#8220;Long Butterfly&#8221; by option traders.</p>
<p>By the way, you can see from this butterfly that you can really produce any profit diagram with a suited combination of options. The position of the butterfly peak is determined by the strike prices, its width by their distance, its height by the number of options. This way, many different butterfly peaks can be theoretically put together to a profit diagram of any shape. Unfortunately, you cannot just as freely determine its vertical position &#8211; a part of the diagram will be always below the zero line&#8230;</p>
<h3>The code</h3>
<p>Here&#8217;s a small C script (for <a href="http://www.financial-hacker.com/hackers-tools-zorro-and-r/" target="_blank" rel="noopener">Zorro</a>) for experiments with all sorts of option combinations:</p>
<pre class="prettyprint">#include &lt;contract.c&gt;
void optionAdd(int Num,int Type,var StrikeOffs);

#define ASSET     "AAPL"
#define EXPIRY	  120	// 4 months
#define BUY	(1&lt;&lt;10)
#define SELL	(1&lt;&lt;11)

void combo() // "Butterfly"
{
	optionAdd(1,BUY|CALL,-5);  
	optionAdd(2,SELL|CALL,0);
	optionAdd(1,BUY|CALL,5);
}

//////////////////////////////////////////////////
#define POINTS 100 
var OptionGains[POINTS],OptionVals50[POINTS];
var UnderL,HistVol;

void optionPlot(int Num,CONTRACT* C,var Premium,var RangeMin,var RangeMax) 
{
	PlotScale = 10;
	var Step = (RangeMax-RangeMin)/POINTS;
	Step = round(Step+0.5,1); // round up
	RangeMin = round(RangeMin,1);

	int i;
	for(i=0; i&lt;POINTS; i++)
	{
		if(Num == 0) {
			OptionGains[i] = OptionVals50[i] = 0;
		} else {
			var Price = RangeMin + i*Step;
			if(Price &gt; RangeMax) break;
			var Gain = 0;
			var Strike = C-&gt;fStrike; 
			var Val50 = contractVal(C,Price,HistVol,0,0);
			switch(C-&gt;Type&amp;(BUY|SELL|CALL|PUT)) {
				case BUY|CALL: 
					if(Price &gt; Strike) Gain = Price - Strike;
					Gain -= Premium;
					Val50 -= Premium;
					break;
				case BUY|PUT: 
					if(Price &lt; Strike) Gain = Strike - Price;
					Gain -= Premium;
					Val50 -= Premium;
					break;
				case SELL|CALL: 
					if(Price &gt; Strike) Gain = Strike - Price;
					Gain += Premium;
					Val50 = Premium - Val50;
					break;
				case SELL|PUT: 
					if(Price &lt; Strike) Gain = Price - Strike;
					Gain += Premium;
					Val50 = Premium - Val50;
					break;
			}
			OptionGains[i] += Multiplier*Num*Gain;
			OptionVals50[i] += Multiplier*Num*Val50;
			plotBar("Zero",i,0,0,LINE,BLACK);
			plotBar("ValueAt50%",i,Price,OptionVals50[i],LINE|LBL2,GREEN);
			plotBar("ValueAtExpiry",i,Price,OptionGains[i],LINE|LBL2,BLUE);
		}
	}
}

void optionAdd(int Num,int Type,var StrikeOffs)
{
	CONTRACT C;
	C.Type = Type;
	C.Expiry = EXPIRY;
	C.fStrike = round(UnderL+StrikeOffs,1);
	var Premium = contractVal(&amp;C,UnderL,HistVol,0,0);
	C.Expiry = EXPIRY*0.5; // for the value at 50% expiration 
	optionPlot(Num,&amp;C,Premium,0.8*UnderL,1.2*UnderL);
}

void run() 
{
	BarPeriod = 1440;
	StartDate = NOW;
	set(PRELOAD);
	if(is(INITRUN)) {
		initRQL();
		assetAdd(ASSET);
		assetHistory(ASSET,FROM_GOOGLE);
		asset(ASSET);
	}
	vars Close = series(priceClose());
	HistVol = Volatility(Close,20);
	UnderL = Close[0];
	Multiplier = 100;

	if(!is(LOOKBACK)) 
	{
		optionAdd(0,0,0); // reset the graphs
		combo();
		quit("Ok!");
	}
}</pre>
<p>This script plots the above diagrams. The core of the script is the <strong>combo()</strong> function at the begin. It contains one or several <strong>optionAdd</strong> calls that get as parameters the number of options, the type (BUY, SELL, CALL, PUT, EUROPEAN, BINARY), and the strike difference to the current price. In the example above you can see the combination for the long butterfly. The asset and expiration can be set up in the <strong>#define</strong> lines above. The script downloads the current asset prices from Google and calculates the volatility that is needed for getting the options values and premiums. For running it you need Zorro, R, and the <strong>RQuantLib</strong> package from <a href="https://cran.r-project.org/bin/windows/contrib/3.3/RQuantLib_0.4.2.zip" target="_blank" rel="noopener">https://cran.r-project.org/bin/windows/contrib/3.3/RQuantLib_0.4.2.zip</a>.</p>
<p>Some more examples of popular option combos:</p>
<pre class="prettyprint">// Call Spread
void combo()
{
	optionAdd(1, BUY|CALL, -5);
	optionAdd(1, SELL|CALL, 5);
}</pre>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s5.png"><img loading="lazy" decoding="async" class="alignnone wp-image-2502" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s5.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s5.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s5-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s5-768x466.png 768w" sizes="auto, (max-width: 423px) 85vw, 423px" /></a></p>
<pre class="prettyprint">// Put Spread
void combo()
{
	optionAdd(1, BUY|PUT, 5);
	optionAdd(1, SELL|PUT, -5);
}</pre>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s6.png"><img loading="lazy" decoding="async" class="alignnone wp-image-2503" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s6.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s6.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s6-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s6-768x466.png 768w" sizes="auto, (max-width: 423px) 85vw, 423px" /></a></p>
<p>Call or Put Spreads limit our risk as well as our profit to a fixed amount. The steepness of the center slope can be controlled with the strike difference. We can see from the diagrams that Spreads are (almost) equivalent to <a href="http://www.financial-hacker.com/binary-options-scam-or-opportunity/" target="_blank" rel="noopener">binary options</a> &#8211; but with a much better payout factor. The diagrams are not completely symmetrical, and the Call Spread above has $514 potential profit and $486 potential loss &#8211; equivalent to a binary option with 105% payout. If the asset has the same likeliness of going up and going down, a Call Spread gives us a statistical advantage similar to the seller&#8217;s advantage of single options. With a Put Spread it&#8217;s the other way around.</p>
<p>The green line shows us whether it makes sense to sell the combo prematurely. Suppose we learned that the new iPhone tends to sudden explosions, and opened an AAPL Put Spread. When the AAPL price goes down and falls below $120 after 2 months, it makes no sense to wait until expiration, since the green line at 120 has almost the same value than the blue line. Only problem is that selling reduces our profit by the bid/ask spread and commission. An option expiration has no bid/ask spread and, if out of the money, also no commission.</p>
<p>Some more combos:</p>
<pre class="prettyprint">// Strangle
void combo()
{
	optionAdd(1, BUY|CALL, 5);
	optionAdd(1, BUY|PUT, -5);
}</pre>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s7.png"><img loading="lazy" decoding="async" class="alignnone wp-image-2511" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s7.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s7.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s7-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s7-768x466.png 768w" sizes="auto, (max-width: 423px) 85vw, 423px" /></a></p>
<pre class="prettyprint">// Condor
void combo()
{
	optionAdd(1, BUY|CALL, -10);
	optionAdd(1, SELL|CALL, -5);
	optionAdd(1, SELL|CALL, 5);
	optionAdd(1, BUY|CALL, 10);
}</pre>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s8.png"><img loading="lazy" decoding="async" class="alignnone wp-image-2514" src="http://www.financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s8.png" alt="" width="423" height="257" srcset="https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s8.png 846w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s8-300x182.png 300w, https://financial-hacker.com/wp-content/uploads/2018/01/OptionsCurve_AAPL_s8-768x466.png 768w" sizes="auto, (max-width: 423px) 85vw, 423px" /></a></p>
<p>Combos that involve both selling and buying options &#8211; such as Spreads, Condors, or Butterflys &#8211; are especially attractive. Their investment is only the difference of the premiums, and the broker&#8217;s margin requirement is also accordingly smaller due to the limited risk. This allows trading with small capital and high leverage.</p>
<h3>Get rich quick</h3>
<p>Here&#8217;s my today&#8217;s get-rich-quick tip, this time for brokers. The problem with options is that you often need to wait weeks, months, or years until they finally expire and you can book your profit. Dear brokers, how about opening a market for <strong>short-term options</strong>? Options that expire at the end of each trading day, with strike prices in steps of cents, not dollars? Those options would be a very interesting instrument especially for short-term algorithmic trading. They would become very popular and produce a lot of commissions. Of course, 10% of those commissions are mine. I just patented this concept. Contact me for license conditions.</p>
<h3>Conclusion</h3>
<ul style="list-style-type: square;">
<li>Options can be clever combined for reducing the investment, limiting the risk, increasing the leverage, and generating profit diagrams of any shape.</li>
<li>Depending on premiums, profit diagrams are often not perfectly symmetrical. This results in a statistial advantage (or disadvantage) of option combos with nondirectional assets.</li>
</ul>
<p>I&#8217;ve included the <strong>OptionsCurve</strong> script in the 2017 script repository. Since price data download from Google rather than <a href="http://www.financial-hacker.com/bye-yahoo-and-thank-you-for-the-fish/" target="_blank" rel="noopener">Yahoo</a> was only recently implemented, you&#8217;ll need Zorro 1.59 or above. You&#8217;ll also need R and the RQuantLib package. In the final article of this series we&#8217;ll test a real options trading strategy.</p>
<p style="text-align: right;"><a href="http://www.financial-hacker.com/algorithmic-options-trading-part-3/">Options Trading, Part 3</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/algorithmic-options-trading-2/feed/</wfw:commentRss>
			<slash:comments>32</slash:comments>
		
		
			</item>
	</channel>
</rss>
