{"id":6408,"date":"2025-06-03T15:01:55","date_gmt":"2025-06-04T07:21:55","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6408"},"modified":"2025-06-04T15:01:55","modified_gmt":"2025-06-04T07:21:55","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e9%9a%a8%e6%a9%9f%e6%8c%87%e6%a8%99%e5%b8%b6kdbands%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%e4%bd%bf%e7%94%a8%e9%9a%a8%e6%a9%9f%e6%8c%87%e6%a8%99%e5%b8%b6kdbands%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99\/","title":{"rendered":"\u6df1\u5165\u5b78\u7fd2 Python \u7684 KD Bands \u4ea4\u6613\u6307\u6a19\uff1a2025 \u6700\u65b0\u5be6\u4f5c\u8207\u6700\u4f73\u5be6\u8e10"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, KD Bands, \u4ea4\u6613\u6307\u6a19, \u96a8\u6a5f\u6307\u6a19\u5e36, \u80a1\u7968\u5206\u6790, \u6280\u8853\u5206\u6790, Python \u5be6\u4f5c\"><\/p>\n<p>KD Bands\uff08\u96a8\u6a5f\u6307\u6a19\u5e36\uff09\u662f\u4e00\u7a2e\u5728\u6280\u8853\u5206\u6790\u4e2d\u5ee3\u6cdb\u4f7f\u7528\u7684\u4ea4\u6613\u6307\u6a19\uff0c\u80fd\u5e6b\u52a9\u6295\u8cc7\u8005\u6e96\u78ba\u5224\u65b7\u80a1\u7968\u50f9\u683c\u7684\u8d70\u52e2\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 Python \u5be6\u4f5c KD Bands \u6307\u6a19\uff0c\u4e26\u63d0\u4f9b\u6700\u65b0\u7684 2025 \u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10\uff0c\u8b93\u4f60\u5728\u6295\u8cc7\u6c7a\u7b56\u4e2d\u66f4\u52a0\u5f97\u5fc3\u61c9\u624b\u3002<\/p>\n<h2>KD Bands\u7684\u4f7f\u7528\u6642\u6a5f<\/h2>\n<p>KD Bands \u6307\u6a19\u901a\u5e38\u7528\u65bc\u4ee5\u4e0b\u60c5\u5883\uff1a<br \/>\n&#8211; **\u8d85\u8cb7\u8207\u8d85\u8ce3\u5224\u65b7**\uff1a\u7576\u6307\u6a19\u63a5\u8fd1\u4e0a\u5e36\u6642\uff0c\u53ef\u80fd\u4ee3\u8868\u8d85\u8cb7\uff1b\u63a5\u8fd1\u4e0b\u5e36\u6642\uff0c\u5247\u53ef\u80fd\u4ee3\u8868\u8d85\u8ce3\u3002<br \/>\n&#8211; **\u8da8\u52e2\u53cd\u8f49\u4fe1\u865f**\uff1a\u7d50\u5408\u5176\u4ed6\u6280\u8853\u6307\u6a19\u4f7f\u7528\u6642\uff0c\u53ef\u4ee5\u5f37\u5316\u8da8\u52e2\u53cd\u8f49\u7684\u4fe1\u865f\u5224\u65b7\u3002<br \/>\n&#8211; **\u4ea4\u6613\u7b56\u7565\u7684\u8f14\u52a9\u5de5\u5177**\uff1a\u6295\u8cc7\u8005\u53ef\u4ee5\u5229\u7528 KD Bands \u6307\u6a19\u5236\u5b9a\u66f4\u7cbe\u78ba\u7684\u9032\u51fa\u5834\u7b56\u7565\u3002<\/p>\n<h2>KD Bands\u7684Python\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528 Python \u4f86\u8a08\u7b97 KD Bands \u7684\u5b8c\u6574\u7bc4\u4f8b\uff0c\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5206\u6790\u80a1\u7968\u50f9\u683c\u7684\u8b8a\u5316\u3002\u8acb\u78ba\u4fdd\u5df2\u5b89\u88dd `numpy` \u548c `pandas` \u51fd\u5f0f\u5eab\u3002<\/p>\n<p>&#8220;`python<br \/>\n# \u8f09\u5165\u6240\u9700\u7684\u51fd\u5f0f\u5eab<br \/>\nimport numpy as np<br \/>\nimport pandas as pd<\/p>\n<p># \u8a08\u7b97KD Bands<br \/>\ndef kd_bands(data, period):<br \/>\n    # \u8a08\u7b97RSV<br \/>\n    rsv = (data[&#8216;Close&#8217;] &#8211; data[&#8216;Low&#8217;].rolling(period).min()) \/ (data[&#8216;High&#8217;].rolling(period).max() &#8211; data[&#8216;Low&#8217;].rolling(period).min()) * 100<br \/>\n    # \u8a08\u7b97K\u503c<br \/>\n    k = pd.Series(np.zeros(len(data)), index=data.index)<br \/>\n    k[period-1] = 50<br \/>\n    for i in range(period, len(data)):<br \/>\n        k[i] = (1\/3) * rsv[i] + (2\/3) * k[i-1]\n    # \u8a08\u7b97D\u503c<br \/>\n    d = pd.Series(np.zeros(len(data)), index=data.index)<br \/>\n    d[period-1] = 50<br \/>\n    for i in range(period, len(data)):<br \/>\n        d[i] = (1\/3) * k[i] + (2\/3) * d[i-1]\n    # \u8a08\u7b97\u4e0a\u8f49\u79fb\u5e36\u8207\u4e0b\u8f49\u79fb\u5e36<br \/>\n    up_band = k + (2 * (d &#8211; k))<br \/>\n    low_band = k &#8211; (2 * (d &#8211; k))<br \/>\n    # \u5c07\u8a08\u7b97\u7d50\u679c\u5b58\u5165dataframe<br \/>\n    data[&#8216;K&#8217;] = k<br \/>\n    data[&#8216;D&#8217;] = d<br \/>\n    data[&#8216;Upper Band&#8217;] = up_band<br \/>\n    data[&#8216;Lower Band&#8217;] = low_band<br \/>\n    return data<\/p>\n<p># \u5047\u8a2d\u6709\u4e00\u500b\u540d\u70ba &#8216;data&#8217; \u7684 DataFrame\uff0c\u5305\u542b &#8216;Close&#8217;, &#8216;High&#8217; \u548c &#8216;Low&#8217; \u6b04\u4f4d<br \/>\ndata = kd_bands(data, period=14)  # \u9019\u88e1\u7684 period \u53ef\u4ee5\u6839\u64da\u9700\u6c42\u8abf\u6574<br \/>\n&#8220;`<\/p>\n<p>\u9019\u6bb5\u7a0b\u5f0f\u78bc\u8a08\u7b97\u4e86 KD Bands \u6307\u6a19\uff0c\u4f7f\u5f97\u6295\u8cc7\u8005\u80fd\u5920\u66f4\u6709\u6548\u5730\u5206\u6790\u5e02\u5834\u8d70\u52e2\u3002\u8acb\u6ce8\u610f\uff0c`data` \u9700\u8981\u662f\u4e00\u500b\u5305\u542b\u80a1\u50f9\u8cc7\u8a0a\u7684 `DataFrame`\uff0c\u5982 `Close`, `High`, `Low` \u6b04\u4f4d\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u6280\u8853\u5206\u6790\u548c Python \u5be6\u4f5c\u7684\u77e5\u8b58\uff0c\u53ef\u4ee5\u53c3\u8003 [\u9019\u7bc7\u6587\u7ae0](https:\/\/miner.tw\/python-technical-analysis)\uff0c\u5176\u4e2d\u63d0\u4f9b\u4e86\u8a31\u591a\u5be6\u7528\u7684\u6559\u5b78\u8207\u7bc4\u4f8b\u3002<\/p>\n<h2>\u5e38\u898b\u554f\u984c\u89e3\u7b54 (Q&#038;A)<\/h2>\n<p>**Q1: KD Bands \u6307\u6a19\u5982\u4f55\u8207\u5176\u4ed6\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff1f**<br \/>\nA: KD Bands \u53ef\u4ee5\u8207\u5982\u79fb\u52d5\u5e73\u5747\u7dda\u3001\u76f8\u5c0d\u5f37\u5f31\u6307\u6a19\uff08RSI\uff09\u7b49\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\uff0c\u9019\u6a23\u53ef\u4ee5\u589e\u5f37\u4ea4\u6613\u4fe1\u865f\u7684\u6e96\u78ba\u6027\uff0c\u5e6b\u52a9\u6295\u8cc7\u8005\u5236\u5b9a\u66f4\u5177\u4f9d\u64da\u7684\u4ea4\u6613\u7b56\u7565\u3002<\/p>\n<p>**Q2: \u4f7f\u7528 KD Bands \u6307\u6a19\u6642\u9700\u8981\u6ce8\u610f\u4ec0\u9ebc\uff1f**<br \/>\nA: \u6295\u8cc7\u8005\u5728\u4f7f\u7528 KD Bands \u6642\uff0c\u61c9\u8a72\u6ce8\u610f\u5e02\u5834\u7684\u6574\u9ad4\u8da8\u52e2\uff0c\u4e26\u7d50\u5408\u5176\u4ed6\u6280\u8853\u6307\u6a19\u9032\u884c\u591a\u91cd\u78ba\u8a8d\uff0c\u4ee5\u907f\u514d\u56e0\u55ae\u4e00\u6307\u6a19\u7522\u751f\u7684\u8aa4\u5224\u3002<\/p>\n<p>**Q3: \u5982\u4f55\u9078\u64c7 KD Bands \u7684\u53c3\u6578\uff1f**<br \/>\nA: KD Bands \u7684\u53c3\u6578\uff0c\u5982\u8a08\u7b97\u5468\u671f\uff0c\u61c9\u6839\u64da\u4e0d\u540c\u7684\u5e02\u5834\u74b0\u5883\u548c\u4ea4\u6613\u7b56\u7565\u9032\u884c\u8abf\u6574\u3002\u4e00\u822c\u4f86\u8aaa\uff0c\u8f03\u77ed\u7684\u5468\u671f\u9069\u5408\u77ed\u671f\u4ea4\u6613\uff0c\u800c\u8f03\u9577\u7684\u5468\u671f\u5247\u9069\u5408\u9577\u671f\u6295\u8cc7\u3002<\/p>\n<p>\u9019\u7bc7\u6587\u7ae0\u5c07\u5e6b\u52a9\u4f60\u66f4\u6df1\u5165\u4e86\u89e3 KD Bands \u6307\u6a19\u7684\u4f7f\u7528\uff0c\u4e26\u63d0\u4f9b\u6700\u65b0\u7684 Python \u5be6\u4f5c\u7bc4\u4f8b\uff0c\u52a9\u4f60\u5728\u80a1\u7968\u5e02\u5834\u4e2d\u7372\u5f97\u66f4\u597d\u7684\u4ea4\u6613\u7d50\u679c\u3002<br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aKDBands\u662f\u4e00\u7a2e\u4ea4\u6613\u6307\u6a19\uff0c\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5206\u6790\u5e02\u5834\u8da8\u52e2\uff0c\u4e26\u63d0\u4f9b\u66f4\u597d\u7684\u4ea4\u6613\u6a5f\u6703\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Python\u4f86\u5206\u6790KDBands\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u7bc4\u4f8b\u4f86\u89e3\u91cb\u5982\u4f55\u4f7f\u7528\u5b83\u5011\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-6408","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-1Fm","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6408","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=6408"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6408\/revisions"}],"predecessor-version":[{"id":6409,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6408\/revisions\/6409"}],"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=6408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}