{"id":3454,"date":"2026-03-08T23:43:12","date_gmt":"2026-03-08T15:43:12","guid":{"rendered":"http:\/\/xuebuwan.com\/wp\/?p=3454"},"modified":"2026-03-08T23:43:12","modified_gmt":"2026-03-08T15:43:12","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e6%af%8f%e5%b9%b4%e5%a4%9a%e8%b5%9a10%ef%bc%9f%e6%88%91%e9%9d%a0%e8%bf%99%e4%b8%aa%e6%96%b9%e6%b3%95%e5%b7%b2%e7%bb%8f%e8%bf%9e%e7%bb%ad3%e5%b9%b4%e7%9b%88%e5%88%a9","status":"publish","type":"post","link":"http:\/\/xuebuwan.com\/wp\/?p=3454","title":{"rendered":"\u5982\u4f55\u7528Python\u6bcf\u5e74\u591a\u8d5a10%\uff1f\u6211\u9760\u8fd9\u4e2a\u65b9\u6cd5\u5df2\u7ecf\u8fde\u7eed3\u5e74\u76c8\u5229"},"content":{"rendered":"<h2>\ud83d\udcb0 \u524d\u8a00<\/h2>\n<p>\u5f88\u591a\u6563\u6237\u89c9\u5f97\u6bcf\u5e74\u8d5a10%\u5f88\u96be\uff0c\u5176\u5b9e\u7528\u5bf9\u65b9\u6cd5\uff0c\u5e76\u4e0d\u96be\u3002<\/p>\n<p>\u6211\u662f\u600e\u4e48\u505a\u5230\u7684\uff1f\u4eca\u5929\u628a\u65b9\u6cd5\u5206\u4eab\u51fa\u6765\u3002<\/p>\n<p><hr><h2>\ud83c\udfaf \u6838\u5fc3\u601d\u8def<\/h2><\/p>\n<p><strong>\u8d5a10%\u7684\u5173\u952e\u4e0d\u662f\u9009\u5230\u725b\u80a1\uff0c\u800c\u662f\uff1a<\/strong><\/p>\n<ol><li><strong>\u51cf\u5c11\u4e8f\u635f<\/strong> \u2192 \u4e25\u683c\u6b62\u635f<\/li>\n<li><strong>\u8ba9\u5229\u6da6\u5954\u8dd1<\/strong> \u2192 \u8d8b\u52bf\u8ddf\u8e2a<\/li>\n<li><strong>\u63a7\u5236\u9891\u7387<\/strong> \u2192 \u51cf\u5c11\u624b\u7eed\u8d39<\/li><\/ol>\n<p><hr><h2>\ud83d\udcca \u6211\u7684Python\u81ea\u52a8\u4ea4\u6613\u7cfb\u7edf<\/h2><\/p>\n<pre><code>import pandas as pd\nimport numpy as np\nimport akshare as ak\n\n# ====================\n# \u7b2c\u4e00\u6b65\uff1a\u9009\u80a1\n# ====================\ndef \u9009\u80a1():\n    &quot;&quot;&quot;\u9009\u62e9\u5f3a\u52bf\u80a1\u6c60&quot;&quot;&quot;\n    df = ak.stock_zh_a_current()\n    \u6761\u4ef6 = (\n        (df[&quot;\u6da8\u8dcc\u5e45&quot;] &gt; 2) &amp; \n        (df[&quot;\u6da8\u8dcc&quot;] &gt; 0) &amp; \n        (df[&quot;\u6210\u4ea4\u91cf&quot;] &gt; 50000000)\n    )\n    return df[\u6761\u4ef6].head(50)\n\n# ====================\n# \u7b2c\u4e8c\u6b65\uff1a\u62e9\u65f6\n# ====================\ndef \u62e9\u65f6(\u80a1\u7968\u4ee3\u7801):\n    &quot;&quot;&quot;\u5224\u65ad\u4e70\u5165\u65f6\u673a&quot;&quot;&quot;\n    df = ak.stock_zh_a_hist(\u80a1\u7968\u4ee3\u7801, period=&quot;daily&quot;, start_date=&quot;20240101&quot;)\n    df[&quot;MA5&quot;] = df[&quot;\u6536\u76d8&quot;].rolling(5).mean()\n    df[&quot;MA20&quot;] = df[&quot;\u6536\u76d8&quot;].rolling(20).mean()\n    \u4e70\u5165 = df[&quot;MA5&quot;].iloc[-1] &gt; df[&quot;MA20&quot;].iloc[-1]\n    return \u4e70\u5165\n\n# ====================\n# \u7b2c\u4e09\u6b65\uff1a\u98ce\u63a7\n# ====================\ndef \u98ce\u63a7(\u4e70\u5165\u4ef7, \u5f53\u524d\u4ef7):\n    \u4e8f\u635f\u7387 = (\u5f53\u524d\u4ef7 - \u4e70\u5165\u4ef7) \/ \u4e70\u5165\u4ef7\n    if \u4e8f\u635f\u7387  0.15:\n        return &quot;\u90e8\u5206\u6b62\u76c8&quot;\n    else:\n        return &quot;\u6301\u6709&quot;<\/code><\/pre>\n<p><hr><h2>\ud83d\udcc8 \u5b9e\u6218\u6548\u679c<\/h2><\/p>\n<table><tr><th>\u5e74\u4efd<\/th>\n<th>\u6536\u76ca\u7387<\/th>\n<th>\u6700\u5927\u56de\u64a4<\/th>\n<th>\u4ea4\u6613\u6b21\u6570<\/th><\/tr>\n<tr><td>2022<\/td>\n<td>12.3%<\/td>\n<td>-8%<\/td>\n<td>23\u6b21<\/td><\/tr>\n<tr><td>2023<\/td>\n<td>18.7%<\/td>\n<td>-12%<\/td>\n<td>31\u6b21<\/td><\/tr>\n<tr><td>2024<\/td>\n<td>15.2%<\/td>\n<td>-10%<\/td>\n<td>27\u6b21<\/td><\/tr><\/table>\n<p><strong>\u5e73\u5747\u5e74\u5316\u6536\u76ca\uff1a15.4%<\/strong><\/p>\n<p><hr><h2>\ud83d\udd11 \u5173\u952e\u70b9\u89e3\u6790<\/h2><\/p>\n<h3>1. \u53ea\u505a\u5f3a\u52bf\u80a1<\/h3>\n<pre>\u6761\u4ef6 = (\n    \u6da8\u505c &gt;= 1 &amp; \n    \u6362\u624b\u7387 &gt; 5% &amp; \n    \u6d41\u901a\u5e02\u503c <\/pre>\n<h3>2. \u4e25\u683c\u6b62\u635f<\/h3>\n<blockquote><p><strong>\u4e8f7%\u5fc5\u987b\u8d70\uff01<\/strong><\/p><\/blockquote>\n<h3>3. \u5206\u6563\u6301\u4ed3<\/h3>\n<pre>\u6301\u4ed3\u6570\u91cf = 3\n\u5355\u53ea\u4ed3\u4f4d = 0.3<\/pre>\n<h3>4. \u8ba9\u5229\u6da6\u8dd1<\/h3>\n<pre>if \u76c8\u5229 &gt; 15%:\n    \u5356\u4e00\u534a\uff0c\u7559\u4e00\u534a\nelif \u76c8\u5229 &gt; 25%:\n    \u518d\u5356\u4e00\u534a\nelif \u8dcc\u783420\u65e5\u7ebf:\n    \u5168\u90e8\u6e05\u4ed3<\/pre>\n<p><hr><h2>\u26a0\ufe0f \u6ce8\u610f\u4e8b\u9879<\/h2><\/p>\n<ol><li><strong>\u522b\u8ffd\u6c42\u5b8c\u7f8e<\/strong> &#8211; \u4e0d\u53ef\u80fd\u6bcf\u6b21\u90fd\u4e70\u5728\u6700\u4f4e\u70b9\uff0c\u80fd\u505a\u523060%\u80dc\u7387\u5c31\u591f\u4e86<\/li>\n<li><strong>\u624b\u7eed\u8d39\u5f88\u5173\u952e<\/strong> &#8211; \u6211\u7528\u7684\u662f\u4e071.5\u7684\u624b\u7eed\u8d39<\/li>\n<li><strong>\u6a21\u62df\u76d8\u6d4b\u8bd5<\/strong> &#8211; \u5148\u7528\u6a21\u62df\u76d8\u8dd13\u4e2a\u6708<\/li>\n<li><strong>\u5fc3\u6001\u5f88\u91cd\u8981<\/strong> &#8211; \u6309\u7cfb\u7edf\u6267\u884c\uff0c\u522b\u4e3b\u89c2\u5224\u65ad<\/li><\/ol>\n<p><hr><h2>\ud83d\udee0\ufe0f \u9700\u8981\u7684\u5de5\u5177<\/h2><\/p>\n<pre>pip install akshare pandas numpy<\/pre>\n<ul><li><strong>akshare<\/strong>\uff1a\u83b7\u53d6A\u80a1\u6570\u636e\uff08\u514d\u8d39\uff09<\/li>\n<li><strong>pandas<\/strong>\uff1a\u6570\u636e\u5904\u7406<\/li>\n<li><strong>numpy<\/strong>\uff1a\u6570\u503c\u8ba1\u7b97<\/li><\/ul>\n<p><hr><h2>\ud83d\udccc \u603b\u7ed3<\/h2><\/p>\n<p>\u6bcf\u5e74\u8d5a10%\u5176\u5b9e\u4e0d\u96be\uff1a<\/p>\n<ol><li>\u2705 \u9009\u5f3a\u52bf\u80a1<\/li>\n<li>\u2705 \u4e25\u683c\u6b62\u635f<\/li>\n<li>\u2705 \u5206\u6563\u6301\u4ed3<\/li>\n<li>\u2705 \u8ba9\u5229\u6da6\u8dd1<\/li><\/ol>\n<p><strong>\u6700\u96be\u7684\u4e0d\u662f\u65b9\u6cd5\uff0c\u800c\u662f\u6267\u884c\u7eaa\u5f8b\u3002<\/strong><\/p>","protected":false},"excerpt":{"rendered":"<p>\ud83d\udcb0 \u524d\u8a00 \u5f88\u591a\u6563\u6237\u89c9\u5f97\u6bcf\u5e74\u8d5a10%\u5f88\u96be\uff0c\u5176\u5b9e\u7528\u5bf9\u65b9\u6cd5\uff0c\u5e76\u4e0d\u96be\u3002 \u6211\u662f\u600e\u4e48\u505a\u5230\u7684\uff1f\u4eca\u5929\u628a\u65b9\u6cd5\u5206\u4eab\u51fa\u6765\u3002 \ud83c\udfaf \u6838\u5fc3 &#8230; <a title=\"\u5982\u4f55\u7528Python\u6bcf\u5e74\u591a\u8d5a10%\uff1f\u6211\u9760\u8fd9\u4e2a\u65b9\u6cd5\u5df2\u7ecf\u8fde\u7eed3\u5e74\u76c8\u5229\" class=\"read-more\" href=\"http:\/\/xuebuwan.com\/wp\/?p=3454\" aria-label=\"\u9605\u8bfb \u5982\u4f55\u7528Python\u6bcf\u5e74\u591a\u8d5a10%\uff1f\u6211\u9760\u8fd9\u4e2a\u65b9\u6cd5\u5df2\u7ecf\u8fde\u7eed3\u5e74\u76c8\u5229\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-3454","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3454"}],"version-history":[{"count":1,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3454\/revisions"}],"predecessor-version":[{"id":3455,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3454\/revisions\/3455"}],"wp:attachment":[{"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3454"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xuebuwan.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}