{"id":4823,"date":"2026-09-08T07:28:00","date_gmt":"2026-09-07T23:28:00","guid":{"rendered":"https:\/\/laoyulaoyu.com\/?p=4823"},"modified":"2026-09-01T20:28:38","modified_gmt":"2026-09-01T12:28:38","slug":"%e5%88%ab%e5%86%8d%e9%9a%8f%e6%89%8b%e7%8c%9c%e5%9d%87%e7%ba%bf%e5%8f%82%e6%95%b0%e4%ba%86%ef%bc%8c%e7%ba%bf%e6%80%a7%e6%90%9c%e7%b4%a2%e6%9b%b4%e9%9d%a0%e8%b0%b1","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2026\/09\/08\/%e5%88%ab%e5%86%8d%e9%9a%8f%e6%89%8b%e7%8c%9c%e5%9d%87%e7%ba%bf%e5%8f%82%e6%95%b0%e4%ba%86%ef%bc%8c%e7%ba%bf%e6%80%a7%e6%90%9c%e7%b4%a2%e6%9b%b4%e9%9d%a0%e8%b0%b1\/","title":{"rendered":"\u522b\u518d\u968f\u624b\u731c\u5747\u7ebf\u53c2\u6570\u4e86\uff0c\u7ebf\u6027\u641c\u7d22\u66f4\u9760\u8c31"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\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 class=\"wp-block-paragraph\"><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-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"900\" height=\"383\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/cover-1.png\" alt=\"\" class=\"wp-image-4824\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/cover-1.png 900w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/cover-1-300x128.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/cover-1-768x327.png 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u6587\u4e2d\u793a\u4f8b\u4ec5\u7528\u4e8e\u6280\u672f\u8ba8\u8bba\uff0c\u4e0d\u6784\u6210\u4efb\u4f55\u64cd\u4f5c\u5efa\u8bae\u3002<br>\u91cf\u5316\u7b56\u7565\u5f00\u53d1\u5e94\u4ee5\u5b66\u4e60\u548c\u6280\u672f\u4ea4\u6d41\u4e3a\u76ee\u7684\u3002<br>\u672c\u53f7\u4e0d\u8350\u80a1\u3001\u4e0d\u5356\u8bfe\u3001\u4e0d\u627f\u8bfa\u6536\u76ca\u3002<br>\u5e02\u573a\u6709\u98ce\u9669\uff0c\u8bf7\u5408\u6cd5\u5408\u89c4\u6295\u8d44\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"has-text-align-left wp-block-paragraph\">\u672c\u6587\u7ea6 4500 \u5b57 | \u9884\u8ba1\u9605\u8bfb 8-11 \u5206\u949f\uff0c\u5185\u6709\u5b9e\u4f8b\u4ee3\u7801\uff0c\u5efa\u8bae\u5148\u6536\u85cf\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">\u00b7 \u00b7 \u00b7<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u672c\u6765\u5c31\u662f\u4e2a\u7b80\u5355\u547d\u9898\uff1a\u5f53\u4ef7\u683c\u7ad9\u4e0a\u5747\u7ebf\u65f6\u6301\u6709\u591a\u5934\uff0c\u8dcc\u7834\u5747\u7ebf\u65f6\u5207\u6362\u6210\u73b0\u91d1\u3002\u4f46\u9ebb\u70e6\u7684\u662f\uff0c\u4f60\u5f97\u5148\u9009\u4e00\u4e2a\u56de\u770b\u7a97\u53e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">20\u65e5\u5747\u7ebf\u548c200\u65e5\u5747\u7ebf\u7ed9\u51fa\u7684\u7ed3\u679c\u4f1a\u5dee\u5f88\u591a\u3002\u9009\u5c0f\u4e86\uff0c\u4fe1\u53f7\u4f1a\u53d8\u591a\uff0c\u624b\u7eed\u8d39\u3001\u6ed1\u70b9\u548c\u5e02\u573a\u566a\u58f0\u4f1a\u628a\u5229\u6da6\u5403\u6389\u3002\u9009\u5927\u4e86\uff0c\u53cd\u5e94\u53c8\u4f1a\u592a\u8fdf\u949d\u3002\u624b\u611f\u5f0f\u62cd\u8111\u888b\uff0c\u5176\u5b9e\u662f\u6700\u4e0d\u7a33\u5b9a\u7684\u90a3\u90e8\u5206\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u7bc7\u6587\u7ae0\u91cc\uff0c\u6211\u628a\u7a97\u53e3\u9009\u62e9\u6539\u6210\u4e00\u4e2a\u53ef\u4ee5\u91cf\u5316\u7684\u641c\u7d22\u95ee\u9898\u3002\u7528\u7ebf\u6027\u641c\u7d22\u4ece2\u5929\u5230300\u5929\u9010\u4e00\u904d\u5386\uff0c\u518d\u7ed9\u9891\u7e41\u4ea4\u6613\u52a0\u4e00\u70b9\u60e9\u7f5a\uff0c\u8ba9\u6a21\u578b\u81ea\u5df1\u627e\u51fa\u517c\u987e\u6536\u76ca\u548c\u4ea4\u6613\u6b21\u6570\u7684\u7a97\u53e3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5148\u770b\u7ed3\u679c<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u641c\u7d22\u6846\u67b6\u7684\u6838\u5fc3\uff0c\u4e0d\u662f\u627e\u51fa\u4e00\u4e2a\u201c\u6c38\u8fdc\u6b63\u786e\u201d\u7684\u5747\u7ebf\uff0c\u800c\u662f\u51cf\u5c11\u7a97\u53e3\u9009\u62e9\u91cc\u7684\u4e3b\u89c2\u6210\u5206\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u7528\u82f9\u679c2021\u5e741\u6708\u52302026\u5e748\u6708\u7684\u65e5\u7ebf\u6570\u636e\u505a\u4e86\u590d\u73b0\uff0c\u6700\u7ec8\u9009\u51fa222\u5929\u4f5c\u4e3a\u6700\u4f18\u7a97\u53e3\u3002\u5386\u53f2\u56de\u6d4b\u91cc\u7684\u51c0\u56de\u62a5\u662f72.65%\uff0c\u4ea4\u6613\u6b21\u6570\u662f25\u6b21\uff0c\u7ed3\u679c\u91cc\u4ecd\u7136\u80fd\u770b\u5230\u591a\u6b21\u7a7a\u4ed3\u4fdd\u73b0\u91d1\u7684\u9636\u6bb5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u770b\u770b\u8fd9\u5f20\u5b9e\u9645\u4e70\u5356\u6267\u884c\u56fe\uff0c\u540e\u9762\u6211\u4f1a\u628a\u4ee3\u7801\u548c\u6bcf\u4e00\u6b65\u62c6\u5f00\u8bb2\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-1-1-1024x512.png\" alt=\"\" class=\"wp-image-4828\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-1-1-1024x512.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-1-1-300x150.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-1-1-768x384.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-1-1.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe1\uff1a\u4f18\u5316\u540e\u7684\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u5b9e\u9645\u4e70\u5356\u6267\u884c\u70b9\u4f4d<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u51e0\u4e2a\u503c\u5f97\u8bb0\u7684\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u77ed\u7a97\u53e3\u5e76\u4e0d\u4e00\u5b9a\u66f4\u597d\uff0c\u4ea4\u6613\u6b21\u6570\u4e0a\u53bb\u540e\uff0c\u6210\u672c\u4f1a\u660e\u663e\u4fb5\u8680\u51c0\u56de\u62a5\u3002<\/li>\n\n\n\n<li>\u7ebf\u6027\u641c\u7d22\u867d\u7136\u6734\u7d20\uff0c\u4f46\u5728\u8fd9\u4e2a\u95ee\u9898\u91cc\u8db3\u591f\u7528\uff0c\u56e0\u4e3a\u5019\u9009\u7a7a\u95f4\u53ea\u6709299\u4e2a\u3002<\/li>\n\n\n\n<li>\u6700\u4f18\u7ed3\u679c\u6765\u81ea\u5386\u53f2\u56de\u6d4b\uff0c\u4e0d\u4ee3\u8868\u672a\u6765\u4e00\u5b9a\u4f1a\u91cd\u590d\u3002<\/li>\n\n\n\n<li>\u628a\u624b\u7eed\u8d39\u3001\u6ed1\u70b9\u548c\u4ea4\u6613\u60e9\u7f5a\u4e00\u8d77\u653e\u8fdb\u540c\u4e00\u5957\u89c4\u5219\uff0c\u7ed3\u8bba\u624d\u66f4\u7a33\u3002<\/li>\n\n\n\n<li>\u771f\u6b63\u9002\u5408\u4f60\u7684\u7a97\u53e3\uff0c\u8fd8\u662f\u8981\u7ed3\u5408\u54c1\u79cd\u3001\u5468\u671f\u548c\u4f60\u7684\u6301\u4ed3\u4e60\u60ef\u518d\u9a8c\u8bc1\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u7b56\u7565\u5230\u5e95\u5728\u6bd4\u4ec0\u4e48<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5747\u7ebf\u4ea4\u53c9\u7b56\u7565\u7684\u6bd4\u8f83\u5bf9\u8c61\u5f88\u5355\u4e00\uff1a\u6536\u76d8\u4ef7\u548c\u4e00\u6761\u7b80\u5355\u5747\u7ebf\u3002\u4ef7\u683c\u5728\u5747\u7ebf\u4e0a\u65b9\u65f6\uff0c\u4fdd\u6301\u591a\u5934\uff1b\u4ef7\u683c\u843d\u5230\u5747\u7ebf\u4e0b\u65b9\u65f6\uff0c\u5207\u6362\u6210\u73b0\u91d1\u3002\u4f60\u8c03\u6574\u7684\u53ea\u662f\u201c\u7528\u8fc7\u53bb\u591a\u5c11\u5929\u7684\u6536\u76d8\u4ef7\u7b97\u8fd9\u6761\u5747\u7ebf\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u628a\u76ee\u6807\u62c6\u6210\u4e24\u90e8\u5206\uff1a\u4e00\u662f\u51c0\u56de\u62a5\uff0c\u4e8c\u662f\u4ea4\u6613\u60e9\u7f5a\u3002\u60e9\u7f5a\u6309\u4ea4\u6613\u6b21\u6570\u8ba1\u7b97\uff0c\u6bcf\u591a\u4e00\u7b14\u4ea4\u6613\u5c31\u6263\u6389\u4e00\u5b9a\u6bd4\u4f8b\u3002\u8fd9\u6837\u77ed\u7a97\u53e3\u5c31\u7b97\u6536\u76ca\u9ad8\uff0c\u4e5f\u5f97\u5148\u56de\u7b54\u4e00\u4e2a\u95ee\u9898\uff1a\u591a\u51fa\u6765\u7684\u4ea4\u6613\u662f\u5426\u503c\u5f97\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u516c\u5f0f\u8868\u793a\uff0c\u76ee\u6807\u51fd\u6570\u5927\u6982\u662f\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u76ee\u6807\u503c = \u51c0\u56de\u62a5 &#8211; \u4ea4\u6613\u60e9\u7f5a<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ebf\u6027\u641c\u7d22\u5728\u8fd9\u91cc\u5e76\u4e0d\u9700\u8981\u70ab\u6280\u3002\u641c\u7d22\u7a7a\u95f4\u53ea\u67092\u5230300\u5929\uff0c\u4e00\u5171299\u4e2a\u5019\u9009\u503c\u3002\u628a\u6bcf\u4e2a\u7a97\u53e3\u90fd\u8dd1\u4e00\u904d\u56de\u6d4b\uff0c\u518d\u628a\u7ed3\u679c\u6392\u4e2a\u5e8f\uff0c\u5c31\u80fd\u770b\u51fa\u54ea\u4e9b\u7a97\u53e3\u662f\u201c\u770b\u8d77\u6765\u70ed\u95f9\u4f46\u6210\u672c\u5403\u5229\u6da6\u201d\uff0c\u54ea\u4e9b\u624d\u662f\u201c\u6536\u76ca\u548c\u4ea4\u6613\u6b21\u6570\u90fd\u66f4\u5e73\u8861\u201d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5148\u628a\u73af\u5883\u548c\u6570\u636e\u51c6\u5907\u597d<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5de5\u4f5c\u5206\u6210\u51e0\u6b65\uff1a\u5148\u88c5\u4f9d\u8d56\uff0c\u518d\u53d6\u6570\u636e\uff0c\u518d\u505a\u65e5\u671f\u5904\u7406\uff0c\u6700\u540e\u53ef\u89c6\u5316\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2460 \u5b89\u88c5\u4f9d\u8d56<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code># \u5b89\u88c5\u540e\u7eed\u8981\u7528\u5230\u7684\u4f9d\u8d56\u5e93<\/code><code>&nbsp;pip&nbsp;install requests pandas python-dotenv matplotlib -q<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461 \u52a0\u8f7d\u73af\u5883\u53d8\u91cf\u548c\u6570\u636e\u63a5\u53e3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u7684\u4ee3\u7801\u8d1f\u8d23\u52a0\u8f7d\u4fdd\u5b58\u5728 .env \u91cc\u7684 API key\uff0c\u7136\u540e\u8bf7\u6c42 EODHD \u7684\u5386\u53f2\u65e5\u7ebf\u6570\u636e\u3002\u6570\u636e\u8303\u56f4\u662f2021\u5e741\u6708\u52302026\u5e748\u6708\uff0c\u54c1\u79cd\u662f\u82f9\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import&nbsp;os<\/code><code>import&nbsp;requests<\/code><code>import&nbsp;pandas&nbsp;as&nbsp;pd<\/code><code>import&nbsp;numpy&nbsp;as&nbsp;np<\/code><code>import&nbsp;matplotlib.pyplot&nbsp;as&nbsp;plt<\/code><code>from&nbsp;dotenv&nbsp;import&nbsp;load_dotenv<\/code><code>load_dotenv()<\/code><code># \u4ece\u73af\u5883\u53d8\u91cf\u4e2d\u8bfb\u53d6 API key<\/code><code>API_KEY = os.getenv(\"EODHD_API_KEY\")<\/code><code>if&nbsp;not&nbsp;API_KEY:<\/code><code>&nbsp; &nbsp;&nbsp;raise&nbsp;ValueError(\"EODHD_API_KEY was not found in your .env file\")<\/code><code>print(\"API key loaded successfully\")<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2462 \u4e0b\u8f7d\u5386\u53f2\u6570\u636e\u5e76\u6574\u7406\u65e5\u671f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u62ff\u5230\u539f\u59cb JSON\uff0c\u518d\u8f6c\u6210 DataFrame\u3002\u65e5\u671f\u5b57\u6bb5\u5148\u8f6c\u6210 Pandas \u7684 datetime\uff0c\u7136\u540e\u8bbe\u6210\u7d22\u5f15\u3002\u8fd9\u6837\u540e\u9762\u753b\u56fe\u548c\u5207\u7247\u90fd\u4f1a\u987a\u624b\u5f88\u591a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ticker =&nbsp;\"AAPL.US\"<\/code><code>url = f\"https:\/\/eodhd.com\/api\/eod\/{ticker}\"<\/code><code>params = {<\/code><code>&nbsp; &nbsp;&nbsp;\"api_token\": API_KEY,<\/code><code>&nbsp; &nbsp;&nbsp;\"fmt\":&nbsp;\"json\",<\/code><code>&nbsp; &nbsp;&nbsp;\"from\":&nbsp;\"2021-01-01\",<\/code><code>&nbsp; &nbsp;&nbsp;\"to\":&nbsp;\"2026-08-20\",<\/code><code>&nbsp; &nbsp;&nbsp;\"order\":&nbsp;\"a\"<\/code><code>}<\/code><code><\/code><code>response = requests.get(url, params=params)<\/code><code>response.raise_for_status()<\/code><code>data = response.json()<\/code><code>df = pd.DataFrame(data)<\/code><code>df.head()<\/code><code><\/code><code># \u628a\u65e5\u671f\u8f6c\u6210 datetime\uff0c\u5e76\u8bbe\u4e3a\u7d22\u5f15<\/code><code>df&#91;\"date\"] = pd.to_datetime(df&#91;\"date\"])<\/code><code>df = df.set_index(\"date\")<\/code><code>df.head()<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u539f\u59cb\u4ef7\u683c\u8d70\u52bf\u5148\u770b\u4e00\u773c\u3002\u4e0b\u9762\u7684\u56fe\u5c31\u662f\u82f9\u679c\u8fd9\u6bb5\u65f6\u95f4\u7684\u6536\u76d8\u4ef7\uff0c\u540e\u9762\u6240\u6709\u5747\u7ebf\u3001\u4fe1\u53f7\u548c\u56de\u6d4b\uff0c\u90fd\u662f\u5728\u8fd9\u4e2a\u6570\u636e\u4e0a\u7ee7\u7eed\u5f80\u4e0b\u505a\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_T9B6TKNTAGqQ65XbVQdGeQ-1024x512.png\" alt=\"\" class=\"wp-image-4831\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_T9B6TKNTAGqQ65XbVQdGeQ-1024x512.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_T9B6TKNTAGqQ65XbVQdGeQ-300x150.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_T9B6TKNTAGqQ65XbVQdGeQ-768x384.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_T9B6TKNTAGqQ65XbVQdGeQ.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe2\uff1a\u82f9\u679c2021\u5e741\u6708\u81f32026\u5e748\u6708\u7684\u6536\u76d8\u4ef7\u8d70\u52bf\uff1b<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(12,&nbsp;6))<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; df.index,<\/code><code>&nbsp; &nbsp; df&#91;\"close\"],<\/code><code>&nbsp; &nbsp; label=\"Close Price\"<\/code><code>)<\/code><code><\/code><code>plt.title(f\"{ticker}&nbsp;Stock Closing Price\")<\/code><code>plt.xlabel(\"Date\")<\/code><code>plt.ylabel(\"Price\")<\/code><code>plt.legend()<\/code><code>plt.grid(True)<\/code><code>plt.savefig(\"stock_price_plot.png\")<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2463 \u56de\u6d4b\u51fd\u6570\u662f\u6574\u5957\u5b9e\u9a8c\u7684\u6838\u5fc3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3b\u5faa\u73af\u51fd\u6570\u91cc\u505a\u4e86\u56db\u4ef6\u4e8b\uff1a\u7b97\u5747\u7ebf\u3001\u751f\u6210\u4fe1\u53f7\u3001\u6309\u6b21\u65e5\u5f00\u76d8\u4ef7\u6267\u884c\u3001\u8bb0\u5f55\u73b0\u91d1\u3001\u6301\u4ed3\u548c\u7ec4\u5408\u4ef7\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def&nbsp;run_backtest(<\/code><code>&nbsp; &nbsp; df,<\/code><code>&nbsp; &nbsp; window,<\/code><code>&nbsp; &nbsp; initial_cash=10_000.00,<\/code><code>&nbsp; &nbsp; transaction_cost=0.001,<\/code><code>&nbsp; &nbsp; slippage=0.0005<\/code><code>):<\/code><code>&nbsp; &nbsp;&nbsp;# \u9488\u5bf9\u67d0\u4e00\u4e2a\u5747\u7ebf\u7a97\u53e3\uff0c\u8fd0\u884c\u4ef7\u683c\u7a7f\u8d8a\u5747\u7ebf\u7684\u7b56\u7565\u56de\u6d4b<\/code><code>&nbsp; &nbsp;&nbsp;# \u4fe1\u53f7\u5728\u6536\u76d8\u540e\u751f\u6210\uff0c\u4ea4\u6613\u5728\u6b21\u65e5\u5f00\u76d8\u6267\u884c<\/code><code>&nbsp; &nbsp;&nbsp;# \u5141\u8bb8\u4e70 fractional shares<\/code><code>&nbsp; &nbsp; data = df.copy()<\/code><code><\/code><code>&nbsp; &nbsp;&nbsp;# \u8ba1\u7b97\u7b80\u5355\u5747\u7ebf<\/code><code>&nbsp; &nbsp; data&#91;\"MA\"] = data&#91;\"close\"].rolling(window).mean()<\/code><code><\/code><code>&nbsp; &nbsp;&nbsp;# \u751f\u6210\u4fe1\u53f7\uff1a\u6536\u76d8\u4ef7\u7ad9\u4e0a\u5747\u7ebf\u8bb0\u4e3a1\uff0c\u5426\u5219\u8bb0\u4e3a0<\/code><code>&nbsp; &nbsp; data&#91;\"signal\"] =&nbsp;0<\/code><code>&nbsp; &nbsp; data.loc&#91;data&#91;\"close\"] &gt; data&#91;\"MA\"],&nbsp;\"signal\"] =&nbsp;1<\/code><code>&nbsp; &nbsp; data.loc&#91;data&#91;\"close\"] &lt;= data&#91;\"MA\"],&nbsp;\"signal\"] =&nbsp;0<\/code><code>&nbsp; &nbsp; data&#91;\"position_change\"] = data&#91;\"signal\"].diff()<\/code><code><\/code><code>&nbsp; &nbsp;&nbsp;# \u521d\u59cb\u5316\u8d26\u6237\u72b6\u6001<\/code><code>&nbsp; &nbsp; cash = initial_cash<\/code><code>&nbsp; &nbsp; shares =&nbsp;0.0<\/code><code>&nbsp; &nbsp; trades = &#91;]<\/code><code>&nbsp; &nbsp; portfolio = &#91;]<\/code><code><\/code><code>&nbsp; &nbsp;&nbsp;# \u6309\u5929\u904d\u5386\uff0c\u6267\u884c\u4ea4\u6613\u903b\u8f91<\/code><code>&nbsp; &nbsp;&nbsp;for&nbsp;i&nbsp;in&nbsp;range(len(data)):<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; date = data.index&#91;i]<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; close_price = data&#91;\"close\"].iloc&#91;i]<\/code><code><\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# \u4fe1\u53f7\u6309\u6b21\u65e5\u5f00\u76d8\u4ef7\u6267\u884c<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;i +&nbsp;1&nbsp;&lt;&nbsp;len(data):<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; next_open = data&#91;\"open\"].iloc&#91;i +&nbsp;1]<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;else:<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; next_open = np.nan<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; signal = data&#91;\"position_change\"].iloc&#91;i]<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# \u5f00\u591a<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;signal ==&nbsp;1&nbsp;and&nbsp;shares ==&nbsp;0&nbsp;and&nbsp;not&nbsp;np.isnan(next_open):<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execution_price = next_open * (1&nbsp;+ slippage)<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amount_to_invest = cash \/ (1&nbsp;+ transaction_cost)<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shares_bought = amount_to_invest \/ execution_price<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trade_value = shares_bought * execution_price<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fee = trade_value * transaction_cost<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash -= trade_value + fee<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shares += shares_bought<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trades.append({<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"date\": data.index&#91;i +&nbsp;1],<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"type\":&nbsp;\"BUY\",<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"price\": execution_price,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"shares\": shares_bought,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"value\": trade_value,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"fee\": fee,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"cash_after\": cash<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# \u6e05\u591a<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;elif&nbsp;signal == -1&nbsp;and&nbsp;shares &gt;&nbsp;0&nbsp;and&nbsp;not&nbsp;np.isnan(next_open):<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execution_price = next_open * (1&nbsp;- slippage)<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trade_value = shares * execution_price<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fee = trade_value * transaction_cost<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cash += trade_value - fee<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trades.append({<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"date\": data.index&#91;i +&nbsp;1],<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"type\":&nbsp;\"SELL\",<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"price\": execution_price,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"shares\": shares,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"value\": trade_value,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"fee\": fee,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"cash_after\": cash<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shares =&nbsp;0.0<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# \u8bb0\u5f55\u5f53\u65e5\u7ec4\u5408\u5e02\u503c<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; stock_value = shares * close_price<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; total_value = cash + stock_value<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; portfolio.append({<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"date\": date,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"cash\": cash,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"shares\": shares,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"stock_value\": stock_value,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"portfolio_value\": total_value<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; })<\/code><code><\/code><code>&nbsp; &nbsp;&nbsp;# \u6c47\u603b\u7ed3\u679c<\/code><code>&nbsp; &nbsp; portfolio_df = pd.DataFrame(portfolio)<\/code><code>&nbsp; &nbsp; portfolio_df.set_index(\"date\", inplace=True)<\/code><code>&nbsp; &nbsp; trades_df = pd.DataFrame(trades)<\/code><code>&nbsp; &nbsp; final_value = portfolio_df&#91;\"portfolio_value\"].iloc&#91;-1]<\/code><code>&nbsp; &nbsp; total_return = (final_value \/ initial_cash -&nbsp;1) *&nbsp;100<\/code><code>&nbsp; &nbsp;&nbsp;return&nbsp;{<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"window\": window,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"final_value\": final_value,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"total_return\": total_return,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"portfolio\": portfolio_df,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"trades\": trades_df,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"data\": data<\/code><code>&nbsp; &nbsp; }<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u65b0\u624b\u4f1a\u628a\u201c\u4fe1\u53f7\u201d\u548c\u201c\u6210\u4ea4\u201d\u6df7\u5728\u4e00\u8d77\u3002\u8fd9\u4e2a\u7248\u672c\u91cc\uff0c\u4fe1\u53f7\u7528\u6536\u76d8\u4ef7\u5224\u65ad\uff0c\u4f46\u5b9e\u9645\u6210\u4ea4\u7528\u6b21\u65e5\u5f00\u76d8\u4ef7\uff0c\u8fd8\u8981\u6263\u6389\u624b\u7eed\u8d39\u548c\u6ed1\u70b9\u3002\u8fd9\u6837\u56de\u6d4b\u51fa\u6765\u7684\u4ea4\u6613\u6b21\u6570\u624d\u66f4\u50cf\u771f\u5b9e\u73af\u5883\uff0c\u800c\u4e0d\u662f\u53ea\u770b\u7406\u60f3\u7a7f\u8d8a\u70b9\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u628a299\u4e2a\u7a97\u53e3\u6328\u4e2a\u8dd1\u4e00\u904d<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u641c\u7d22\u8303\u56f4\u8bbe\u4e3a2\u5230300\u5929\uff0c\u5171299\u4e2a\u5019\u9009\u7a97\u53e3\u3002\u5bf9\u6bcf\u4e2a\u7a97\u53e3\u90fd\u8dd1\u4e00\u6b21\u5b8c\u6574\u56de\u6d4b\uff0c\u518d\u628a\u51c0\u56de\u62a5\u3001\u4ea4\u6613\u6b21\u6570\u548c\u60e9\u7f5a\u4e00\u8d77\u8bb0\u4e0b\u6765\u3002\u8fd9\u6837\u4e0d\u540c\u7a97\u53e3\u4e4b\u95f4\u5c31\u662f\u540c\u4e00\u5957\u6bd4\u8d5b\u89c4\u5219\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2460 \u641c\u7d22\u8303\u56f4\u548c\u7ebf\u6027\u641c\u7d22\u914d\u7f6e<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code># \u8bbe\u5b9a\u641c\u7d22\u8fb9\u754c<\/code><code>MIN_WINDOW =&nbsp;2<\/code><code>MAX_WINDOW =&nbsp;300<\/code><code>windows =&nbsp;range(MIN_WINDOW, MAX_WINDOW +&nbsp;1)<\/code><code>print(f\"Testing&nbsp;{MIN_WINDOW}&nbsp;to&nbsp;{MAX_WINDOW}&nbsp;day moving averages\")<\/code><code>print(f\"Total windows to test:&nbsp;{len(windows)}\")<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\u4f1a\u76f4\u63a5\u544a\u8bc9\u4f60\u8fd9\u6b21\u8981\u904d\u5386\u591a\u5c11\u4e2a\u7a97\u53e3\u3002\u8fd9\u4e2a\u6570\u5b57\u5f88\u5c0f\uff0c\u6240\u4ee5\u7ebf\u6027\u641c\u7d22\u5b8c\u5168\u591f\u7528\u3002\u771f\u6b63\u8981\u6ce8\u610f\u7684\u662f\u540e\u9762\u7684\u60e9\u7f5a\u9879\uff0c\u522b\u8ba9\u6a21\u578b\u88ab\u591a\u4ea4\u6613\u51e0\u6b21\u7684\u9ad8\u6536\u76ca\u5e26\u504f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461 \u7ebf\u6027\u641c\u7d22\u4e3b\u5faa\u73af<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5faa\u73af\u91cc\u6bcf\u6b21\u90fd\u8c03\u7528\u540c\u4e00\u4e2a\u56de\u6d4b\u51fd\u6570\uff0c\u8fd9\u6837\u4fdd\u8bc1\u6bcf\u4e2a\u7a97\u53e3\u770b\u5230\u7684\u4ea4\u6613\u6210\u672c\u3001\u6ed1\u70b9\u548c\u521d\u59cb\u8d44\u91d1\u90fd\u4e00\u6837\u3002\u7ed3\u679c\u653e\u8fdb\u4e00\u4e2a DataFrame \u4e4b\u540e\uff0c\u540e\u9762\u6311\u6700\u4f18\u7a97\u53e3\u5c31\u5f88\u65b9\u4fbf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># \u6bcf\u591a\u4e00\u7b14\u4ea4\u6613\uff0c\u989d\u5916\u6263 0.25 \u4e2a\u767e\u5206\u70b9<\/code><code>trade_penalty = 0.25<\/code><code>optimization_results = &#91;]<\/code><code>for window in windows:<\/code><code>&nbsp; &nbsp; result = run_backtest(<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; df=df,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; window=window,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; initial_cash=10_000.00,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; transaction_cost=0.001,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp; slippage=0.0005<\/code><code>&nbsp; &nbsp; )<\/code><code>&nbsp; &nbsp; number_of_trades = len(result&#91;\"trades\"])<\/code><code>&nbsp; &nbsp; net_return = result&#91;\"total_return\"]<\/code><code>&nbsp; &nbsp; penalty = number_of_trades * trade_penalty<\/code><code>&nbsp; &nbsp; objective = net_return - penalty<\/code><code>&nbsp; &nbsp; optimization_results.append({<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"window\": window,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"final_value\": result&#91;\"final_value\"],<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"total_return\": net_return,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"number_of_trades\": number_of_trades,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"penalty\": penalty,<\/code><code>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\"objective\": objective<\/code><code>&nbsp; &nbsp; })<\/code><code>optimization_df = pd.DataFrame(optimization_results)<\/code><code>optimization_df.head()<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2462 \u6311\u51fa\u6700\u4f18\u7a97\u53e3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u7684\u201c\u6700\u4f18\u201d\u4e0d\u662f\u53ea\u770b\u51c0\u56de\u62a5\u6700\u9ad8\uff0c\u800c\u662f\u770b\u76ee\u6807\u51fd\u6570\u6700\u9ad8\u3002\u76ee\u6807\u51fd\u6570\u5df2\u7ecf\u628a\u4ea4\u6613\u60e9\u7f5a\u7b97\u8fdb\u53bb\u4e86\uff0c\u6240\u4ee5\u6700\u7ec8\u9009\u51fa\u6765\u7684\u7a97\u53e3\uff0c\u901a\u5e38\u662f\u201c\u6536\u76ca\u4e0d\u9519\uff0c\u540c\u65f6\u4e0d\u4f1a\u4e71\u4ea4\u6613\u201d\u7684\u90a3\u79cd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>best_result = optimization_df.loc&#91;<\/code><code>&nbsp; &nbsp; optimization_df&#91;\"objective\"].idxmax()<\/code><code>]<\/code><code>best_window =&nbsp;int(best_result&#91;\"window\"])<\/code><code>best_return = best_result&#91;\"total_return\"]<\/code><code>best_final_value = best_result&#91;\"final_value\"]<\/code><code>best_trades =&nbsp;int(best_result&#91;\"number_of_trades\"])<\/code><code>best_penalty = best_result&#91;\"penalty\"]<\/code><code>best_objective = best_result&#91;\"objective\"]<\/code><code>print(f\"Optimal moving-average window:&nbsp;{best_window}&nbsp;days\")<\/code><code>print(f\"Final portfolio value: ${best_final_value:,.2f}\")<\/code><code>print(f\"Net return:&nbsp;{best_return:.2f}%\")<\/code><code>print(f\"Number of trades:&nbsp;{best_trades}\")<\/code><code>print(f\"Trading penalty:&nbsp;{best_penalty:.2f}%\")<\/code><code>print(f\"Optimization objective:&nbsp;{best_objective:.2f}%\")<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6b21\u8dd1\u51fa\u6765\u7684\u7ed3\u679c\u662f222\u5929\u7a97\u53e3\u3002\u51c0\u56de\u62a572.65%\uff0c\u4ea4\u6613\u6b21\u657025\u6b21\uff0c\u60e9\u7f5a6.25%\uff0c\u76ee\u6807\u503c66.40%\u3002\u8fd9\u4e2a\u7ed3\u679c\u8bf4\u660e\uff0c\u66f4\u957f\u7684\u7a97\u53e3\u867d\u7136\u53ef\u80fd\u9519\u8fc7\u4e00\u4e9b\u77ed\u7ebf\u6ce2\u52a8\uff0c\u4f46\u4e5f\u56e0\u6b64\u51cf\u5c11\u4e86\u53cd\u590d\u8fdb\u51fa\u5e26\u6765\u7684\u6210\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2463 \u628a\u6bcf\u4e2a\u7a97\u53e3\u7684\u7ed3\u679c\u90fd\u53ef\u89c6\u5316<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u5f20\u56fe\u6700\u80fd\u8bf4\u660e\u95ee\u9898\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_BfXrzIoAsFIo3k3rF4T6XA-1024x512.png\" alt=\"\" class=\"wp-image-4834\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_BfXrzIoAsFIo3k3rF4T6XA-1024x512.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_BfXrzIoAsFIo3k3rF4T6XA-300x150.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_BfXrzIoAsFIo3k3rF4T6XA-768x384.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_BfXrzIoAsFIo3k3rF4T6XA.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe3\uff1a\u4e0d\u540c\u5747\u7ebf\u7a97\u53e3\u7684\u51c0\u56de\u62a5\u66f2\u7ebf\u4e0e\u6700\u4f18\u7a97\u53e3\u6807\u6ce8\uff1b<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6a2a\u8f74\u662f\u4ece2\u5230300\u5929\u7684\u5019\u9009\u7a97\u53e3\uff0c\u7eb5\u8f74\u662f\u6bcf\u4e2a\u7a97\u53e3\u7684\u51c0\u56de\u62a5\u3002\u6a59\u8272\u661f\u6807\u5c31\u662f\u6700\u7ec8\u9009\u51fa\u7684222\u5929\u3002\u6211\u4eec\u53ef\u4ee5\u5f88\u76f4\u89c2\u5730\u770b\u5230\uff0c\u5e76\u4e0d\u662f\u8d8a\u9760\u8fd1\u5de6\u8fb9\u8d8a\u597d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(14,&nbsp;7))<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; optimization_df&#91;\"window\"],<\/code><code>&nbsp; &nbsp; optimization_df&#91;\"total_return\"],<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>plt.scatter(<\/code><code>&nbsp; &nbsp; best_window,<\/code><code>&nbsp; &nbsp; best_return,<\/code><code>&nbsp; &nbsp; marker=\"*\",<\/code><code>&nbsp; &nbsp; s=500,<\/code><code>&nbsp; &nbsp; color=\"orange\",<\/code><code>&nbsp; &nbsp; label=f\"Best:&nbsp;{best_window}-Day MA\",<\/code><code>&nbsp; &nbsp; zorder=10<\/code><code>)<\/code><code>plt.title(\"Moving Average Window Optimization\")<\/code><code>plt.xlabel(\"Moving Average Window (Days)\")<\/code><code>plt.ylabel(\"Total Return (%)\")<\/code><code>plt.legend()<\/code><code>plt.grid(True)<\/code><code>plt.savefig(\"optimization_performance_plot.png\")<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u7528\u6700\u4f18\u7a97\u53e3\u8dd1\u6700\u540e\u4e00\u8f6e\u56de\u6d4b<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u627e\u5230222\u5929\u540e\uff0c\u518d\u7528\u8fd9\u4e2a\u7a97\u53e3\u5b8c\u6574\u56de\u6d4b\u4e00\u6b21\u3002\u8fd9\u4e00\u6b65\u4e0d\u53ea\u662f\u4e3a\u4e86\u597d\u770b\uff0c\u800c\u662f\u4e3a\u4e86\u62ff\u5230\u6700\u7ec8\u7684\u65e5\u7ebf\u6301\u4ed3\u3001\u4ea4\u6613\u8bb0\u5f55\u548c\u7ec4\u5408\u66f2\u7ebf\uff0c\u65b9\u4fbf\u540e\u9762\u7ee7\u7eed\u68c0\u67e5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>best_backtest = run_backtest(<\/code><code>&nbsp; &nbsp; df=df,<\/code><code>&nbsp; &nbsp; window=best_window,<\/code><code>&nbsp; &nbsp; initial_cash=10_000.00,<\/code><code>&nbsp; &nbsp; transaction_cost=0.001,<\/code><code>&nbsp; &nbsp; slippage=0.0005<\/code><code>)<\/code><code>final_df = best_backtest&#91;\"data\"]<\/code><code>portfolio_df = best_backtest&#91;\"portfolio\"]<\/code><code>trades_df = best_backtest&#91;\"trades\"]<\/code><code>final_value = best_backtest&#91;\"final_value\"]<\/code><code>total_return = best_backtest&#91;\"total_return\"]<\/code><code>print(f\"Optimal MA window:&nbsp;{best_window}&nbsp;days\")<\/code><code>print(f\"Initial capital: $10,000.00\")<\/code><code>print(f\"Final portfolio value: ${final_value:,.2f}\")<\/code><code>print(f\"Total return:&nbsp;{total_return:.2f}%\")<\/code><code>print(f\"Number of trades:&nbsp;{len(trades_df)}\")<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa\u91cc\u6700\u5173\u952e\u7684\u662f\u4e09\u4e2a\u6570\u5b57\uff1a222\u5929\u7a97\u53e3\u30011\u4e07\u7f8e\u5143\u672c\u91d1\u300125\u6b21\u4ea4\u6613\u3002\u540e\u9762\u7684\u56fe\u548c\u4fe1\u53f7\uff0c\u90fd\u662f\u57fa\u4e8e\u8fd9\u7ec4\u53c2\u6570\u7ee7\u7eed\u5f80\u4e0b\u62c6\u7684\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4ef7\u628a\u683c\u548c\u4f18\u5316\u540e\u7684\u5747\u7ebf\u653e\u5728\u4e00\u8d77\u770b<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u5f20\u56fe\u628a\u6536\u76d8\u4ef7\u548c222\u5929\u5747\u7ebf\u53e0\u5728\u4e00\u8d77\uff0c\u65b9\u4fbf\u4f60\u76f4\u89c2\u611f\u53d7\u8fd9\u4e2a\u7a97\u53e3\u5230\u5e95\u662f\u504f\u6162\u8fd8\u662f\u504f\u5feb\u3002\u5bf9\u82f9\u679c\u8fd9\u6bb5\u65f6\u95f4\u6765\u8bf4\uff0c\u5b83\u660e\u663e\u66f4\u504f\u5411\u201c\u5c11\u52a8\u201d\u7684\u98ce\u683c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_LMZ4KiR6jhN8UomJvYYfGA-1-1024x512.png\" alt=\"\" class=\"wp-image-4835\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_LMZ4KiR6jhN8UomJvYYfGA-1-1024x512.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_LMZ4KiR6jhN8UomJvYYfGA-1-300x150.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_LMZ4KiR6jhN8UomJvYYfGA-1-768x384.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_LMZ4KiR6jhN8UomJvYYfGA-1.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe4\uff1a\u6536\u76d8\u4ef7\u4e0e\u4f18\u5316\u540e\u7684222\u5929\u5747\u7ebf\u5bf9\u6bd4\uff1b<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(14,&nbsp;7))<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; final_df.index,<\/code><code>&nbsp; &nbsp; final_df&#91;\"close\"],<\/code><code>&nbsp; &nbsp; label=\"Close Price\",<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; final_df.index,<\/code><code>&nbsp; &nbsp; final_df&#91;\"MA\"],<\/code><code>&nbsp; &nbsp; label=f\"{best_window}-Day Moving Average\",<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>plt.title(<\/code><code>&nbsp; &nbsp;&nbsp;f\"Price vs Optimized&nbsp;{best_window}-Day Moving Average\"<\/code><code>)<\/code><code>plt.xlabel(\"Date\")<\/code><code>plt.ylabel(\"Price\")<\/code><code>plt.legend()<\/code><code>plt.grid(True)<\/code><code>plt.savefig(\"optimized_moving_average_plot.png\")<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u628a\u771f\u5b9e\u4e70\u5356\u70b9\u4f4d\u6807\u51fa\u6765<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u7684\u56fe\u662f\u5f88\u591a\u4eba\u6700\u5173\u5fc3\u7684\u90e8\u5206\uff1a\u7b56\u7565\u5230\u5e95\u5728\u54ea\u4e9b\u5929\u5f00\u591a\uff0c\u54ea\u4e9b\u5929\u6e05\u591a\u3002\u7eff\u8272\u4e09\u89d2\u4ee3\u8868\u5b9e\u9645\u4e70\u70b9\uff0c\u7ea2\u8272\u4e09\u89d2\u4ee3\u8868\u5b9e\u9645\u5356\u70b9\u3002\u56e0\u4e3a\u4ea4\u6613\u662f\u6b21\u65e5\u5f00\u76d8\u6267\u884c\uff0c\u6240\u4ee5\u8fd9\u4e9b\u70b9\u4f4d\u4e0d\u4e00\u5b9a\u6b63\u597d\u51fa\u73b0\u5728\u4fe1\u53f7\u5f53\u5929\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"350\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ.png\" alt=\"\" class=\"wp-image-4837\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ.png 700w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_8Ax9YXdTwNq7AL8R6G6NcQ-300x150.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\">\u56fe5\uff1a\u4f18\u5316\u7b56\u7565\u4e0b\u7684\u5b9e\u9645\u4e70\u5356\u6267\u884c\u70b9\u4f4d\uff1b<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><code># \u751f\u6210\u6301\u4ed3\u4fe1\u53f7<\/code><code>final_df&#91;\"signal\"] =&nbsp;0<\/code><code>final_df.loc&#91;<\/code><code>&nbsp; &nbsp; final_df&#91;\"close\"] &gt; final_df&#91;\"MA\"],<\/code><code>&nbsp; &nbsp;&nbsp;\"signal\"<\/code><code>] =&nbsp;1<\/code><code>final_df.loc&#91;<\/code><code>&nbsp; &nbsp; final_df&#91;\"close\"] &lt;= final_df&#91;\"MA\"],<\/code><code>&nbsp; &nbsp;&nbsp;\"signal\"<\/code><code>] =&nbsp;0<\/code><code>final_df&#91;\"position_change\"] = final_df&#91;\"signal\"].diff()<\/code><code># \u753b\u51fa\u4ef7\u683c\u3001\u5747\u7ebf\u548c\u5b9e\u9645\u4ea4\u6613\u70b9\u4f4d<\/code><code>plt.figure(figsize=(14,&nbsp;7))<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; final_df.index,<\/code><code>&nbsp; &nbsp; final_df&#91;\"close\"],<\/code><code>&nbsp; &nbsp; label=\"Close Price\",<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; final_df.index,<\/code><code>&nbsp; &nbsp; final_df&#91;\"MA\"],<\/code><code>&nbsp; &nbsp; label=f\"{best_window}-Day Moving Average\",<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>buy_trades = trades_df&#91;<\/code><code>&nbsp; &nbsp; trades_df&#91;\"type\"] ==&nbsp;\"BUY\"<\/code><code>]<\/code><code>plt.scatter(<\/code><code>&nbsp; &nbsp; buy_trades&#91;\"date\"],<\/code><code>&nbsp; &nbsp; buy_trades&#91;\"price\"],<\/code><code>&nbsp; &nbsp; marker=\"^\",<\/code><code>&nbsp; &nbsp; s=120,<\/code><code>&nbsp; &nbsp; label=\"Buy\",<\/code><code>&nbsp; &nbsp; color=\"green\",<\/code><code>&nbsp; &nbsp; zorder=10<\/code><code>)<\/code><code>sell_trades = trades_df&#91;<\/code><code>&nbsp; &nbsp; trades_df&#91;\"type\"] ==&nbsp;\"SELL\"<\/code><code>]<\/code><code>plt.scatter(<\/code><code>&nbsp; &nbsp; sell_trades&#91;\"date\"],<\/code><code>&nbsp; &nbsp; sell_trades&#91;\"price\"],<\/code><code>&nbsp; &nbsp; marker=\"v\",<\/code><code>&nbsp; &nbsp; s=120,<\/code><code>&nbsp; &nbsp; label=\"Sell\",<\/code><code>&nbsp; &nbsp; color=\"red\",<\/code><code>&nbsp; &nbsp; zorder=10<\/code><code>)<\/code><code>plt.title(<\/code><code>&nbsp; &nbsp;&nbsp;f\"Price Crossover Strategy -&nbsp;{best_window}-Day MA\"<\/code><code>)<\/code><code>plt.xlabel(\"Date\")<\/code><code>plt.ylabel(\"Price\")<\/code><code>plt.legend()<\/code><code>plt.grid(True)<\/code><code>plt.savefig(\"trading_signals_plot.png\")<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u770b\u8fd9\u5f20\u56fe\u65f6\u522b\u53ea\u76ef\u7740\u4e70\u70b9\u548c\u5356\u70b9\u3002\u66f4\u8981\u770b\u7b56\u7565\u5728\u54ea\u4e9b\u65f6\u95f4\u6bb5\u4e00\u76f4\u7a7a\u4ed3\u6301\u5e01\u3002222\u5929\u5747\u7ebf\u672c\u8eab\u5c31\u662f\u504f\u6162\u7684\u53c2\u6570\uff0c\u6240\u4ee5\u5f88\u591a\u9707\u8361\u5e02\u91cc\u5b83\u4f1a\u9009\u62e9\u4e0d\u52a8\u3002\u5bf9\u91cf\u5316\u65b0\u4eba\u6765\u8bf4\uff0c\u8fd9\u4e00\u70b9\u6bd4\u201c\u6293\u5230\u591a\u5c11\u6ce2\u201d\u66f4\u503c\u5f97\u5148\u5b66\u4f1a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u7ec4\u5408\u51c0\u503c\u66f2\u7ebf\u8bf4\u660e\u56de\u6d4b\u5168\u8fc7\u7a0b<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\u4e00\u5e45\u56fe\u662f\u7ec4\u5408\u5e02\u503c\u66f2\u7ebf\u3002\u6700\u503c\u5f97\u6ce8\u610f\u7684\uff0c\u4e0d\u662f\u6700\u540e\u6570\u5b57\u597d\u770b\u4e0d\u597d\u770b\uff0c\u800c\u662f\u4e2d\u95f4\u6709\u51e0\u6bb5\u660e\u663e\u6a2a\u76d8\u751a\u81f3\u8d70\u5e73\u3002\u90a3\u4e9b\u9636\u6bb5\u8bf4\u660e\u7b56\u7565\u6ca1\u6709\u5f3a\u884c\u6301\u4ed3\uff0c\u800c\u662f\u901a\u8fc7\u7a7a\u4ed3\u8eb2\u6389\u4e86\u4e00\u90e8\u5206\u4e0d\u786e\u5b9a\u6027\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_XzZ38rvXSDw7PPcMC3tAFQ-2-1024x512.png\" alt=\"\" class=\"wp-image-4839\" srcset=\"https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_XzZ38rvXSDw7PPcMC3tAFQ-2-1024x512.png 1024w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_XzZ38rvXSDw7PPcMC3tAFQ-2-300x150.png 300w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_XzZ38rvXSDw7PPcMC3tAFQ-2-768x384.png 768w, https:\/\/laoyulaoyu.com\/wp-content\/uploads\/2026\/09\/1_XzZ38rvXSDw7PPcMC3tAFQ-2.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe6\uff1a\u4f18\u5316\u7b56\u7565\u4e0b\u7684\u7ec4\u5408\u5e02\u503c\u66f2\u7ebf\uff1b<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(14,&nbsp;7))<\/code><code>plt.plot(<\/code><code>&nbsp; &nbsp; portfolio_df.index,<\/code><code>&nbsp; &nbsp; portfolio_df&#91;\"portfolio_value\"],<\/code><code>&nbsp; &nbsp; label=\"Strategy Portfolio\",<\/code><code>&nbsp; &nbsp; zorder=2<\/code><code>)<\/code><code>plt.axhline(<\/code><code>&nbsp; &nbsp;&nbsp;10_000,<\/code><code>&nbsp; &nbsp; linestyle=\"--\",<\/code><code>&nbsp; &nbsp; label=\"Initial Capital\",<\/code><code>&nbsp; &nbsp; zorder=1<\/code><code>)<\/code><code>plt.title(<\/code><code>&nbsp; &nbsp;&nbsp;f\"Portfolio Value - Optimized&nbsp;{best_window}-Day MA Strategy\"<\/code><code>)<\/code><code>plt.xlabel(\"Date\")<\/code><code>plt.ylabel(\"Portfolio Value ($)\")<\/code><code>plt.legend()<\/code><code>plt.grid(True)<\/code><code>plt.savefig(\"portfolio_performance_plot.png\")<\/code><code>plt.show()<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u7ec8\u7ed3\u679c\u662f1\u4e07\u7f8e\u5143\u53d8\u621017264.66\u7f8e\u5143\uff0c\u51c0\u56de\u62a572.65%\uff0c\u517125\u6b21\u4ea4\u6613\u3002\u8fd9\u4e2a\u6570\u5b57\u6211\u53ea\u5f53\u5b9e\u9a8c\u7ed3\u679c\u770b\uff0c\u4e0d\u628a\u5b83\u5305\u88c5\u6210\u67d0\u79cd\u201c\u5e74\u5316\u6807\u51c6\u7b54\u6848\u201d\u3002\u5b83\u66f4\u50cf\u662f\u5728\u8bf4\uff1a\u5982\u679c\u4e25\u683c\u6309\u7167\u8fd9\u5957\u89c4\u5219\u6267\u884c\uff0c\u8fc7\u53bb\u8fd9\u6bb5\u65f6\u95f4\u91cc\uff0c222\u5929\u7a97\u53e3\u6bd4\u968f\u610f\u9009\u4e00\u4e2a20\u5929\u621650\u5929\u7a97\u53e3\u66f4\u7a33\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u8fd9\u4ef6\u4e8b\u7ed9\u6211\u7684\u63d0\u9192<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u4eba\u7814\u7a76\u5747\u7ebf\u7b56\u7565\uff0c\u7b2c\u4e00\u6b65\u5c31\u662f\u8c03\u53c2\u6570\uff0c\u7b2c\u4e8c\u6b65\u5c31\u5f00\u59cb\u627e\u201c\u6700\u597d\u7528\u7684\u6570\u5b57\u201d\u3002\u8fd9\u7bc7\u6587\u7ae0\u771f\u6b63\u503c\u5f97\u501f\u9274\u7684\uff0c\u662f\u628a\u53c2\u6570\u8fd9\u4ef6\u4e8b\u505a\u6210\u4e00\u4e2a\u53ef\u91cd\u590d\u3001\u53ef\u6bd4\u8f83\u3001\u53ef\u60e9\u7f5a\u8fc7\u5ea6\u4ea4\u6613\u7684\u6d41\u7a0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ebf\u6027\u641c\u7d22\u5e76\u4e0d\u662f\u6700\u9ad8\u7ea7\u7684\u65b9\u6cd5\uff0c\u4f46\u5b83\u8db3\u591f\u76f4\u767d\u6613\u61c2\uff0c\u4e0d\u9700\u8981\u9ed1\u7bb1\u4e5f\u80fd\u770b\u61c2\u3002\u4f60\u80fd\u6e05\u695a\u5730\u770b\u5230\uff0c\u641c\u7d22\u6d41\u7a0b\u4e3a\u4ec0\u4e48\u9009222\u5929\uff0c\u800c\u4e0d\u662f200\u5929\u6216250\u5929\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u771f\u6b63\u503c\u5f97\u7ee7\u7eed\u505a\u7684\uff0c\u4e0d\u662f\u628a222\u5929\u5f53\u552f\u4e00\u7b54\u6848\uff0c\u800c\u662f\u628a\u540c\u6837\u7684\u6d41\u7a0b\u642c\u5230\u522b\u7684\u54c1\u79cd\u3001\u522b\u7684\u5468\u671f\u3001\u522b\u7684\u60e9\u7f5a\u7cfb\u6570\u91cc\u518d\u8dd1\u4e00\u904d\u3002\u5982\u679c\u4e0d\u540c\u5e02\u573a\u90fd\u80fd\u7ed9\u51fa\u63a5\u8fd1\u7684\u7ed3\u8bba\uff0c\u90a3\u624d\u8bf4\u660e\u8fd9\u4e2a\u65b9\u6cd5\u4e0d\u662f\u8fc7\u5ea6\u62df\u5408\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u70b9\u5b9e\u64cd\u5efa\u8bae<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u8981\u81ea\u5df1\u590d\u73b0\uff0c\u6211\u5efa\u8bae\u5148\u4ece\u4e09\u4e2a\u5730\u65b9\u4e0b\u624b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\uff0c\u628a\u4ea4\u6613\u6210\u672c\u3001\u6ed1\u70b9\u548c penalty \u8bbe\u6210\u53d8\u91cf\uff0c\u4e0d\u8981\u786c\u7f16\u7801\uff0c\u540e\u9762\u8c03\u53c2\u4f1a\u65b9\u4fbf\u5f88\u591a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\uff0c\u628a\u7ed3\u679c\u6309\u5e74\u62c6\u5f00\u770b\uff0c\u4e0d\u8981\u53ea\u770b\u603b\u56de\u62a5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e09\uff0c\u518d\u62ff\u4e00\u6bb5\u6837\u672c\u5916\u6570\u636e\u6d4b\u8bd5\uff0c\u770b\u770b222\u5929\u5728\u672a\u89c1\u8fc7\u7684\u884c\u60c5\u91cc\u662f\u5426\u8fd8\u80fd\u4fdd\u6301\u76f8\u5bf9\u7a33\u5b9a\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><a>#\u91cf\u5316\u7b56\u7565<\/a>&nbsp;<a>#\u5747\u7ebf\u7b56\u7565<\/a>&nbsp;<a>#\u7ebf\u6027\u641c\u7d22<\/a>&nbsp;<a>#Python\u56de\u6d4b<\/a>&nbsp;<a>#\u53c2\u6570\u4f18\u5316<\/a>&nbsp;<a>#\u4ea4\u6613\u6210\u672c<\/a>&nbsp;<a>#AAPL<\/a>&nbsp;<a>#\u5386\u53f2\u56de\u6d4b<\/a><\/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:\/\/laoyulaoyu.com\/index.php\/2026\/09\/08\/%e5%88%ab%e5%86%8d%e9%9a%8f%e6%89%8b%e7%8c%9c%e5%9d%87%e7%ba%bf%e5%8f%82%e6%95%b0%e4%ba%86%ef%bc%8c%e7%ba%bf%e6%80%a7%e6%90%9c%e7%b4%a2%e6%9b%b4%e9%9d%a0%e8%b0%b1\/\">Continue reading<span class=\"screen-reader-text\">\u522b\u518d\u968f\u624b\u731c\u5747\u7ebf\u53c2\u6570\u4e86\uff0c\u7ebf\u6027\u641c\u7d22\u66f4\u9760\u8c31<\/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":["post-4823","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","tag-6","entry"],"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/4823","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=4823"}],"version-history":[{"count":5,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/4823\/revisions"}],"predecessor-version":[{"id":4840,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/4823\/revisions\/4840"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=4823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=4823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=4823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}