{"id":2447,"date":"2025-07-23T07:06:00","date_gmt":"2025-07-22T23:06:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=2447"},"modified":"2025-07-19T15:30:09","modified_gmt":"2025-07-19T07:30:09","slug":"%e9%9c%87%e6%83%8a%ef%bc%8190%e7%9a%84k%e7%ba%bf%e5%9b%be%e9%83%bd%e5%9c%a8%e8%af%b4%e8%b0%8e%ef%bc%9f%e7%94%a8adfarima%e6%a8%a1%e5%9e%8b%e7%9c%8b%e6%b8%85%e8%b6%8b%e5%8a%bf","status":"publish","type":"post","link":"https:\/\/www.laoyulaoyu.com\/index.php\/2025\/07\/23\/%e9%9c%87%e6%83%8a%ef%bc%8190%e7%9a%84k%e7%ba%bf%e5%9b%be%e9%83%bd%e5%9c%a8%e8%af%b4%e8%b0%8e%ef%bc%9f%e7%94%a8adfarima%e6%a8%a1%e5%9e%8b%e7%9c%8b%e6%b8%85%e8%b6%8b%e5%8a%bf\/","title":{"rendered":"\u9707\u60ca\uff0190%\u7684K\u7ebf\u56fe\u90fd\u5728\u8bf4\u8c0e\uff1f\u7528ADF+ARIMA\u6a21\u578b\u770b\u6e05\u8d8b\u52bf"},"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 decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/07\/4250b3b02ce99e98d63296fd27438ce2041f124-1024x511.webp\" alt=\"\" class=\"wp-image-5850\"\/><\/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>\u6709\u8bfb\u8005\u95ee\u6211\uff0c\u81ea\u5df1\u4e3a\u4ec0\u4e48k\u7ebf\u56fe\u603b\u662f\u770b\u4e0d\u51c6\uff1f\u6240\u4ee5<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4eca\u5929\u6211\u5c31\u5206\u4eab\u4e00\u4e2a\u7528\u6570\u636e\u6765\u5224\u65ad\u80a1\u7968\u53d1\u5c55\u8d8b\u52bf\u7684\u4e24\u6b65\u6cd5<\/mark>\uff1a\u5148\u7528ADF\u6d4b\u8bd5\u68c0\u67e5\u6570\u636e\u662f\u5426\u6709\u8d8b\u52bf\uff0c\u518d\u7528ARIMA\u6a21\u578b\u786e\u8ba4\u8d8b\u52bf\u7684\u65b9\u5411\u548c\u663e\u8457\u6027\u3002\u8fd9\u4e2a\u65b9\u6cd5\u8ba9\u53ef\u4ee5\u8ba9\u6211\u4eec<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4ece\u7e41\u6742\u7684\u80a1\u5e02\u6570\u636e\u4e2d\u627e\u5230\u4e86\u6e05\u6670\u7684\u7b54\u6848\uff0c\u544a\u522b\u76f2\u731c\uff01<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<p>\u4f60\u662f\u4e0d\u662f\u4e5f\u6709\u8fd9\u6837\u7684\u56f0\u60d1\uff1a\u770b\u7740\u80a1\u7968K\u7ebf\u56fe\uff0c\u611f\u89c9\u50cf\u5728\u89e3\u4e00\u4e2a\u7f3a\u4e86\u4e00\u534a\u7684\u62fc\u56fe\uff1f\u5404\u79cd\u8d22\u7ecf\u65b0\u95fb\u94fa\u5929\u76d6\u5730\uff0c\u4e13\u5bb6\u89c2\u70b9\u4e94\u82b1\u516b\u95e8\uff0c\u6700\u540e\u8d8a\u770b\u8d8a\u7cca\u6d82\uff0c\u5b8c\u5168\u4e0d\u77e5\u9053\u8be5\u4e70\u8fd8\u662f\u8be5\u5356\uff1f<\/p>\n\n\n\n<p>\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u5229\u7528AI\u91cf\u5316\u5de5\u5177\uff0c\u901a\u8fc7\u4e00\u5957\u201c\u4e24\u6b65\u8d70\u201d\u5206\u6790\u6cd5\uff0c\u50cf\u4e00\u540d\u4e13\u4e1a\u7684\u201c\u6570\u636e\u4fa6\u63a2\u201d\u4e00\u6837\uff0c\u4ece\u6570\u636e\u672c\u8eab\u627e\u5230\u7b54\u6848\uff0c\u63ed\u793a\u80a1\u7968\u771f\u6b63\u7684\u8d8b\u52bf\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u201c\u4e24\u6b65\u8d70\u201d\u5206\u6790\u6cd5<\/strong><\/h2>\n\n\n\n<p>\u6211\u4eec\u7684\u5206\u6790\u6838\u5fc3\u975e\u5e38\u7b80\u5355\uff0c\u5c31\u50cf\u4fa6\u63a2\u7834\u6848\u4e00\u6837\uff0c\u5206\u4e3a\u4e24\u4e2a\u5173\u952e\u9636\u6bb5\uff0c\u800c\u91cf\u5316\u5de5\u5177\u4f1a\u5e2e\u6211\u4eec\u81ea\u52a8\u5b8c\u6210\u8fd9\u4e9b\u7e41\u7410\u7684\u5de5\u4f5c\u3002<\/p>\n\n\n\n<p>\u8bdd\u4e0d\u591a\u8bf4\uff0c\u8ba9\u6211\u4eec\u7528\u4e00\u4e2a\u771f\u5b9e\u7684\u6848\u4f8b\uff0c\u6765\u770b\u770b\u8fd9\u5957\u201c\u4fa6\u63a2\u6cd5\u201d\u662f\u5982\u4f55\u5927\u663e\u8eab\u624b\u7684\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b2c\u4e00\u6b65\uff1a\u8d8b\u52bf\u4f53\u68c0\uff08\u5e73\u7a33\u6027\u68c0\u9a8c\uff09<\/strong><\/h3>\n\n\n\n<p>\u5728\u5206\u6790\u80a1\u7968\u8d8b\u52bf\u4e4b\u524d\uff0c\u6211\u4eec\u5f97\u5148\u641e\u6e05\u695a\u4e00\u4e2a\u6982\u5ff5\uff0c\u53eb\u505a\u201c\u5e73\u7a33\u6027\u201d\u3002\u4f60\u53ef\u4ee5\u628a\u80a1\u7968\u6570\u636e\u60f3\u8c61\u6210\u4e00\u4e2a\u4eba\u7684\u201c\u813e\u6c14\u201d\uff1a<\/p>\n\n\n\n<p><strong>\u201c\u813e\u6c14\u4e0d\u597d\u201d\u7684\u6570\u636e\uff08\u4e0d\u5e73\u7a33\uff09<\/strong>\uff1a\u5c31\u50cf\u4e00\u6761\u5954\u817e\u4e0d\u606f\u7684\u6cb3\u6d41\uff0c\u6709\u660e\u663e\u7684\u65b9\u5411\u6216\u8d8b\u52bf\u3002<strong>\u80a1\u7968\u4ef7\u683c<\/strong>\u672c\u8eab\u901a\u5e38\u5c31\u662f\u201c\u813e\u6c14\u4e0d\u597d\u201d\u7684\uff0c\u56e0\u4e3a\u5b83\u4e00\u76f4\u5728\u6da8\u6da8\u8dcc\u8dcc\uff0c\u6ca1\u6709\u4e00\u4e2a\u56fa\u5b9a\u7684\u5e73\u5747\u503c\u3002<\/p>\n\n\n\n<p><strong>\u201c\u813e\u6c14\u5f88\u597d\u201d\u7684\u6570\u636e\uff08\u5e73\u7a33\uff09<\/strong>\uff1a\u5c31\u50cf\u5e73\u9759\u7684\u6e56\u9762\uff0c\u56f4\u7ed5\u7740\u4e00\u4e2a\u56fa\u5b9a\u7684\u5e73\u5747\u503c\u6ce2\u52a8\uff0c\u6ca1\u6709\u660e\u663e\u7684\u4e0a\u6da8\u6216\u4e0b\u8dcc\u8d8b\u52bf\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u80a1\u7968\u7684\u6bcf\u65e5\u6da8\u8dcc\u5e45\uff08\u6536\u76ca\u7387\uff09\u5c31\u662f\u201c\u813e\u6c14\u5f88\u597d\u201d\u7684\uff0c\u56e0\u4e3a\u5b83\u4f1a\u56f4\u7ed5\u4e00\u4e2a\u5e73\u5747\u503c\u4e0a\u4e0b\u6ce2\u52a8\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7528\u4e00\u4e2a\u4e13\u4e1a\u7684\u201c\u4f53\u68c0\u5de5\u5177\u201d\u2014\u2014<strong>ADF\uff08\u589e\u5e7f\u8fea\u57fa-\u5bcc\u52d2\uff09\u68c0\u9a8c<\/strong>\u6765\u68c0\u67e5\u6570\u636e\u7684\u201c\u813e\u6c14\u201d\u3002\u5224\u65ad\u89c4\u5219\u5f88\u7b80\u5355\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><td>P\u503c\u5927\u5c0f<\/td><td>\u68c0\u9a8c\u7ed3\u679c<\/td><td>\u7ed3\u8bba<\/td><\/tr><\/thead><tbody><tr><td><strong>P\u503c\u5927\u4e8e0.05<\/strong><\/td><td><strong>\u4e0d\u5e73\u7a33<\/strong><\/td><td>\u6570\u636e\u6709\u660e\u663e\u7684\u8d8b\u52bf\uff0c\u6bd4\u5982\u6301\u7eed\u4e0a\u6da8\u6216\u4e0b\u8dcc\u3002\ud83d\udcc8<\/td><\/tr><tr><td><strong>P\u503c\u5c0f\u4e8e0.05<\/strong><\/td><td><strong>\u5e73\u7a33<\/strong><\/td><td>\u6570\u636e\u6ca1\u6709\u660e\u663e\u7684\u8d8b\u52bf\uff0c\u53ea\u662f\u968f\u673a\u6ce2\u52a8\u3002\u2194\ufe0f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u6211\u4eec\u7684\u4ee3\u7801\u4f1a\u9996\u5148\u5bf9<strong>\u539f\u59cb\u80a1\u7968\u4ef7\u683c<\/strong>\u8fdb\u884c\u68c0\u9a8c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Augmented Dickey-Fuller Test Results for Prices:\np-value: 0.9744\nConclusion: Series is NON-STATIONARY (likely has trend)<\/code><\/pre>\n\n\n\n<p>\u4ece\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/p>\n\n\n\n<p><strong>\u80a1\u7968\u4ef7\u683c\u7684ADF\u68c0\u9a8c\u7ed3\u679c\uff1a<\/strong> P\u503c\uff1a0.9744 \u7ed3\u8bba\uff1a\u6570\u636e\u201c\u813e\u6c14\u4e0d\u597d\u201d\uff08\u4e0d\u5e73\u7a33\uff0c\u5f88\u53ef\u80fd\u6709\u8d8b\u52bf\uff09<\/p>\n\n\n\n<p>P\u503c\u975e\u5e38\u9ad8\uff080.9744\uff09\uff0c\u8fd9\u8bf4\u660e\u80a1\u7968\u4ef7\u683c\u786e\u5b9e\u6709\u660e\u663e\u7684\u8d8b\u52bf\uff01\u8fd9\u662f\u4e00\u4e2a\u597d\u4fe1\u53f7\uff0c\u610f\u5473\u7740\u6211\u4eec\u6709\u620f\uff0c\u53ef\u4ee5\u7ee7\u7eed\u5f80\u4e0b\u5206\u6790\u4e86\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\uff0c\u63a5\u7740\u68c0\u9a8c<strong>\u80a1\u7968\u7684\u6bcf\u65e5\u6da8\u8dcc\u5e45\uff08\u6536\u76ca\u7387\uff09<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Augmented Dickey-Fuller Test Results for Returns:\np-value: 0.0000\nConclusion: Series is STATIONARY (no strong trend)<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u663e\u793a\uff1a<\/p>\n\n\n\n<p><strong>\u80a1\u7968\u6536\u76ca\u7387\u7684ADF\u68c0\u9a8c\u7ed3\u679c\uff1a<\/strong> P\u503c\uff1a0.0000 \u7ed3\u8bba\uff1a\u6570\u636e\u201c\u813e\u6c14\u5f88\u597d\u201d\uff08\u5e73\u7a33\uff0c\u6ca1\u6709\u5f3a\u8d8b\u52bf\uff09<\/p>\n\n\n\n<p>P\u503c\u51e0\u4e4e\u4e3a\u96f6\uff0c\u8fd9\u8bc1\u5b9e\u4e86\u6bcf\u65e5\u6da8\u8dcc\u5e45\u6570\u636e\u662f\u5e73\u7a33\u7684\u3002\u8fd9\u610f\u5473\u7740\u6211\u4eec\u6709\u4e86\u4e00\u4efd\u201c\u813e\u6c14\u5f88\u597d\u201d\u7684\u7a33\u5b9a\u6570\u636e\uff0c\u975e\u5e38\u9002\u5408\u8fdb\u884c\u4e0b\u4e00\u6b65\u7684\u201c\u5ba1\u8baf\u201d\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u7b2c\u4e8c\u6b65\uff1a\u8d8b\u52bf\u5224\u65ad\uff08ARIMA\u6a21\u578b\u5206\u6790\uff09<\/strong><\/h3>\n\n\n\n<p>\u65e2\u7136\u56de\u62a5\u7387\u662f\u5e73\u7a33\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u7528ARIMA\u6a21\u578b\u6765\u5206\u6790\u5b83\u3002ARIMA\uff08\u81ea\u56de\u5f52\u79ef\u5206\u79fb\u52a8\u5e73\u5747\u6a21\u578b\uff09\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5224\u65ad\u6570\u636e\u4e2d\u662f\u5426\u6709\u663e\u8457\u7684\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5173\u6ce8ARIMA\u6a21\u578b\u7684\u5e38\u6570\u9879\uff08const\uff09\u53ca\u5176p\u503c\uff1a<\/p>\n\n\n\n<p><strong>const &gt; 0 \u4e14 p\u503c &lt; 0.05<\/strong>\uff1a\u6709\u663e\u8457\u7684\u4e0a\u6da8\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p><strong>const &lt; 0 \u4e14 p\u503c &lt; 0.05<\/strong>\uff1a\u6709\u663e\u8457\u7684\u4e0b\u8dcc\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p><strong>p\u503c &gt; 0.05<\/strong>\uff1a\u6ca1\u6709\u663e\u8457\u8d8b\u52bf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/07\/\u4e0b\u8f7d.png\" alt=\"\" class=\"wp-image-5851\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>ARIMA(1, 0, 1) \u6a21\u578b\u6536\u76ca\u6458\u8981\uff1a\n========================================================================================= \n                 coef std err z P&gt;|z| &#91;0.025 0.975] \n------------------------------------------------------------------------------\n const 0.0012 0.001 2.069 0.039 6.52e-05 0.002 \nar.L1 -0.2658 0.672 -0.396 0.692 -1.582 1.050 \nma.L1 0.2321 0.678 0.342 0.732 -1.098 1.562 \n... \n=========================================================================================\n<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cARIMA(1,0,1)\u6a21\u578b\u7684\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th class=\"has-text-align-center\" data-align=\"center\">\u53c2\u6570<\/th><th class=\"has-text-align-center\" data-align=\"center\">\u7cfb\u6570<\/th><th class=\"has-text-align-center\" data-align=\"center\">p\u503c<\/th><th class=\"has-text-align-center\" data-align=\"center\">\u7ed3\u8bba<\/th><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">const<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.0012<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.039<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u663e\u8457\u6b63\u8d8b\u52bf\uff08\u6bcf\u65e5\u4e0a\u6da80.12%\uff09<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">ar.L1<\/td><td class=\"has-text-align-center\" data-align=\"center\">-0.2658<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.692<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u4e0d\u663e\u8457<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">ma.L1<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.2321<\/td><td class=\"has-text-align-center\" data-align=\"center\">0.732<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u4e0d\u663e\u8457<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u89e3\u8bfb<\/strong>\uff1a<\/p>\n\n\n\n<p><strong>\u5e38\u6570\u9879\u7cfb\u6570\uff08coef\uff09\uff1a0.0012<\/strong>\u3002\u8fd9\u4e2a\u6570\u5b57\u544a\u8bc9\u6211\u4eec\uff0c\u8fd9\u53ea\u80a1\u7968\u5e73\u5747\u6bcf\u5929\u4e0a\u6da8<strong>0.12%<\/strong>\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u53d1\u73b0\u7684\u6f5c\u5728\u4e0a\u6da8\u8d8b\u52bf\uff01<\/p>\n\n\n\n<p><strong>\u5e38\u6570\u9879P\u503c\uff08P&gt;|z|\uff09\uff1a0.039<\/strong>\u3002\u8fd9\u662f\u6700\u91cd\u8981\u7684\u6570\u5b57\uff01\u56e0\u4e3a\u8fd9\u4e2aP\u503c<strong>\u5c0f\u4e8e0.05<\/strong>\uff0c\u8fd9\u8bc1\u5b9e\u4e86\u6211\u4eec\u53d1\u73b0\u7684\u8fd9\u4e2a\u6b63\u5411\u6da8\u5e45\u662f<strong>\u7edf\u8ba1\u4e0a\u663e\u8457\u7684<\/strong>\uff0c\u5b83\u4e0d\u662f\u968f\u673a\u6ce2\u52a8\uff0c\u800c\u662f\u4e00\u4e2a\u771f\u5b9e\u5b58\u5728\u7684\u3001\u6301\u7eed\u7684\u4e0a\u6da8\u8d8b\u52bf\uff01<\/p>\n\n\n\n<p>\u81f3\u4e8e\u5176\u4ed6\u7684\u9879\u76ee\uff0c\u6bd4\u5982\u81ea\u56de\u5f52\u9879(ar.L1)\u548c\u79fb\u52a8\u5e73\u5747\u9879(ma.L1)\uff0c\u5b83\u4eec\u7684P\u503c\u90fd\u975e\u5e38\u9ad8\uff080.692\u548c0.732\uff09\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u4e0d\u91cd\u8981\uff0c\u53ef\u4ee5\u5ffd\u7565\u3002\u8fd9\u4e2a\u6a21\u578b\u552f\u4e00\u771f\u6b63\u53d1\u73b0\u7684\u201c\u529b\u91cf\u201d\uff0c\u5c31\u662f\u80a1\u7968\u6bcf\u65e5\u6301\u7eed\u4e0a\u6da8\u7684\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p>\u6700\u7ec8\u7ed3\u8bba\u4e00\u76ee\u4e86\u7136\uff1a\u8fd9\u53ea\u80a1\u7968\u6b63\u5904\u4e8e\u4e00\u4e2a<strong>\u7edf\u8ba1\u610f\u4e49\u4e0a\u663e\u8457\u7684\u4e0a\u6da8\u8d8b\u52bf<\/strong>\u4e2d\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u624b\u628a\u624b\u6559\u5b66<\/strong><\/h2>\n\n\n\n<p>\u8fd9\u4e00\u6574\u5957\u201c\u4e24\u6b65\u8d70\u201d\u7684\u5206\u6790\u6d41\u7a0b\uff0c\u90fd\u7531\u4e0b\u9762\u7684Python\u4ee3\u7801\u9a71\u52a8\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u7b2c\u4e00\u6b65\uff1a\u8bf7\u6570\u636e\u51fa\u573a<br>import yfinance as yf<br>stock = yf.download('META', start='2020-01-03') # META\u793a\u4f8b<br>returns = stock['Close'].pct_change().dropna() # \u7b97\u6bcf\u65e5\u6da8\u8dcc<br><br># \u7b2c\u4e8c\u6b65\uff1a\u505a\u7a33\u5b9a\u6027\u4f53\u68c0<br>from statsmodels.tsa.stattools import adfuller<br>def check_stable(data):<br>    result = adfuller(data)<br>    print(f'p\u503c\uff1a{result[1]:.4f}')<br>    print('\u7ed3\u8bba\uff1a\u6709\u8d8b\u52bf\uff01' if result[1] &gt; 0.05 else '\u7ed3\u8bba\uff1a\u6ca1\u8d8b\u52bf\uff01')<br>    <br>print(\"\u80a1\u4ef7\u68c0\u6d4b\uff1a\")<br>check_stable(stock['Close']) <br>print(\"\\n\u6da8\u8dcc\u5e45\u68c0\u6d4b\uff1a\")<br>check_stable(returns)<\/pre>\n\n\n\n<p><strong>\u8fd0\u884c\u7ed3\u679c\u79d2\u61c2\u8868<\/strong>\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u68c0\u6d4b\u5bf9\u8c61<\/th><th>p\u503c<\/th><th>\u89e3\u8bfb<\/th><th>\u884c\u52a8\u6307\u5357<\/th><\/tr><\/thead><tbody><tr><td>\u80a1\u4ef7<\/td><td>0.97<\/td><td>\u91ce\u9a6c\uff08\u6709\u8d8b\u52bf\uff09<\/td><td>\u8fdb\u5165\u4e0b\u4e00\u6b65<\/td><\/tr><tr><td>\u6da8\u8dcc\u5e45<\/td><td>0.00<\/td><td>\u905b\u5f2f\u72d7\uff08\u5e73\u7a33\uff09<\/td><td>\u53ef\u5efa\u6a21\u5206\u6790<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u8ba9AI\u88c1\u5224\u4e0b\u7ed3\u8bba<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u7b2c\u4e09\u6b65\uff1a\u8d8b\u52bf\u8bca\u65ad\nfrom statsmodels.tsa.arima.model import ARIMA\nmodel = ARIMA(returns, order=(1,0,1)) \nresult = model.fit()\n\n# \u5173\u952e\u770b\u8fd9\u91cc\uff01\nprint(result.summary())<\/pre>\n\n\n\n<p><strong>\u6838\u5fc3\u8bc1\u636e\u9501\u5b9a\u533a<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>============================================================================\n <strong>coef   std err    z    P&gt;|z|  &#91;0.025  0.975]  &lt;-- \u76ef\u4f4f\u8fd9\u884c\uff01\n-------------------------------------------------------------------<\/strong>\nconst    0.0012   0.001    2.069 0.039   0.0001  0.002  &lt;-- \u6838\u5fc3\u6307\u6807\uff01\nar.L1   -0.2658   0.672   -0.396 0.692  -1.582  1.050\n<strong>ma.L1    0.2321   0.678    0.342 0.732  -1.098  1.562\n===================================================================<\/strong><\/code><\/pre>\n\n\n\n<p><strong>\u5206\u6790\u62a5\u544a\u89e3\u8bfb<\/strong>\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><code>const=0.0012<\/code>&nbsp;\u2192 \u6bcf\u5929\u5e73\u5747\u6da80.12%<\/li>\n\n\n\n<li><code>P&gt;|z|=0.039<\/code>&nbsp;\u2192 \u5c0f\u4e8e0.05\uff01\u4e0d\u662f\u5de7\u5408\uff01<\/li>\n\n\n\n<li>\u5176\u4ed6\u53c2\u6570P\u503c&gt;0.7 \u2192 \u90fd\u662f\u6742\u97f3<\/li>\n<\/ol>\n\n\n\n<p><strong>\u6211\u7684\u79c1\u5bb6\u76d1\u63a7\u4eea\u8868\u76d8<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u4e00\u952e\u751f\u6210\u53ef\u89c6\u5316\u6218\u60c5\u5ba4\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots(3, figsize=(12,10))\nax[0].plot(stock['Close'], label='\u80a1\u4ef7\u8d70\u52bf') \nax[1].plot(returns, label='\u6bcf\u65e5\u6da8\u8dcc', color='orange')\nax[2].hist(returns, bins=50, label='\u6da8\u8dcc\u5206\u5e03', alpha=0.6)\nplt.savefig('\u80a1\u7968\u4f53\u68c0\u62a5\u544a.jpg') # \u81ea\u52a8\u5b58\u56fe<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/07\/\u4e0b\u8f7d-1-1024x837.png\" alt=\"\" class=\"wp-image-5853\"\/><\/figure>\n\n\n\n<p>\u73b0\u5728\uff0c\u4f60\u4e0d\u518d\u9700\u8981\u5bf9\u7740\u590d\u6742\u7684\u80a1\u7968K\u7ebf\u56fe\u4e00\u7b79\u83ab\u5c55\uff0c\u4e5f\u4e0d\u5fc5\u88ab\u94fa\u5929\u76d6\u5730\u7684\u8d22\u7ecf\u4fe1\u606f\u641e\u5f97\u6655\u5934\u8f6c\u5411\u3002\u901a\u8fc7\u8fd9\u5957\u201c\u8d8b\u52bf\u4f53\u68c0\u201d\u548c\u201c\u8d8b\u52bf\u5ba1\u8baf\u201d\u7684\u201c\u4e24\u6b65\u8d70\u201d\u65b9\u6cd5\uff0c\u518d\u7ed3\u5408Python\u4ee3\u7801\uff0c\u4f60\u5c31\u80fd\u4ece\u6570\u636e\u672c\u8eab\u627e\u5230\u7b54\u6848\uff0c\u81ea\u4fe1\u5730\u5224\u65ad\u80a1\u7968\u7684\u672a\u6765\u8d8b\u52bf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u89c2\u70b9\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u672c\u6587\u6df1\u5165\u6d45\u51fa\u5730\u8bb2\u89e3\u4e86\u5982\u4f55\u5229\u7528Python\u8fdb\u884c\u80a1\u7968\u8d8b\u52bf\u5206\u6790\uff0c\u6838\u5fc3\u5728\u4e8e\u201c\u4e24\u6b65\u8d70\u201d\u7b56\u7565\uff1a\u5e73\u7a33\u6027\u68c0\u9a8c\u548cARIMA\u6a21\u578b\u5206\u6790\u3002\u901a\u8fc7\u5c06\u4e13\u4e1a\u672f\u8bed\u8f6c\u5316\u4e3a\u901a\u4fd7\u6613\u61c2\u7684\u8bed\u8a00\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u4ee3\u7801\u6559\u5b66\uff0c\u65e8\u5728\u5e2e\u52a9\u666e\u901a\u6295\u8d44\u8005\u4e5f\u80fd\u8fd0\u7528\u91cf\u5316\u5de5\u5177\uff0c\u79d1\u5b66\u5224\u65ad\u80a1\u7968\u8d8b\u52bf\u3002<\/p>\n\n\n\n<p><strong>\u6838\u5fc3\u601d\u60f3\uff1a<\/strong> \u5c06\u80a1\u7968\u8d8b\u52bf\u5224\u65ad\u8fc7\u7a0b\u62c6\u89e3\u4e3a\u201c\u8d8b\u52bf\u4f53\u68c0\u201d\uff08\u5e73\u7a33\u6027\u68c0\u9a8c\uff09\u548c\u201c\u8d8b\u52bf\u5ba1\u8baf\u201d\uff08ARIMA\u6a21\u578b\u5206\u6790\uff09\u4e24\u4e2a\u6838\u5fc3\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p><strong>\u5de5\u5177\u5229\u5668\uff1a<\/strong> \u8fd0\u7528Python\u7f16\u7a0b\u8bed\u8a00\uff0c\u7ed3\u5408<code>yfinance<\/code>\u3001<code>statsmodels<\/code>\u7b49\u5e93\uff0c\u5b9e\u73b0\u6570\u636e\u83b7\u53d6\u3001\u5e73\u7a33\u6027\u68c0\u9a8c\u548cARIMA\u6a21\u578b\u6784\u5efa\u3002<\/p>\n\n\n\n<p><strong>\u5173\u952e\u6307\u6807\uff1a<\/strong> \u901a\u8fc7ADF\u68c0\u9a8c\u7684P\u503c\u5224\u65ad\u6570\u636e\u662f\u5426\u5e73\u7a33\uff0c\u518d\u901a\u8fc7ARIMA\u6a21\u578b\u4e2d\u201c\u5e38\u6570\u9879\u201d\u7684\u7cfb\u6570\u548cP\u503c\uff0c\u5224\u65ad\u8d8b\u52bf\u65b9\u5411\u548c\u663e\u8457\u6027\u3002<\/p>\n\n\n\n<p><strong>\u64cd\u4f5c\u7b80\u4fbf\uff1a<\/strong> \u63d0\u4f9b\u4e86\u5b8c\u6574\u7684Python\u4ee3\u7801\u548c\u8be6\u7ec6\u7684\u6ce8\u91ca\uff0c\u624b\u628a\u624b\u6559\u5b66\uff0c\u5373\u4f7f\u662f\u7f16\u7a0b\u5c0f\u767d\u4e5f\u80fd\u5feb\u901f\u4e0a\u624b\u5b9e\u8df5\u3002<\/p>\n\n\n\n<p><strong>\u544a\u522b\u76f2\u731c\uff1a<\/strong> \u5e2e\u52a9\u6295\u8d44\u8005\u4ece\u6570\u636e\u9a71\u52a8\u7684\u89d2\u5ea6\uff0c\u66f4\u79d1\u5b66\u3001\u66f4\u7406\u6027\u5730\u5206\u6790\u80a1\u7968\u8d70\u52bf\uff0c\u51cf\u5c11\u76f2\u76ee\u731c\u6d4b\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/07\/image-58-788x1024.png\" alt=\"\" class=\"wp-image-5854\"\/><\/figure>\n\n\n\n<p>\u8d76\u5feb\u52a8\u624b\u8bd5\u8bd5\u5427\uff0c\u6210\u4e3a\u81ea\u5df1\u7684\u80a1\u5e02\u201c\u6570\u636e\u4fa6\u63a2\u201d\uff01\u9700\u8981\u5b8c\u6574\u6e90\u4ee3\u7801\u8bf7\u540e\u53f0\u7559\u8a00\uff01<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Python\u91cf\u5316 #\u80a1\u7968\u5206\u6790 #\u8d8b\u52bf\u9884\u6d4b #ARIMA\u6a21\u578b #\u6570\u636e\u4fa6\u63a2 #\u80a1\u5e02\u9ed1\u79d1\u6280 #\u91d1\u878d\u79d1\u6280 #\u91cf\u5316\u4ea4\u6613 #\u65b0\u624b\u7092\u80a1 #Python\u7f16\u7a0b<\/p>\n\n\n\n<p><em>\u8bfb\u5230\u6700\u540e\uff0c\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u4e3a\u60a8\u5e26\u6765\u4e86\u65b0\u7684\u542f\u53d1\u548c\u5b9e\u7528\u7684\u77e5\u8bc6\uff01\u5982\u679c\u89c9\u5f97\u6709\u5e2e\u52a9\uff0c\u8bf7\u4e0d\u541d\u70b9\u8d5e\u548c\u5206\u4eab\uff0c\u60a8\u7684\u652f\u6301\u662f\u6211\u6301\u7eed\u521b\u4f5c\u7684\u52a8\u529b\u3002\u795d\u60a8\u6295\u8d44\u987a\u5229\uff0c\u6536\u76ca\u957f\u8679\uff01\u5982\u679c\u5bf9\u6587\u4e2d\u5185\u5bb9\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u6b22\u8fce\u7559\u8a00\uff0c\u6211\u4f1a\u5c3d\u5feb\u56de\u590d\uff01<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\">\u672c\u6587\u5185\u5bb9\u4ec5\u9650\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/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&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.laoyulaoyu.com\/index.php\/2025\/07\/23\/%e9%9c%87%e6%83%8a%ef%bc%8190%e7%9a%84k%e7%ba%bf%e5%9b%be%e9%83%bd%e5%9c%a8%e8%af%b4%e8%b0%8e%ef%bc%9f%e7%94%a8adfarima%e6%a8%a1%e5%9e%8b%e7%9c%8b%e6%b8%85%e8%b6%8b%e5%8a%bf\/\">Continue reading<span class=\"screen-reader-text\">\u9707\u60ca\uff0190%\u7684K\u7ebf\u56fe\u90fd\u5728\u8bf4\u8c0e\uff1f\u7528ADF+ARIMA\u6a21\u578b\u770b\u6e05\u8d8b\u52bf<\/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-2447","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:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=2447"}],"version-history":[{"count":2,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2447\/revisions"}],"predecessor-version":[{"id":2449,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2447\/revisions\/2449"}],"wp:attachment":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=2447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=2447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=2447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}