{"id":6332,"date":"2025-05-28T14:06:00","date_gmt":"2025-06-04T07:00:00","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6332"},"modified":"2025-06-04T14:06:00","modified_gmt":"2025-06-04T07:00:00","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e8%82%a1%e7%a5%a8%e5%b8%82%e5%80%bc%e6%af%94%e9%80%9a%e9%81%93stock-to-marketratiochannel%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99-2","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%e8%82%a1%e7%a5%a8%e5%b8%82%e5%80%bc%e6%af%94%e9%80%9a%e9%81%93stock-to-marketratiochannel%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99-2\/","title":{"rendered":"\u6df1\u5165\u63a2\u7d22\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff08Stock-to-Market Ratio Channel\uff09\uff1aPython \u5be6\u4f5c\u8207\u4ea4\u6613\u7b56\u7565"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, \u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053, Stock-to-Market Ratio Channel, \u4ea4\u6613\u6307\u6a19, \u4f7f\u7528\u6642\u6a5f, \u6295\u8cc7\u7b56\u7565\"><\/p>\n<h1>\u6df1\u5165\u63a2\u7d22\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff08Stock-to-Market Ratio Channel\uff09\uff1aPython \u5be6\u4f5c\u8207\u4ea4\u6613\u7b56\u7565<\/h1>\n<p>\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff08Stock-to-Market Ratio Channel\uff09\u662f\u4e00\u7a2e\u91cd\u8981\u7684\u6280\u8853\u5206\u6790\u6307\u6a19\uff0c\u5e6b\u52a9\u6295\u8cc7\u8005\u5224\u65b7\u80a1\u7968\u7684\u50f9\u683c\u8d70\u52e2\u4e26\u63d0\u4f9b\u4ea4\u6613\u6c7a\u7b56\u7684\u4f9d\u64da\u3002\u672c\u6587\u5c07\u5168\u9762\u4ecb\u7d39\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u7684\u5b9a\u7fa9\u3001\u61c9\u7528\u6642\u6a5f\u3001Python \u5be6\u4f5c\u7bc4\u4f8b\uff0c\u4ee5\u53ca\u4e00\u4e9b\u5e38\u898b\u7684\u932f\u8aa4\u6392\u9664\u6280\u5de7\uff0c\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u6709\u6548\u5730\u5229\u7528\u9019\u500b\u6307\u6a19\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff1f<\/h2>\n<p>\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u662f\u4e00\u7a2e\u57fa\u65bc\u80a1\u7968\u5e02\u503c\u6bd4\u7387\u7684\u6280\u8853\u6307\u6a19\uff0c\u7528\u65bc\u5224\u65b7\u80a1\u7968\u50f9\u683c\u662f\u5426\u5408\u7406\u3002\u5b83\u80fd\u5920\u5e6b\u52a9\u6295\u8cc7\u8005\u8b58\u5225\u80a1\u7968\u7684\u6f5b\u5728\u8cb7\u5165\u6216\u8ce3\u51fa\u6642\u6a5f\uff0c\u901a\u904e\u8a08\u7b97\u80a1\u7968\u50f9\u683c\u8207\u517620\u65e5\u79fb\u52d5\u5e73\u5747\u7684\u6bd4\u7387\uff0c\u6295\u8cc7\u8005\u53ef\u4ee5\u66f4\u6e05\u6670\u5730\u4e86\u89e3\u5e02\u5834\u72c0\u6cc1\u3002<\/p>\n<h2>\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u7684\u4f7f\u7528\u6642\u6a5f<\/h2>\n<p>\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u7684\u4e0a\u4e0b\u9650\u53ef\u4f5c\u70ba\u4ea4\u6613\u4fe1\u865f\uff1a<br \/>\n&#8211; \u7576\u80a1\u7968\u7684\u5e02\u503c\u6bd4\u7387\u8d85\u904e\u4e0a\u9650\u6642\uff0c\u8868\u793a\u80a1\u7968\u50f9\u683c\u904e\u9ad8\uff0c\u6295\u8cc7\u8005\u53ef\u8003\u616e\u8ce3\u51fa\u3002<br \/>\n&#8211; \u7576\u5e02\u503c\u6bd4\u7387\u4f4e\u65bc\u4e0b\u9650\u6642\uff0c\u8868\u793a\u80a1\u7968\u50f9\u683c\u904e\u4f4e\uff0c\u6295\u8cc7\u8005\u53ef\u8003\u616e\u8cb7\u5165\u3002<\/p>\n<p>\u9019\u4e9b\u4fe1\u865f\u4e0d\u50c5\u80fd\u63d0\u793a\u4ea4\u6613\u6642\u6a5f\uff0c\u9084\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u907f\u514d\u5e02\u5834\u8aa4\u5224\u3002<\/p>\n<h2>Python\u7bc4\u4f8b\uff1a\u8a08\u7b97\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053<\/h2>\n<p>\u4e0b\u9762\u7684 Python \u7a0b\u5f0f\u78bc\u793a\u7bc4\u5982\u4f55\u8a08\u7b97\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff0c\u4e26\u7e6a\u88fd\u51fa\u76f8\u61c9\u7684\u5716\u8868\uff1a<\/p>\n<p>&#8220;`python<br \/>\n# \u8f09\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\u80a1\u7968\u8cc7\u6599<br \/>\ndf = pd.read_csv(&#8216;stock_data.csv&#8217;)<\/p>\n<p># \u8a08\u7b9720\u65e5\u79fb\u52d5\u5e73\u5747<br \/>\ndf[&#8217;20ma&#8217;] = df[&#8216;Close&#8217;].rolling(window=20).mean()<\/p>\n<p># \u8a08\u7b97\u5e02\u503c\u6bd4<br \/>\ndf[&#8216;mkt_ratio&#8217;] = df[&#8216;Close&#8217;] \/ df[&#8217;20ma&#8217;]\n<p># \u8a08\u7b97\u5e02\u503c\u6bd4\u901a\u9053<br \/>\ndf[&#8216;upper_channel&#8217;] = df[&#8216;mkt_ratio&#8217;] + 0.1<br \/>\ndf[&#8216;lower_channel&#8217;] = df[&#8216;mkt_ratio&#8217;] &#8211; 0.1<\/p>\n<p># \u7e6a\u88fd\u5716\u8868<br \/>\nplt.figure(figsize=(12, 6))<br \/>\nplt.plot(df[&#8216;Date&#8217;], df[&#8216;mkt_ratio&#8217;], label=&#8217;Market Ratio&#8217;, color=&#8217;blue&#8217;)<br \/>\nplt.plot(df[&#8216;Date&#8217;], df[&#8216;upper_channel&#8217;], label=&#8217;Upper Channel&#8217;, linestyle=&#8217;&#8211;&#8216;, color=&#8217;red&#8217;)<br \/>\nplt.plot(df[&#8216;Date&#8217;], df[&#8216;lower_channel&#8217;], label=&#8217;Lower Channel&#8217;, linestyle=&#8217;&#8211;&#8216;, color=&#8217;green&#8217;)<br \/>\nplt.title(&#8216;Stock Market Ratio Channel&#8217;)<br \/>\nplt.xlabel(&#8216;Date&#8217;)<br \/>\nplt.ylabel(&#8216;Market Ratio&#8217;)<br \/>\nplt.legend()<br \/>\nplt.grid()<br \/>\nplt.show()<br \/>\n&#8220;`<\/p>\n<p>\u9019\u6bb5\u7a0b\u5f0f\u78bc\u5c07\u5e6b\u52a9\u6295\u8cc7\u8005\u8a08\u7b97\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u4e26\u7e6a\u88fd\u51fa\u76f8\u61c9\u7684\u5716\u8868\uff0c\u4ee5\u4fbf\u65bc\u9032\u884c\u8996\u89ba\u5316\u5206\u6790\uff0c\u5f9e\u800c\u66f4\u597d\u5730\u505a\u51fa\u4ea4\u6613\u6c7a\u7b56\u3002<\/p>\n<h2>\u932f\u8aa4\u6392\u9664\u6280\u5de7<\/h2>\n<p>\u5728\u4f7f\u7528\u4e0a\u8ff0\u7a0b\u5f0f\u78bc\u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u5e38\u898b\u7684\u932f\u8aa4\uff1a<br \/>\n1. **\u8cc7\u6599\u8b80\u53d6\u932f\u8aa4**\uff1a\u78ba\u4fdd `stock_data.csv` \u6a94\u6848\u5b58\u5728\u4e14\u683c\u5f0f\u6b63\u78ba\u3002<br \/>\n2. **NaN \u503c**\uff1a\u4f7f\u7528 `dropna()` \u65b9\u6cd5\u4f86\u8655\u7406\u7f3a\u5931\u6578\u64da\u3002<br \/>\n3. **\u7e6a\u5716\u554f\u984c**\uff1a\u78ba\u4fdd\u5df2\u5b89\u88dd Matplotlib \u51fd\u5f0f\u5eab\uff0c\u4e26\u6b63\u78ba\u8a2d\u5b9a\u5716\u8868\u5927\u5c0f\u3002<\/p>\n<h2>\u5ef6\u4f38\u61c9\u7528<\/h2>\n<p>\u6295\u8cc7\u8005\u53ef\u4ee5\u6839\u64da\u5e02\u5834\u7684\u4e0d\u540c\u60c5\u6cc1\u8abf\u6574\u901a\u9053\u7684\u4e0a\u4e0b\u9650\uff0c\u4ee5\u4fbf\u9069\u61c9\u4e0d\u540c\u7684\u5e02\u5834\u74b0\u5883\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u5c07\u6b64\u6307\u6a19\u8207\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff0c\u5982 RSI\uff08\u76f8\u5c0d\u5f37\u5f31\u6307\u6a19\uff09\u6216 MACD\uff08\u79fb\u52d5\u5e73\u5747\u6536\u6582\u767c\u6563\u6307\u6a19\uff09\uff0c\u4ee5\u63d0\u5347\u4ea4\u6613\u7b56\u7565\u7684\u6e96\u78ba\u6027\u3002<\/p>\n<p>\u5728\u6b64\u6211\u5011\u4e5f\u63a8\u85a6\u60a8\u53c3\u8003\u9019\u7bc7[Python \u80a1\u7968\u5206\u6790\u5165\u9580](https:\/\/vocus.cc\/article\/634f0f1f8c4f4f001cda9e49)\u7684\u6587\u7ae0\uff0c\u4ee5\u7372\u53d6\u66f4\u591a\u5be6\u7528\u7684 Python \u80a1\u7968\u5206\u6790\u6280\u5de7\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u662f\u4e00\u500b\u6709\u529b\u7684\u4ea4\u6613\u6307\u6a19\uff0c\u80fd\u5920\u5e6b\u52a9\u6295\u8cc7\u8005\u5728\u8b8a\u5316\u83ab\u6e2c\u7684\u5e02\u5834\u4e2d\u628a\u63e1\u6a5f\u6703\u3002\u900f\u904e\u672c\u6587\u7684\u4ecb\u7d39\u8207 Python \u7684\u5be6\u4f5c\u7bc4\u4f8b\uff0c\u60a8\u53ef\u4ee5\u66f4\u597d\u5730\u5229\u7528\u9019\u500b\u6307\u6a19\u4f86\u505a\u51fa\u660e\u667a\u7684\u6295\u8cc7\u6c7a\u7b56\u3002<\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<p>**Q1: \u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA1: \u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u662f\u57fa\u65bc\u80a1\u7968\u5e02\u503c\u6bd4\u7387\u7684\u6280\u8853\u5206\u6790\u6307\u6a19\uff0c\u7528\u65bc\u5224\u65b7\u80a1\u7968\u50f9\u683c\u662f\u5426\u5408\u7406\u3002<\/p>\n<p>**Q2: \u5982\u4f55\u4f7f\u7528 Python \u8a08\u7b97\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff1f**<br \/>\nA2: \u60a8\u53ef\u4ee5\u4f7f\u7528 Pandas \u51fd\u5f0f\u5eab\u8a08\u7b9720\u65e5\u79fb\u52d5\u5e73\u5747\uff0c\u4e26\u6839\u64da\u6b64\u8a08\u7b97\u5e02\u503c\u6bd4\u901a\u9053\u7684\u4e0a\u4e0b\u9650\u3002<\/p>\n<p>**Q3: \u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\u7684\u6700\u4f73\u4ea4\u6613\u6642\u6a5f\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA3: \u7576\u5e02\u503c\u6bd4\u7387\u8d85\u904e\u4e0a\u9650\u6642\u53ef\u8003\u616e\u8ce3\u51fa\uff0c\u4f4e\u65bc\u4e0b\u9650\u6642\u53ef\u8003\u616e\u8cb7\u5165\uff0c\u9019\u4e9b\u662f\u57fa\u672c\u7684\u4ea4\u6613\u4fe1\u865f\u3002<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053(Stock-to-MarketRatioChannel)\u662f\u4e00\u7a2e\u4ea4\u6613\u6307\u6a19\uff0c\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5206\u6790\u80a1\u7968\u5e02\u5834\uff0c\u4e26\u63d0\u4f9b\u6295\u8cc7\u8005\u66f4\u591a\u7684\u4ea4\u6613\u6a5f\u6703\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Python\u4f86\u5206\u6790\u80a1\u7968\u5e02\u503c\u6bd4\u901a\u9053\uff0c\u4ee5\u53ca\u5982\u4f55\u5229\u7528\u5b83\u4f86\u66f4\u597d\u5730\u4ea4\u6613\u80a1\u7968\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-6332","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-1E8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6332","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=6332"}],"version-history":[{"count":2,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6332\/revisions"}],"predecessor-version":[{"id":12726,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6332\/revisions\/12726"}],"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=6332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}