{"id":3311,"date":"2026-01-06T07:37:00","date_gmt":"2026-01-05T23:37:00","guid":{"rendered":"https:\/\/www.laoyulaoyu.com\/?p=3311"},"modified":"2025-12-22T21:38:03","modified_gmt":"2025-12-22T13:38:03","slug":"%e4%b8%89%e4%b8%aa%e7%ae%80%e5%8d%95python%e7%ad%96%e7%95%a5%e8%ae%a9%e4%bd%a0%e7%9a%84%e4%ba%a4%e6%98%93%e7%b3%bb%e7%bb%9f%e6%9b%b4%e8%81%aa%e6%98%8e","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2026\/01\/06\/%e4%b8%89%e4%b8%aa%e7%ae%80%e5%8d%95python%e7%ad%96%e7%95%a5%e8%ae%a9%e4%bd%a0%e7%9a%84%e4%ba%a4%e6%98%93%e7%b3%bb%e7%bb%9f%e6%9b%b4%e8%81%aa%e6%98%8e\/","title":{"rendered":"\u4e09\u4e2a\u7b80\u5355Python\u7b56\u7565,\u8ba9\u4f60\u7684\u4ea4\u6613\u7cfb\u7edf\u66f4\u806a\u660e"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/0b8491e3-3b40-421b-ad11-f684386b5b52-1024x559.png\" alt=\"\" class=\"wp-image-3312\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/0b8491e3-3b40-421b-ad11-f684386b5b52-1024x559.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/0b8491e3-3b40-421b-ad11-f684386b5b52-300x164.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/0b8491e3-3b40-421b-ad11-f684386b5b52-768x419.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/0b8491e3-3b40-421b-ad11-f684386b5b52.png 1408w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u5f88\u591a\u4eba\u4ee5\u4e3a\u91cf\u5316\u5c31\u662f\u590d\u6742\u7684\u6570\u5b66\u6a21\u578b\u548c\u9ad8\u6df1\u7684\u7b97\u6cd5,\u5176\u5b9e\u4e0d\u7136\uff08\u96be\uff09\u3002\u8fd9\u7bc7\u6587\u7ae0\u4f1a\u5e26\u4f60\u7528Python\u5b9e\u73b0\u4e09\u79cd\u7528\u7684\u6700\u591a\u7684\u7ecf\u5178\u7b56\u7565:\u5747\u7ebf\u4ea4\u53c9\u3001\u5747\u503c\u56de\u5f52\u548c\u8d8b\u52bf\u8ddf\u968f,\u5e76\u544a\u8bc9\u4f60\u5728\u4ec0\u4e48\u5e02\u573a\u73af\u5883\u4e0b\u8be5\u7528\u54ea\u4e00\u4e2a\u3002<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4e0d\u7528\u6015\uff0c\u8ddf\u7740\u6211\uff0c\u4e00\u6b65\u6b65\u6765\uff0c\u4f60\u4e5f\u80fd\u63a8\u5f00\u91cf\u5316\u4e16\u754c\u7684\u5927\u95e8\u3002<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u4e3a\u4ec0\u4e48\u7b80\u5355\u7684\u7b56\u7565\u5f80\u5f80\u66f4\u6709\u6548?<\/strong><\/h2>\n\n\n\n<p>\u5728\u91cf\u5316\u4ea4\u6613\u9886\u57df\u6478\u722c\u6eda\u6253\u8fd9\u4e48\u591a\u5e74,\u6211\u53d1\u73b0\u4e00\u4e2a\u6709\u8da3\u7684\u73b0\u8c61:\u8bb8\u591a\u6563\u6237\u6295\u8d44\u8005\u603b\u662f\u8ffd\u6c42\u590d\u6742\u7684\u7b97\u6cd5\u548c\u9ad8\u6df1\u7684\u6a21\u578b,\u89c9\u5f97\u8d8a\u590d\u6742\u8d8a\u5389\u5bb3\u3002\u4f46\u4e8b\u5b9e\u4e0a,\u534e\u5c14\u8857\u90a3\u4e9b\u9876\u7ea7\u5bf9\u51b2\u57fa\u91d1\u7684\u6838\u5fc3\u7b56\u7565,\u5f80\u5f80\u7b80\u5355\u5f97\u8ba9\u4eba\u610f\u5916\u3002<\/p>\n\n\n\n<p>\u590d\u6742\u5e76\u4e0d\u7b49\u4e8e\u6709\u6548\u3002\u5c31\u50cf\u79d1\u5b66\u7814\u7a76\u548c\u5e02\u573a\u8425\u9500\u4e00\u6837,\u5728\u4ea4\u6613\u4e2d,\u7b80\u5355\u3001\u7ecf\u8fc7\u5145\u5206\u6d4b\u8bd5\u7684\u7b56\u7565,\u5f80\u5f80\u80fd\u5728\u957f\u671f\u5185\u8dd1\u8d62\u90a3\u4e9b\u770b\u8d77\u6765\u5f88\u70ab\u9177\u7684\u590d\u6742\u6a21\u578b\u3002\u5173\u952e\u4e0d\u5728\u4e8e\u7b56\u7565\u6709\u591a\u590d\u6742,\u800c\u5728\u4e8e\u4f60\u80fd\u4e0d\u80fd\u4e25\u683c\u6267\u884c,\u80fd\u4e0d\u80fd\u505a\u597d\u98ce\u9669\u7ba1\u7406,\u80fd\u4e0d\u80fd\u5728\u6b63\u786e\u7684\u65f6\u95f4\u7528\u5bf9\u6b63\u786e\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p><strong>\ud83d\udca1 \u8001\u4f59\u7684\u7ecf\u9a8c\u4e4b\u8c08:<\/strong><br>\u6211\u89c1\u8fc7\u592a\u591a\u4eba\u5728\u56de\u6d4b\u65f6\u62ff\u5230\u6f02\u4eae\u7684\u6570\u636e,\u4f46\u4e00\u5230\u5b9e\u76d8\u5c31\u4e8f\u5f97\u4e00\u584c\u7cca\u6d82\u3002\u539f\u56e0\u5c31\u662f\u7b56\u7565\u592a\u590d\u6742,\u6267\u884c\u8d77\u6765\u53d8\u5f62\u8d70\u6837\u3002\u8bb0\u4f4f\u4e00\u53e5\u8bdd:\u80fd\u575a\u6301\u6267\u884c\u7684\u7b80\u5355\u7b56\u7565,\u6c38\u8fdc\u5f3a\u8fc7\u53ea\u80fd\u770b\u4e0d\u80fd\u7528\u7684\u590d\u6742\u6a21\u578b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u4e09\u5927\u6838\u5fc3\u7b56\u7565\u8be6\u89e3<\/strong><\/h2>\n\n\n\n<p>\u63a5\u4e0b\u6765,\u6211\u4f1a\u8be6\u7ec6\u8bb2\u89e3\u4e09\u79cd\u6700\u7ecf\u5178\u3001\u6700\u5b9e\u7528\u7684\u91cf\u5316\u7b56\u7565\u3002\u8fd9\u4e9b\u7b56\u7565\u6211\u7684\u56e2\u961f\u5728\u5b9e\u76d8\u4e2d\u90fd\u9a8c\u8bc1\u8fc7,\u6548\u679c\u7a33\u5b9a\u53ef\u9760\u3002\u66f4\u91cd\u8981\u7684\u662f,\u5b83\u4eec\u7b80\u5355\u6613\u61c2,\u65b0\u624b\u4e5f\u80fd\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b56\u7565\u4e00:\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565 &#8211; \u8d8b\u52bf\u5e02\u573a\u7684\u5229\u5668<\/strong><\/h3>\n\n\n\n<p>\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565,\u8bf4\u767d\u4e86\u5c31\u662f\u7528\u4e24\u6761\u79fb\u52a8\u5e73\u5747\u7ebf\u7684\u4ea4\u53c9\u70b9\u6765\u5224\u65ad\u4f55\u65f6\u8be5\u5165\u573a\u3001\u4f55\u65f6\u8be5\u79bb\u573a\u3002\u8fd9\u4e2a\u7b56\u7565\u5728\u5e02\u573a\u6709\u660e\u786e\u8d8b\u52bf\u7684\u65f6\u5019\u7279\u522b\u597d\u7528\u3002<\/p>\n\n\n\n<p><strong>\u5de5\u4f5c\u539f\u7406:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8bbe\u7f6e\u4e24\u6761\u79fb\u52a8\u5e73\u5747\u7ebf:\u4e00\u6761\u77ed\u671f(\u6bd4\u598250\u5929),\u4e00\u6761\u957f\u671f(\u6bd4\u5982200\u5929)<\/li>\n\n\n\n<li>\u5f53\u77ed\u671f\u5747\u7ebf\u4ece\u4e0b\u5f80\u4e0a\u7a7f\u8fc7\u957f\u671f\u5747\u7ebf\u65f6,\u8fd9\u53eb&#8221;\u9ec4\u91d1\u4ea4\u53c9&#8221;,\u5e02\u573a\u53ef\u80fd\u8981\u6da8,\u53ef\u4ee5\u8003\u8651\u5165\u573a<\/li>\n\n\n\n<li>\u5f53\u77ed\u671f\u5747\u7ebf\u4ece\u4e0a\u5f80\u4e0b\u7a7f\u8fc7\u957f\u671f\u5747\u7ebf\u65f6,\u8fd9\u53eb&#8221;\u6b7b\u4ea1\u4ea4\u53c9&#8221;,\u5e02\u573a\u53ef\u80fd\u8981\u8dcc,\u53ef\u4ee5\u8003\u8651\u79bb\u573a<\/li>\n<\/ul>\n\n\n\n<p><strong>\ud83d\udcca \u9002\u7528\u573a\u666f:<\/strong><br>\u5f53\u5e02\u573a\u5904\u4e8e\u5355\u8fb9\u884c\u60c5\u65f6,\u4e0d\u8bba\u662f\u4e0a\u6da8\u8fd8\u662f\u4e0b\u8dcc,\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u90fd\u80fd\u5e2e\u4f60\u6355\u6349\u5230\u4e3b\u8981\u8d8b\u52bf\u3002\u4f46\u8981\u6ce8\u610f,\u5728\u9707\u8361\u5e02\u4e2d\u8fd9\u4e2a\u7b56\u7565\u4f1a\u9891\u7e41\u53d1\u51fa\u9519\u8bef\u4fe1\u53f7,\u5bfc\u81f4\u6765\u56de\u88ab&#8221;\u6253\u8138&#8221;\u3002<\/p>\n\n\n\n<p><strong>\u4f18\u52bf\u5206\u6790:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u80fd\u591f\u6709\u6548\u8fc7\u6ee4\u77ed\u671f\u5e02\u573a\u566a\u97f3,\u4e13\u6ce8\u4e8e\u4e3b\u8981\u8d8b\u52bf<\/li>\n\n\n\n<li>\u64cd\u4f5c\u903b\u8f91\u6e05\u6670,\u6267\u884c\u8d77\u6765\u4e0d\u9700\u8981\u4e3b\u89c2\u5224\u65ad<\/li>\n\n\n\n<li>\u5728\u5f3a\u8d8b\u52bf\u5e02\u573a\u4e2d\u8868\u73b0\u4f18\u5f02<\/li>\n<\/ul>\n\n\n\n<p><strong>\u52a3\u52bf\u5206\u6790:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4fe1\u53f7\u6709\u4e00\u5b9a\u6ede\u540e\u6027,\u5f80\u5f80\u8d8b\u52bf\u5df2\u7ecf\u8d70\u4e86\u4e00\u6bb5\u624d\u53d1\u51fa\u4fe1\u53f7<\/li>\n\n\n\n<li>\u5728\u6a2a\u76d8\u6574\u7406\u671f\u5bb9\u6613\u4ea7\u751f\u5047\u4fe1\u53f7<\/li>\n\n\n\n<li>\u53ef\u80fd\u9519\u8fc7\u8d8b\u52bf\u7684\u8d77\u59cb\u9636\u6bb5\u548c\u7ed3\u675f\u9636\u6bb5\u7684\u6700\u4f73\u70b9\u4f4d<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"380\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/1.jpg\" alt=\"\" class=\"wp-image-3314\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/1.jpg 700w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/1-300x163.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\">\u56fe1: \u79fb\u52a8\u5e73\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u793a\u4f8b &#8211; \u84dd\u7ebf\u4e3a\u77ed\u671f\u5747\u7ebf,\u7ea2\u7ebf\u4e3a\u957f\u671f\u5747\u7ebf<\/figcaption><\/figure>\n\n\n\n<p><strong>Python\u5b9e\u73b0\u4ee3\u7801:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport numpy as np\nimport yfinance as yf\nimport matplotlib.pyplot as plt\n\n# \u83b7\u53d6\u80a1\u7968\u6570\u636e\nsymbol = \"AAPL\"\ndf = yf.download(symbol, start=\"2020-01-01\", end=\"2024-01-01\")\n\n# \u8ba1\u7b97\u77ed\u671f\u548c\u957f\u671f\u79fb\u52a8\u5e73\u5747\u7ebf\ndf&#91;\"Short_MA\"] = df&#91;\"Adj Close\"].rolling(window=50).mean()\ndf&#91;\"Long_MA\"] = df&#91;\"Adj Close\"].rolling(window=200).mean()\n\n# \u751f\u6210\u4ea4\u6613\u4fe1\u53f7\ndf&#91;\"Signal\"] = np.where(df&#91;\"Short_MA\"] &gt; df&#91;\"Long_MA\"], 1, -1)\n\n# \u53ef\u89c6\u5316\u5c55\u793a\nplt.figure(figsize=(12,6))\nplt.plot(df.index, df&#91;\"Adj Close\"], label=\"\u80a1\u7968\u4ef7\u683c\", color=\"black\")\nplt.plot(df.index, df&#91;\"Short_MA\"], label=\"50\u65e5\u5747\u7ebf\", color=\"blue\", linestyle=\"--\")\nplt.plot(df.index, df&#91;\"Long_MA\"], label=\"200\u65e5\u5747\u7ebf\", color=\"red\", linestyle=\"--\")\nplt.legend(loc=\"best\")\nplt.title(\"\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u793a\u4f8b\")\nplt.show()\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b56\u7565\u4e8c:\u5747\u503c\u56de\u5f52\u7b56\u7565 &#8211; \u9707\u8361\u5e02\u573a\u7684\u6cd5\u5b9d<\/strong><\/h3>\n\n\n\n<p>\u5747\u503c\u56de\u5f52\u7b56\u7565\u57fa\u4e8e\u4e00\u4e2a\u7b80\u5355\u7684\u60f3\u6cd5:\u4ef7\u683c\u504f\u79bb\u5e73\u5747\u503c\u592a\u8fdc\u4e86,\u65e9\u665a\u8981\u56de\u5f52\u3002\u5c31\u50cf\u5f39\u7c27\u4e00\u6837,\u62c9\u5f97\u8d8a\u8fdc,\u56de\u5f39\u7684\u529b\u91cf\u5c31\u8d8a\u5927\u3002<\/p>\n\n\n\n<p><strong>\u5de5\u4f5c\u539f\u7406:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8ba1\u7b97\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u4ef7\u683c\u5e73\u5747\u503c\u548c\u6807\u51c6\u5dee<\/li>\n\n\n\n<li>\u7528Z-score(\u6807\u51c6\u5206\u6570)\u6765\u8861\u91cf\u5f53\u524d\u4ef7\u683c\u504f\u79bb\u5e73\u5747\u503c\u7684\u7a0b\u5ea6<\/li>\n\n\n\n<li>\u5f53Z-score\u5c0f\u4e8e-2\u65f6(\u4ef7\u683c\u8fdc\u4f4e\u4e8e\u5e73\u5747\u503c),\u8ba4\u4e3a\u4ef7\u683c\u88ab\u4f4e\u4f30,\u53ef\u4ee5\u8003\u8651\u5165\u573a<\/li>\n\n\n\n<li>\u5f53Z-score\u56de\u5f52\u52300\u9644\u8fd1\u65f6(\u4ef7\u683c\u56de\u5230\u5e73\u5747\u6c34\u5e73),\u53ef\u4ee5\u8003\u8651\u79bb\u573a<\/li>\n<\/ul>\n\n\n\n<p><strong>\u26a0\ufe0f \u91cd\u8981\u63d0\u9192:<\/strong><br>\u5747\u503c\u56de\u5f52\u7b56\u7565\u6709\u4e2a\u81f4\u547d\u98ce\u9669:\u5982\u679c\u80a1\u7968\u56e0\u4e3a\u57fa\u672c\u9762\u51fa\u4e86\u95ee\u9898\u800c\u6301\u7eed\u4e0b\u8dcc,\u4f60\u6309\u7167\u8fd9\u4e2a\u7b56\u7565\u53bb&#8221;\u6284\u5e95&#8221;,\u90a3\u5c31\u662f\u63a5\u98de\u5200,\u4f1a\u4e8f\u5f97\u5f88\u60e8\u3002\u6240\u4ee5\u4e00\u5b9a\u8981\u7ed3\u5408\u57fa\u672c\u9762\u5206\u6790,\u786e\u4fdd\u516c\u53f8\u6ca1\u6709\u91cd\u5927\u95ee\u9898\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"700\" height=\"383\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/2-1.jpg\" alt=\"\" class=\"wp-image-3315\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/2-1.jpg 700w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/2-1-300x164.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\">\u56fe2: \u5747\u503c\u56de\u5f52\u7b56\u7565\u7684Z-score\u793a\u4f8b<\/figcaption><\/figure>\n\n\n\n<p><strong>Python\u5b9e\u73b0\u4ee3\u7801:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8ba1\u7b97\u5747\u503c\u56de\u5f52\u6307\u6807\ndf&#91;\"Rolling_Mean\"] = df&#91;\"Adj Close\"].rolling(window=50).mean()\ndf&#91;\"Rolling_Std\"] = df&#91;\"Adj Close\"].rolling(window=50).std()\ndf&#91;\"Z_Score\"] = (df&#91;\"Adj Close\"] - df&#91;\"Rolling_Mean\"]) \/ df&#91;\"Rolling_Std\"]\n\n# \u751f\u6210\u4ea4\u6613\u4fe1\u53f7\ndf&#91;\"Mean_Revert_Signal\"] = np.where(\n    df&#91;\"Z_Score\"] &lt; -2, 1,\n    np.where(df&#91;\"Z_Score\"] &gt; 0, -1, 0)\n)\n\n# \u53ef\u89c6\u5316\nplt.figure(figsize=(12,6))\nplt.plot(df.index, df&#91;\"Z_Score\"], label=\"Z-Score\", color=\"purple\")\nplt.axhline(y=2, color='r', linestyle='--', label='\u4e0a\u9650')\nplt.axhline(y=-2, color='g', linestyle='--', label='\u4e0b\u9650')\nplt.legend()\nplt.title(\"\u5747\u503c\u56de\u5f52\u7b56\u7565\")\nplt.show()\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b56\u7565\u4e09:\u8d8b\u52bf\u8ddf\u968f\u7b56\u7565 &#8211; \u725b\u5e02\u4e2d\u7684\u5370\u949e\u673a<\/strong><\/h3>\n\n\n\n<p>\u8d8b\u52bf\u8ddf\u968f\u7b56\u7565\u7684\u6838\u5fc3\u601d\u60f3\u662f:&#8221;\u5f3a\u8005\u6052\u5f3a&#8221;\u3002\u5728\u725b\u5e02\u4e2d,\u6da8\u5f97\u597d\u7684\u80a1\u7968\u5f80\u5f80\u4f1a\u7ee7\u7eed\u6da8,\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u627e\u51fa\u8fd9\u4e9b\u5f3a\u52bf\u80a1,\u7136\u540e\u8ddf\u7740\u5b83\u4eec\u4e00\u8d77\u8d5a\u94b1\u3002<\/p>\n\n\n\n<p><strong>\u5de5\u4f5c\u539f\u7406:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8ba1\u7b97\u8fc7\u53bb\u4e00\u6bb5\u65f6\u95f4(\u6bd4\u5982120\u5929)\u7684\u4ef7\u683c\u6da8\u8dcc\u5e45,\u8fd9\u5c31\u662f&#8221;\u8d8b\u52bf\u5f3a\u5ea6&#8221;<\/li>\n\n\n\n<li>\u628a\u6240\u6709\u80a1\u7968\u6309\u7167\u8d8b\u52bf\u5f3a\u5ea6\u6392\u5e8f<\/li>\n\n\n\n<li>\u4e70\u5165\u6392\u540d\u524d10%\u7684\u5f3a\u52bf\u80a1<\/li>\n\n\n\n<li>\u5f53\u80a1\u7968\u8dcc\u5230\u6392\u540d\u540e10%\u65f6,\u679c\u65ad\u6e05\u4ed3<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"375\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/3.jpg\" alt=\"\" class=\"wp-image-3316\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/3.jpg 700w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2025\/12\/3-300x161.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\">\u56fe3: \u8d8b\u52bf\u8ddf\u968f\u7b56\u7565\u7684\u52a8\u91cf\u5206\u6790<\/figcaption><\/figure>\n\n\n\n<p><strong>Python\u5b9e\u73b0\u4ee3\u7801:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8ba1\u7b97120\u5929\u52a8\u91cf\ndf&#91;\"Momentum\"] = df&#91;\"Adj Close\"].pct_change(periods=120)\n\n# \u751f\u6210\u4ea4\u6613\u4fe1\u53f7\ndf&#91;\"Momentum_Signal\"] = np.where(\n    df&#91;\"Momentum\"] &gt; df&#91;\"Momentum\"].quantile(0.9), 1,\n    np.where(df&#91;\"Momentum\"] &lt; df&#91;\"Momentum\"].quantile(0.1), -1, 0)\n)\n\n# \u53ef\u89c6\u5316\nplt.figure(figsize=(12,6))\nplt.plot(df.index, df&#91;\"Momentum\"], label=\"120\u65e5\u52a8\u91cf\", color=\"orange\")\nplt.axhline(y=df&#91;\"Momentum\"].quantile(0.9), color='g', linestyle='--')\nplt.axhline(y=df&#91;\"Momentum\"].quantile(0.1), color='r', linestyle='--')\nplt.legend()\nplt.title(\"\u8d8b\u52bf\u8ddf\u968f\u7b56\u7565\")\nplt.show()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u30013\u5927\u7b56\u7565\u5b9e\u6218\u5bf9\u6bd4\u5206\u6790<\/strong><\/h2>\n\n\n\n<p>\u7406\u8bba\u8bb2\u5b8c\u4e86,\u6211\u4eec\u6765\u770b\u770b\u5b9e\u6218\u6548\u679c\u3002\u6211\u75282020\u5e74\u52302022\u5e74\u7684\u771f\u5b9e\u6570\u636e\u505a\u4e86\u56de\u6d4b,\u4e0b\u9762\u662f\u4e09\u4e2a\u7b56\u7565\u7684\u8868\u73b0\u5bf9\u6bd4\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u7b56\u7565\u7c7b\u578b<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u9002\u7528\u5e02\u573a<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u5b9e\u6d4b\u6536\u76ca(2020-2022)<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u98ce\u9669\u7b49\u7ea7<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u6267\u884c\u96be\u5ea6<\/th><\/tr><\/thead><tbody><tr><td>\u957f\u671f\u6301\u6709<\/td><td>\u725b\u5e02<\/td><td>\u7ea620%<\/td><td>\u4e2d\u7b49<\/td><td>\u6781\u4f4e<\/td><\/tr><tr><td>\u5747\u7ebf\u4ea4\u53c9<\/td><td>\u8d8b\u52bf\u660e\u786e\u5e02\u573a<\/td><td>\u7ea630%<\/td><td>\u4e2d\u7b49<\/td><td>\u4f4e<\/td><\/tr><tr><td>\u5747\u503c\u56de\u5f52<\/td><td>\u9707\u8361\u5e02<\/td><td>\u8d1f\u6536\u76ca<\/td><td>\u9ad8<\/td><td>\u4e2d<\/td><\/tr><tr><td>\u8d8b\u52bf\u8ddf\u968f<\/td><td>\u725b\u5e02<\/td><td>\u7ea620%<\/td><td>\u9ad8<\/td><td>\u4e2d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\ud83d\udcca \u6570\u636e\u89e3\u8bfb:<\/strong><br>\u57282020-2022\u5e74\u8fd9\u4e2a\u603b\u4f53\u5411\u4e0a\u7684\u5e02\u573a\u4e2d,\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u8868\u73b0\u6700\u597d,\u6bd4\u7b80\u5355\u6301\u6709\u591a\u8d5a\u4e8610\u4e2a\u767e\u5206\u70b9\u3002\u539f\u56e0\u662f\u5b83\u57282021\u5e745\u6708\u7684\u9ad8\u70b9\u9644\u8fd1\u53d1\u51fa\u4e86\u79bb\u573a\u4fe1\u53f7(\u80a1\u4ef7105\u7f8e\u5143),\u7136\u540e\u57282022\u5e743\u6708\u7684\u76f8\u5bf9\u4f4e\u70b9(95\u7f8e\u5143)\u91cd\u65b0\u5165\u573a,\u6210\u529f\u89c4\u907f\u4e86\u4e00\u6ce2\u4e0b\u8dcc\u3002\u800c\u5747\u503c\u56de\u5f52\u7b56\u7565\u5728\u8fd9\u4e2a\u5355\u8fb9\u4e0a\u6da8\u7684\u5e02\u573a\u91cc\u8868\u73b0\u4e0d\u4f73,\u56e0\u4e3a\u5b83\u7684\u903b\u8f91\u662f\u4ef7\u683c\u4f1a\u56de\u5f52\u5e73\u5747\u503c,\u4f46\u5b9e\u9645\u4e0a\u4ef7\u683c\u4e00\u8def\u5411\u4e0a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u5982\u4f55\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\u7b56\u7565?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u5e02\u573a\u7279\u5f81<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u63a8\u8350\u7b56\u7565<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u64cd\u4f5c\u8981\u70b9<\/th><\/tr><\/thead><tbody><tr><td>\u725b\u5e02\/\u660e\u786e\u4e0a\u5347\u8d8b\u52bf<\/td><td>\u5747\u7ebf\u4ea4\u53c9+\u8d8b\u52bf\u8ddf\u968f<\/td><td>\u4fdd\u6301\u8010\u5fc3,\u8ba9\u5229\u6da6\u5954\u8dd1<\/td><\/tr><tr><td>\u718a\u5e02\/\u660e\u786e\u4e0b\u964d\u8d8b\u52bf<\/td><td>\u5747\u7ebf\u4ea4\u53c9(\u505a\u7a7a\u65b9\u5411)<\/td><td>\u5feb\u8fdb\u5feb\u51fa,\u4e0d\u8981\u8d2a\u5fc3<\/td><\/tr><tr><td>\u9707\u8361\u5e02\/\u6a2a\u76d8\u6574\u7406<\/td><td>\u5747\u503c\u56de\u5f52<\/td><td>\u4e25\u683c\u6b62\u635f,\u63a7\u5236\u4ed3\u4f4d<\/td><\/tr><tr><td>\u5e02\u573a\u4e0d\u660e\u6717<\/td><td>\u4e09\u79cd\u7b56\u7565\u7ec4\u5408<\/td><td>\u5206\u6563\u98ce\u9669,\u964d\u4f4e\u4ed3\u4f4d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\ud83d\udca1 \u8001\u4f59\u7684\u5efa\u8bae:<\/strong><br>\u5982\u679c\u4f60\u662f\u65b0\u624b,\u5efa\u8bae\u4ece\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u5f00\u59cb\u3002\u8fd9\u4e2a\u7b56\u7565\u6700\u7b80\u5355,\u4fe1\u53f7\u660e\u786e,\u4e0d\u9700\u8981\u592a\u591a\u4e3b\u89c2\u5224\u65ad\u3002\u7b49\u4f60\u79ef\u7d2f\u4e86\u7ecf\u9a8c,\u5bf9\u5e02\u573a\u6709\u4e86\u66f4\u6df1\u7684\u7406\u89e3,\u518d\u53bb\u5c1d\u8bd5\u5176\u4ed6\u7b56\u7565\u3002\u5982\u679c\u4f60\u5b9e\u5728\u5206\u4e0d\u6e05\u695a\u5f53\u524d\u662f\u4ec0\u4e48\u5e02\u573a\u73af\u5883,\u90a3\u5c31\u628a\u8d44\u91d1\u5206\u6210\u4e09\u4efd,\u4e09\u4e2a\u7b56\u7565\u90fd\u7528\u4e00\u70b9\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u5b9e\u6218\u4e2d\u7684\u5173\u952e\u7ec6\u8282<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>1. \u53c2\u6570\u9009\u62e9\u7684\u827a\u672f<\/strong><\/h3>\n\n\n\n<p>\u5f88\u591a\u4eba\u95ee\u6211:&#8221;50\u5929\u548c200\u5929\u7684\u5747\u7ebf\u662f\u4e0d\u662f\u6700\u597d\u7684?&#8221;\u7b54\u6848\u662f:\u4e0d\u4e00\u5b9a\u3002\u8fd9\u4e9b\u53c2\u6570\u9700\u8981\u6839\u636e\u4f60\u4ea4\u6613\u7684\u6807\u7684\u548c\u5e02\u573a\u73af\u5883\u6765\u8c03\u6574\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u77ed\u7ebf\u4ea4\u6613:<\/strong>\u00a0\u53ef\u4ee5\u75285\u65e5\u300110\u65e5\u8fd9\u6837\u7684\u77ed\u5468\u671f\u5747\u7ebf<\/li>\n\n\n\n<li><strong>\u4e2d\u7ebf\u4ea4\u6613:<\/strong>\u00a0\u53ef\u4ee5\u752820\u65e5\u300160\u65e5\u8fd9\u6837\u7684\u4e2d\u671f\u5747\u7ebf<\/li>\n\n\n\n<li><strong>\u957f\u7ebf\u4ea4\u6613:<\/strong>\u00a0\u53ef\u4ee5\u752850\u65e5\u3001200\u65e5\u8fd9\u6837\u7684\u957f\u671f\u5747\u7ebf<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u98ce\u9669\u7ba1\u7406\u6c38\u8fdc\u662f\u7b2c\u4e00\u4f4d<\/strong><\/h3>\n\n\n\n<p>\u4e0d\u7ba1\u4f60\u7528\u4ec0\u4e48\u7b56\u7565,\u98ce\u9669\u7ba1\u7406\u90fd\u662f\u91cd\u4e2d\u4e4b\u91cd\u3002\u6211\u7ed9\u56e2\u961f\u5b9a\u7684\u94c1\u5f8b\u662f:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5355\u7b14\u4ea4\u6613\u98ce\u9669\u4e0d\u8d85\u8fc7\u603b\u8d44\u91d1\u76842%<\/li>\n\n\n\n<li>\u540c\u4e00\u65f6\u95f4\u6301\u4ed3\u4e0d\u8d85\u8fc75\u4e2a\u6807\u7684<\/li>\n\n\n\n<li>\u6bcf\u4e2a\u7b56\u7565\u7684\u6700\u5927\u56de\u64a4\u4e0d\u80fd\u8d85\u8fc720%<\/li>\n\n\n\n<li>\u8fde\u7eed\u4e8f\u635f3\u6b21\u5fc5\u987b\u505c\u4e0b\u6765\u590d\u76d8<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udcdd \u5168\u6587\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u91cf\u5316\u4ea4\u6613\u5e76\u4e0d\u795e\u79d8,\u5173\u952e\u5728\u4e8e\u7406\u89e3\u5e02\u573a\u89c4\u5f8b\u5e76\u4e25\u683c\u6267\u884c\u3002\u672c\u6587\u4ecb\u7ecd\u7684\u4e09\u79cd\u7b56\u7565\u5404\u6709\u5343\u79cb:\u5747\u7ebf\u4ea4\u53c9\u9002\u5408\u8d8b\u52bf\u5e02\u573a,\u5747\u503c\u56de\u5f52\u9002\u5408\u9707\u8361\u5e02\u573a,\u8d8b\u52bf\u8ddf\u968f\u9002\u5408\u725b\u5e02\u3002\u8bb0\u4f4f,\u6ca1\u6709\u5b8c\u7f8e\u7684\u7b56\u7565,\u53ea\u6709\u5408\u9002\u7684\u7b56\u7565\u3002\u6210\u529f\u7684\u5173\u952e\u5728\u4e8e:\u9009\u5bf9\u7b56\u7565\u3001\u4e25\u683c\u6267\u884c\u3001\u7ba1\u597d\u98ce\u9669\u3001\u4e0d\u65ad\u5b66\u4e60\u3002<\/p>\n\n\n\n<p><strong>\u6838\u5fc3\u8981\u70b9\u56de\u987e:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b80\u5355\u7b56\u7565\u5f80\u5f80\u6bd4\u590d\u6742\u6a21\u578b\u66f4\u6709\u6548,\u5173\u952e\u5728\u4e8e\u6267\u884c\u529b\u548c\u98ce\u9669\u7ba1\u7406\u3002<\/li>\n\n\n\n<li>\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u9002\u5408\u8d8b\u52bf\u660e\u786e\u7684\u5e02\u573a,\u4fe1\u53f7\u6e05\u6670\u4f46\u6709\u6ede\u540e\u6027\u3002<\/li>\n\n\n\n<li>\u5747\u503c\u56de\u5f52\u7b56\u7565\u9002\u5408\u9707\u8361\u5e02,\u4f46\u9700\u4e25\u9632\u57fa\u672c\u9762\u6076\u5316\u5bfc\u81f4\u7684\u6301\u7eed\u4e0b\u8dcc\u3002<\/li>\n\n\n\n<li>\u8d8b\u52bf\u8ddf\u968f\u7b56\u7565\u5728\u725b\u5e02\u4e2d\u8868\u73b0\u4f18\u5f02,\u4f46\u718a\u5e02\u4e2d\u98ce\u9669\u6781\u5927\u3002<\/li>\n\n\n\n<li>\u6839\u636e\u5e02\u573a\u73af\u5883\u9009\u62e9\u7b56\u7565,\u4e0d\u786e\u5b9a\u65f6\u53ef\u91c7\u7528\u591a\u7b56\u7565\u7ec4\u5408\u5206\u6563\u98ce\u9669\u3002<\/li>\n<\/ul>\n\n\n\n<p><a>#\u91cf\u5316\u4ea4\u6613<\/a>\u00a0<a>#Python\u7f16\u7a0b<\/a>\u00a0<a>#\u7b56\u7565\u4ea4\u6613<\/a>\u00a0<a>#\u6280\u672f\u5206\u6790<\/a>\u00a0<a>#\u5747\u7ebf\u7cfb\u7edf<\/a>\u00a0<a>#\u7b97\u6cd5\u4ea4\u6613<\/a>\u00a0<a>#\u91d1\u878d\u79d1\u6280<\/a>\u00a0<a>#\u6295\u8d44\u7b56\u7565<\/a>\u00a0<a>#\u6570\u636e\u5206\u6790<\/a>\u00a0<a>#\u98ce\u9669\u7ba1\u7406<\/a><\/p>\n\n\n\n<p>\u611f\u8c22\u9605\u8bfb\uff01\u613f\u672c\u6587\u4e3a\u60a8\u5e26\u6765\u65b0\u542f\u53d1\u4e0e\u5b9e\u7528\u77e5\u8bc6\u3002\u82e5\u89c9\u6709\u76ca\uff0c\u8bf7\u70b9\u8d5e\u5206\u4eab\uff0c\u60a8\u7684\u652f\u6301\u662f\u6211\u521b\u4f5c\u7684\u52a8\u529b\uff0c\u6b22\u8fce\u7559\u8a00\u5fc5\u590d\u3002\u795d\u6295\u8d44\u987a\u5229\uff0c\u6536\u76ca\u4e30\u539a\uff01<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u98ce\u9669\u63d0\u793a\uff1a<\/strong><em>\u672c\u6587\u4ec5\u4f9b\u53c2\u8003\uff0c\u4e0d\u6784\u6210\u6295\u8d44\u5efa\u8bae\u3002\u91cf\u5316\u7b56\u7565\u5f00\u53d1\u5e94\u4ee5\u5b66\u4e60\u548c\u6280\u672f\u4ea4\u6d41\u4e3a\u76ee\u7684\u3002\u6295\u8d44\u6709\u98ce\u9669\uff0c\u5165\u5e02\u9700\u8c28\u614e\u3002<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2026\/01\/06\/%e4%b8%89%e4%b8%aa%e7%ae%80%e5%8d%95python%e7%ad%96%e7%95%a5%e8%ae%a9%e4%bd%a0%e7%9a%84%e4%ba%a4%e6%98%93%e7%b3%bb%e7%bb%9f%e6%9b%b4%e8%81%aa%e6%98%8e\/\">Continue reading<span class=\"screen-reader-text\">\u4e09\u4e2a\u7b80\u5355Python\u7b56\u7565,\u8ba9\u4f60\u7684\u4ea4\u6613\u7cfb\u7edf\u66f4\u806a\u660e<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[17,4,5,6],"class_list":{"0":"post-3311","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","10":"tag-6","11":"entry"},"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/3311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=3311"}],"version-history":[{"count":2,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/3311\/revisions"}],"predecessor-version":[{"id":3317,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/3311\/revisions\/3317"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=3311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=3311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=3311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}