{"id":6062,"date":"2025-06-02T15:40:39","date_gmt":"2025-06-04T07:59:39","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6062"},"modified":"2025-06-04T15:40:39","modified_gmt":"2025-06-04T07:59:39","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e7%9b%b8%e5%b0%8d%e5%bc%b7%e5%bc%b1%e6%8c%87%e6%95%b8rsi%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99%e5%8f%8apython%e7%af%84%e4%be%8b","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e7%9b%b8%e5%b0%8d%e5%bc%b7%e5%bc%b1%e6%8c%87%e6%95%b8rsi%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99%e5%8f%8apython%e7%af%84%e4%be%8b\/","title":{"rendered":"\u5982\u4f55\u5229\u7528\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)\u4ea4\u6613\u6307\u6a19\u53caPython\u7bc4\u4f8b\uff082025 \u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10\uff09"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, \u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI), \u4ea4\u6613\u6307\u6a19, \u4f7f\u7528\u6642\u6a5f, \u7bc4\u4f8b, \u80a1\u7968\u5206\u6790, \u6280\u8853\u5206\u6790\"><\/p>\n<h1>\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI) \u4ea4\u6613\u6307\u6a19\u4f7f\u7528\u6642\u6a5f\u53caPython\u7bc4\u4f8b\uff082025 \u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10\uff09<\/h1>\n<p>\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)\u662f\u4e00\u7a2e\u5e38\u7528\u7684\u6280\u8853\u5206\u6790\u6307\u6a19\uff0c\u5b83\u80fd\u5e6b\u52a9\u6295\u8cc7\u8005\u5224\u65b7\u80a1\u7968\u5e02\u5834\u7684\u8da8\u52e2\uff0c\u4ee5\u53ca\u4f55\u6642\u9032\u884c\u4ea4\u6613\u3002\u672c\u6587\u5c07\u4ecb\u7d39RSI\u7684\u4f7f\u7528\u6642\u6a5f\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528Python\u4f86\u8a08\u7b97\u548c\u7e6a\u88fdRSI\u6307\u6a19\uff0c\u4e26\u63d0\u4f9b2025\u5e74\u7684\u6700\u65b0\u8a9e\u6cd5\u53ca\u6700\u4f73\u5be6\u8e10\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)<\/h2>\n<p>\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)\u662f\u4e00\u7a2e\u91cf\u5316\u6307\u6a19\uff0c\u65e8\u5728\u8861\u91cf\u80a1\u7968\u5e02\u5834\u7684\u76f8\u5c0d\u5f37\u5f31\u3002\u5b83\u7684\u8a08\u7b97\u57fa\u65bc\u4e00\u5b9a\u6642\u9593\u5167\u7684\u50f9\u683c\u8b8a\u5316\uff0c\u4e26\u53ef\u4ee5\u7528\u4f86\u5224\u65b7\u5e02\u5834\u7684\u8d85\u8cb7\u6216\u8d85\u8ce3\u60c5\u6cc1\u3002RSI\u7684\u8a08\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`python<br \/>\nRSI = 100 &#8211; (100 \/ (1 + RS))<br \/>\n&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0cRS\u662f\u76f8\u5c0d\u5f37\u5f31\u6bd4\u7387\uff0c\u8a08\u7b97\u65b9\u5f0f\u70ba\u4e00\u5b9a\u6642\u9593\u5167\u4e0a\u6f32\u5e73\u5747\u5e45\u5ea6\u8207\u4e0b\u8dcc\u5e73\u5747\u5e45\u5ea6\u7684\u6bd4\u4f8b\u3002<\/p>\n<h2>RSI\u7684\u4f7f\u7528\u6642\u6a5f<\/h2>\n<p>RSI\u53ef\u4ee5\u7528\u4f86\u5224\u65b7\u80a1\u7968\u5e02\u5834\u7684\u8da8\u52e2\uff0c\u5177\u9ad4\u7684\u4f7f\u7528\u6642\u6a5f\u5982\u4e0b\uff1a<\/p>\n<p>&#8211; \u7576RSI\u503c\u8d85\u904e70\u6642\uff0c\u8868\u793a\u5e02\u5834\u53ef\u80fd\u51fa\u73fe\u8d85\u8cb7\u60c5\u6cc1\uff0c\u6295\u8cc7\u8005\u61c9\u8003\u616e\u8ce3\u51fa\u3002<br \/>\n&#8211; \u7576RSI\u503c\u4f4e\u65bc30\u6642\uff0c\u8868\u793a\u5e02\u5834\u53ef\u80fd\u51fa\u73fe\u8d85\u8ce3\u60c5\u6cc1\uff0c\u6295\u8cc7\u8005\u61c9\u8003\u616e\u8cb7\u5165\u3002<br \/>\n&#8211; \u7576RSI\u503c\u7531\u4f4e\u65bc30\u8f49\u70ba\u9ad8\u65bc70\u6642\uff0c\u53ef\u80fd\u51fa\u73fe\u8cb7\u5165\u4fe1\u865f\u3002<br \/>\n&#8211; \u7576RSI\u503c\u7531\u9ad8\u65bc70\u8f49\u70ba\u4f4e\u65bc30\u6642\uff0c\u53ef\u80fd\u51fa\u73fe\u8ce3\u51fa\u4fe1\u865f\u3002<\/p>\n<p>\u9019\u4e9b\u4fe1\u865f\u53ef\u4ee5\u5e6b\u52a9\u4ea4\u6613\u8005\u505a\u51fa\u66f4\u660e\u667a\u7684\u6c7a\u7b56\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528Python\u5be6\u73feRSI\u6307\u6a19<\/h2>\n<p>\u5728Python\u4e2d\u5be6\u73feRSI\u6307\u6a19\u975e\u5e38\u7c21\u55ae\uff0c\u53ea\u9700\u8981\u4f7f\u7528`numpy`\u548c`pandas`\u5169\u500b\u5eab\u3002\u4ee5\u4e0b\u662f\u5b8c\u6574\u7684\u5be6\u4f5c\u6b65\u9a5f\uff1a<\/p>\n<p>1. **\u5c0e\u5165\u5fc5\u8981\u7684\u5eab**\uff1a<br \/>\n&#8220;`python<br \/>\nimport numpy as np<br \/>\nimport pandas as pd<br \/>\nimport matplotlib.pyplot as plt<br \/>\n&#8220;`<\/p>\n<p>2. **\u8b80\u53d6\u80a1\u7968\u5e02\u5834\u7684\u6536\u76e4\u50f9\u6578\u64da**\uff1a<br \/>\n&#8220;`python<br \/>\n# \u8b80\u53d6\u80a1\u7968\u5e02\u5834\u7684\u6536\u76e4\u50f9\u6578\u64da<br \/>\ndata = pd.read_csv(&#8216;stock_data.csv&#8217;)<\/p>\n<p># \u5c07\u6578\u64da\u8f49\u63db\u70bapandas\u7684DataFrame\u683c\u5f0f<br \/>\ndf = pd.DataFrame(data)<br \/>\n&#8220;`<\/p>\n<p>3. **\u8a08\u7b97RSI\u503c**\uff1a<br \/>\n&#8220;`python<br \/>\n# \u8a08\u7b97\u6f32\u5e45\u548c\u8dcc\u5e45<br \/>\nchange = df[&#8216;Close&#8217;].diff()<\/p>\n<p># \u8a08\u7b97\u4e0a\u6f32\u548c\u4e0b\u8dcc\u7684\u5e73\u5747\u503c<br \/>\nup = change.where(change > 0, 0).rolling(window=14).mean()<br \/>\ndown = -change.where(change < 0, 0).rolling(window=14).mean()\n\n# \u8a08\u7b97RSI\u503c\nrs = up \/ down\nrsi = 100 - (100 \/ (1 + rs))\n```\n\n4. **\u7e6a\u88fdRSI\u503c\u7684\u5716\u8868**\uff1a\n```python\n# \u7e6a\u88fdRSI\u503c\u7684\u5716\u8868\nplt.figure(figsize=(10, 5))\nplt.plot(rsi, label='RSI', color='blue')\nplt.axhline(70, linestyle='--', alpha=0.5, color='red')\nplt.axhline(30, linestyle='--', alpha=0.5, color='green')\nplt.title('\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)')\nplt.xlabel('\u6642\u9593')\nplt.ylabel('RSI\u503c')\nplt.legend()\nplt.show()\n```\n\n\u9019\u6bb5\u7a0b\u5f0f\u78bc\u5c07\u8a08\u7b97\u51faRSI\u4e26\u4ee5\u5716\u8868\u5f62\u5f0f\u5448\u73fe\uff0c\u5e6b\u52a9\u60a8\u66f4\u597d\u5730\u5206\u6790\u80a1\u7968\u5e02\u5834\u7684\u8da8\u52e2\u3002\n\n\n\n<h2>\u932f\u8aa4\u6392\u9664\u8207\u5ef6\u4f38\u61c9\u7528<\/h2>\n<p>\u5728\u5be6\u4f5c\u904e\u7a0b\u4e2d\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u4e00\u4e9b\u5e38\u898b\u932f\u8aa4\uff1a<\/p>\n<p>&#8211; **\u6578\u64da\u683c\u5f0f\u932f\u8aa4**\uff1a\u78ba\u4fdd\u8b80\u53d6\u7684CSV\u6587\u4ef6\u4e2d\u542b\u6709\u6b63\u78ba\u7684\u5217\u540d\uff08\u4f8b\u5982`Close`\uff09\u3002<br \/>\n&#8211; **\u6578\u64da\u4e0d\u8db3**\uff1a\u5982\u679c\u6578\u64da\u96c6\u904e\u5c0f\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u8a08\u7b97RSI\u6642\u51fa\u73feNaN\u503c\u3002\u78ba\u4fdd\u6709\u8db3\u5920\u7684\u6578\u64da\u9032\u884c\u8a08\u7b97\u3002<\/p>\n<p>\u5ef6\u4f38\u61c9\u7528\u65b9\u9762\uff0c\u60a8\u53ef\u4ee5\u5c07RSI\u8207\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\u79fb\u52d5\u5e73\u5747\u7dda\uff0c\u4f86\u589e\u5f37\u4ea4\u6613\u7b56\u7565\u7684\u6548\u679c\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3Python\u53ca\u76f8\u95dc\u6280\u8853\uff0c\u5efa\u8b70\u53c3\u8003[\u9019\u88e1](https:\/\/vocus.cc)\u7684\u6df1\u5165\u6559\u5b78\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)\u7684\u4f7f\u7528\u6642\u6a5f\u53ca\u5982\u4f55\u4f7f\u7528Python\u4f86\u5be6\u73feRSI\u6307\u6a19\u3002\u900f\u904e2025\u5e74\u7684\u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u8a08\u7b97\u548c\u8996\u89ba\u5316RSI\u503c\uff0c\u9032\u800c\u8f14\u52a9\u60a8\u7684\u4ea4\u6613\u6c7a\u7b56\u3002<\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<p>**Q1: RSI\u7684\u6700\u4f73\u4f7f\u7528\u6642\u9593\u7bc4\u570d\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA1: \u901a\u5e38\u4f7f\u752814\u5929\u4f5c\u70ba\u8a08\u7b97RSI\u7684\u6642\u9593\u7bc4\u570d\uff0c\u4f46\u60a8\u53ef\u4ee5\u6839\u64da\u81ea\u5df1\u7684\u4ea4\u6613\u7b56\u7565\u8abf\u6574\u9019\u500b\u7bc4\u570d\u3002<\/p>\n<p>**Q2: RSI\u503c\u7684\u7bc4\u570d\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA2: RSI\u503c\u7bc4\u570d\u57280\u5230100\u4e4b\u9593\u3002\u901a\u5e3870\u4ee5\u4e0a\u88ab\u8996\u70ba\u8d85\u8cb7\uff0c30\u4ee5\u4e0b\u88ab\u8996\u70ba\u8d85\u8ce3\u3002<\/p>\n<p>**Q3: RSI\u5982\u4f55\u8207\u5176\u4ed6\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff1f**<br \/>\nA3: RSI\u53ef\u8207\u79fb\u52d5\u5e73\u5747\u7dda\u3001\u5e03\u6797\u5e36\u7b49\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff0c\u4ee5\u63d0\u9ad8\u4ea4\u6613\u7b56\u7565\u7684\u6e96\u78ba\u6027\u3002<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5229\u7528\u76f8\u5c0d\u5f37\u5f31\u6307\u6578(RSI)\u4ea4\u6613\u6307\u6a19\uff0c\u4ee5\u53ca\u4f7f\u7528Python\u7a0b\u5f0f\u78bc\u7bc4\u4f8b\u4f86\u61c9\u7528\u65bc\u4ea4\u6613\u6295\u8cc7\uff0c\u8b93\u6295\u8cc7\u8005\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u7684\u5206\u6790\u80a1\u7968\u5e02\u5834\u8da8\u52e2\uff0c\u4e26\u63d0\u5347\u6295\u8cc7\u6536\u76ca\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-6062","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-1zM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6062","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=6062"}],"version-history":[{"count":2,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6062\/revisions"}],"predecessor-version":[{"id":12759,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6062\/revisions\/12759"}],"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=6062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}