{"id":1174054,"date":"2025-01-15T17:11:45","date_gmt":"2025-01-15T09:11:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1174054.html"},"modified":"2025-01-15T17:11:49","modified_gmt":"2025-01-15T09:11:49","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%88%86%e6%9e%90%e8%82%a1%e7%a5%a8%e6%94%b6%e7%9b%8a","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1174054.html","title":{"rendered":"\u5982\u4f55\u7528python\u5206\u6790\u80a1\u7968\u6536\u76ca"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26075642\/3981e07a-0b3a-4004-95eb-bd7f7f5167d4.webp\" alt=\"\u5982\u4f55\u7528python\u5206\u6790\u80a1\u7968\u6536\u76ca\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca<\/strong><\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u83b7\u53d6\u5386\u53f2\u6570\u636e\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u3001\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868\u3001\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u3001\u56de\u6d4b\u7b56\u7565\u3002<\/strong>\u5176\u4e2d\uff0c\u83b7\u53d6\u5386\u53f2\u6570\u636e\u662f\u6700\u5173\u952e\u7684\u4e00\u6b65\u3002\u901a\u8fc7\u4f7f\u7528\u50cf<code>yfinance<\/code>\u8fd9\u6837\u7684\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u83b7\u53d6\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\u3002\u83b7\u53d6\u5230\u6570\u636e\u540e\uff0c\u53ef\u4ee5\u8ba1\u7b97\u6536\u76ca\u7387\uff0c\u5e76\u901a\u8fc7\u7ed8\u5236\u56fe\u8868\u548c\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u6765\u7406\u89e3\u80a1\u7968\u7684\u8868\u73b0\u3002\u6700\u540e\uff0c\u901a\u8fc7\u56de\u6d4b\u7b56\u7565\uff0c\u53ef\u4ee5\u6d4b\u8bd5\u4e0d\u540c\u7684\u6295\u8d44\u7b56\u7565\u7684\u6548\u679c\u3002<\/p>\n<\/p>\n<p><p><strong>\u83b7\u53d6\u5386\u53f2\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u83b7\u53d6\u5386\u53f2\u6570\u636e\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u7b2c\u4e00\u6b65\u3002Python\u6709\u8bb8\u591a\u5e93\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u83b7\u53d6\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\uff0c\u5982<code>yfinance<\/code>\u3001<code>pandas_datareader<\/code>\u7b49\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528<code>yfinance<\/code>\u5e93\u83b7\u53d6\u80a1\u7968\u5386\u53f2\u6570\u636e\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import yfinance as yf<\/p>\n<h2><strong>\u4e0b\u8f7d\u82f9\u679c\u516c\u53f8\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e<\/strong><\/h2>\n<p>stock_data = yf.download(&#39;AAPL&#39;, start=&#39;2020-01-01&#39;, end=&#39;2023-01-01&#39;)<\/p>\n<p>print(stock_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>yfinance<\/code>\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u4e0b\u8f7d\u5230\u4e0d\u540c\u65f6\u95f4\u6bb5\u7684\u80a1\u7968\u6570\u636e\uff0c\u5305\u62ec\u5f00\u76d8\u4ef7\u3001\u6536\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u548c\u4ea4\u6613\u91cf\u7b49\u3002<\/p>\n<\/p>\n<p><p><strong>\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387<\/strong><\/p>\n<\/p>\n<p><p>\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u516c\u5f0f\u8ba1\u7b97\u5355\u65e5\u6536\u76ca\u7387\uff1a<\/p>\n<\/p>\n<p><p>[ \\text{\u6536\u76ca\u7387} = \\frac{\\text{\u4eca\u65e5\u6536\u76d8\u4ef7} &#8211; \\text{\u6628\u65e5\u6536\u76d8\u4ef7}}{\\text{\u6628\u65e5\u6536\u76d8\u4ef7}} ]<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387<\/strong><\/h2>\n<p>stock_data[&#39;D<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ly Return&#39;] = stock_data[&#39;Close&#39;].pct_change()<\/p>\n<p>print(stock_data[[&#39;Close&#39;, &#39;Daily Return&#39;]])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u8ba1\u7b97\u80a1\u7968\u7684\u7d2f\u8ba1\u6536\u76ca\u7387\u3001\u5e73\u5747\u6536\u76ca\u7387\u4ee5\u53ca\u6ce2\u52a8\u7387\u7b49\u3002<\/p>\n<\/p>\n<p><p><strong>\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/p>\n<\/p>\n<p><p>\u7ed8\u5236\u56fe\u8868\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u91cd\u8981\u65b9\u5f0f\u3002\u901a\u8fc7\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u4e86\u89e3\u80a1\u7968\u7684\u8868\u73b0\u3002\u4ee5\u4e0b\u662f\u7ed8\u5236\u6bcf\u65e5\u6536\u76ca\u7387\u56fe\u8868\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u6bcf\u65e5\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(stock_data[&#39;Daily Return&#39;])<\/p>\n<p>plt.title(&#39;Daily Return of AAPL&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Daily Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u7ed8\u5236\u56fe\u8868\uff0c\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u53d1\u73b0\u80a1\u7968\u6536\u76ca\u7387\u7684\u6ce2\u52a8\u60c5\u51b5\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><p><strong>\u8fdb\u884c\u7edf\u8ba1\u5206\u6790<\/strong><\/p>\n<\/p>\n<p><p>\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u662f\u6df1\u5165\u4e86\u89e3\u80a1\u7968\u6536\u76ca\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u8ba1\u7b97\u80a1\u7968\u7684\u5e73\u5747\u6536\u76ca\u7387\u3001\u6807\u51c6\u5dee\u3001\u6700\u5927\u56de\u64a4\u7b49\u6307\u6807\uff0c\u4ee5\u66f4\u597d\u5730\u8bc4\u4f30\u80a1\u7968\u7684\u8868\u73b0\u3002\u4ee5\u4e0b\u662f\u8ba1\u7b97\u8fd9\u4e9b\u6307\u6807\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u5e73\u5747\u6536\u76ca\u7387<\/p>\n<p>mean_return = stock_data[&#39;Daily Return&#39;].mean()<\/p>\n<h2><strong>\u8ba1\u7b97\u6536\u76ca\u7387\u7684\u6807\u51c6\u5dee<\/strong><\/h2>\n<p>std_dev = stock_data[&#39;Daily Return&#39;].std()<\/p>\n<h2><strong>\u8ba1\u7b97\u6700\u5927\u56de\u64a4<\/strong><\/h2>\n<p>cumulative_return = (1 + stock_data[&#39;Daily Return&#39;]).cumprod()<\/p>\n<p>drawdown = cumulative_return.cummax() - cumulative_return<\/p>\n<p>max_drawdown = drawdown.max()<\/p>\n<p>print(f&#39;\u5e73\u5747\u6536\u76ca\u7387: {mean_return}&#39;)<\/p>\n<p>print(f&#39;\u6536\u76ca\u7387\u6807\u51c6\u5dee: {std_dev}&#39;)<\/p>\n<p>print(f&#39;\u6700\u5927\u56de\u64a4: {max_drawdown}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u7edf\u8ba1\u6307\u6807\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u4e86\u89e3\u80a1\u7968\u7684\u98ce\u9669\u548c\u6536\u76ca\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><p><strong>\u56de\u6d4b\u7b56\u7565<\/strong><\/p>\n<\/p>\n<p><p>\u56de\u6d4b\u7b56\u7565\u662f\u6d4b\u8bd5\u4e0d\u540c\u6295\u8d44\u7b56\u7565\u6548\u679c\u7684\u91cd\u8981\u65b9\u6cd5\u3002\u901a\u8fc7\u56de\u6d4b\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u7b56\u7565\u5728\u5386\u53f2\u6570\u636e\u4e0a\u7684\u8868\u73b0\uff0c\u4ece\u800c\u8bc4\u4f30\u5176\u6709\u6548\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5747\u7ebf\u7b56\u7565\u56de\u6d4b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u77ed\u671f\u548c\u957f\u671f\u5747\u7ebf<\/p>\n<p>stock_data[&#39;Short MA&#39;] = stock_data[&#39;Close&#39;].rolling(window=20).mean()<\/p>\n<p>stock_data[&#39;Long MA&#39;] = stock_data[&#39;Close&#39;].rolling(window=50).mean()<\/p>\n<h2><strong>\u751f\u6210\u4e70\u5165\u548c\u5356\u51fa\u4fe1\u53f7<\/strong><\/h2>\n<p>stock_data[&#39;Signal&#39;] = 0<\/p>\n<p>stock_data[&#39;Signal&#39;][20:] = np.where(stock_data[&#39;Short MA&#39;][20:] &gt; stock_data[&#39;Long MA&#39;][20:], 1, -1)<\/p>\n<h2><strong>\u8ba1\u7b97\u7b56\u7565\u6536\u76ca\u7387<\/strong><\/h2>\n<p>stock_data[&#39;Strategy Return&#39;] = stock_data[&#39;Daily Return&#39;] * stock_data[&#39;Signal&#39;].shift(1)<\/p>\n<h2><strong>\u7ed8\u5236\u7b56\u7565\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot((1 + stock_data[&#39;Strategy Return&#39;]).cumprod(), label=&#39;Strategy Return&#39;)<\/p>\n<p>plt.plot((1 + stock_data[&#39;Daily Return&#39;]).cumprod(), label=&#39;Buy and Hold Return&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.title(&#39;Strategy vs Buy and Hold Return&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Cumulative Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u56de\u6d4b\u7b56\u7565\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u5747\u7ebf\u7b56\u7565\u5728\u5386\u53f2\u6570\u636e\u4e0a\u7684\u8868\u73b0\uff0c\u5e76\u4e0e\u4e70\u5165\u6301\u6709\u7b56\u7565\u8fdb\u884c\u5bf9\u6bd4\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca\uff0c\u5305\u62ec\u83b7\u53d6\u5386\u53f2\u6570\u636e\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u3001\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868\u3001\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u3001\u56de\u6d4b\u7b56\u7565\u3002\u6bcf\u4e00\u6b65\u90fd\u6709\u5176\u91cd\u8981\u6027\uff0c\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u4e86\u89e3\u80a1\u7968\u7684\u8868\u73b0\u548c\u6f5c\u5728\u7684\u6295\u8d44\u673a\u4f1a\u3002<\/p>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001\u83b7\u53d6\u80a1\u7968\u5386\u53f2\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u57fa\u7840\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cd\u83b7\u53d6\u80a1\u7968\u6570\u636e\u7684\u5e93\uff0c\u5982<code>yfinance<\/code>\u3001<code>pandas_datareader<\/code>\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528yfinance\u83b7\u53d6\u6570\u636e<\/h4>\n<\/p>\n<p><p><code>yfinance<\/code>\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u83b7\u53d6\u82f9\u679c\u516c\u53f8\u5386\u53f2\u6570\u636e\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import yfinance as yf<\/p>\n<h2><strong>\u4e0b\u8f7d\u82f9\u679c\u516c\u53f8\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e<\/strong><\/h2>\n<p>stock_data = yf.download(&#39;AAPL&#39;, start=&#39;2020-01-01&#39;, end=&#39;2023-01-01&#39;)<\/p>\n<p>print(stock_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u80a1\u7968\u7684\u5f00\u76d8\u4ef7\u3001\u6536\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u548c\u4ea4\u6613\u91cf\u7b49\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528pandas_datareader\u83b7\u53d6\u6570\u636e<\/h4>\n<\/p>\n<p><p><code>pandas_datareader<\/code>\u4e5f\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u83b7\u53d6\u91d1\u878d\u6570\u636e\u7684\u5e93\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u83b7\u53d6\u82f9\u679c\u516c\u53f8\u5386\u53f2\u6570\u636e\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas_datareader.data as web<\/p>\n<p>import datetime<\/p>\n<p>start = datetime.datetime(2020, 1, 1)<\/p>\n<p>end = datetime.datetime(2023, 1, 1)<\/p>\n<h2><strong>\u83b7\u53d6\u82f9\u679c\u516c\u53f8\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e<\/strong><\/h2>\n<p>stock_data = web.DataReader(&#39;AAPL&#39;, &#39;yahoo&#39;, start, end)<\/p>\n<p>print(stock_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4e5f\u53ef\u4ee5\u83b7\u53d6\u5230\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387<\/h3>\n<\/p>\n<p><p>\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u6838\u5fc3\u6b65\u9aa4\u3002\u6536\u76ca\u7387\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u4e86\u89e3\u80a1\u7968\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u8868\u73b0\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387<\/h4>\n<\/p>\n<p><p>\u6bcf\u65e5\u6536\u76ca\u7387\u662f\u6307\u80a1\u7968\u6bcf\u5929\u7684\u6536\u76ca\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u516c\u5f0f\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><p>[ \\text{\u6536\u76ca\u7387} = \\frac{\\text{\u4eca\u65e5\u6536\u76d8\u4ef7} &#8211; \\text{\u6628\u65e5\u6536\u76d8\u4ef7}}{\\text{\u6628\u65e5\u6536\u76d8\u4ef7}} ]<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387<\/strong><\/h2>\n<p>stock_data[&#39;Daily Return&#39;] = stock_data[&#39;Close&#39;].pct_change()<\/p>\n<p>print(stock_data[[&#39;Close&#39;, &#39;Daily Return&#39;]])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8ba1\u7b97\u7d2f\u8ba1\u6536\u76ca\u7387<\/h4>\n<\/p>\n<p><p>\u7d2f\u8ba1\u6536\u76ca\u7387\u662f\u6307\u80a1\u7968\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u603b\u6536\u76ca\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u6bcf\u65e5\u6536\u76ca\u7387\u7d2f\u4e58\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u7d2f\u8ba1\u6536\u76ca\u7387<\/p>\n<p>cumulative_return = (1 + stock_data[&#39;Daily Return&#39;]).cumprod()<\/p>\n<p>print(cumulative_return)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u8ba1\u7b97\u5e73\u5747\u6536\u76ca\u7387\u548c\u6ce2\u52a8\u7387<\/h4>\n<\/p>\n<p><p>\u5e73\u5747\u6536\u76ca\u7387\u548c\u6ce2\u52a8\u7387\u662f\u8bc4\u4f30\u80a1\u7968\u8868\u73b0\u7684\u91cd\u8981\u6307\u6807\u3002\u5e73\u5747\u6536\u76ca\u7387\u53ef\u4ee5\u8861\u91cf\u80a1\u7968\u7684\u6574\u4f53\u8868\u73b0\uff0c\u800c\u6ce2\u52a8\u7387\u53ef\u4ee5\u8861\u91cf\u80a1\u7968\u7684\u98ce\u9669\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u5e73\u5747\u6536\u76ca\u7387<\/p>\n<p>mean_return = stock_data[&#39;Daily Return&#39;].mean()<\/p>\n<h2><strong>\u8ba1\u7b97\u6536\u76ca\u7387\u7684\u6807\u51c6\u5dee\uff08\u6ce2\u52a8\u7387\uff09<\/strong><\/h2>\n<p>std_dev = stock_data[&#39;Daily Return&#39;].std()<\/p>\n<p>print(f&#39;\u5e73\u5747\u6536\u76ca\u7387: {mean_return}&#39;)<\/p>\n<p>print(f&#39;\u6536\u76ca\u7387\u6807\u51c6\u5dee: {std_dev}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868<\/h3>\n<\/p>\n<p><p>\u7ed8\u5236\u56fe\u8868\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u91cd\u8981\u624b\u6bb5\u3002\u901a\u8fc7\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u4e86\u89e3\u80a1\u7968\u7684\u8868\u73b0\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7ed8\u5236\u6bcf\u65e5\u6536\u76ca\u7387\u56fe\u8868<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u7ed8\u5236\u6bcf\u65e5\u6536\u76ca\u7387\u56fe\u8868\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u6bcf\u65e5\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(stock_data[&#39;Daily Return&#39;])<\/p>\n<p>plt.title(&#39;Daily Return of AAPL&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Daily Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u7ed8\u5236\u7d2f\u8ba1\u6536\u76ca\u7387\u56fe\u8868<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u7ed8\u5236\u7d2f\u8ba1\u6536\u76ca\u7387\u56fe\u8868\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u7d2f\u8ba1\u6536\u76ca\u7387\u56fe\u8868<\/p>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(cumulative_return)<\/p>\n<p>plt.title(&#39;Cumulative Return of AAPL&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Cumulative Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u8fdb\u884c\u7edf\u8ba1\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u662f\u6df1\u5165\u4e86\u89e3\u80a1\u7968\u6536\u76ca\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u8ba1\u7b97\u80a1\u7968\u7684\u5e73\u5747\u6536\u76ca\u7387\u3001\u6807\u51c6\u5dee\u3001\u6700\u5927\u56de\u64a4\u7b49\u6307\u6807\uff0c\u4ee5\u66f4\u597d\u5730\u8bc4\u4f30\u80a1\u7968\u7684\u8868\u73b0\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8ba1\u7b97\u6700\u5927\u56de\u64a4<\/h4>\n<\/p>\n<p><p>\u6700\u5927\u56de\u64a4\u662f\u6307\u80a1\u7968\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u4ece\u6700\u9ad8\u70b9\u5230\u6700\u4f4e\u70b9\u7684\u6700\u5927\u8dcc\u5e45\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u6700\u5927\u56de\u64a4<\/p>\n<p>cumulative_return = (1 + stock_data[&#39;Daily Return&#39;]).cumprod()<\/p>\n<p>drawdown = cumulative_return.cummax() - cumulative_return<\/p>\n<p>max_drawdown = drawdown.max()<\/p>\n<p>print(f&#39;\u6700\u5927\u56de\u64a4: {max_drawdown}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8ba1\u7b97\u590f\u666e\u6bd4\u7387<\/h4>\n<\/p>\n<p><p>\u590f\u666e\u6bd4\u7387\u662f\u8bc4\u4f30\u6295\u8d44\u56de\u62a5\u76f8\u5bf9\u4e8e\u98ce\u9669\u7684\u6307\u6807\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u8ba1\u7b97\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u5e74\u5316\u6536\u76ca\u7387\u548c\u6ce2\u52a8\u7387<\/p>\n<p>annual_return = stock_data[&#39;Daily Return&#39;].mean() * 252<\/p>\n<p>annual_volatility = stock_data[&#39;Daily Return&#39;].std() * (252  0.5)<\/p>\n<h2><strong>\u8ba1\u7b97\u590f\u666e\u6bd4\u7387\uff08\u5047\u8bbe\u65e0\u98ce\u9669\u5229\u7387\u4e3a0\uff09<\/strong><\/h2>\n<p>sharpe_ratio = annual_return \/ annual_volatility<\/p>\n<p>print(f&#39;\u590f\u666e\u6bd4\u7387: {sharpe_ratio}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u56de\u6d4b\u7b56\u7565<\/h3>\n<\/p>\n<p><p>\u56de\u6d4b\u7b56\u7565\u662f\u6d4b\u8bd5\u4e0d\u540c\u6295\u8d44\u7b56\u7565\u6548\u679c\u7684\u91cd\u8981\u65b9\u6cd5\u3002\u901a\u8fc7\u56de\u6d4b\uff0c\u53ef\u4ee5\u9a8c\u8bc1\u7b56\u7565\u5728\u5386\u53f2\u6570\u636e\u4e0a\u7684\u8868\u73b0\uff0c\u4ece\u800c\u8bc4\u4f30\u5176\u6709\u6548\u6027\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7b80\u5355\u7684\u5747\u7ebf\u7b56\u7565\u56de\u6d4b<\/h4>\n<\/p>\n<p><p>\u5747\u7ebf\u7b56\u7565\u662f\u5e38\u89c1\u7684\u6280\u672f\u5206\u6790\u7b56\u7565\u4e4b\u4e00\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5747\u7ebf\u7b56\u7565\u56de\u6d4b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u8ba1\u7b97\u77ed\u671f\u548c\u957f\u671f\u5747\u7ebf<\/strong><\/h2>\n<p>stock_data[&#39;Short MA&#39;] = stock_data[&#39;Close&#39;].rolling(window=20).mean()<\/p>\n<p>stock_data[&#39;Long MA&#39;] = stock_data[&#39;Close&#39;].rolling(window=50).mean()<\/p>\n<h2><strong>\u751f\u6210\u4e70\u5165\u548c\u5356\u51fa\u4fe1\u53f7<\/strong><\/h2>\n<p>stock_data[&#39;Signal&#39;] = 0<\/p>\n<p>stock_data[&#39;Signal&#39;][20:] = np.where(stock_data[&#39;Short MA&#39;][20:] &gt; stock_data[&#39;Long MA&#39;][20:], 1, -1)<\/p>\n<h2><strong>\u8ba1\u7b97\u7b56\u7565\u6536\u76ca\u7387<\/strong><\/h2>\n<p>stock_data[&#39;Strategy Return&#39;] = stock_data[&#39;Daily Return&#39;] * stock_data[&#39;Signal&#39;].shift(1)<\/p>\n<h2><strong>\u7ed8\u5236\u7b56\u7565\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot((1 + stock_data[&#39;Strategy Return&#39;]).cumprod(), label=&#39;Strategy Return&#39;)<\/p>\n<p>plt.plot((1 + stock_data[&#39;Daily Return&#39;]).cumprod(), label=&#39;Buy and Hold Return&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.title(&#39;Strategy vs Buy and Hold Return&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Cumulative Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5176\u4ed6\u7b56\u7565\u56de\u6d4b<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u5747\u7ebf\u7b56\u7565\uff0c\u8fd8\u53ef\u4ee5\u6d4b\u8bd5\u5176\u4ed6\u7b56\u7565\uff0c\u5982\u52a8\u91cf\u7b56\u7565\u3001\u5747\u503c\u56de\u5f52\u7b56\u7565\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u52a8\u91cf\u7b56\u7565\u56de\u6d4b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u52a8\u91cf<\/p>\n<p>stock_data[&#39;Momentum&#39;] = stock_data[&#39;Close&#39;] \/ stock_data[&#39;Close&#39;].shift(20) - 1<\/p>\n<h2><strong>\u751f\u6210\u4e70\u5165\u548c\u5356\u51fa\u4fe1\u53f7<\/strong><\/h2>\n<p>stock_data[&#39;Signal&#39;] = 0<\/p>\n<p>stock_data[&#39;Signal&#39;][20:] = np.where(stock_data[&#39;Momentum&#39;][20:] &gt; 0, 1, -1)<\/p>\n<h2><strong>\u8ba1\u7b97\u7b56\u7565\u6536\u76ca\u7387<\/strong><\/h2>\n<p>stock_data[&#39;Strategy Return&#39;] = stock_data[&#39;Daily Return&#39;] * stock_data[&#39;Signal&#39;].shift(1)<\/p>\n<h2><strong>\u7ed8\u5236\u7b56\u7565\u6536\u76ca\u7387\u56fe\u8868<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot((1 + stock_data[&#39;Strategy Return&#39;]).cumprod(), label=&#39;Strategy Return&#39;)<\/p>\n<p>plt.plot((1 + stock_data[&#39;Daily Return&#39;]).cumprod(), label=&#39;Buy and Hold Return&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.title(&#39;Momentum Strategy vs Buy and Hold Return&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Cumulative Return&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u56de\u6d4b\u4e0d\u540c\u7684\u7b56\u7565\uff0c\u53ef\u4ee5\u627e\u5230\u9002\u5408\u81ea\u5df1\u7684\u6295\u8d44\u7b56\u7565\uff0c\u5e76\u5728\u5b9e\u9645\u6295\u8d44\u4e2d\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca\uff0c\u5305\u62ec\u83b7\u53d6\u5386\u53f2\u6570\u636e\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u3001\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868\u3001\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u3001\u56de\u6d4b\u7b56\u7565\u3002\u6bcf\u4e00\u6b65\u90fd\u6709\u5176\u91cd\u8981\u6027\uff0c\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u4e86\u89e3\u80a1\u7968\u7684\u8868\u73b0\u548c\u6f5c\u5728\u7684\u6295\u8d44\u673a\u4f1a\u3002<\/p>\n<\/p>\n<p><p><strong>\u83b7\u53d6\u5386\u53f2\u6570\u636e\u662f\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u57fa\u7840<\/strong>\uff0c\u901a\u8fc7<code>yfinance<\/code>\u7b49\u5e93\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u5230\u6240\u9700\u6570\u636e\u3002<strong>\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u662f\u6838\u5fc3\u6b65\u9aa4<\/strong>\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u91cf\u5316\u80a1\u7968\u7684\u8868\u73b0\u3002<strong>\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868\u4f7f\u5206\u6790\u66f4\u52a0\u76f4\u89c2<\/strong>\uff0c\u901a\u8fc7\u53ef\u89c6\u5316\u53ef\u4ee5\u66f4\u6e05\u6670\u5730\u770b\u5230\u80a1\u7968\u7684\u6ce2\u52a8\u548c\u8d8b\u52bf\u3002<strong>\u8fdb\u884c\u7edf\u8ba1\u5206\u6790<\/strong>\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u6df1\u5165\u4e86\u89e3\u80a1\u7968\u7684\u98ce\u9669\u548c\u6536\u76ca\u60c5\u51b5\u3002<strong>\u56de\u6d4b\u7b56\u7565<\/strong>\u662f\u9a8c\u8bc1\u6295\u8d44\u7b56\u7565\u6709\u6548\u6027\u7684\u91cd\u8981\u65b9\u6cd5\uff0c\u901a\u8fc7\u56de\u6d4b\u5386\u53f2\u6570\u636e\u53ef\u4ee5\u8bc4\u4f30\u7b56\u7565\u7684\u53ef\u884c\u6027\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u548c\u6295\u8d44\u7b56\u7565\uff0c\u7075\u6d3b\u4f7f\u7528\u4e0a\u8ff0\u65b9\u6cd5\u8fdb\u884c\u80a1\u7968\u6536\u76ca\u5206\u6790\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5b66\u4e60\u548c\u5b9e\u8df5\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1\u80a1\u7968\u6536\u76ca\u5206\u6790\u7684\u6280\u5de7\uff0c\u63d0\u9ad8\u6295\u8d44\u51b3\u7b56\u7684\u79d1\u5b66\u6027\u548c\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u7528Python\u83b7\u53d6\u80a1\u7968\u5386\u53f2\u6570\u636e\uff1f<\/strong><br \/>\u8981\u5206\u6790\u80a1\u7968\u6536\u76ca\uff0c\u9996\u5148\u9700\u8981\u83b7\u53d6\u76f8\u5173\u7684\u5386\u53f2\u6570\u636e\u3002Python\u6709\u8bb8\u591a\u5e93\u53ef\u4ee5\u7528\u4e8e\u83b7\u53d6\u80a1\u7968\u6570\u636e\uff0c\u6bd4\u5982<code>yfinance<\/code>\u548c<code>pandas_datareader<\/code>\u3002\u4f7f\u7528<code>yfinance<\/code>\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u8f7b\u677e\u83b7\u53d6\u67d0\u53ea\u80a1\u7968\u7684\u5386\u53f2\u6570\u636e\uff1a  <\/p>\n<pre><code class=\"language-python\">import yfinance as yf\n\n# \u83b7\u53d6\u82f9\u679c\u516c\u53f8\uff08AAPL\uff09\u7684\u5386\u53f2\u6570\u636e\ndata = yf.download(&#39;AAPL&#39;, start=&#39;2020-01-01&#39;, end=&#39;2023-01-01&#39;)\nprint(data.head())\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u6307\u5b9a\u65f6\u95f4\u6bb5\u5185\u7684\u80a1\u7968\u6570\u636e\uff0c\u5305\u62ec\u5f00\u76d8\u4ef7\u3001\u6536\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u548c\u4ea4\u6613\u91cf\u7b49\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Python\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\uff1f<\/strong><br \/>\u8ba1\u7b97\u80a1\u7968\u7684\u6536\u76ca\u7387\u662f\u5206\u6790\u5176\u8868\u73b0\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u516c\u5f0f\u8ba1\u7b97\u6536\u76ca\u7387\uff1a<br \/>[ \\text{\u6536\u76ca\u7387} = \\frac{\\text{\u7ed3\u675f\u4ef7\u683c} &#8211; \\text{\u5f00\u59cb\u4ef7\u683c}}{\\text{\u5f00\u59cb\u4ef7\u683c}} ]<br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u5229\u7528<code>pandas<\/code>\u5e93\u8f7b\u677e\u5b9e\u73b0\u6536\u76ca\u7387\u7684\u8ba1\u7b97\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">import pandas as pd\n\n# \u5047\u8bbedata\u662f\u4e4b\u524d\u4e0b\u8f7d\u7684\u80a1\u7968\u6570\u636e\ndata[&#39;\u6536\u76ca\u7387&#39;] = data[&#39;\u6536\u76d8\u4ef7&#39;].pct_change()\nprint(data[[&#39;\u6536\u76d8\u4ef7&#39;, &#39;\u6536\u76ca\u7387&#39;]].head())\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u4e3a\u6bcf\u4e2a\u4ea4\u6613\u65e5\u8ba1\u7b97\u51fa\u76f8\u5bf9\u4e8e\u524d\u4e00\u5929\u7684\u6536\u76ca\u7387\u3002<\/p>\n<p><strong>\u5982\u4f55\u53ef\u89c6\u5316\u80a1\u7968\u6536\u76ca\u6570\u636e\uff1f<\/strong><br \/>\u6570\u636e\u53ef\u89c6\u5316\u80fd\u591f\u5e2e\u52a9\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u80a1\u7968\u7684\u8868\u73b0\u3002\u4f7f\u7528<code>matplotlib<\/code>\u6216<code>seaborn<\/code>\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u7ed8\u5236\u6536\u76ca\u7387\u56fe\u8868\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u7ed8\u5236\u6536\u76ca\u7387\u7684\u65f6\u95f4\u5e8f\u5217\u56fe\uff1a  <\/p>\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\n# \u7ed8\u5236\u6536\u76ca\u7387\u56fe\nplt.figure(figsize=(12, 6))\nplt.plot(data.index, data[&#39;\u6536\u76ca\u7387&#39;], label=&#39;\u6536\u76ca\u7387&#39;, color=&#39;blue&#39;)\nplt.title(&#39;\u80a1\u7968\u6536\u76ca\u7387\u65f6\u95f4\u5e8f\u5217&#39;)\nplt.xlabel(&#39;\u65e5\u671f&#39;)\nplt.ylabel(&#39;\u6536\u76ca\u7387&#39;)\nplt.legend()\nplt.grid()\nplt.show()\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u53ef\u89c6\u5316\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u80a1\u7968\u5728\u4e0d\u540c\u65f6\u95f4\u6bb5\u7684\u8868\u73b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca \u4f7f\u7528Python\u5206\u6790\u80a1\u7968\u6536\u76ca\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u83b7\u53d6\u5386\u53f2\u6570\u636e\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387\u3001\u7ed8\u5236\u6536\u76ca [&hellip;]","protected":false},"author":3,"featured_media":1174061,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1174054"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1174054"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1174054\/revisions"}],"predecessor-version":[{"id":1174064,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1174054\/revisions\/1174064"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1174061"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1174054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1174054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1174054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}