{"id":20345,"date":"2024-01-12T16:05:43","date_gmt":"2024-01-12T08:05:43","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=20345"},"modified":"2024-07-09T09:52:45","modified_gmt":"2024-07-09T01:52:45","slug":"loss-aversion-strategy","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/","title":{"rendered":"TQuant Lab Loss Aversion Strategy \u2014 Average True Range"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-large caption-align-center\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-1024x576.jpg\" alt=\"Loss Aversion Strategy\" class=\"wp-image-19891\" style=\"aspect-ratio:1.5;object-fit:cover\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-1024x576.jpg 1024w, https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-300x169.jpg 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-150x84.jpg 150w, https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-768x432.jpg 768w, https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881-1536x864.jpg 1536w, https:\/\/www.tejwin.com\/wp-content\/uploads\/PIMCO_Behavioral_Insights_Faller_Dec2018_Twitter_1600x900_61881.jpg 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/photos\/wdBqEHzo39g?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" class=\"ek-link\" target=\"_blank\" rel=\"noopener\">PIMCO<\/a><\/figcaption><\/figure>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f10f7f654f8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69f10f7f654f8\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Highlight\" >Highlight<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Preface\" >Preface<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Loss_Aversion_Strategy_Using_Bollinger_Bands_ATR\" >Loss Aversion Strategy Using Bollinger Bands &amp; ATR<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#The_Editing_Environment_and_Module_Required\" >The Editing Environment and Module Required<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Data_Import\" >Data Import<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Construct_the_Loss_Aversion_Strategy_by_TQuant_Lab\" >Construct the Loss Aversion Strategy by TQuant Lab<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Execute_the_Trading_Strategy\" >Execute the Trading Strategy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Performance_Evaluation_Using_Pyfolio\" >Performance Evaluation Using Pyfolio<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Draw_a_Sharpe_Ratio_Comparison_Chart\" >Draw a Sharpe Ratio Comparison Chart<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Compare_the_Top_5_Trading_Drawdown_Periods\" >Compare the Top 5 Trading Drawdown Periods<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Source_Code\" >Source Code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.tejwin.com\/en\/insight\/loss-aversion-strategy\/#Extended_Reading\" >Extended Reading<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Highlight\"><\/span>Highlight<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Article Difficulty: \u2605\u2605\u2606\u2606\u2606<\/li>\n\n\n\n<li>Using the Average True Range (ATR) indicator to determine stop-loss points for loss aversion purpose.<\/li>\n\n\n\n<li>This Article is adapted from <a href=\"https:\/\/www.tejwin.com\/en\/insight\/how-to-avoid-common-mistakes-during-trading-loss-avoidance\/\" class=\"ek-link\">How to Avoid Common Mistakes During Trading &#8211; Loss Avoidance<\/a>, using the TQuant Lab backtesting platform to develop trading strategies and backtest risks and performance.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Preface\"><\/span>Preface<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Average True Range (ATR), an indicator developed by J. Welles Wilder, is designed to assess the extent of price fluctuations within a specific period. ATR is commonly utilized as a tool in technical analysis, assisting traders in understanding the volatility of a particular asset and subsequently determining entry points, exit points, and stop-loss levels for loss aversion purpose.<\/p>\n\n\n\n<p>When the ATR value is high, it indicates that the asset&#8217;s price is experiencing more significant fluctuations. Conversely, when the ATR value is low, it signifies that the asset&#8217;s price is relatively stable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Loss_Aversion_Strategy_Using_Bollinger_Bands_ATR\"><\/span>Loss Aversion Strategy Using Bollinger Bands &amp; ATR<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the closing price falls below the lower Bollinger Band and there is sufficient cash reserves, buy 1000 shares the next day.<\/li>\n\n\n\n<li>If the closing price surpasses the upper Bollinger Band and there is an existing position, liquidate the position the next day.<\/li>\n\n\n\n<li>If the closing price falls below the lower Bollinger Band, and there is enough cash, and the closing price has not fallen below the stop-loss point, add 1000 shares the next day.<\/li>\n\n\n\n<li>If the closing price falls below the stop-loss point and there is an existing position, liquidate the position the next day.<br><br>\u203b Stop-loss Point Calculation: Closing price of the day &#8211; k \u00d7 ATR (The value of k depends on the volatility of the stock; if the volatility is higher, a larger k value can be set, and vice versa.)<\/li>\n<\/ul>\n\n\n\n<p>This article will use the &#8220;Bollinger Bands &amp; ATR Loss Aversion Strategy&#8221; as the experimental group and the commonly used &#8220;<a href=\"https:\/\/www.tejwin.com\/en\/insight\/tquant-lab-bollinger-bands-trading-strategy\/\" class=\"ek-link\">Bollinger Bands<\/a>&#8221; strategy as the control group. The objective is to observe whether the experimental group employing the loss aversion strategy can perform better.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Editing_Environment_and_Module_Required\"><\/span>The Editing Environment and Module Required<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This article is written using Windows 11 and Jupyter Lab as the editor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport tejapi\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Data_Import\"><\/span>Data Import<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The backtesting time period is between 2022\u201301\u201301 to 2023\u201301\u201301, and we take<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\"> TSMC(2330)<\/mark> as an example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># set tej_key and base\ntej_key = 'Your Key'\napi_base = 'https:\/\/api.tej.com.tw'\n\nos.environ&#91;'TEJAPI_KEY'] = tej_key\nos.environ&#91;'TEJAPI_BASE'] = api_base\n\n# set date\nstart = '2022-01-01'\nend = '2023-01-01'\n\nos.environ&#91;'mdate'] = start + ' ' + end\nos.environ&#91;'ticker'] = '2330'\n\n!zipline ingest -b tquant<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Construct_the_Loss_Aversion_Strategy_by_TQuant_Lab\"><\/span>Construct the Loss Aversion Strategy by TQuant Lab<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>From the pipeline and zipline function provided in TQuant Lab, we can: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Calculate the ATR and upper, middle &amp; lower Bollinger Bands.<\/li>\n\n\n\n<li>Add liquidity slippage, transaction fees, and set the return of buying and holding TSMC(2330) as the benchmark.<\/li>\n\n\n\n<li>Set the trading strategy and record the transaction details.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Execute_the_Trading_Strategy\"><\/span>Execute the Trading Strategy<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We executed the configured loss aversion strategy with the trading period from 2022-01-01 to 2022-12-31 and with the initial capital of 10,000,000 NTD. The output shows the portfolio value chart and illustrate the stock price trends of TSMC, along with the Bollinger Bands and buy\/sell signals.<\/p>\n\n\n\n<p>Since this article uses an experimental group and a control group to observe the effectiveness of setting stop-loss points, the results of the two groups will be presented separately below to facilitate our loss aversion analysis of the stop-loss effect.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from zipline import run_algorithm\n\nresults = run_algorithm(\n    start = start_time,\n    end = end_time,\n    initialize=initialize,\n    bundle='tquant',\n    analyze=analyze,\n    capital_base=1e7,\n    handle_data = handle_data\n)\n\nresults<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img decoding=\"async\" width=\"982\" height=\"418\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5be6\u9a57\u7d44results-2.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20380\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5be6\u9a57\u7d44results-2.png 982w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5be6\u9a57\u7d44results-2-300x128.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5be6\u9a57\u7d44results-2-150x64.png 150w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5be6\u9a57\u7d44results-2-768x327.png 768w\" sizes=\"(max-width: 982px) 100vw, 982px\" \/><figcaption class=\"wp-element-caption\">The portfolio value and trading points of the <strong>experimental<\/strong> <strong>group<\/strong><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img decoding=\"async\" width=\"1096\" height=\"466\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20382\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2.png 1096w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2-300x128.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2-1024x435.png 1024w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2-150x64.png 150w, https:\/\/www.tejwin.com\/wp-content\/uploads\/\u5c0d\u7167\u7d44results-2-768x327.png 768w\" sizes=\"(max-width: 1096px) 100vw, 1096px\" \/><figcaption class=\"wp-element-caption\">The portfolio value and trading points of the <strong>control<\/strong> <strong>group<\/strong><\/figcaption><\/figure>\n\n\n\n<p>Comparing the experimental group with the control group, it is evident that the asset value of the experimental group incurred only a slight loss due to the implementation of stop-loss points, and the overall assets have room for upward profitability. In contrast, the asset value of the control group mainly experienced losses, with the maximum loss exceeding 6%.<\/p>\n\n\n\n<p>Next, we can observe the timing of stop-loss in the experimental group through the chart of trading entry and exit points (red arrows indicate buying, green arrows indicate selling). Our loss aversion strategy implemented two stop-losses in March, limiting the loss to only 0.5% and effectively avoiding the bearish trend in April and May. Additionally, stop-losses were executed in September and October, when the control group did not carry out stop-loss and continued to average down. Consequently, the control group experienced a gradual reduction in asset value. Although there was a profit from the price spread when exiting, restoring the asset value to the initial level, investors had to endure the downside risk in September and October.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Performance_Evaluation_Using_Pyfolio\"><\/span>Performance Evaluation Using Pyfolio<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import pyfolio as pf \nreturns, positions, transactions = pf.utils.extract_rets_pos_txn_from_zipline(results)\nbenchmark_rets = results&#91;'benchmark_return']<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Draw_a_Sharpe_Ratio_Comparison_Chart\"><\/span>Draw a Sharpe Ratio Comparison Chart<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>On average, the experimental group, which implemented stop-loss, has a Sharpe Ratio of around 0.9, while the control group has only 0.1. Additionally, the Sharpe Ratio of the experimental group remains greater than 0 throughout the backtesting period, whereas the control group once drops to around -0.1.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> pf.plotting.plot_rolling_returns(returns, factor_returns=benchmark_rets)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" width=\"582\" height=\"407\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-sharpe.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20293\" style=\"object-fit:cover\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-sharpe.png 582w, https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-sharpe-300x210.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-sharpe-150x105.png 150w\" sizes=\"(max-width: 582px) 100vw, 582px\" \/><figcaption class=\"wp-element-caption\">Sharpe ratio of the <strong>experimental group<\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"406\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/control-sharpe.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20295\" style=\"object-fit:cover\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/control-sharpe.png 581w, https:\/\/www.tejwin.com\/wp-content\/uploads\/control-sharpe-300x210.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/control-sharpe-150x105.png 150w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><figcaption class=\"wp-element-caption\">Sharpe ratio of the <strong>control group<\/strong><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Compare_the_Top_5_Trading_Drawdown_Periods\"><\/span>Compare the Top 5 Trading Drawdown Periods<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The charts shows that the control group without setting stop-loss experiences more significant drawdowns, with the maximum drawdown reaching 7.14%. In contrast, the experimental group&#8217;s maximum drawdown is only 2.8%, and aside from the maximum drawdown, all other drawdowns are less than 1%.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyfolio.plotting import show_worst_drawdown_periods\nshow_worst_drawdown_periods(returns, top=5)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"173\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-drawdown.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20299\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-drawdown.png 647w, https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-drawdown-300x80.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/treatment-drawdown-150x40.png 150w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><figcaption class=\"wp-element-caption\">Top 5 trading drawdown periods of the <strong>experimental group<\/strong> <\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" width=\"646\" height=\"167\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/control-drawdown.png\" alt=\"Loss Aversion Strategy\" class=\"wp-image-20301\" srcset=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/control-drawdown.png 646w, https:\/\/www.tejwin.com\/wp-content\/uploads\/control-drawdown-300x78.png 300w, https:\/\/www.tejwin.com\/wp-content\/uploads\/control-drawdown-150x39.png 150w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><figcaption class=\"wp-element-caption\">Top 5 trading drawdown periods of the <strong>control group<\/strong> <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For this implementation, in order to achieve the effect of &#8220;loss aversion,&#8221; we combined the Bollinger Bands strategy with the Average True Range (ATR) to implement stop-loss. Simultaneously, we used the Bollinger Bands strategy without setting stop-loss as the control group to highlight the effectiveness of the ATR stop-loss.<\/p>\n\n\n\n<p>From the analysis we conducted above, we can see that ATR indeed helps us achieve &#8220;loss aversion,&#8221; especially during bearish trends, where the establishment of stop-loss points effectively helps us avoid the risk of asset depreciation. Using the Pyfolio performance evaluation tool in TQuant Lab, we also observe that the loss aversion strategy efficiently increases the average Sharpe ratio from 0.1 to 0.9. This implies that investors under the same level of risk can achieve higher returns. Furthermore, the loss aversion strategy significantly reduces drawdowns during the trading period, preventing excessive loss of investors&#8217; capital.<\/p>\n\n\n\n<p>Please note that the strategy and target discussed in this article are for reference only and do not constitute any recommendation for specific commodities or investments. In the future, we will also introduce using the TEJ database to construct various indicators and backtest their performance. Therefore, we welcome readers interested in various trading backtesting to consider purchasing relevant solutions from&nbsp;<a href=\"https:\/\/tquant.tejwin.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">TQuant Lab<\/a>. With our high-quality databases, you can construct a trading strategy that suits your needs.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-100 has-custom-font-size is-style-fill\" style=\"font-size:20px\"><a class=\"wp-block-button__link has-background wp-element-button\" href=\"https:\/\/www.tejwin.com\/en\/databank-solution\/market-data\/\" style=\"border-radius:12px;background:linear-gradient(135deg,rgb(240,215,106) 0%,rgb(75,209,200) 50%,rgb(76,132,205) 100%)\"><strong>Learn More About the High-Quality Investment Database by TEJ!<br>Construct Trading Strategies With Market Data.<\/strong><\/a><\/div>\n<\/div>\n\n\n\n<div style=\"height:19px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Source_Code\"><\/span>Source Code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Quant\/blob\/main\/%E5%B8%83%E6%9E%97%20%2B%20ATR_%E5%AF%A6%E9%A9%97%E7%B5%84.ipynb\" class=\"ek-link\" target=\"_blank\" rel=\"noopener\">Click here to Github<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Extended_Reading\"><\/span>Extended Reading<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-tej wp-block-embed-tej\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"k2YvpxvkE1\"><a href=\"https:\/\/www.tejwin.com\/en\/insight\/how-to-avoid-common-mistakes-during-trading-loss-avoidance\/\">How to avoid common mistakes during trading &#8211; Loss Avoidance<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;How to avoid common mistakes during trading &#8211; Loss Avoidance&#8221; &#8212; TEJ\" src=\"https:\/\/www.tejwin.com\/en\/insight\/how-to-avoid-common-mistakes-during-trading-loss-avoidance\/embed\/#?secret=VFTaU5t9GW#?secret=k2YvpxvkE1\" data-secret=\"k2YvpxvkE1\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-tej wp-block-embed-tej\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"9VRyyxBmeY\"><a href=\"https:\/\/www.tejwin.com\/en\/insight\/tquant-lab-bollinger-bands-trading-strategy\/\">TQuant Lab Bollinger Bands Trading Strategy<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;TQuant Lab Bollinger Bands Trading Strategy&#8221; &#8212; TEJ\" src=\"https:\/\/www.tejwin.com\/en\/insight\/tquant-lab-bollinger-bands-trading-strategy\/embed\/#?secret=cgoSMK3uw3#?secret=9VRyyxBmeY\" data-secret=\"9VRyyxBmeY\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Average True Range (ATR) is designed to assess the extent of price fluctuations within a specific period. ATR is commonly utilized as a tool in technical analysis, assisting traders to determine entry points, exit points, and stop-loss levels for loss aversion purpose.<\/p>\n","protected":false},"featured_media":19892,"template":"","tags":[2572,2988,2989,2990,2388,2537],"insight-category":[690,50,1356],"class_list":["post-20345","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-data-analysis","tag-quantitative-analysis","tag-quantitive-analysis","tag-quantitive-trading","tag-tquant-lab","tag-2537","insight-category-data-analysis","insight-category-fintech","insight-category-tquant-lab-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/20345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"version-history":[{"count":20,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/20345\/revisions"}],"predecessor-version":[{"id":25066,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/20345\/revisions\/25066"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/19892"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=20345"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=20345"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight-category?post=20345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}