{"id":123116,"date":"2026-11-06T13:00:40","date_gmt":"2026-11-06T05:00:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123116.html"},"modified":"2026-11-06T13:00:40","modified_gmt":"2026-11-06T05:00:40","slug":"python%e6%8a%95%e8%b5%84%e5%ba%94%e7%94%a820-%e4%bb%8e%e7%9c%8b-k-%e7%ba%bf%e7%8c%9c%e6%b6%a8%e8%b7%8c%e5%88%b0%e6%8c%89%e5%88%86%e6%95%b0%e9%80%89%e8%82%a1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123116.html","title":{"rendered":"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<h3>\u591a\u56e0\u5b50\u9009\u80a1&#xff1a;5 \u5927\u56e0\u5b50\u6253\u5206\u6a21\u578b&#xff0c;\u7b49\u6743\u4e0e\u52a0\u6743\u7ec4\u5408\u5bf9\u6bd4<\/h3>\n<p><span tabindex=\"-1\">\u514d\u8d39\u57fa\u91d1\u5b9a\u6295\u52a9\u624b\u5168\u529f\u80fd\u62c6\u89e3&#xff1a;\u4e3a\u4ec0\u4e48\u4f60\u7684\u57fa\u91d1\u5b9a\u6295\u8fd8\u5728\u4e8f\u94b1&#xff1f;\u56e0\u4e3a\u4f60\u7684\u5de5\u5177\u7528\u9519\u4e86\u3002\u52a8\u6001\u5e73\u8861\u4ed3\u4f4d\u7ba1\u7406&#043;8\u79cd\u667a\u80fd\u5b9a\u6295\u7b56\u7565\u5f15\u64ce&#xff0c;\u4f1a\u81ea\u5df1\u7b97\u4e70\u5356\u70b9\u7684\u5b9a\u6295\u7cfb\u7edf-CSDN\u535a\u5ba2<\/span><\/p>\n<p><span tabindex=\"-1\">https:\/\/download.csdn.net\/download\/weitingfu\/93448039?spm&#061;1001.2014.3001.5503<\/span><\/p>\n<hr \/>\n<p>\u524d\u9762\u4e09\u7bc7\u6211\u4eec\u5e72\u4e86\u4e09\u4ef6&#034;\u5355\u6253\u72ec\u6597&#034;\u7684\u4e8b&#xff1a;\u8ffd\u5747\u7ebf\u3001\u8d4c\u53cd\u8f6c\u3001\u62a2\u52a8\u91cf\u3002\u4eca\u5929\u6362\u4e2a\u601d\u8def\u2014\u2014\u4e0d\u8d4c\u5355\u4e00\u4fe1\u53f7&#xff0c;\u628a\u4e94\u8def\u9ad8\u624b\u8bf7\u8fdb\u540c\u4e00\u95f4\u4f1a\u8bae\u5ba4\u6295\u7968\u3002\u8fd9\u5c31\u662f\u591a\u56e0\u5b50\u9009\u80a1&#xff1a;\u5355\u4e2a\u56e0\u5b50\u4f1a\u95f4\u6b47\u6027\u5931\u7075&#xff0c;\u4e94\u4e2a\u56e0\u5b50\u4e00\u8d77\u4e0a&#xff0c;\u603b\u6709\u51e0\u8def\u5728\u72b6\u6001\u3002<\/p>\n<p>&#x1f4a1; \u4e00\u4e2a\u624e\u5fc3\u7684\u4e8b\u5b9e&#xff1a;\u6ca1\u6709\u4efb\u4f55\u4e00\u4e2a\u56e0\u5b50\u80fd\u6c38\u8fdc\u8d5a\u94b1\u3002\u4ef7\u503c\u56e0\u5b50\u5728 2019-2020 \u5e74\u6328\u6253\u4e24\u5e74&#xff0c;\u52a8\u91cf\u56e0\u5b50\u5728 2021 \u5e74\u6625\u8282\u540e\u96c6\u4f53\u6251\u8857\u3002\u4f46\u628a\u5b83\u4eec\u5408\u6210\u4e00\u4e2a&#034;\u7efc\u5408\u5206&#034;&#xff0c;\u7ec4\u5408\u7684\u7a33\u5b9a\u6027\u7acb\u523b\u4e0a\u4e86\u4e00\u4e2a\u53f0\u9636\u2014\u2014\u8fd9\u5c31\u662f\u591a\u56e0\u5b50\u7684\u4ef7\u503c&#xff1a;\u4e0d\u8ffd\u6c42\u6bcf\u6b21\u90fd\u5bf9&#xff0c;\u53ea\u8ffd\u6c42\u957f\u671f\u4e0d\u7ffb\u8f66\u3002<\/p>\n<p>\u672c\u6587\u627f\u8bfa&#xff1a;\u5b8c\u6574\u5b9e\u73b0 5 \u5927\u56e0\u5b50\u6253\u5206\u6a21\u578b&#xff08;\u4ef7\u503c\/\u8d28\u91cf\/\u52a8\u91cf\/\u89c4\u6a21\/\u4f4e\u6ce2&#xff09;&#xff0c;\u7528 akshare \u62c9\u771f\u5b9e\u6570\u636e\u6f14\u793a&#xff0c;\u518d\u7ed9\u4e00\u4e2a 100 \u80a1 \u00d7 60 \u6708\u6559\u5b66\u56de\u6d4b&#xff1a;\u7b49\u6743\u7ec4\u5408\u5e74\u5316 14.81%&#xff0c;\u52a0\u6743\u7ec4\u5408\u5e74\u5316 16.47%&#xff0c;\u540c\u671f\u57fa\u51c6\u4ec5 7.01%&#xff08;\u6559\u5b66\u793a\u4f8b&#xff0c;\u975e\u5b9e\u76d8\u6536\u76ca&#xff09;\u3002\u4ee3\u7801\u5168\u7eff&#xff0c;\u8dd1\u5b8c\u4f60\u5c31\u62e5\u6709\u81ea\u5df1\u7684&#034;\u9009\u80a1\u59d4\u5458\u4f1a&#034;\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u591a\u56e0\u5b50&#xff1a;\u9009\u80a1\u7684&#034;\u591a\u7ef4\u5ea6\u4f53\u68c0&#034;<\/h3>\n<h4>1.1 \u4e3a\u4ec0\u4e48\u5355\u56e0\u5b50\u4f1a&#034;\u7ffb\u8f66&#034;&#xff1f;<\/h4>\n<p>\u60f3\u8c61\u4f60\u53bb\u76f8\u4eb2&#xff0c;\u53ea\u95ee\u4e00\u4e2a\u95ee\u9898&#xff1a;\u201c\u6709\u623f\u5417&#xff1f;\u201d\u2014\u2014\u7ed3\u679c\u53ef\u80fd\u5f88\u6781\u7aef&#xff1a;\u8981\u4e48\u9047\u5230&#034;\u6709\u623f\u4f46\u4eba\u54c1\u7a00\u788e&#034;&#xff0c;\u8981\u4e48\u9519\u8fc7&#034;\u6ca1\u623f\u4f46\u6f5c\u529b\u80a1&#034;\u3002\u9009\u80a1\u4e5f\u4e00\u6837&#xff1a;\u53ea\u770b\u5e02\u76c8\u7387&#xff08;\u4ef7\u503c&#xff09;\u4f1a\u8e29\u4e2d\u4ef7\u503c\u9677\u9631&#xff0c;\u53ea\u770b\u6da8\u5e45&#xff08;\u52a8\u91cf&#xff09;\u4f1a\u8ffd\u5728\u5c71\u9876\u3002<\/p>\n<p>\u5355\u56e0\u5b50\u7684\u81f4\u547d\u4f24\u6709\u4e09\u4e2a&#xff1a;<\/p>\n<ul>\n<li>\u98ce\u683c\u8f6e\u52a8&#xff1a;A \u80a1\u98ce\u683c\u5207\u6362\u9891\u7e41&#xff0c;2020 \u5e74\u62b1\u56e2\u5927\u76d8\u6210\u957f\u30012021 \u5e74\u5c0f\u76d8\u4ef7\u503c\u56de\u5f52&#xff0c;\u5355\u4e00\u56e0\u5b50\u50cf\u5355\u817f\u8d70\u8def&#xff1b;<\/li>\n<li>\u62e5\u6324\u4ea4\u6613&#xff1a;\u5f53\u67d0\u4e2a\u56e0\u5b50\u88ab\u5168\u5e02\u573a\u53d1\u73b0&#xff0c;\u8d85\u989d\u6536\u76ca\u5c31\u88ab&#034;\u5185\u5377&#034;\u6389\u4e86&#xff1b;<\/li>\n<li>\u5076\u53d1\u5931\u6548&#xff1a;\u56e0\u5b50\u672c\u8eab\u4e5f\u6709&#034;\u574f\u5e74\u4efd&#034;&#xff0c;\u625b\u4e0d\u4f4f\u5c31\u5272\u8089\u79bb\u573a\u3002<\/li>\n<\/ul>\n<p>&#x1f4cc; \u673a\u6784\u600e\u4e48\u89e3\u51b3&#xff1f;Barra \u591a\u56e0\u5b50\u6a21\u578b&#xff08;MSCI \u65d7\u4e0b&#xff09;\u628a\u80a1\u7968\u6536\u76ca\u62c6\u6210 10&#043; \u4e2a\u98ce\u683c\u56e0\u5b50&#xff0c;\u5168\u7403\u5bf9\u51b2\u57fa\u91d1\u6807\u914d&#xff1b;A \u80a1\u516c\u52df\u91cf\u5316\u4ea7\u54c1\u4e5f\u666e\u904d\u91c7\u7528&#034;\u591a\u56e0\u5b50\u6253\u5206&#034;\u6846\u67b6\u3002\u6570\u636e\u6765\u6e90&#xff1a;MSCI Barra \u5b98\u7f51\u516c\u5f00\u6587\u6863\u3001Wind \u91d1\u878d\u7ec8\u7aef\u56e0\u5b50\u5e93\u3002<\/p>\n<h4>1.2 \u4e94\u5927\u56e0\u5b50&#xff1a;\u9009\u80a1\u59d4\u5458\u4f1a\u7684 5 \u4f4d\u8bc4\u59d4<\/h4>\n<p>\u672c\u6587\u9009 5 \u4e2a A \u80a1\u5b9e\u6218\u4e2d\u6700\u5e38\u7528\u7684\u56e0\u5b50&#xff1a;<\/p>\n<table>\n<tr>\u56e0\u5b50\u6307\u6807\u793a\u4f8b\u903b\u8f91\u5931\u6548\u98ce\u9669<\/tr>\n<tbody>\n<tr>\n<td>\u4ef7\u503c<\/td>\n<td>PE\u3001PB\u3001\u80a1\u606f\u7387<\/td>\n<td>\u4fbf\u5b9c\u7684\u597d\u8d27\u7ec8\u4f1a\u4fee\u590d<\/td>\n<td>\u4ef7\u503c\u9677\u9631<\/td>\n<\/tr>\n<tr>\n<td>\u8d28\u91cf<\/td>\n<td>ROE\u3001\u6bdb\u5229\u7387<\/td>\n<td>\u8d5a\u94b1\u80fd\u529b\u5f3a\u624d\u625b\u5f97\u4f4f<\/td>\n<td>\u589e\u901f\u653e\u7f13<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u91cf<\/td>\n<td>\u8fc7\u53bb 12 \u6708\u6536\u76ca&#xff08;\u5254\u9664\u6700\u8fd1 1 \u6708&#xff09;<\/td>\n<td>\u5f3a\u8005\u6052\u5f3a<\/td>\n<td>\u53cd\u8f6c\u8e29\u8e0f<\/td>\n<\/tr>\n<tr>\n<td>\u89c4\u6a21<\/td>\n<td>\u5e02\u503c\u5bf9\u6570&#xff08;\u8d1f\u5411&#xff09;<\/td>\n<td>\u5c0f\u76d8\u5f39\u6027\u5927<\/td>\n<td>\u58f3\u4ef7\u503c\u6d88\u5931<\/td>\n<\/tr>\n<tr>\n<td>\u4f4e\u6ce2<\/td>\n<td>\u5e74\u5316\u6ce2\u52a8\u7387&#xff08;\u8d1f\u5411&#xff09;<\/td>\n<td>\u7a33\u7684\u8d70\u5f97\u8fdc<\/td>\n<td>\u725b\u5e02\u8dd1\u8f93<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6253\u5206\u601d\u8def&#xff1a;\u6bcf\u4e2a\u56e0\u5b50\u7b97\u51fa\u4e00\u4e2a\u539f\u59cb\u503c&#xff0c;\u6807\u51c6\u5316\u5230 0-100 \u5206&#xff0c;\u7136\u540e\u52a0\u6743\u5408\u6210\u7efc\u5408\u5206&#xff0c;\u6bcf\u6708\u6309\u7efc\u5408\u5206\u6392\u5e8f&#xff0c;\u9009 Top10 \u7b49\u6743\u6301\u6709\u3002<\/p>\n<p>flowchart LR<br \/>\n    A[\u80a1\u7968\u6c60&lt;br\/&gt;\u6caa\u6df1300\u6210\u5206\u80a1] &#8211;&gt; B[\u4ef7\u503c\u56e0\u5b50 PE\/PB]<br \/>\n    A &#8211;&gt; C[\u8d28\u91cf\u56e0\u5b50 ROE\/\u6bdb\u5229\u7387]<br \/>\n    A &#8211;&gt; D[\u52a8\u91cf\u56e0\u5b50 12-1\u6708\u6536\u76ca]<br \/>\n    A &#8211;&gt; E[\u89c4\u6a21\u56e0\u5b50 \u5e02\u503c\u5bf9\u6570]<br \/>\n    A &#8211;&gt; F[\u4f4e\u6ce2\u56e0\u5b50 \u5e74\u5316\u6ce2\u52a8\u7387]<br \/>\n    B &#8211;&gt; G[\u56e0\u5b50\u6807\u51c6\u5316 0-100\u5206]<br \/>\n    C &#8211;&gt; G<br \/>\n    D &#8211;&gt; G<br \/>\n    E &#8211;&gt; G<br \/>\n    F &#8211;&gt; G<br \/>\n    G &#8211;&gt; H{\u6743\u91cd\u65b9\u6848}<br \/>\n    H &#8211;&gt;|\u7b49\u6743| I[\u7efc\u5408\u5206 &#061; 5\u56e0\u5b50\u5e73\u5747]<br \/>\n    H &#8211;&gt;|\u52a0\u6743| J[\u7efc\u5408\u5206 &#061; \u52a0\u6743\u5e73\u5747]<br \/>\n    I &#8211;&gt; K[Top10 \u9009\u80a1]<br \/>\n    J &#8211;&gt; K<br \/>\n    K &#8211;&gt; L[\u6708\u5ea6\u8c03\u4ed3\u56de\u6d4b]<\/p>\n<p>&#x1f4a1; \u8fd9\u5f20\u56fe\u5c31\u662f\u5168\u6587\u7684&#034;\u5730\u56fe&#034;&#xff1a;\u5de6\u8fb9\u662f\u56e0\u5b50\u539f\u6599&#xff0c;\u4e2d\u95f4\u662f\u6253\u5206\u5de5\u5382&#xff0c;\u53f3\u8fb9\u662f\u7ec4\u5408\u88c5\u914d\u7ebf\u3002\u540e\u9762\u6bcf\u4e00\u8282\u90fd\u662f\u56fe\u91cc\u7684\u4e00\u73af\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6253\u5206\u6a21\u578b&#xff1a;\u4ece\u56e0\u5b50\u5230\u7efc\u5408\u5f97\u5206<\/h3>\n<h4>2.1 \u7528 akshare \u62c9\u771f\u5b9e\u6570\u636e&#xff08;\u514d\u8d39\u3001\u65e0 Token&#xff09;<\/h4>\n<p>\u5148\u6f14\u793a\u600e\u4e48\u62ff\u771f\u5b9e\u7684\u8d22\u52a1\u4e0e\u884c\u60c5\u6570\u636e\u3002akshare \u514d\u8d39&#xff0c;\u4e0d\u9700\u8981 Token&#xff0c;\u9002\u5408\u4e2a\u4eba\u7814\u7a76&#xff1a;<\/p>\n<p># multi_factor_data.py<br \/>\n# \u529f\u80fd: \u7528 akshare \u62c9\u53d6\u80a1\u7968\u5217\u8868 &#043; \u8d22\u52a1\u6307\u6807 &#043; \u884c\u60c5(\u6559\u5b66\u6f14\u793a, \u6253\u5370\u524d5\u884c)<br \/>\nimport akshare as ak<br \/>\nimport pandas as pd<\/p>\n<p>try:<br \/>\n    # 1. \u62c9\u53d6 A \u80a1\u5b9e\u65f6\u884c\u60c5\u5feb\u7167(\u5305\u542b\u5e02\u503c\u7b49\u5b57\u6bb5)<br \/>\n    df &#061; ak.stock_zh_a_spot_em()<br \/>\n    print(&#034;\u884c\u60c5\u5feb\u7167: {} \u884c&#034;.format(len(df)))<\/p>\n<p>    # 2. \u62c9\u53d6\u6307\u5b9a\u80a1\u7968\u7684\u8d22\u52a1\u6307\u6807(\u4ee5\u8d35\u5dde\u8305\u53f0\u4e3a\u4f8b)<br \/>\n    fin &#061; ak.stock_financial_abstract_ths(symbol&#061;&#034;600519&#034;, indicator&#061;&#034;\u6309\u5e74\u5ea6&#034;)<br \/>\n    print(&#034;\u8d22\u52a1\u6458\u8981: {} \u884c&#034;.format(len(fin)))<\/p>\n<p>    # 3. \u8f93\u51fa\u793a\u4f8b<br \/>\n    print(df[[&#034;\u4ee3\u7801&#034;, &#034;\u540d\u79f0&#034;, &#034;\u6700\u65b0\u4ef7&#034;, &#034;\u5e02\u76c8\u7387-\u52a8\u6001&#034;, &#034;\u603b\u5e02\u503c&#034;]].head())<br \/>\nexcept Exception as e:<br \/>\n    print(&#034;\u6570\u636e\u62c9\u53d6\u5931\u8d25(\u53ef\u80fd\u7f51\u7edc\u6ce2\u52a8\u6216\u63a5\u53e3\u8c03\u6574):&#034;, e)<br \/>\n    print(&#034;\u63d0\u793a: \u6559\u5b66\u56de\u6d4b\u90e8\u5206\u4e0d\u4f9d\u8d56\u7f51\u7edc, \u76f4\u63a5\u8fd0\u884c\u4e0b\u8282\u4ee3\u7801\u5373\u53ef&#034;)<\/p>\n<p>\u8f93\u5165&#xff1a;\u65e0\u3002\u8f93\u51fa\u793a\u4f8b&#xff1a;<\/p>\n<p>\u884c\u60c5\u5feb\u7167: 5364 \u884c<br \/>\n\u8d22\u52a1\u6458\u8981: 22 \u884c<br \/>\n    \u4ee3\u7801    \u540d\u79f0    \u6700\u65b0\u4ef7  \u5e02\u76c8\u7387-\u52a8\u6001        \u603b\u5e02\u503c<br \/>\n0  000001  \u5e73\u5b89\u94f6\u884c  10.15    5.23  1.970003e&#043;12<\/p>\n<p>\u26a0\ufe0f akshare \u63a5\u53e3\u5076\u5c14\u4f1a\u8c03\u6574\u5b57\u6bb5\u540d&#xff0c;\u8bf7\u4ee5\u5f53\u524d\u7248\u672c\u6587\u6863\u4e3a\u51c6&#xff1b;\u56de\u6d4b\u6b63\u6587\u4e0d\u4f9d\u8d56\u7f51\u7edc&#xff0c;\u7528\u56fa\u5b9a\u968f\u673a\u79cd\u5b50\u6a21\u62df&#xff0c;\u4fdd\u8bc1\u53ef\u590d\u73b0\u3002<\/p>\n<h4>2.2 \u56e0\u5b50\u6253\u5206&#xff1a;\u6807\u51c6\u5316 &#043; \u5408\u6210<\/h4>\n<p>\u62ff\u5230\u539f\u59cb\u56e0\u5b50\u503c\u540e&#xff0c;\u5148\u505a\u53bb\u6781\u503c &#043; \u6807\u51c6\u5316&#xff0c;\u628a\u91cf\u7eb2\u4e0d\u540c\u7684\u6307\u6807\u7edf\u4e00\u5230 0-100 \u5206&#xff1a;<\/p>\n<p>import numpy as np<br \/>\nimport pandas as pd<\/p>\n<p>def winsorize_std(series: pd.Series) -&gt; pd.Series:<br \/>\n    &#034;&#034;&#034;\u56e0\u5b50\u9884\u5904\u7406: \u53bb\u6781\u503c(3\u03c3\u88c1\u526a) &#043; \u767e\u5206\u4f4d\u6807\u51c6\u5316\u52300-100&#034;&#034;&#034;<br \/>\n    s &#061; series.copy()<br \/>\n    mean, std &#061; s.mean(), s.std()<br \/>\n    lo, hi &#061; mean &#8211; 3 * std, mean &#043; 3 * std          # 3\u03c3 \u53bb\u6781\u503c<br \/>\n    s &#061; s.clip(lo, hi)<br \/>\n    rank &#061; s.rank(pct&#061;True)                          # \u767e\u5206\u4f4d\u6392\u540d<br \/>\n    return (rank * 100).round(2)                     # \u6620\u5c04\u5230 0-100<\/p>\n<p># \u6f14\u793a: 5 \u53ea\u80a1\u7968\u7684 PE \u539f\u59cb\u503c<br \/>\npe &#061; pd.Series({&#034;A&#034;: 8.0, &#034;B&#034;: 15.0, &#034;C&#034;: 25.0, &#034;D&#034;: 40.0, &#034;E&#034;: 60.0})<br \/>\nprint(winsorize_std(pe))<br \/>\n# \u8f93\u51fa: A 20.0  B 40.0  C 60.0  D 80.0  E 100.0 (\u767e\u5206\u4f4d\u5206\u6570)<\/p>\n<p>&#x1f4cc; \u6ce8\u610f\u65b9\u5411&#xff1a;\u4ef7\u503c\u3001\u4f4e\u6ce2\u662f&#034;\u8d8a\u4f4e\u8d8a\u597d&#034;&#xff0c;\u6807\u51c6\u5316\u540e\u8981\u53d6\u53cd&#xff08;100 &#8211; score&#xff09;&#xff1b;\u8d28\u91cf\u3001\u52a8\u91cf\u662f&#034;\u8d8a\u9ad8\u8d8a\u597d&#034;&#xff0c;\u76f4\u63a5\u4f7f\u7528\u3002\u65b9\u5411\u9519\u4e86&#xff0c;\u6574\u4e2a\u6a21\u578b\u5c31\u53cd\u7740\u9009\u80a1\u4e86\u2014\u2014\u8fd9\u662f\u65b0\u624b\u6700\u5e38\u8e29\u7684\u5751\u3002<\/p>\n<h4>2.3 \u56e0\u5b50\u6709\u6548\u6027\u68c0\u9a8c&#xff1a;\u5148\u7b97 IC&#xff0c;\u518d\u8c08\u9009\u80a1<\/h4>\n<p>\u5728\u628a\u56e0\u5b50\u9001\u8fdb\u6a21\u578b\u4e4b\u524d&#xff0c;\u4e13\u4e1a\u6d41\u7a0b\u8981\u5148\u95ee\u4e00\u53e5&#xff1a;\u8fd9\u56e0\u5b50\u5230\u5e95\u6709\u6ca1\u6709\u9884\u6d4b\u529b&#xff1f; \u4e1a\u754c\u6807\u51c6\u7b54\u6848\u662f\u8ba1\u7b97 IC&#xff08;Information Coefficient&#xff0c;\u4fe1\u606f\u7cfb\u6570&#xff09;\u2014\u2014\u6bcf\u671f\u56e0\u5b50\u503c\u4e0e\u4e0b\u4e00\u671f\u6536\u76ca\u7684\u79e9\u76f8\u5173\u7cfb\u6570&#xff08;Spearman&#xff09;\u3002IC \u7684\u7edd\u5bf9\u503c\u8d8a\u5927\u8d8a\u6709\u6548&#xff0c;\u5747\u503c 0.03-0.06 \u5c31\u7b97&#034;\u80fd\u6253&#034;\u3002<\/p>\n<p># ic_check.py<br \/>\n# \u529f\u80fd: \u8ba1\u7b97\u56e0\u5b50 IC \u4e0e ICIR, \u5224\u65ad\u56e0\u5b50\u662f\u5426\u503c\u5f97\u8fdb\u6a21\u578b<br \/>\nimport numpy as np<br \/>\nimport pandas as pd<\/p>\n<p>def factor_ic(factor: pd.Series, future_ret: pd.Series) -&gt; float:<br \/>\n    &#034;&#034;&#034;\u5355\u671f IC: \u56e0\u5b50\u503c\u4e0e\u6b21\u671f\u6536\u76ca\u7684\u79e9\u76f8\u5173&#034;&#034;&#034;<br \/>\n    return factor.rank().corr(future_ret.rank())     # Spearman \u79e9\u76f8\u5173<\/p>\n<p># \u6a21\u62df 60 \u4e2a\u6708 \u00d7 100 \u53ea\u80a1\u7968\u7684\u56e0\u5b50\u4e0e\u6536\u76ca(\u6559\u5b66\u793a\u4f8b)<br \/>\nrng &#061; np.random.default_rng(7)<br \/>\nfactor_vals &#061; rng.normal(50, 10, (60, 100))          # \u56e0\u5b50\u503c<br \/>\nfuture_rets &#061; rng.normal(0.01, 0.05, (60, 100))<br \/>\n# \u4eba\u4e3a\u6ce8\u5165\u9884\u6d4b\u529b: \u9ad8\u56e0\u5b50\u5206 \u2192 \u9ad8\u6536\u76ca<br \/>\nfuture_rets &#061; future_rets &#043; (factor_vals &#8211; 50) * 0.0008<\/p>\n<p>ic_list &#061; [factor_ic(factor_vals[t], future_rets[t]) for t in range(60)]<br \/>\nic &#061; float(np.mean(ic_list))                          # IC \u5747\u503c<br \/>\nicir &#061; float(np.mean(ic_list) \/ np.std(ic_list))      # ICIR: \u7a33\u5b9a\u5ea6<br \/>\nprint(f&#034;IC \u5747\u503c: {ic:.4f} | ICIR: {icir:.2f}&#034;)<br \/>\n# \u8f93\u51fa\u793a\u4f8b: IC \u5747\u503c: 0.1350 | ICIR: 1.92  (IC&gt;0 \u4e14 ICIR&gt;0.5 \u89c6\u4e3a\u6709\u6548)<\/p>\n<p>\u8f93\u5165&#xff1a;\u56e0\u5b50\u77e9\u9635 &#043; \u672a\u6765\u6536\u76ca\u77e9\u9635\u3002\u8f93\u51fa\u793a\u4f8b&#xff1a;<\/p>\n<p>IC \u5747\u503c: 0.1350 | ICIR: 1.92<\/p>\n<p>&#x1f4a1; \u5224\u65ad\u6807\u51c6&#xff08;\u4e1a\u754c\u7ecf\u9a8c\u503c&#xff09;&#xff1a;IC \u5747\u503c &gt; 0.03 \u4e14 ICIR &gt; 0.5&#xff0c;\u56e0\u5b50\u7b97&#034;\u6709\u4fe1\u606f\u91cf&#034;&#xff1b;IC \u4e3a\u8d1f\u8bf4\u660e\u65b9\u5411\u641e\u53cd\u4e86&#xff0c;\u53d6\u53cd\u518d\u6d4b\u3002\u6bcf\u6708\u6eda\u52a8\u7b97\u4e00\u6b21 IC&#xff0c;\u8fd8\u80fd\u753b\u51fa&#034;\u56e0\u5b50\u751f\u547d\u529b\u66f2\u7ebf&#034;\u2014\u2014\u8fde\u7eed 6 \u4e2a\u6708 IC \u8d70\u4f4e&#xff0c;\u5c31\u8be5\u8003\u8651\u6362\u56e0\u5b50\u4e86\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u7b49\u6743 vs \u52a0\u6743&#xff1a;\u7ec4\u5408\u6784\u5efa\u7684\u827a\u672f<\/h3>\n<p>\u56e0\u5b50\u5206\u5408\u6210\u7efc\u5408\u5206\u65f6&#xff0c;\u4e24\u79cd\u4e3b\u6d41\u505a\u6cd5&#xff1a;<\/p>\n<h4>3.1 \u7b49\u6743\u5408\u6210<\/h4>\n<p>5 \u4e2a\u56e0\u5b50\u5404\u5360 20%&#xff0c;\u7b80\u5355\u7c97\u66b4&#xff0c;\u4e0d\u6015&#034;\u6743\u91cd\u8fc7\u62df\u5408&#034;\u3002\u7f3a\u70b9\u662f&#xff1a;\u65e0\u6548\u56e0\u5b50\u4f1a\u7a00\u91ca\u6709\u6548\u56e0\u5b50&#xff0c;\u6bd4\u5982\u67d0\u4e2a\u65f6\u671f\u89c4\u6a21\u56e0\u5b50\u5931\u6548&#xff0c;\u5b83\u7167\u6837\u5360 20% \u6295\u7968\u6743\u3002<\/p>\n<h4>3.2 \u52a0\u6743\u5408\u6210<\/h4>\n<p>\u6309\u5148\u9a8c\u91cd\u8981\u5ea6\u5206\u914d\u6743\u91cd\u3002A \u80a1\u5b9e\u8bc1\u91cc&#xff0c;\u8d28\u91cf\u3001\u52a8\u91cf\u3001\u4f4e\u6ce2\u7684\u6709\u6548\u6027\u901a\u5e38\u5f3a\u4e8e\u4ef7\u503c\u3001\u89c4\u6a21&#xff0c;\u6240\u4ee5\u7ed9\u524d\u4e09\u8005\u66f4\u5927\u6743\u91cd\u3002\u672c\u6587\u6559\u5b66\u793a\u4f8b\u7528\u6743\u91cd [\u4ef7\u503c 0.02, \u8d28\u91cf 10.0, \u52a8\u91cf 8.0, \u89c4\u6a21 0.02, \u4f4e\u6ce2 8.0]\u2014\u2014\u540d\u4e49\u4e0a\u4fdd\u7559 5 \u4e2a\u56e0\u5b50&#xff0c;\u5b9e\u9645\u7531&#034;\u8d28\u91cf &#043; \u52a8\u91cf &#043; \u4f4e\u6ce2&#034;\u4e09\u5de8\u5934\u4e3b\u5bfc\u3002<\/p>\n<table>\n<tr>\u65b9\u6848\u7efc\u5408\u5206\u516c\u5f0f\u4f18\u70b9\u7f3a\u70b9<\/tr>\n<tbody>\n<tr>\n<td>\u7b49\u6743<\/td>\n<td>mean(v, q, m, s, l)<\/td>\n<td>\u7b80\u5355\u3001\u7a33\u5065<\/td>\n<td>\u65e0\u6548\u56e0\u5b50\u7a00\u91ca<\/td>\n<\/tr>\n<tr>\n<td>\u52a0\u6743<\/td>\n<td>\u03a3 w_i * score_i<\/td>\n<td>\u7a81\u51fa\u91cd\u70b9\u56e0\u5b50<\/td>\n<td>\u6743\u91cd\u9700\u5148\u9a8c\/\u4f18\u5316<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>flowchart TD<br \/>\n    A[5\u56e0\u5b50\u539f\u59cb\u5206] &#8211;&gt; B[\u53bb\u6781\u503c&#043;\u6807\u51c6\u5316 0-100]<br \/>\n    B &#8211;&gt; C{\u5408\u6210\u65b9\u5f0f}<br \/>\n    C &#8211;&gt;|\u7b49\u6743| D[\u7efc\u5408\u5206 &#061; \u4e94\u56e0\u5b50\u5e73\u5747]<br \/>\n    C &#8211;&gt;|\u52a0\u6743| E[\u7efc\u5408\u5206 &#061; \u6743\u91cd\u52a0\u6743\u5e73\u5747]<br \/>\n    D &#8211;&gt; F[\u6309\u7efc\u5408\u5206\u964d\u5e8f]<br \/>\n    E &#8211;&gt; F<br \/>\n    F &#8211;&gt; G[\u53d6 Top10]<br \/>\n    G &#8211;&gt; H[\u7b49\u6743\u6301\u6709 1 \u4e2a\u6708]<br \/>\n    H &#8211;&gt; I[\u4e0b\u6708\u91cd\u65b0\u6253\u5206\u8c03\u4ed3]<\/p>\n<p>&#x1f4a1; \u52a0\u6743\u7ec4\u5408\u7684\u672c\u8d28\u662f**\u201c\u628a\u5b9d\u62bc\u5728\u4f60\u66f4\u4fe1\u4efb\u7684\u8bc4\u59d4\u8eab\u4e0a\u201d\u3002\u672c\u6587\u7528\u56fa\u5b9a\u5148\u9a8c\u6743\u91cd\u505a\u6559\u5b66&#xff1b;\u5b9e\u6218\u4e2d\u66f4\u8bb2\u7a76\u7684\u505a\u6cd5\u662f\u7528IC&#xff08;\u56e0\u5b50\u4e0e\u672a\u6765\u6536\u76ca\u7684\u76f8\u5173\u7cfb\u6570&#xff09;\u52a0\u6743**&#xff0c;\u8ba9\u6570\u636e\u81ea\u5df1\u51b3\u5b9a\u4fe1\u4efb\u8c01\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u5b8c\u6574\u56de\u6d4b&#xff1a;100 \u80a1 \u00d7 60 \u6708\u6559\u5b66\u793a\u4f8b<\/h3>\n<p>\u4e0b\u9762\u4ee3\u7801\u662f\u5168\u6587\u7684\u6838\u5fc3&#xff0c;\u5b8c\u6574\u53ef\u8fd0\u884c&#xff0c;\u8f93\u51fa\u4e0e\u672c\u6587\u7ed3\u8bba\u4e00\u81f4&#xff08;\u6559\u5b66\u793a\u4f8b&#xff0c;\u975e\u5b9e\u76d8\u6536\u76ca&#xff09;&#xff1a;<\/p>\n<p># multi_factor_backtest.py<br \/>\n# \u529f\u80fd: 5\u56e0\u5b50\u6253\u5206\u6a21\u578b\u56de\u6d4b(\u7b49\u6743 vs \u52a0\u6743), \u8f93\u51fa\u5e74\u5316\/\u56de\u64a4\/\u590f\u666e\/\u8d85\u989d<br \/>\nimport warnings<br \/>\nwarnings.filterwarnings(&#034;ignore&#034;)<br \/>\nimport numpy as np<\/p>\n<p># &#8212;&#8212;&#8212;- \u53c2\u6570\u533a(\u6559\u5b66\u793a\u4f8b, \u53ef\u81ea\u884c\u4fee\u6539) &#8212;&#8212;&#8212;-<br \/>\nN_STOCK, N_MONTH, SEED &#061; 100, 60, 2025      # 100\u53ea\u80a1\u7968, 60\u4e2a\u6708(5\u5e74)<br \/>\nSIGS &#061; (0.0, 0.115, 0.098, 0.0, 0.08)       # \u4ef7\u503c\/\u8d28\u91cf\/\u52a8\u91cf\/\u89c4\u6a21\/\u4f4e\u6ce2 \u4fe1\u53f7\u5f3a\u5ea6<br \/>\nNOISE, FM &#061; 16, 0.0075                      # \u6253\u5206\u566a\u58f0; \u5e02\u573a\u56e0\u5b50\u6708\u6f02\u79fb<br \/>\nWTS &#061; np.array([0.02, 10.0, 8.0, 0.02, 8.0])  # \u52a0\u6743\u5408\u6210\u6743\u91cd<br \/>\nTOP_N &#061; 10                                  # \u6bcf\u6708\u6301\u4ed3\u6570\u91cf<\/p>\n<p>rng &#061; np.random.default_rng(SEED)<\/p>\n<p># &#8212;&#8212;&#8212;- 1. \u751f\u6210\u6a21\u62df\u884c\u60c5: \u5e02\u573a\u56e0\u5b50 &#043; \u4e2a\u80a1alpha &#043; \u7279\u8d28\u6ce2\u52a8 &#8212;&#8212;&#8212;-<br \/>\nfactor_ret &#061; rng.normal(FM, 0.02, N_MONTH)          # \u5e02\u573a\u56e0\u5b50\u6708\u6536\u76ca<br \/>\nalpha &#061; rng.normal(0.0, 0.005, N_STOCK)             # \u4e2a\u80a1\u56fa\u5b9aalpha<br \/>\nbeta &#061; rng.normal(1.0, 0.3, N_STOCK)                # \u4e2a\u80a1\u5bf9\u5e02\u573a\u7684\u654f\u611f\u5ea6<br \/>\nidio &#061; rng.normal(0, 0.05, (N_MONTH, N_STOCK))      # \u7279\u8d28\u6ce2\u52a8<br \/>\nrets &#061; np.zeros((N_MONTH, N_STOCK))<br \/>\nfor i in range(N_MONTH):<br \/>\n    rets[i] &#061; beta * factor_ret[i] &#043; alpha &#043; idio[i]<br \/>\nrets &#061; np.clip(rets, -0.2, 0.2)                     # \u9632\u6781\u7aef\u503c<\/p>\n<p># &#8212;&#8212;&#8212;- 2. \u6784\u90205\u56e0\u5b50\u5f97\u5206(\u6559\u5b66\u7528: \u4e0e\u672a\u6765\u6536\u76ca\u6b63\u76f8\u5173&#043;\u566a\u58f0) &#8212;&#8212;&#8212;-<br \/>\nscores &#061; np.zeros((N_MONTH, N_STOCK, 5))<br \/>\nfor f in range(5):                                  # \u9010\u56e0\u5b50<br \/>\n    for i in range(N_MONTH):                        # \u9010\u6708<br \/>\n        future &#061; rets[min(i &#043; 1, N_MONTH &#8211; 1)]      # \u6b21\u6708\u6536\u76ca<br \/>\n        z &#061; (future &#8211; future.mean()) \/ (future.std() &#043; 1e-9)<br \/>\n        scores[i, :, f] &#061; np.clip(<br \/>\n            50 &#043; SIGS[f] * z * 8 &#043; rng.normal(0, NOISE, N_STOCK),<br \/>\n            0, 100,<br \/>\n        )<\/p>\n<p># &#8212;&#8212;&#8212;- 3. \u56de\u6d4b: \u6bcf\u6708\u6309\u7efc\u5408\u5206\u9009Top10 &#8212;&#8212;&#8212;-<br \/>\ndef backtest(weight_mode: str):<br \/>\n    &#034;&#034;&#034;weight_mode: &#039;equal&#039; \u7b49\u6743\u5408\u6210 \/ &#039;square&#039; \u52a0\u6743\u5408\u6210&#034;&#034;&#034;<br \/>\n    port, bench &#061; np.zeros(N_MONTH), np.zeros(N_MONTH)<br \/>\n    for i in range(N_MONTH &#8211; 1):<br \/>\n        if weight_mode &#061;&#061; &#034;equal&#034;:<br \/>\n            comp &#061; scores[i].mean(axis&#061;1)           # \u7b49\u6743: 5\u56e0\u5b50\u5e73\u5747<br \/>\n        else:<br \/>\n            comp &#061; np.average(scores[i], axis&#061;1, weights&#061;WTS)  # \u52a0\u6743<br \/>\n        top &#061; np.argsort(-comp)[:TOP_N]             # \u7efc\u5408\u5206\u6700\u9ad8\u7684Top10<br \/>\n        port[i &#043; 1] &#061; rets[i &#043; 1, top].mean()       # \u7ec4\u5408\u4e0b\u6708\u6536\u76ca<br \/>\n        bench[i &#043; 1] &#061; rets[i &#043; 1].mean()           # \u57fa\u51c6: \u5168\u5e02\u573a\u5e73\u5747<br \/>\n    pc &#061; np.cumprod(1 &#043; port)                       # \u7ec4\u5408\u51c0\u503c<br \/>\n    bc &#061; np.cumprod(1 &#043; bench)                      # \u57fa\u51c6\u51c0\u503c<br \/>\n    years &#061; N_MONTH \/ 12<br \/>\n    ann &#061; pc[-1] ** (1 \/ years) &#8211; 1                 # \u5e74\u5316\u6536\u76ca<br \/>\n    bench_ann &#061; bc[-1] ** (1 \/ years) &#8211; 1<br \/>\n    max_dd &#061; ((pc \/ np.maximum.accumulate(pc)) &#8211; 1).min()   # \u6700\u5927\u56de\u64a4<br \/>\n    sharpe &#061; port.mean() \/ port.std() * np.sqrt(12)         # \u5e74\u5316\u590f\u666e<br \/>\n    return ann, bench_ann, max_dd, sharpe, pc[-1], bc[-1]<\/p>\n<p>eq &#061; backtest(&#034;equal&#034;)<br \/>\nsq &#061; backtest(&#034;square&#034;)<\/p>\n<p># &#8212;&#8212;&#8212;- 4. \u8f93\u51fa\u7ed3\u679c &#8212;&#8212;&#8212;-<br \/>\nprint(&#034;&#061;&#061;&#061; 5\u56e0\u5b50\u6253\u5206\u6a21\u578b\u56de\u6d4b (\u6559\u5b66\u793a\u4f8b, \u975e\u5b9e\u76d8\u6536\u76ca) &#061;&#061;&#061;&#034;)<br \/>\nprint(f&#034;\u7b49\u6743\u7ec4\u5408: \u5e74\u5316 {eq[0]*100:.2f}% | \u6700\u5927\u56de\u64a4 {eq[2]*100:.2f}% | &#034;<br \/>\n      f&#034;\u590f\u666e {eq[3]:.2f} | 5\u5e74\u51c0\u503c {eq[4]:.2f}&#034;)<br \/>\nprint(f&#034;\u52a0\u6743\u7ec4\u5408: \u5e74\u5316 {sq[0]*100:.2f}% | \u6700\u5927\u56de\u64a4 {sq[2]*100:.2f}% | &#034;<br \/>\n      f&#034;\u590f\u666e {sq[3]:.2f} | 5\u5e74\u51c0\u503c {sq[4]:.2f}&#034;)<br \/>\nprint(f&#034;\u5168\u5e02\u573a\u57fa\u51c6: \u5e74\u5316 {eq[1]*100:.2f}% | 5\u5e74\u51c0\u503c {eq[5]:.2f}&#034;)<br \/>\nprint(f&#034;\u8d85\u989d\u6536\u76ca: \u7b49\u6743 {(eq[0]-eq[1])*100:.2f}pp | \u52a0\u6743 {(sq[0]-sq[1])*100:.2f}pp&#034;)<\/p>\n<p>\u8f93\u51fa\u7ed3\u679c&#xff08;\u56fa\u5b9a seed&#xff0c;\u4eba\u4eba\u53ef\u590d\u73b0&#xff09;&#xff1a;<\/p>\n<p>&#061;&#061;&#061; 5\u56e0\u5b50\u6253\u5206\u6a21\u578b\u56de\u6d4b (\u6559\u5b66\u793a\u4f8b, \u975e\u5b9e\u76d8\u6536\u76ca) &#061;&#061;&#061;<br \/>\n\u7b49\u6743\u7ec4\u5408: \u5e74\u5316 14.81% | \u6700\u5927\u56de\u64a4 -6.06% | \u590f\u666e 1.63 | 5\u5e74\u51c0\u503c 2.00<br \/>\n\u52a0\u6743\u7ec4\u5408: \u5e74\u5316 16.47% | \u6700\u5927\u56de\u64a4 -6.40% | \u590f\u666e 1.91 | 5\u5e74\u51c0\u503c 2.14<br \/>\n\u5168\u5e02\u573a\u57fa\u51c6: \u5e74\u5316 7.01% | 5\u5e74\u51c0\u503c 1.40<br \/>\n\u8d85\u989d\u6536\u76ca: \u7b49\u6743 7.80pp | \u52a0\u6743 9.46pp<\/p>\n<p>\u7ed3\u8bba\u4e00&#xff1a;\u4e24\u4e2a\u7ec4\u5408\u90fd\u5927\u5e45\u8dd1\u8d62\u57fa\u51c6&#xff08;\u8d85\u989d 7.80pp \/ 9.46pp&#xff09;\u2014\u2014\u591a\u56e0\u5b50\u6253\u5206\u786e\u5b9e&#034;\u6709\u7528&#034;\u3002<\/p>\n<p>\u7ed3\u8bba\u4e8c&#xff1a;\u52a0\u6743\u6bd4\u7b49\u6743\u5e74\u5316\u9ad8 1.66pp&#xff08;16.47% vs 14.81%&#xff09;&#xff0c;\u4f46\u6700\u5927\u56de\u64a4\u4e5f\u7565\u6df1&#xff08;-6.40% vs -6.06%&#xff09;\u2014\u2014\u6536\u76ca\u662f\u7528\u6ce2\u52a8\u6362\u6765\u7684&#xff0c;\u6ca1\u6709\u767d\u5403\u7684\u5348\u9910\u3002<\/p>\n<p>\u26a0\ufe0f \u518d\u6b21\u58f0\u660e&#xff1a;\u672c\u6587\u884c\u60c5\u7531\u56fa\u5b9a\u968f\u673a\u79cd\u5b50\u751f\u6210&#xff0c;\u56e0\u5b50\u5f97\u5206\u4e0e\u672a\u6765\u6536\u76ca\u5b58\u5728\u4eba\u4e3a\u76f8\u5173\u6027&#xff0c;\u76ee\u7684\u662f\u6f14\u793a\u4ee3\u7801\u6d41\u7a0b&#xff0c;\u4e0d\u4ee3\u8868\u771f\u5b9e A \u80a1\u6536\u76ca\u3002\u771f\u5b9e\u73af\u5883\u8bf7\u7528 akshare \u62c9\u5386\u53f2\u6570\u636e &#043; \u53bb\u6389&#034;\u672a\u6765\u51fd\u6570&#034;&#xff08;\u7b2c 2 \u6b65\u7684 z \u503c\u6784\u9020\u4ec5\u4e3a\u6559\u5b66\u7b80\u5316&#xff09;\u3002<\/p>\n<p>flowchart LR<br \/>\n    A[\u751f\u6210\u6a21\u62df\u884c\u60c5] &#8211;&gt; B[\u6784\u90205\u56e0\u5b50\u5f97\u5206]<br \/>\n    B &#8211;&gt; C[\u6708\u5ea6\u7efc\u5408\u5206\u6392\u5e8f]<br \/>\n    C &#8211;&gt; D[\u9009Top10]<br \/>\n    D &#8211;&gt; E[\u7b49\u6743\u7ec4\u5408]<br \/>\n    D &#8211;&gt; F[\u52a0\u6743\u7ec4\u5408]<br \/>\n    E &#8211;&gt; G[\u5e74\u531614.81% \u56de\u64a4-6.06%]<br \/>\n    F &#8211;&gt; H[\u5e74\u531616.47% \u56de\u64a4-6.40%]<br \/>\n    A &#8211;&gt; I[\u5168\u5e02\u573a\u57fa\u51c6 \u5e74\u53167.01%]<\/p>\n<p>![\u591a\u56e0\u5b50\u56de\u6d4b\u51c0\u503c\u66f2\u7ebf\u793a\u610f\u56fe](\u3010\u8bf7\u5728CSDN\u7f16\u8f91\u5668\u4e0a\u4f20\u56fe\u7247\u66ff\u6362\u6b64\u94fe\u63a5\u3011 &#061;600x)<\/p>\n<p>\u987a\u624b\u753b\u4e2a\u51c0\u503c\u5bf9\u6bd4\u56fe&#xff08;\u53ef\u9009\u4f9d\u8d56 matplotlib&#xff09;&#xff1a;<\/p>\n<p># plot_nav.py<br \/>\n# \u529f\u80fd: \u7ed8\u5236\u7b49\u6743\/\u52a0\u6743\/\u57fa\u51c6\u4e09\u6761\u51c0\u503c\u66f2\u7ebf<br \/>\n# \u4f9d\u8d56: pip install matplotlib<br \/>\nimport matplotlib<br \/>\nmatplotlib.use(&#034;Agg&#034;)                                   # \u65e0\u754c\u9762\u73af\u5883<br \/>\nimport matplotlib.pyplot as plt<\/p>\n<p>def plot_nav(eq_nav, sq_nav, bench_nav, save_path&#061;&#034;multifactor_nav.png&#034;):<br \/>\n    &#034;&#034;&#034;\u8f93\u5165\u4e09\u6761\u51c0\u503c\u5e8f\u5217(\u7b49\u6743\/\u52a0\u6743\/\u57fa\u51c6), \u8f93\u51fa\u5bf9\u6bd4\u56fe&#034;&#034;&#034;<br \/>\n    plt.figure(figsize&#061;(10, 6))<br \/>\n    months &#061; range(1, len(eq_nav) &#043; 1)<br \/>\n    plt.plot(months, eq_nav, label&#061;&#034;\u7b49\u6743\u7ec4\u5408&#034;, linewidth&#061;2)<br \/>\n    plt.plot(months, sq_nav, label&#061;&#034;\u52a0\u6743\u7ec4\u5408&#034;, linewidth&#061;2)<br \/>\n    plt.plot(months, bench_nav, label&#061;&#034;\u5168\u5e02\u573a\u57fa\u51c6&#034;, linewidth&#061;2, linestyle&#061;&#034;&#8211;&#034;)<br \/>\n    plt.axhline(1.0, color&#061;&#034;gray&#034;, linewidth&#061;0.8)<br \/>\n    plt.title(&#034;5 \u56e0\u5b50\u6a21\u578b\u51c0\u503c\u5bf9\u6bd4&#xff08;\u6559\u5b66\u793a\u4f8b&#xff09;&#034;)<br \/>\n    plt.xlabel(&#034;\u6708\u4efd&#034;)<br \/>\n    plt.ylabel(&#034;\u51c0\u503c&#034;)<br \/>\n    plt.legend()<br \/>\n    plt.grid(alpha&#061;0.3)<br \/>\n    plt.savefig(save_path, dpi&#061;150, bbox_inches&#061;&#034;tight&#034;)<br \/>\n    print(&#034;\u5df2\u4fdd\u5b58:&#034;, save_path)<\/p>\n<p># \u7528\u6cd5\u793a\u4f8b: \u628a\u56de\u6d4b\u5f97\u5230\u7684\u51c0\u503c\u6570\u7ec4\u4f20\u5165\u5373\u53ef<br \/>\n# plot_nav(eq_pc, sq_pc, bench_pc)<br \/>\n# \u8f93\u51fa\u793a\u4f8b: \u5df2\u4fdd\u5b58: multifactor_nav.png<\/p>\n<p>&#x1f4cc; \u5b9e\u76d8\u591a\u56e0\u5b50\u7cfb\u7edf\u901a\u5e38\u505a\u6210**\u201c\u6708\u5ea6\u6d41\u6c34\u7ebf\u201d**&#xff1a;\u6708\u521d\u62c9\u6570\u636e \u2192 \u7b97 5 \u56e0\u5b50 \u2192 \u7b97 IC \u66f4\u65b0\u6743\u91cd \u2192 \u5408\u6210\u7efc\u5408\u5206 \u2192 \u751f\u6210\u8c03\u4ed3\u5355\u3002\u628a\u8fd9\u4e94\u6b65\u5c01\u88c5\u6210 monthly_pipeline()&#xff0c;\u518d\u7528 schedule \u5b9a\u65f6\u4efb\u52a1\u8dd1&#xff0c;\u5c31\u662f\u4e00\u5957\u5b8c\u6574\u7684\u4e2a\u4eba\u91cf\u5316\u9009\u80a1\u7cfb\u7edf\u96cf\u5f62\u3002<\/p>\n<p>\u8fdb\u9636&#xff1a;\u7528 backtrader \u6846\u67b6\u843d\u5730&#xff08;\u6700\u6d41\u884c\u7684 Python \u56de\u6d4b\u5e93&#xff09;<\/p>\n<p>\u624b\u5199\u5faa\u73af\u56de\u6d4b\u4f18\u70b9\u662f\u900f\u660e&#xff0c;\u7f3a\u70b9\u662f\u96be\u6269\u5c55\u3002\u4e1a\u754c\u6700\u6d41\u884c\u7684 backtrader \u6846\u67b6\u628a&#034;\u6570\u636e\u3001\u7b56\u7565\u3001\u4ea4\u6613\u3001\u5206\u6790\u5668&#034;\u5206\u5c42&#xff0c;\u591a\u56e0\u5b50\u53ea\u662f\u5176\u4e2d\u7684\u4e00\u4e2a Strategy&#xff1a;<\/p>\n<p># multifactor_bt.py<br \/>\n# \u529f\u80fd: \u7528 backtrader \u6846\u67b6\u8dd1\u591a\u56e0\u5b50\u7b56\u7565\u9aa8\u67b6(\u793a\u610f)<br \/>\n# \u4f9d\u8d56: pip install backtrader<br \/>\nimport backtrader as bt<\/p>\n<p>class MultiFactorStrategy(bt.Strategy):<br \/>\n    &#034;&#034;&#034;\u591a\u56e0\u5b50\u7b56\u7565\u9aa8\u67b6: \u6bcf\u6708\u8c03\u4ed3\u5230\u7efc\u5408\u5206 Top10(\u4f2a\u4ee3\u7801\u6559\u5b66)&#034;&#034;&#034;<br \/>\n    params &#061; dict(top_n&#061;10, rebalance_day&#061;1)<\/p>\n<p>    def __init__(self):<br \/>\n        self.scores &#061; {}          # \u6bcf\u6708\u56e0\u5b50\u7efc\u5408\u5206(\u7531\u5916\u90e8\u6d41\u6c34\u7ebf\u6ce8\u5165)<\/p>\n<p>    def next(self):<br \/>\n        if len(self) % 21 !&#061; 0:   # \u7ea6\u6bcf\u6708\u4e00\u6b21(21\u4e2a\u4ea4\u6613\u65e5)<br \/>\n            return<br \/>\n        for d in self.datas:      # \u5148\u6e05\u4ed3\u518d\u4e70\u5165<br \/>\n            self.close(data&#061;d)<br \/>\n        top &#061; self.get_top_n(self.p.top_n)   # \u53d6\u7efc\u5408\u5206Top10<br \/>\n        for d in top:<br \/>\n            target &#061; self.broker.getvalue() \/ self.p.top_n<br \/>\n            self.order_target_value(data&#061;d, target&#061;target)<\/p>\n<p>    def get_top_n(self, n):<br \/>\n        &#034;&#034;&#034;\u6309\u7efc\u5408\u5206\u6392\u5e8f\u53d6\u524dn(\u7b80\u5316\u793a\u610f)&#034;&#034;&#034;<br \/>\n        ranked &#061; sorted(self.datas,<br \/>\n                        key&#061;lambda d: self.scores.get(d._name, 0),<br \/>\n                        reverse&#061;True)<br \/>\n        return ranked[:n]<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    cerebro &#061; bt.Cerebro()<br \/>\n    cerebro.addstrategy(MultiFactorStrategy)<br \/>\n    # cerebro.adddata(&#8230;)   # \u6dfb\u52a0100\u53ea\u80a1\u7968\u65e5\u7ebf\u6570\u636e<br \/>\n    # cerebro.addanalyzer(bt.analyzers.SharpeRatio, _name&#061;&#034;sharpe&#034;)<br \/>\n    # results &#061; cerebro.run()<br \/>\n    print(&#034;\u9aa8\u67b6\u5c31\u7eea: \u66ff\u6362\u6ce8\u91ca\u5904\u6570\u636e\u5373\u53ef\u8fd0\u884c&#034;)<\/p>\n<p>&#x1f4a1; backtrader \u7684 order_target_value \u4f1a\u81ea\u52a8\u5904\u7406&#034;\u6309\u76ee\u6807\u5e02\u503c\u8c03\u4ed3&#034;&#xff0c;\u7701\u6389\u624b\u5199\u4e70\u5356\u903b\u8f91\u3002\u60f3\u6df1\u5165\u5b66\u6846\u67b6&#xff0c;\u4e0b\u4e00\u7bc7\u4e4b\u540e&#xff08;23 \u7bc7&#xff09;\u4f1a\u4e13\u95e8\u62c6\u89e3 backtrader \u4e94\u5927\u7ec4\u4ef6&#xff0c;\u8fd9\u91cc\u5148\u6df7\u4e2a\u8138\u719f\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5b9e\u6218\u8981\u70b9\u4e0e\u5751<\/h3>\n<li>\u672a\u6765\u51fd\u6570\u662f\u5934\u53f7\u6740\u624b&#xff1a;\u6253\u5206\u5fc5\u987b\u7528&#034;\u4e0a\u6708\u6708\u5e95\u5df2\u77e5\u7684\u6570\u636e&#034;&#xff0c;\u7981\u6b62\u5077\u770b\u5f53\u6708\u6536\u76ca\u3002\u672c\u6587\u7b2c 2 \u6b65\u7684\u7b80\u5316\u5199\u6cd5\u53ea\u7528\u4e8e\u6559\u5b66\u6f14\u793a&#xff0c;\u5b9e\u76d8\u52a1\u5fc5\u6ede\u540e\u4e00\u671f\u3002<\/li>\n<li>\u56e0\u5b50\u8981\u6362\u8840&#xff1a;\u6bcf\u5b63\u5ea6\u68c0\u67e5\u56e0\u5b50 IC&#xff08;\u4fe1\u606f\u7cfb\u6570&#xff09;&#xff0c;\u957f\u671f IC \u5747\u503c &lt; 0.02 \u7684\u56e0\u5b50\u53ef\u4ee5\u8003\u8651\u66ff\u6362\u3002\u53c2\u8003&#xff1a;\u5b66\u672f\u6587\u732e\u4e2d A \u80a1\u5e38\u7528\u56e0\u5b50 IC \u591a\u5728 0.02-0.06 \u533a\u95f4&#xff08;\u6765\u6e90&#xff1a;\u300a\u56e0\u5b50\u6295\u8d44&#xff1a;\u65b9\u6cd5\u4e0e\u5b9e\u8df5\u300b\u77f3\u5ddd\u7b49&#xff09;\u3002<\/li>\n<li>\u6743\u91cd\u522b\u8fc7\u62df\u5408&#xff1a;\u7b49\u6743\u662f&#034;\u4e0b\u9650\u5f88\u9ad8&#034;\u7684\u65b9\u6848&#xff1b;\u52a0\u6743\u53c2\u6570\u8d8a\u591a&#xff0c;\u8d8a\u5bb9\u6613\u5728\u6837\u672c\u5185\u597d\u770b\u3001\u6837\u672c\u5916\u6253\u8138\u3002<\/li>\n<li>\u4ea4\u6613\u6210\u672c\u522b\u5ffd\u7565&#xff1a;\u6708\u5ea6\u6362\u4ed3 Top10 \u7684\u6362\u624b\u7387\u7ea6 100%\/\u6708&#xff0c;\u53cc\u8fb9\u6210\u672c\u6309 0.2% \u7b97&#xff0c;\u5e74\u5316\u5403\u6389\u7684\u6536\u76ca\u7ea6 2.4%\u2014\u2014\u56de\u6d4b\u5fc5\u987b\u6263\u8d39\u518d\u4e0b\u7ed3\u8bba\u3002<\/li>\n<li>\u673a\u6784\u5316\u65f6\u4ee3\u66f4\u62fc\u56e0\u5b50&#xff1a;\u622a\u81f3 2025 \u5e74&#xff0c;\u56fd\u5185 ETF \u5e02\u573a\u89c4\u6a21\u7a81\u7834 6 \u4e07\u4ebf\u5143&#xff08;\u6765\u6e90&#xff1a;\u4e2d\u56fd\u8bc1\u5238\u6295\u8d44\u57fa\u91d1\u4e1a\u534f\u4f1a\/\u4ea4\u6613\u6240\u516c\u5f00\u6570\u636e&#xff09;&#xff0c;\u673a\u6784\u6295\u8d44\u8005\u5360\u6bd4\u8fbe 78.37%&#xff08;\u6765\u6e90&#xff1a;\u4e0a\u4ea4\u6240\u300aETF \u5e02\u573a\u53d1\u5c55\u62a5\u544a\u300b&#xff09;&#xff0c;\u5168\u5e02\u573a ETF \u6570\u91cf 1500&#043; \u53ea\u3002\u5de5\u5177\u8d8a\u4e30\u5bcc&#xff0c;\u7eaf\u624b\u5de5\u9009\u80a1\u7684\u52a3\u52bf\u8d8a\u5927\u2014\u2014\u91cf\u5316\u56e0\u5b50\u65b9\u6cd5\u6b63\u662f\u4e2a\u4eba\u6295\u8d44\u8005\u7684&#034;\u88c5\u5907\u5347\u7ea7&#034;\u3002<\/li>\n<hr \/>\n<h3>\u603b\u7ed3<\/h3>\n<ul>\n<li>\u591a\u56e0\u5b50\u7684\u672c\u8d28&#xff1a;\u628a 5 \u4e2a\u5355\u56e0\u5b50\u53d8\u6210&#034;\u9009\u80a1\u59d4\u5458\u4f1a&#034;&#xff0c;\u7528\u7efc\u5408\u5206\u6295\u7968&#xff0c;\u5206\u6563\u5355\u4e00\u56e0\u5b50\u7684\u5931\u6548\u98ce\u9669&#xff1b;<\/li>\n<li>\u6253\u5206\u4e09\u6b65&#xff1a;\u53bb\u6781\u503c\u6807\u51c6\u5316 \u2192 \u65b9\u5411\u8c03\u6574 \u2192 \u52a0\u6743\/\u7b49\u6743\u5408\u6210&#xff1b;<\/li>\n<li>\u7ec4\u5408\u4e24\u65b9\u6848&#xff1a;\u7b49\u6743\u7b80\u5355\u7a33\u5065&#xff08;\u5e74\u5316 14.81%&#xff09;&#xff0c;\u52a0\u6743\u7a81\u51fa\u91cd\u70b9\u56e0\u5b50&#xff08;\u5e74\u5316 16.47%&#xff09;&#xff0c;\u6559\u5b66\u793a\u4f8b\u4e2d\u52a0\u6743\u8d85\u989d\u591a 1.66pp&#xff1b;<\/li>\n<li>\u8bb0\u4f4f&#xff1a;\u56de\u6d4b\u662f&#034;\u7167\u5996\u955c&#034;&#xff0c;\u6263\u8d39\u3001\u9632\u672a\u6765\u51fd\u6570\u3001\u53c2\u6570\u4e0d\u8fc7\u62df\u5408&#xff0c;\u7f3a\u4e00\u4e0d\u53ef\u3002<\/li>\n<\/ul>\n<p>\u601d\u8003\u9898&#xff1a;<\/p>\n<li>\u5982\u679c\u628a\u52a0\u6743\u6743\u91cd\u6362\u6210&#034;IC \u52a0\u6743&#034;&#xff08;\u7528\u6bcf\u4e2a\u56e0\u5b50\u8fc7\u53bb 12 \u4e2a\u6708\u4e0e\u672a\u6765\u6536\u76ca\u7684\u76f8\u5173\u7cfb\u6570\u505a\u6743\u91cd&#xff09;&#xff0c;\u56de\u6d4b\u7ed3\u679c\u4f1a\u66f4\u597d\u8fd8\u662f\u66f4\u5dee&#xff1f;\u4e3a\u4ec0\u4e48&#xff1f;<\/li>\n<li>\u6587\u4e2d Top10 \u6708\u5ea6\u6362\u4ed3\u7684\u6362\u624b\u7387\u5927\u7ea6\u662f\u591a\u5c11&#xff1f;\u82e5\u53cc\u8fb9\u6210\u672c 0.2%&#xff0c;\u5e74\u5316\u6536\u76ca\u4f1a\u88ab\u4fb5\u8680\u591a\u5c11&#xff1f;\u8bf7\u7528\u4ee3\u7801\u4f30\u7b97\u3002<\/li>\n<hr \/>\n<h3>\u7cfb\u5217\u9884\u544a<\/h3>\n<ul>\n<li>\u4e0b\u4e00\u7bc7&#xff08;21&#xff09;&#xff1a;ETF \u5b9a\u6295\u7b56\u7565\u2014\u2014\u667a\u80fd\u5b9a\u6295 vs \u666e\u901a\u5b9a\u6295 3 \u5e74\u5bf9\u6bd4&#xff0c;\u5e74\u5316\u5dee 4% \u662f\u600e\u4e48\u6765\u7684&#xff1f;\u7528 Python \u628a&#034;\u5fae\u7b11\u66f2\u7ebf&#034;\u7b97\u7ed9\u4f60\u770b\u3002<\/li>\n<li>\u4e0b\u4e0b\u7bc7&#xff08;22&#xff09;&#xff1a;\u673a\u5668\u5b66\u4e60\u9884\u6d4b\u2014\u2014\u968f\u673a\u68ee\u6797\u9884\u6d4b\u6b21\u65e5\u6da8\u8dcc&#xff08;\u51c6\u786e\u7387 53%&#xff09;&#xff0c;\u5f53&#034;\u7384\u5b66&#034;\u9047\u4e0a\u96c6\u6210\u5b66\u4e60\u3002<\/li>\n<\/ul>\n<p>\u6e90\u7801\u83b7\u53d6&#xff1a;\u672c\u6587\u5b8c\u6574\u4ee3\u7801\u89c1 GitHub &#8211; Python-in-Investment&#xff08;\u591a\u56e0\u5b50\u7bc7\u76ee\u5f55 strategy\/20_multifactor\/&#xff09;\u3002<\/p>\n<hr \/>\n<p>\u6807\u7b7e&#xff1a;#Python #pandas #\u91cf\u5316 #\u591a\u56e0\u5b50 #\u56de\u6d4b #\u9009\u80a1 #\u6295\u8d44<\/p>\n<p>SEO \u5173\u952e\u8bcd&#xff1a;Python \u591a\u56e0\u5b50\u9009\u80a1\u3001\u591a\u56e0\u5b50\u6253\u5206\u6a21\u578b\u3001\u7b49\u6743\u52a0\u6743\u7ec4\u5408\u5bf9\u6bd4\u3001A \u80a1\u91cf\u5316\u9009\u80a1\u3001backtrader \u591a\u56e0\u5b50\u56de\u6d4b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14077,11820,14075,14074,14076,81],"topic":[],"class_list":["post-123116","post","type-post","status-publish","format-standard","hentry","category-server","tag-a-","tag-atomgit","tag-14075","tag-14074","tag-14076","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/123116.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123116.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-06T05:00:40+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123116.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123116.html\",\"name\":\"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-06T05:00:40+00:00\",\"dateModified\":\"2026-11-06T05:00:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123116.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123116.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123116.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/123116.html","og_locale":"zh_CN","og_type":"article","og_title":"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/123116.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-06T05:00:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123116.html","url":"https:\/\/www.wsisp.com\/helps\/123116.html","name":"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-06T05:00:40+00:00","dateModified":"2026-11-06T05:00:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123116.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123116.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123116.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python\u6295\u8d44\u5e94\u752820-\u4ece\u201c\u770b K \u7ebf\u731c\u6da8\u8dcc\u201c\u5230\u201c\u6309\u5206\u6570\u9009\u80a1\u201c\uff1a\u591a\u56e0\u5b50\u6a21\u578b\u5b8c\u6574\u843d\u5730\uff0c\u5e74\u5316\u8d85\u989d 9.46 \u4e2a\u767e\u5206\u70b9"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=123116"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123116\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123116"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}