{"id":469,"date":"2024-05-29T15:49:57","date_gmt":"2024-05-29T07:49:57","guid":{"rendered":"https:\/\/blog.alltick.co\/?p=469"},"modified":"2025-04-23T16:15:38","modified_gmt":"2025-04-23T08:15:38","slug":"parabolic-sar-indicator","status":"publish","type":"post","link":"https:\/\/blog.alltick.co\/zh-CN\/parabolic-sar-indicator\/","title":{"rendered":"\u629b\u7269\u7ebfSAR\u6307\u6807\u8be6\u89e3"},"content":{"rendered":"\n<p>\u629b\u7269\u7ebfSAR\u6307\u6807\uff08Stop and Reverse\uff0c\u7b80\u79f0SAR\uff09\u662f\u6280\u672f\u5206\u6790\u5e08\u548c\u4ea4\u6613\u8005\u5e38\u7528\u7684\u4e00\u79cd\u5de5\u5177\u3002\u5b83\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u53d1\u73b0\u6f5c\u5728\u7684\u8d8b\u52bf\u53cd\u8f6c\u70b9\uff0c\u5e76\u6307\u5bfc\u6211\u4eec\u4f55\u65f6\u5165\u573a\u6216\u9000\u573a\u3002\u5728<a href=\"https:\/\/blog.alltick.co\/andreas-clenow-trend-following-strategy\/\"><strong>\u8d8b\u52bf\u8ddf\u8e2a\u7b56\u7565<\/strong><\/a>\u4e2d\uff0c\u8fd9\u4e2a\u6307\u6807\u7279\u522b\u6709\u7528\u3002\u638c\u63e1SAR\u7684\u8fd0\u4f5c\u539f\u7406\u548c\u5e94\u7528\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u597d\u5730\u9a7e\u9a6d\u91d1\u878d\u5e02\u573a\u7684\u590d\u6742\u53d8\u5316\u3002\u56e0\u4e3a\u7b80\u5355\u6613\u61c2\u4e14\u5728\u8d8b\u52bf\u5e02\u573a\u4e2d\u76f8\u5f53\u53ef\u9760\uff0cSAR\u53d7\u5230\u4e86\u5f88\u591a\u8d44\u6df1\u4e13\u4e1a\u4eba\u58eb\u548c\u521d\u5b66\u8005\u7684\u559c\u7231\u3002\u800cSAR\u5176\u5b9e\u5e76\u4e0d\u590d\u6742\uff0c\u65e0\u8bba\u4f60\u662f\u4e00\u4e2a\u60f3\u8981\u63d0\u5347\u81ea\u5df1\u7b56\u7565\u7684\u8001\u9e1f\uff0c\u8fd8\u662f\u4e00\u4e2a\u521a\u5165\u95e8\u7684\u5c0f\u767d\uff0c\u90fd\u503c\u5f97\u4f60\u82b1\u70b9\u65f6\u95f4\u7814\u7a76\u4e00\u4e0b\u8fd9\u4e2a\u6307\u6807\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u5148\u6765\u4e86\u89e3\u4e00\u4e0bSAR\u6307\u6807\u80fd\u5e2e\u6211\u4eec\u5e72\u4ec0\u4e48\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u8fa8\u522b\u884c\u60c5\u8d8b\u52bf<\/strong><\/h3>\n\n\n\n<p>\u629b\u7269\u7ebfSAR\u7684\u4e3b\u8981\u7279\u70b9\u5c31\u662f\u5b83\u80fd\u591f\u8bc6\u522b\u5f53\u524d\u7684\u8d8b\u52bf\u65b9\u5411\u3002\u8fd9\u4e2a\u6307\u6807\u4f1a\u5728\u56fe\u8868\u4e0a\u663e\u793a\u7531\u5c0f\u7ea2\u70b9\u7ec4\u6210\u7684\u629b\u7269\u7ebf\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"796\" height=\"430\" src=\"https:\/\/i0.wp.com\/blog.alltick.co\/wp-content\/uploads\/2024\/05\/SAR%E6%8C%87%E6%A0%87.jpg?resize=796%2C430&#038;ssl=1\" alt=\"SAR\u6307\u6807\" class=\"wp-image-470\" srcset=\"https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2024\/05\/SAR%E6%8C%87%E6%A0%87.jpg?w=796&amp;ssl=1 796w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2024\/05\/SAR%E6%8C%87%E6%A0%87.jpg?resize=300%2C162&amp;ssl=1 300w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2024\/05\/SAR%E6%8C%87%E6%A0%87.jpg?resize=768%2C415&amp;ssl=1 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/figure>\n\n\n\n<p><strong>\u5f53\u629b\u7269\u7ebf\u5728\u4ef7\u683c\u4e0b\u65b9\u65f6\uff0c\u8868\u793a\u5e02\u573a\u5904\u4e8e\u4e0a\u5347\u8d8b\u52bf\u3002\u800c\u629b\u7269\u7ebf\u5728\u4ef7\u683c\u4e0a\u65b9\u65f6\uff0c\u5219\u4ee3\u8868\u5e02\u573a\u662f\u5904\u4e8e\u4e0b\u964d\u8d8b\u52bf\u7684\u3002<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u53d1\u73b0\u6f5c\u5728\u7684\u884c\u60c5\u53cd\u8f6c\u70b9<\/strong><\/h3>\n\n\n\n<p>SAR\u6307\u6807\u8fd8\u53ef\u4ee5\u7528\u6765\u5bfb\u627e\u6f5c\u5728\u7684\u53cd\u8f6c\u70b9\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u89c2\u5bdf\u629b\u7269\u7ebf\u7684\u8d70\u5411\uff0c\u5bc6\u5207\u7559\u610f\u629b\u7269\u7ebf\u662f\u5426\u4ece\u4ef7\u683c\u4e0b\u65b9\u7ffb\u8f6c\u5230\u4e0a\u65b9\uff0c\u6216\u4ece\u4e0a\u65b9\u7ffb\u8f6c\u5230\u4e0b\u65b9\u65f6\uff0c\u8fd9\u8868\u660e\u53ef\u80fd\u5373\u5c06\u53d1\u751f\u8d8b\u52bf\u53cd\u8f6c\u3002\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u4fe1\u53f7\u6765\u51b3\u5b9a\u5165\u573a\u8fd8\u662f\u64a4\u8d44\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>SAR\u6307\u6807\u7684\u8ba1\u7b97\u65b9\u6cd5<\/strong><\/h2>\n\n\n\n<p>\u629b\u7269\u7ebfSAR\u6307\u6807\u7684\u8ba1\u7b97\u65b9\u6cd5\u7531\u4e24\u4e2a\u91cd\u8981\u90e8\u5206\u7ec4\u6210\uff1a\u6781\u7aef\u4ef7\u683c\u548c\u52a0\u901f\u56e0\u5b50\u3002<\/p>\n\n\n\n<p><strong>\u6781\u7aef\u4ef7\u683c\uff08EP\uff09<\/strong><\/p>\n\n\n\n<p>\u6781\u7aef\u4ef7\u683c\uff08EP\uff09\u8868\u793a\u5f53\u524d\u8d8b\u52bf\u671f\u95f4\u8bb0\u5f55\u7684\u6700\u9ad8\u70b9\u6216\u6700\u4f4e\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u6574\u4f53\u8d8b\u52bf\u662f\u4e0a\u5347\u7684\uff0cEP\u7684\u503c\u7b49\u4e8e\u81ea\u8d8b\u52bf\u5f00\u59cb\u4ee5\u6765\u89c2\u5bdf\u5230\u7684\u6700\u9ad8\u70b9\u3002<\/li>\n\n\n\n<li>\u53cd\u4e4b\uff0c\u5728\u4e0b\u964d\u8d8b\u52bf\u4e2d\uff0cEP\u662f\u4ece\u8d8b\u52bf\u5f00\u59cb\u4ee5\u6765\u89c2\u5bdf\u5230\u7684\u6700\u4f4e\u70b9\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u52a0\u901f\u56e0\u5b50\uff08AF\uff09 <\/strong><\/p>\n\n\n\n<p>\u52a0\u901f\u56e0\u5b50\uff08AF\uff09\u51b3\u5b9a\u4e86SAR\u6307\u6807\u7684\u7075\u654f\u5ea6\u3002<strong>\u5b83\u7684\u521d\u59cb\u503c\u4e3a0.02<\/strong>\uff0c\u5e76\u4e14\u5728\u8d8b\u52bf\u4e2d\u6bcf\u8fbe\u5230\u4e00\u4e2a\u65b0\u7684\u6781\u503c\u70b9\u65f6\u53ef\u4ee5\u9010\u6b65\u589e\u52a0\uff0c\u6700\u9ad8\u53ef\u8fbe\u52300.20\u3002AF\u7684\u8c03\u6574\u5982\u4e0b\uff1a <\/p>\n\n\n\n<p>&#8211; \u521d\u59cb\u503c\u4e3a0.02\u3002 <\/p>\n\n\n\n<p>&#8211; \u6bcf\u8fbe\u5230\u4e00\u4e2a\u65b0\u7684\u6781\u503c\u70b9\uff08\u6700\u9ad8\u70b9\u6216\u6700\u4f4e\u70b9\uff09\uff0cAF\u589e\u52a00.02\u3002 <\/p>\n\n\n\n<p>&#8211; \u8fbe\u52300.20\u540e\u4e0d\u518d\u589e\u52a0\u3002 <\/p>\n\n\n\n<p>\u8fd9\u79cd\u8c03\u6574\u786e\u4fdd\u4e86SAR\u5728\u8d8b\u52bf\u52a0\u5f3a\u65f6\u53d8\u5f97\u66f4\u52a0\u7075\u654f\uff0c\u80fd\u591f\u66f4\u7d27\u5bc6\u5730\u8ddf\u8e2a\u4ef7\u683c\u3002 <\/p>\n\n\n\n<p>\u629b\u7269\u7ebfSAR\u7684\u8ba1\u7b97\u516c\u5f0f \u629b\u7269\u7ebfSAR\u7684\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a <\/p>\n\n\n\n<div class=\"wp-block-mathml-mathmlblock\">\\begin{equation}\n \\text{SAR}_{\\text{new}} = \\text{SAR}_{\\text{current}} + \\text{AF} \\times (\\text{EP} &#8211; \\text{SAR}_{\\text{current}}) \n\\end{equation}<script type='text\/javascript' src='https:\/\/blog.alltick.co\/zh-CN\/wp-includes\/js\/dist\/hooks.min.js?m=1764796677'><\/script>\n<script src=\"https:\/\/blog.alltick.co\/zh-CN\/wp-includes\/js\/dist\/i18n.min.js?ver=c26c3dc7bed366793375\" id=\"wp-i18n-js\"><\/script>\n<script id=\"wp-i18n-js-after\">\nwp.i18n.setLocaleData( { 'text direction\\u0004ltr': [ 'ltr' ] } );\n\/\/# sourceURL=wp-i18n-js-after\n<\/script>\n<script  async src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/mathjax\/2.7.7\/MathJax.js?config=TeX-MML-AM_CHTML\" id=\"mathjax-js\"><\/script>\n<\/div>\n\n\n\n<p>\u8fd9\u4e2a\u516c\u5f0f\u786e\u4fdd\u968f\u7740\u8d8b\u52bf\u7684\u53d1\u5c55\uff0cSAR\u503c\u9010\u6e10\u9760\u8fd1\u4ef7\u683c\uff0c\u4e3a\u5e02\u573a\u7684\u53d8\u5316\u63d0\u4f9b\u4e00\u4e2a\u52a8\u6001\u7684\u6307\u6807\u3002 <\/p>\n\n\n\n<p><strong>\u8d8b\u52bf\u53cd\u8f6c <\/strong><\/p>\n\n\n\n<p>\u5f53\u4ef7\u683c\u7a7f\u8d8aSAR\u503c\u65f6\uff0c\u5c31\u53d1\u751f\u4e86\u8d8b\u52bf\u53cd\u8f6c\u3002\u8fd9\u65f6\uff0cSAR\u503c\u4f1a\u88ab\u91cd\u7f6e\uff0c\u8d8b\u52bf\u65b9\u5411\u4e5f\u4f1a\u5207\u6362\u3002\u65b0\u7684SAR\u503c\u5c06\u8bbe\u7f6e\u4e3a\u524d\u4e00\u4e2a\u8d8b\u52bf\u7684EP\uff0cAF\u5219\u91cd\u65b0\u56de\u5230\u521d\u59cb\u503c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>SAR\u6307\u6807\u4ee3\u7801\u793a\u4f8b<\/strong><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\nimport matplotlib.pyplot as plt\nimport allticks\n\n# \u4ee5\u4e0b\u4ee5\u7f8e\u80a1\u82f9\u679c\u80a1\u7968\u4e3a\u4f8b\n# \u4eceAlltick\u7684\u884c\u60c5\u63a5\u53e3\u83b7\u53d6\u82f9\u679c\u80a1\u7968\u4ef7\u683c\u6570\u636e\napple_stock_data = allticks.get_stock_data('AAPL')\n\n# \u786e\u4fdd\u6570\u636e\u6309\u65e5\u671f\u6392\u5e8f\napple_stock_data = apple_stock_data.sort_index()\n\n# \u8ba1\u7b97\u629b\u7269\u7ebfSAR\ndef calculate_parabolic_sar(data, af_start=0.02, af_increment=0.02, af_max=0.20):\n    # \u521d\u59cb\u5316\u53d8\u91cf\n    sar = [0] * len(data)\n    trend = 1  # 1\u8868\u793a\u4e0a\u5347\u8d8b\u52bf\uff0c-1\u8868\u793a\u4e0b\u964d\u8d8b\u52bf\n    ep = data['Low'][0]  # \u6781\u7aef\u70b9\uff1a\u4e0a\u5347\u8d8b\u52bf\u65f6\u4e3a\u6700\u4f4e\u4ef7\uff0c\u4e0b\u964d\u8d8b\u52bf\u65f6\u4e3a\u6700\u9ad8\u4ef7\n    af = af_start  # \u52a0\u901f\u56e0\u5b50\n\n    # \u8bbe\u7f6e\u521d\u59cbSAR\u503c\n    sar[0] = data['Low'][0] if trend == 1 else data['High'][0]\n\n    for i in range(1, len(data)):\n        prev_sar = sar[i - 1]\n        if trend == 1:\n            sar[i] = prev_sar + af * (ep - prev_sar)\n            if data['Low'][i] &lt; sar[i]:\n                trend = -1\n                sar[i] = ep\n                ep = data['High'][i]\n                af = af_start\n            else:\n                if data['High'][i] > ep:\n                    ep = data['High'][i]\n                    af = min(af + af_increment, af_max)\n        else:\n            sar[i] = prev_sar - af * (prev_sar - ep)\n            if data['High'][i] > sar[i]:\n                trend = 1\n                sar[i] = ep\n                ep = data['Low'][i]\n                af = af_start\n            else:\n                if data['Low'][i] &lt; ep:\n                    ep = data['Low'][i]\n                    af = min(af + af_increment, af_max)\n\n    return sar\n\n# \u8ba1\u7b97SAR\u503c\napple_stock_data['SAR'] = calculate_parabolic_sar(apple_stock_data)\n\n# \u53ef\u89c6\u5316\u7ed3\u679c\nplt.figure(figsize=(14, 7))\nplt.plot(apple_stock_data['Close'], label='Apple Stock Price')\nplt.plot(apple_stock_data['SAR'], label='Parabolic SAR', linestyle='--')\nplt.title('Apple Stock Price with Parabolic SAR')\nplt.xlabel('Date')\nplt.ylabel('Price')\nplt.legend()\nplt.show()\n<\/pre>\n\n\n\n<p><strong>\u3010\u63a8\u8350\u9605\u8bfb\u3011<a href=\"https:\/\/blog.alltick.co\/pairs-trading\/\">Pairs Trading \u914d\u5bf9\u4ea4\u6613\u7b56\u7565<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u629b\u7269\u7ebfSAR\u6307\u6807\uff08Stop and Reverse\uff0c\u7b80\u79f0SAR\uff09\u662f\u6280\u672f\u5206\u6790\u5e08\u548c\u4ea4\u6613\u8005\u5e38\u7528\u7684\u4e00\u79cd\u5de5\u5177\u3002\u5b83\u80fd\u591f\u5e2e\u52a9&#8230;<\/p>\n","protected":false},"author":1,"featured_media":475,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-469","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tick-data-wiki"],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/comments?post=469"}],"version-history":[{"count":6,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/469\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/469\/revisions\/477"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media\/475"}],"wp:attachment":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media?parent=469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/categories?post=469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/tags?post=469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}