{"id":6056,"date":"2025-06-01T15:04:10","date_gmt":"2025-06-04T07:57:10","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6056"},"modified":"2025-06-04T15:04:10","modified_gmt":"2025-06-04T07:57:10","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8python%e4%b8%ad%e7%9a%84adx%e6%8c%87%e6%a8%99%e6%8f%90%e5%8d%87%e4%ba%a4%e6%98%93%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8python%e4%b8%ad%e7%9a%84adx%e6%8c%87%e6%a8%99%e6%8f%90%e5%8d%87%e4%ba%a4%e6%98%93%e6%8a%80%e5%b7%a7\/","title":{"rendered":"\u5229\u7528Python\u63d0\u5347\u4ea4\u6613\u6280\u5de7\uff1a\u6df1\u5165\u5206\u6790\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u6307\u6a19"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, \u5e73\u5747\u8da8\u5411\u6307\u6578, ADX, \u4ea4\u6613\u6307\u6a19, \u4f7f\u7528\u6642\u6a5f\"><\/p>\n<h1>\u5229\u7528Python\u63d0\u5347\u4ea4\u6613\u6280\u5de7\uff1a\u6df1\u5165\u5206\u6790\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u6307\u6a19<\/h1>\n<p>\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u662f\u4e00\u500b\u95dc\u9375\u7684\u6280\u8853\u6307\u6a19\uff0c\u7528\u65bc\u8a55\u4f30\u5e02\u5834\u8da8\u52e2\u7684\u5f37\u5ea6\u3002\u900f\u904e\u6b63\u78ba\u5730\u4f7f\u7528ADX\u6307\u6a19\uff0c\u6295\u8cc7\u8005\u80fd\u5920\u66f4\u6709\u6548\u5730\u5236\u5b9a\u4ea4\u6613\u7b56\u7565\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u57282025\u5e74\u4f7f\u7528Python\u5be6\u73feADX\u6307\u6a19\uff0c\u4e26\u63d0\u4f9b\u6700\u4f73\u5be6\u8e10\u3001\u5be6\u4f5c\u7bc4\u4f8b\u53ca\u932f\u8aa4\u6392\u9664\u5efa\u8b70\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)<\/h2>\n<p>\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u662f\u5e02\u5834\u5206\u6790\u5e2bWelles Wilder\u65bc1978\u5e74\u63d0\u51fa\u7684\u6280\u8853\u6307\u6a19\uff0c\u65e8\u5728\u5e6b\u52a9\u6295\u8cc7\u8005\u5206\u6790\u8da8\u52e2\u7684\u5f37\u5ea6\u3002ADX\u6307\u6a19\u7531\u4e09\u500b\u90e8\u5206\u7d44\u6210\uff1a<\/p>\n<ul>\n<li>+DI\uff08\u6b63\u5411\u8da8\u5411\u6307\u6578\uff09\uff1a\u53cd\u6620\u80a1\u50f9\u4e0a\u6f32\u7684\u8da8\u52e2\u5f37\u5ea6\u3002<\/li>\n<li>-DI\uff08\u8ca0\u5411\u8da8\u5411\u6307\u6578\uff09\uff1a\u53cd\u6620\u80a1\u50f9\u4e0b\u8dcc\u7684\u8da8\u52e2\u5f37\u5ea6\u3002<\/li>\n<li>ADX\uff08\u5e73\u5747\u8da8\u5411\u6307\u6578\uff09\uff1a\u8868\u793a\u6574\u9ad4\u5e02\u5834\u8da8\u52e2\u7684\u5f37\u5ea6\u3002<\/li>\n<\/ul>\n<p>ADX\u7684\u503c\u4ecb\u65bc0\u5230100\u4e4b\u9593\uff0c\u8d8a\u9ad8\u7684\u503c\u4ee3\u8868\u8457\u8d8a\u5f37\u7684\u8da8\u52e2\u3002<\/p>\n<h2>ADX\u6307\u6a19\u7684\u4f7f\u7528\u6642\u6a5f<\/h2>\n<p>\u5728\u4ea4\u6613\u4e2d\uff0cADX\u6307\u6a19\u4e3b\u8981\u7528\u65bc\u5224\u65b7\u5e02\u5834\u8da8\u52e2\u7684\u5f37\u5f31\u3002\u7576ADX\u6307\u6a19\u7684\u503c\u5927\u65bc25\u6642\uff0c\u986f\u793a\u5e02\u5834\u8da8\u52e2\u8f03\u5f37\uff0c\u6295\u8cc7\u8005\u61c9\u8003\u616e\u9032\u884c\u4ea4\u6613\uff0c\u800c\u7576\u6307\u6a19\u503c\u5c0f\u65bc20\u6642\uff0c\u5247\u5efa\u8b70\u89c0\u671b\u4ee5\u907f\u514d\u640d\u5931\u3002<\/p>\n<p>&#8211; **\u505a\u591a\u7b56\u7565**\uff1a\u7576+DI\u5927\u65bc-DI\u6642\uff0c\u5e02\u5834\u8da8\u52e2\u5411\u4e0a\uff0c\u8003\u616e\u9032\u5834\u505a\u591a\u3002<br \/>\n&#8211; **\u505a\u7a7a\u7b56\u7565**\uff1a\u7576-DI\u5927\u65bc+DI\u6642\uff0c\u5e02\u5834\u8da8\u52e2\u5411\u4e0b\uff0c\u8003\u616e\u9032\u5834\u505a\u7a7a\u3002<\/p>\n<h2>\u4f7f\u7528Python\u5be6\u73feADX\u6307\u6a19<\/h2>\n<p>\u4ee5\u4e0b\u662f\u66f4\u65b0\u7248\u7684Python\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0c\u5c55\u793a\u5982\u4f55\u8a08\u7b97ADX\u6307\u6a19\uff0c\u4f7f\u7528\u4e862025\u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<p>&#8220;`python<br \/>\nimport pandas as pd<br \/>\nimport numpy as np<\/p>\n<p># \u8b80\u53d6\u8cc7\u6599<br \/>\ndf = pd.read_csv(&#8216;data.csv&#8217;)<\/p>\n<p># \u8a08\u7b97\u6536\u76e4\u50f9\u7684\u6f32\u8dcc\u5e45<br \/>\ndf[&#8216;change&#8217;] = df[&#8216;close&#8217;].diff()<\/p>\n<p># \u8a08\u7b97+DI\u548c-DI<br \/>\ndf[&#8216;+DI&#8217;] = np.where(df[&#8216;change&#8217;] > 0, df[&#8216;change&#8217;], 0)<br \/>\ndf[&#8216;-DI&#8217;] = np.where(df[&#8216;change&#8217;] < 0, abs(df['change']), 0)\n\n# \u8a08\u7b97+DI\u548c-DI\u768414\u65e5\u79fb\u52d5\u5e73\u5747\ndf['+DI_MA'] = df['+DI'].rolling(window=14).mean()\ndf['-DI_MA'] = df['-DI'].rolling(window=14).mean()\n\n# \u8a08\u7b97DI\u5dee\ndf['DI_diff'] = df['+DI_MA'] - df['-DI_MA']\n\n# \u8a08\u7b97DI\u5dee\u7684\u767e\u5206\u6bd4\ndf['DI_diff_percent'] = df['DI_diff'] \/ (df['+DI_MA'] + df['-DI_MA'])\n\n# \u8a08\u7b97ADX\ndf['ADX'] = df['DI_diff_percent'].rolling(window=14).mean()\n\n# \u8f38\u51fa\u7d50\u679c\nprint(df['ADX'])\n```\n\n\u9019\u6bb5\u7a0b\u5f0f\u78bc\u4e0d\u50c5\u80fd\u8a08\u7b97ADX\u6307\u6a19\uff0c\u9084\u6703\u8f38\u51fa\u7d50\u679c\u5230\u63a7\u5236\u53f0\uff0c\u5e6b\u52a9\u60a8\u5feb\u901f\u5206\u6790\u8da8\u52e2\u3002\n\n\n\n<h2>\u932f\u8aa4\u6392\u9664\u5efa\u8b70<\/h2>\n<p>\u5728\u4f7f\u7528ADX\u6307\u6a19\u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u554f\u984c\uff1a<\/p>\n<p>1. **\u8cc7\u6599\u4e0d\u5b8c\u6574**\uff1a\u78ba\u4fdd\u60a8\u7684CSV\u6a94\u6848\u4e2d\u6709\u8db3\u5920\u7684\u6b77\u53f2\u6578\u64da\uff0c\u4ee5\u4fbf\u8a08\u7b97\u79fb\u52d5\u5e73\u5747\u3002<br \/>\n2. **\u7a0b\u5f0f\u78bc\u932f\u8aa4**\uff1a\u78ba\u8a8d\u4f7f\u7528\u6700\u65b0\u7684Python\u8a9e\u6cd5\uff0c\u7279\u5225\u662fPandas\u548cNumPy\u5eab\u7684\u4f7f\u7528\u3002<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u6709\u52a9\u65bc\u6295\u8cc7\u8005\u5224\u65b7\u5e02\u5834\u8da8\u52e2\uff0c\u9032\u800c\u5236\u5b9a\u6709\u6548\u7684\u4ea4\u6613\u7b56\u7565\u3002\u900f\u904e\u672c\u6587\u7684Python\u5be6\u4f5c\u7bc4\u4f8b\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u8a08\u7b97\u4e26\u61c9\u7528ADX\u6307\u6a19\u65bc\u5be6\u969b\u4ea4\u6613\u4e2d\uff0c\u63d0\u5347\u4ea4\u6613\u6280\u80fd\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3Python\u5728\u4ea4\u6613\u4e2d\u7684\u61c9\u7528\uff0c\u8acb\u53c3\u8003 [\u9019\u7bc7\u6559\u5b78\u6587\u7ae0](https:\/\/vocus.cc\/article\/605a4c0efc4c5d001b5d0c77) \u3002<\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<p>**Q1: ADX\u6307\u6a19\u7684\u6700\u4f73\u4f7f\u7528\u7bc4\u570d\u662f\u4ec0\u9ebc\uff1f**<br \/>\nA1: ADX\u6307\u6a19\u4e3b\u8981\u5728\u503c\u5927\u65bc25\u6642\u6709\u6548\uff0c\u9019\u8868\u793a\u5e02\u5834\u6709\u8f03\u5f37\u7684\u8da8\u52e2\u3002<\/p>\n<p>**Q2: \u5982\u4f55\u78ba\u4fdd\u6211\u4f7f\u7528\u7684\u6578\u64da\u662f\u6b63\u78ba\u7684\uff1f**<br \/>\nA2: \u8acb\u6aa2\u67e5CSV\u6a94\u6848\u4e2d\u7684\u6578\u64da\u662f\u5426\u5b8c\u6574\uff0c\u4e26\u78ba\u8a8d\u6578\u64da\u683c\u5f0f\u6b63\u78ba\u3002<\/p>\n<p>**Q3: \u6211\u53ef\u4ee5\u7528ADX\u6307\u6a19\u9032\u884c\u54ea\u4e9b\u7b56\u7565\uff1f**<br \/>\nA3: \u6839\u64da+DI\u548c-DI\u7684\u6bd4\u8f03\uff0c\u60a8\u53ef\u4ee5\u5236\u5b9a\u505a\u591a\u6216\u505a\u7a7a\u7b56\u7565\uff0c\u4e26\u6839\u64daADX\u7684\u503c\u6c7a\u5b9a\u662f\u5426\u9032\u5834\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\u7528Python\u4e2d\u7684\u5e73\u5747\u8da8\u5411\u6307\u6578(ADX)\u6307\u6a19\uff0c\u4f86\u63d0\u5347\u6295\u8cc7\u8005\u7684\u4ea4\u6613\u6280\u5de7\uff0c\u4e26\u63d0\u4f9b\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0c\u8b93\u8b80\u8005\u53ef\u4ee5\u66f4\u6df1\u5165\u7684\u4e86\u89e3ADX\u6307\u6a19\u7684\u4f7f\u7528\u65b9\u5f0f\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-6056","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-1zG","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6056","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=6056"}],"version-history":[{"count":2,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6056\/revisions"}],"predecessor-version":[{"id":12760,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6056\/revisions\/12760"}],"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=6056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}