{"id":6390,"date":"2025-06-01T14:28:04","date_gmt":"2025-06-04T07:13:03","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6390"},"modified":"2025-06-04T14:28:04","modified_gmt":"2025-06-04T07:13:03","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e5%a8%81%e5%bb%89%e6%8c%87%e6%a8%99%e9%80%9a%e9%81%93williamrchannel%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e5%a8%81%e5%bb%89%e6%8c%87%e6%a8%99%e9%80%9a%e9%81%93williamrchannel%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99\/","title":{"rendered":"\u638c\u63e1\u5a01\u5ec9\u6307\u6a19\u901a\u9053 (William %R Channel) \u7684 Python \u5be6\u4f5c\u8207\u4ea4\u6613\u7b56\u7565"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, \u5a01\u5ec9\u6307\u6a19\u901a\u9053, William %R Channel, \u4ea4\u6613\u6307\u6a19, \u4f7f\u7528\u6642\u6a5f, \u80a1\u5e02\u5206\u6790, \u6280\u8853\u5206\u6790\"><\/p>\n<h1>\u5a01\u5ec9\u6307\u6a19\u901a\u9053 (William %R Channel) \u4ea4\u6613\u6307\u6a19\u4f7f\u7528\u6642\u6a5f\u8207 Python \u5be6\u4f5c\u7bc4\u4f8b<\/h1>\n<p>\u5a01\u5ec9\u6307\u6a19\u901a\u9053\uff08William %R Channel\uff09\u662f\u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u6280\u8853\u5206\u6790\u5de5\u5177\uff0c\u80fd\u5e6b\u52a9\u6295\u8cc7\u8005\u8a55\u4f30\u80a1\u7968\u50f9\u683c\u8d70\u52e2\uff0c\u4e26\u63d0\u4f9b\u4ea4\u6613\u6a5f\u6703\u3002\u5a01\u5ec9\u6307\u6a19\u57fa\u65bc\u4ea4\u6613\u8005\u7684\u5fc3\u7406\uff0c\u65e8\u5728\u5224\u65b7\u80a1\u7968\u662f\u5426\u8655\u65bc\u8d85\u8cb7\u6216\u8d85\u8ce3\u72c0\u614b\u3002\u4e86\u89e3\u5982\u4f55\u4f7f\u7528\u9019\u500b\u6307\u6a19\u53ef\u4ee5\u5e6b\u52a9\u4f60\u5728\u80a1\u5e02\u4e2d\u505a\u51fa\u66f4\u660e\u667a\u7684\u4ea4\u6613\u6c7a\u7b56\u3002<\/p>\n<p>### \u5a01\u5ec9\u6307\u6a19\u901a\u9053\u7684\u6838\u5fc3\u6982\u5ff5<\/p>\n<p>\u5a01\u5ec9\u6307\u6a19\u901a\u9053\u7684\u4f7f\u7528\u6642\u6a5f\u4e3b\u8981\u662f\u7576\u80a1\u7968\u50f9\u683c\u8d85\u51fa\u901a\u9053\u7684\u4e0a\u9650\u6216\u4e0b\u9650\u6642\u3002\u5177\u9ad4\u4f86\u8aaa\uff1a<br \/>\n&#8211; **\u4e0a\u9650\u7a81\u7834**\uff1a\u7576\u80a1\u7968\u50f9\u683c\u8d85\u8d8a\u901a\u9053\u7684\u4e0a\u9650\uff0c\u53ef\u80fd\u610f\u5473\u8457\u50f9\u683c\u5373\u5c07\u56de\u843d\uff0c\u56e0\u6b64\u6295\u8cc7\u8005\u53ef\u4ee5\u8003\u616e\u8ce3\u51fa\u3002<br \/>\n&#8211; **\u4e0b\u9650\u7a81\u7834**\uff1a\u7576\u80a1\u7968\u50f9\u683c\u4f4e\u65bc\u901a\u9053\u7684\u4e0b\u9650\uff0c\u5247\u53ef\u80fd\u9810\u793a\u8457\u50f9\u683c\u5373\u5c07\u53cd\u5f48\uff0c\u9069\u5408\u8003\u616e\u8cb7\u5165\u3002<\/p>\n<p>### \u4f7f\u7528 Python \u8a08\u7b97\u5a01\u5ec9\u6307\u6a19\u901a\u9053<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528 Python \u4f86\u8a08\u7b97\u5a01\u5ec9\u6307\u6a19\u901a\u9053\u7684\u7bc4\u4f8b\uff0c\u4f7f\u7528\u6700\u65b0\u7684\u8a9e\u6cd5\u548c\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<p>&#8220;`python<br \/>\n# \u5f15\u5165\u6240\u9700\u7684\u51fd\u5f0f\u5eab<br \/>\nimport pandas as pd<br \/>\nimport numpy as np<br \/>\nimport matplotlib.pyplot as plt<\/p>\n<p># \u8b80\u53d6\u8cc7\u6599<br \/>\ndata = pd.read_csv(&#8216;data.csv&#8217;)<\/p>\n<p># \u8a08\u7b97\u5a01\u5ec9\u6307\u6a19<br \/>\ndata[&#8216;william_r&#8217;] = (data[&#8216;high&#8217;] &#8211; data[&#8216;close&#8217;]) \/ (data[&#8216;high&#8217;] &#8211; data[&#8216;low&#8217;]) * -100<\/p>\n<p># \u8a08\u7b97\u5a01\u5ec9\u6307\u6a19\u901a\u9053<br \/>\ndata[&#8216;william_r_upper&#8217;] = data[&#8216;william_r&#8217;].rolling(window=20).mean() + 2 * data[&#8216;william_r&#8217;].rolling(window=20).std()<br \/>\ndata[&#8216;william_r_lower&#8217;] = data[&#8216;william_r&#8217;].rolling(window=20).mean() &#8211; 2 * data[&#8216;william_r&#8217;].rolling(window=20).std()<\/p>\n<p># \u7e6a\u88fd\u5a01\u5ec9\u6307\u6a19\u901a\u9053<br \/>\nplt.figure(figsize=(12, 6))<br \/>\nplt.plot(data[&#8216;date&#8217;], data[&#8216;william_r&#8217;], label=&#8217;William %R&#8217;, color=&#8217;blue&#8217;)<br \/>\nplt.plot(data[&#8216;date&#8217;], data[&#8216;william_r_upper&#8217;], label=&#8217;Upper Channel&#8217;, linestyle=&#8217;&#8211;&#8216;, color=&#8217;red&#8217;)<br \/>\nplt.plot(data[&#8216;date&#8217;], data[&#8216;william_r_lower&#8217;], label=&#8217;Lower Channel&#8217;, linestyle=&#8217;&#8211;&#8216;, color=&#8217;green&#8217;)<br \/>\nplt.title(&#8216;\u5a01\u5ec9\u6307\u6a19\u901a\u9053 (William %R Channel)&#8217;)<br \/>\nplt.xlabel(&#8216;\u65e5\u671f&#8217;)<br \/>\nplt.ylabel(&#8216;\u6307\u6a19\u503c&#8217;)<br \/>\nplt.legend()<br \/>\nplt.show()<br \/>\n&#8220;`<\/p>\n<p>\u9019\u6bb5\u7a0b\u5f0f\u78bc\u4e0d\u50c5\u8a08\u7b97\u4e86\u5a01\u5ec9\u6307\u6a19\uff0c\u9084\u7e6a\u88fd\u4e86\u6307\u6a19\u901a\u9053\u7684\u5716\u8868\uff0c\u4f7f\u5f97\u5206\u6790\u8b8a\u5f97\u76f4\u89c0\u6613\u61c2\u3002\u900f\u904e\u9019\u500b\u7bc4\u4f8b\uff0c\u6295\u8cc7\u8005\u53ef\u4ee5\u6e05\u6670\u5730\u770b\u5230\u50f9\u683c\u8d70\u52e2\u548c\u901a\u9053\u7684\u8b8a\u5316\uff0c\u9032\u800c\u505a\u51fa\u66f4\u597d\u7684\u4ea4\u6613\u6c7a\u7b56\u3002<\/p>\n<p>### \u932f\u8aa4\u6392\u9664<\/p>\n<p>\u5728\u5be6\u4f5c\u904e\u7a0b\u4e2d\uff0c\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u5e7e\u500b\u5e38\u898b\u932f\u8aa4\uff1a<br \/>\n1. **\u8cc7\u6599\u683c\u5f0f\u932f\u8aa4**\uff1a\u78ba\u4fdd CSV \u6a94\u6848\u4e2d\u7684\u8cc7\u6599\u683c\u5f0f\u6b63\u78ba\uff0c\u7279\u5225\u662f\u65e5\u671f\u548c\u6578\u503c\u578b\u5225\u3002<br \/>\n2. **\u7f3a\u5931\u503c\u8655\u7406**\uff1a\u5728\u8a08\u7b97\u79fb\u52d5\u5e73\u5747\u6642\uff0c\u53ef\u80fd\u6703\u51fa\u73fe NaN \u503c\uff0c\u4f7f\u7528 `dropna()` \u51fd\u6578\u6e05\u7406\u8cc7\u6599\u3002<br \/>\n3. **\u7e6a\u5716\u554f\u984c**\uff1a\u78ba\u8a8d\u5df2\u5b89\u88dd `matplotlib` \u51fd\u5f0f\u5eab\uff0c\u4e26\u6b63\u78ba\u8a2d\u5b9a\u5716\u8868\u986f\u793a\u3002<\/p>\n<p>### \u5ef6\u4f38\u61c9\u7528<\/p>\n<p>\u5a01\u5ec9\u6307\u6a19\u901a\u9053\u53ef\u4ee5\u8207\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\u76f8\u5c0d\u5f37\u5f31\u6307\u6578\uff08RSI\uff09\u6216\u79fb\u52d5\u5e73\u5747\u7dda\uff08MA\uff09\uff0c\u4ee5\u7372\u5f97\u66f4\u5168\u9762\u7684\u5e02\u5834\u5206\u6790\u3002\u9019\u6a23\u7684\u7d44\u5408\u80fd\u5e6b\u52a9\u4f60\u66f4\u597d\u5730\u8b58\u5225\u4ea4\u6613\u6a5f\u6703\u548c\u98a8\u96aa\u3002<\/p>\n<p>\u9700\u8981\u9032\u4e00\u6b65\u4e86\u89e3 Python \u7684\u5176\u4ed6\u61c9\u7528\u55ce\uff1f\u53ef\u4ee5\u53c3\u8003 [\u9019\u7bc7 Python \u6559\u5b78\u6587\u7ae0](https:\/\/vocus.cc\/article\/605ca3d6fd89780001f7489e) \u4f86\u6df1\u5165\u5b78\u7fd2\u3002<\/p>\n<p>### Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/p>\n<p>**Q1: \u5a01\u5ec9\u6307\u6a19\u901a\u9053\u7684\u6700\u4f73\u4f7f\u7528\u6642\u6a5f\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA1: \u7576\u80a1\u7968\u50f9\u683c\u7a81\u7834\u901a\u9053\u7684\u4e0a\u9650\u6216\u4e0b\u9650\u6642\uff0c\u662f\u9032\u884c\u4ea4\u6613\u7684\u6700\u4f73\u6642\u6a5f\u3002<\/p>\n<p>**Q2: \u5982\u4f55\u9078\u64c7\u5a01\u5ec9\u6307\u6a19\u901a\u9053\u7684\u8a08\u7b97\u7a97\u53e3\uff1f**<br \/>\nA2: \u5e38\u898b\u7684\u9078\u64c7\u662f 14 \u5929\u6216 20 \u5929\uff0c\u5177\u9ad4\u53ef\u6839\u64da\u5e02\u5834\u60c5\u6cc1\u548c\u500b\u4eba\u98a8\u96aa\u627f\u53d7\u80fd\u529b\u9032\u884c\u8abf\u6574\u3002<\/p>\n<p>**Q3: Python \u7684\u5a01\u5ec9\u6307\u6a19\u8a08\u7b97\u662f\u5426\u9700\u8981\u984d\u5916\u7684\u51fd\u5f0f\u5eab\uff1f**<br \/>\nA3: \u662f\u7684\uff0c\u901a\u5e38\u9700\u8981\u5b89\u88dd `pandas` \u548c `matplotlib` \u7b49\u51fd\u5f0f\u5eab\u4f86\u9032\u884c\u6578\u64da\u8655\u7406\u548c\u53ef\u8996\u5316\u3002<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u5a01\u5ec9\u6307\u6a19\u901a\u9053(William%RChannel)\u662f\u4e00\u7a2e\u91dd\u5c0d\u80a1\u7968\u5e02\u5834\u7684\u4ea4\u6613\u6307\u6a19\uff0c\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5206\u6790\u80a1\u7968\u5e02\u5834\u7684\u8da8\u52e2\uff0c\u4e26\u63d0\u4f9b\u6295\u8cc7\u8005\u66f4\u597d\u7684\u4ea4\u6613\u6c7a\u7b56\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Python\u4f86\u5be6\u73fe\u5a01\u5ec9\u6307\u6a19\u901a\u9053(William%RChannel)\u4ea4\u6613\u6307\u6a19\uff0c\u4ee5\u53ca\u5982\u4f55\u5229\u7528\u5b83\u4f86\u66f4\u597d\u5730\u4ea4\u6613\u80a1\u7968\u5e02\u5834\u3002<\/p>\n","protected":false},"author":1,"featured_media":2518,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,189],"tags":[15,188],"class_list":["post-6390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-189","tag-python","tag-188"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2022\/12\/DALL\u00b7E-2022-12-28-14.25.55-\u62f7\u8c9d2.png","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1F4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=6390"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6390\/revisions"}],"predecessor-version":[{"id":6391,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6390\/revisions\/6391"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/2518"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=6390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}