{"id":1082288,"date":"2025-01-08T12:47:26","date_gmt":"2025-01-08T04:47:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1082288.html"},"modified":"2025-01-08T12:47:28","modified_gmt":"2025-01-08T04:47:28","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e7%94%bb%e5%87%ba%e8%b5%84%e6%9c%ac%e9%85%8d%e7%bd%ae%e7%ba%bf-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1082288.html","title":{"rendered":"\u5982\u4f55\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183901\/612e2131-0830-4fdd-8cd8-126dd0572c4c.webp\" alt=\"\u5982\u4f55\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf<\/strong><\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf\u4e3b\u8981\u6d89\u53ca\uff1a\u5b9a\u4e49\u8d44\u672c\u914d\u7f6e\u7ebf\u3001\u8ba1\u7b97\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669\u3001\u53ef\u89c6\u5316\u6570\u636e\u3002<\/strong>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u7406\u89e3\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u6982\u5ff5\uff0c\u5b83\u662f\u7528\u6765\u5c55\u793a\u6295\u8d44\u7ec4\u5408\u7684\u98ce\u9669\u548c\u6536\u76ca\u4e4b\u95f4\u5173\u7cfb\u7684\u56fe\u7ebf\u3002\u901a\u8fc7\u6295\u8d44\u65e0\u98ce\u9669\u8d44\u4ea7\u548c\u98ce\u9669\u8d44\u4ea7\u7684\u7ec4\u5408\uff0c\u53ef\u4ee5\u5f97\u5230\u4e0d\u540c\u7684\u98ce\u9669\u548c\u6536\u76ca\u7ec4\u5408\uff0c\u4ece\u800c\u5f62\u6210\u8d44\u672c\u914d\u7f6e\u7ebf\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf\uff0c\u5e76\u5bf9\u5176\u4e2d\u7684\u8ba1\u7b97\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669\u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b9a\u4e49\u8d44\u672c\u914d\u7f6e\u7ebf<\/p>\n<\/p>\n<p><p>\u8d44\u672c\u914d\u7f6e\u7ebf\uff08Capital Market Line, CML\uff09\u662f\u4e00\u6761\u5728\u5747\u503c-\u65b9\u5dee\u56fe\u4e0a\u63cf\u7ed8\u7684\u76f4\u7ebf\uff0c\u8868\u793a\u65e0\u98ce\u9669\u8d44\u4ea7\u548c\u5e02\u573a\u6295\u8d44\u7ec4\u5408\u4e4b\u95f4\u7684\u6743\u8861\u3002CML\u7684\u659c\u7387\u662f\u5e02\u573a\u7ec4\u5408\u7684\u590f\u666e\u6bd4\u7387\u3002\u516c\u5f0f\u4e3a\uff1a<\/p>\n<p>[ E(R_p) = R_f + \\frac{E(R_m) &#8211; R_f}{\\sigma_m} \\cdot \\sigma_p ]<\/p>\n<p>\u5176\u4e2d\uff0c( E(R_p) ) \u662f\u6295\u8d44\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\uff0c( R_f ) \u662f\u65e0\u98ce\u9669\u6536\u76ca\u7387\uff0c( E(R_m) ) \u662f\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\uff0c( \\sigma_m ) \u662f\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee\uff0c( \\sigma_p ) \u662f\u6295\u8d44\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u8ba1\u7b97\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8ba1\u7b97\u9884\u671f\u6536\u76ca<\/strong><\/p>\n<p>\u8981\u8ba1\u7b97\u6295\u8d44\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\uff0c\u9996\u5148\u9700\u8981\u4e86\u89e3\u65e0\u98ce\u9669\u6536\u76ca\u7387\u548c\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u3002\u65e0\u98ce\u9669\u6536\u76ca\u7387\u901a\u5e38\u7531\u653f\u5e9c\u53d1\u884c\u7684\u77ed\u671f\u503a\u5238\u6536\u76ca\u7387\u8868\u793a\uff0c\u800c\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u53ef\u4ee5\u901a\u8fc7\u5386\u53f2\u5e02\u573a\u6570\u636e\u4f30\u8ba1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u98ce\u9669<\/strong><\/p>\n<p>\u6295\u8d44\u7ec4\u5408\u7684\u98ce\u9669\u7531\u5176\u6807\u51c6\u5dee\u8868\u793a\uff0c\u6807\u51c6\u5dee\u8861\u91cf\u7684\u662f\u6536\u76ca\u7387\u7684\u6ce2\u52a8\u6027\u3002\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u53ef\u4ee5\u901a\u8fc7\u5386\u53f2\u5e02\u573a\u6570\u636e\u8ba1\u7b97\u5f97\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528Python\u5b9e\u73b0<\/p>\n<\/p>\n<ol>\n<li><strong>\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5b9a\u4e49\u65e0\u98ce\u9669\u6536\u76ca\u7387\u548c\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u53ca\u6807\u51c6\u5dee<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">Rf = 0.03  # \u65e0\u98ce\u9669\u6536\u76ca\u7387<\/p>\n<p>Rm = 0.12  # \u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387<\/p>\n<p>sigma_m = 0.2  # \u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u8ba1\u7b97\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u9884\u671f\u6536\u76ca<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">def cml(sigma_p, Rf, Rm, sigma_m):<\/p>\n<p>    return Rf + (Rm - Rf) \/ sigma_m * sigma_p<\/p>\n<p>sigma_p = np.linspace(0, 0.35, 100)  # \u6295\u8d44\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u8303\u56f4<\/p>\n<p>E_Rp = cml(sigma_p, Rf, Rm, sigma_m)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(sigma_p, E_Rp, label=&#39;Capital Market Line (CML)&#39;)<\/p>\n<p>plt.xlabel(&#39;Portfolio Risk (Standard Deviation)&#39;)<\/p>\n<p>plt.ylabel(&#39;Portfolio Expected Return&#39;)<\/p>\n<p>plt.title(&#39;Capital Market Line&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.grid(True)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u8be6\u7ec6\u63cf\u8ff0\u8ba1\u7b97\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8ba1\u7b97\u65e0\u98ce\u9669\u6536\u76ca\u7387<\/strong><\/p>\n<p>\u65e0\u98ce\u9669\u6536\u76ca\u7387\u901a\u5e38\u901a\u8fc7\u653f\u5e9c\u53d1\u884c\u7684\u77ed\u671f\u503a\u5238\u7684\u6536\u76ca\u7387\u6765\u8861\u91cf\uff0c\u56e0\u4e3a\u8fd9\u7c7b\u503a\u5238\u7684\u8fdd\u7ea6\u98ce\u9669\u6781\u4f4e\uff0c\u51e0\u4e4e\u53ef\u4ee5\u5ffd\u7565\u4e0d\u8ba1\u3002\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u5c06\u65e0\u98ce\u9669\u6536\u76ca\u7387\u8bbe\u5b9a\u4e3a3%\uff0c\u8fd9\u901a\u5e38\u662f\u5728\u53d1\u8fbe\u56fd\u5bb6\u7ecf\u6d4e\u73af\u5883\u4e2d\u7684\u4e00\u4e2a\u5408\u7406\u503c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387<\/strong><\/p>\n<p>\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u53ef\u4ee5\u901a\u8fc7\u5386\u53f2\u5e02\u573a\u6570\u636e\u6765\u4f30\u8ba1\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u6807\u51c6\u666e\u5c14500\u6307\u6570\uff08S&amp;P 500\uff09\u7b49\u4ee3\u8868\u6027\u5e02\u573a\u6307\u6570\u7684\u5386\u53f2\u6536\u76ca\u7387\u8ba1\u7b97\u5e73\u5747\u503c\uff0c\u53ef\u4ee5\u5f97\u5230\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u3002\u5728\u6211\u4eec\u7684\u793a\u4f8b\u4e2d\uff0c\u8bbe\u5b9a\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u4e3a12%\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee<\/strong><\/p>\n<p>\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u5386\u53f2\u6570\u636e\u8ba1\u7b97\u5f97\u51fa\u3002\u6807\u51c6\u5dee\u662f\u8861\u91cf\u6295\u8d44\u7ec4\u5408\u6536\u76ca\u7387\u6ce2\u52a8\u6027\u7684\u6307\u6807\u3002\u901a\u8fc7\u8ba1\u7b97\u5e02\u573a\u6307\u6570\u7684\u5386\u53f2\u6536\u76ca\u7387\u7684\u6807\u51c6\u5dee\uff0c\u53ef\u4ee5\u5f97\u5230\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u3002\u5728\u6211\u4eec\u7684\u793a\u4f8b\u4e2d\uff0c\u8bbe\u5b9a\u5e02\u573a\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u4e3a20%\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u8fdb\u4e00\u6b65\u6269\u5c55\u548c\u4f18\u5316<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5b9e\u9645\u6570\u636e\u8ba1\u7b97<\/strong><\/p>\n<p>\u4e3a\u4e86\u4f7f\u7ed8\u5236\u7684\u8d44\u672c\u914d\u7f6e\u7ebf\u66f4\u4e3a\u51c6\u786e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b9e\u9645\u7684\u5e02\u573a\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684pandas\u5e93\u8bfb\u53d6\u5386\u53f2\u5e02\u573a\u6570\u636e\uff0c\u7136\u540e\u8ba1\u7b97\u65e0\u98ce\u9669\u6536\u76ca\u7387\u3001\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u548c\u6807\u51c6\u5dee\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u4e0d\u540c\u7684\u6295\u8d44\u7ec4\u5408<\/strong><\/p>\n<p>\u53ef\u4ee5\u5728\u8d44\u672c\u914d\u7f6e\u7ebf\u56fe\u4e0a\u6dfb\u52a0\u4e0d\u540c\u7684\u6295\u8d44\u7ec4\u5408\uff0c\u4ee5\u6bd4\u8f83\u5b83\u4eec\u7684\u98ce\u9669\u548c\u6536\u76ca\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u5b9e\u9645\u6295\u8d44\u7ec4\u5408\u7684\u70b9\uff0c\u5c55\u793a\u5176\u76f8\u5bf9\u4e8e\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8003\u8651\u6295\u8d44\u7ec4\u5408\u7684\u591a\u6837\u5316<\/strong><\/p>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6295\u8d44\u7ec4\u5408\u901a\u5e38\u7531\u591a\u79cd\u8d44\u4ea7\u7ec4\u6210\u3002\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6269\u5c55\u6a21\u578b\uff0c\u8003\u8651\u591a\u8d44\u4ea7\u6295\u8d44\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684numpy\u548cpandas\u5e93\u8ba1\u7b97\u591a\u8d44\u4ea7\u6295\u8d44\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u548c\u534f\u65b9\u5dee\u77e9\u9635\uff0c\u7136\u540e\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f18\u5316\u6295\u8d44\u7ec4\u5408<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u73b0\u4ee3\u6295\u8d44\u7ec4\u5408\u7406\u8bba\uff08Markowitz Portfolio Theory\uff09\u6765\u4f18\u5316\u6295\u8d44\u7ec4\u5408\u3002\u901a\u8fc7\u4f18\u5316\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u627e\u5230\u5728\u7ed9\u5b9a\u98ce\u9669\u6c34\u5e73\u4e0b\u7684\u6700\u4f18\u6295\u8d44\u7ec4\u5408\uff0c\u5e76\u5c55\u793a\u5176\u5728\u8d44\u672c\u914d\u7f6e\u7ebf\u56fe\u4e0a\u7684\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u5b9e\u9645\u5e94\u7528\u793a\u4f8b<\/p>\n<\/p>\n<ol>\n<li><strong>\u5bfc\u5165\u5b9e\u9645\u5e02\u573a\u6570\u636e<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import yfinance as yf<\/p>\n<h2><strong>\u83b7\u53d6\u5e02\u573a\u6570\u636e\uff0c\u4f8b\u5982\u6807\u51c6\u666e\u5c14500\u6307\u6570<\/strong><\/h2>\n<p>data = yf.download(&#39;^GSPC&#39;, start=&#39;2010-01-01&#39;, end=&#39;2020-01-01&#39;)<\/p>\n<p>data[&#39;Returns&#39;] = data[&#39;Adj Close&#39;].pct_change()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u8ba1\u7b97\u65e0\u98ce\u9669\u6536\u76ca\u7387\u3001\u5e02\u573a\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u548c\u6807\u51c6\u5dee<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">Rf = 0.03  # \u65e0\u98ce\u9669\u6536\u76ca\u7387<\/p>\n<p>Rm = data[&#39;Returns&#39;].mean() * 252  # \u5e74\u5316\u9884\u671f\u6536\u76ca\u7387<\/p>\n<p>sigma_m = data[&#39;Returns&#39;].std() * np.sqrt(252)  # \u5e74\u5316\u6807\u51c6\u5dee<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">sigma_p = np.linspace(0, 0.35, 100)  # \u6295\u8d44\u7ec4\u5408\u7684\u6807\u51c6\u5dee\u8303\u56f4<\/p>\n<p>E_Rp = cml(sigma_p, Rf, Rm, sigma_m)<\/p>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(sigma_p, E_Rp, label=&#39;Capital Market Line (CML)&#39;)<\/p>\n<p>plt.xlabel(&#39;Portfolio Risk (Standard Deviation)&#39;)<\/p>\n<p>plt.ylabel(&#39;Portfolio Expected Return&#39;)<\/p>\n<p>plt.title(&#39;Capital Market Line&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.grid(True)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u7ed8\u5236\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf\uff0c\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u6839\u636e\u5e02\u573a\u6570\u636e\u8fdb\u884c\u8c03\u6574\u548c\u4f18\u5316\u3002\u4f7f\u7528\u5b9e\u9645\u6570\u636e\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u51c6\u786e\u6027\uff0c\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6295\u8d44\u8005\u66f4\u597d\u5730\u7406\u89e3\u4e0d\u540c\u98ce\u9669\u6c34\u5e73\u4e0b\u7684\u9884\u671f\u6536\u76ca\uff0c\u4e3a\u51b3\u7b56\u63d0\u4f9b\u6709\u529b\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u57fa\u672c\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728Python\u4e2d\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf\uff08Capital Market Line, CML\uff09\u901a\u5e38\u9700\u8981\u51e0\u4e2a\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u5e76\u5bfc\u5165\u5fc5\u8981\u7684\u5e93\uff0c\u6bd4\u5982NumPy\u548cMatplotlib\u3002\u63a5\u4e0b\u6765\uff0c\u5b9a\u4e49\u65e0\u98ce\u9669\u8d44\u4ea7\u7684\u6536\u76ca\u7387\u548c\u5e02\u573a\u6295\u8d44\u7ec4\u5408\u7684\u9884\u671f\u6536\u76ca\u7387\u4ee5\u53ca\u6807\u51c6\u5dee\u3002\u6700\u540e\uff0c\u901a\u8fc7\u4f7f\u7528Matplotlib\u7ed8\u5236\u56fe\u5f62\uff0c\u5c06\u65e0\u98ce\u9669\u6536\u76ca\u7387\u4f5c\u4e3ay\u8f74\uff0c\u5e02\u573a\u7ec4\u5408\u7684\u98ce\u9669\uff08\u6807\u51c6\u5dee\uff09\u4f5c\u4e3ax\u8f74\uff0c\u8fde\u63a5\u8fd9\u4e24\u70b9\u5f62\u6210\u8d44\u672c\u914d\u7f6e\u7ebf\u3002<\/p>\n<p><strong>\u6709\u54ea\u4e9bPython\u5e93\u53ef\u4ee5\u5e2e\u52a9\u5b9e\u73b0\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u7ed8\u5236\uff1f<\/strong><br \/>\u7ed8\u5236\u8d44\u672c\u914d\u7f6e\u7ebf\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2aPython\u5e93\u3002\u5176\u4e2d\uff0cNumPy\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\uff0cMatplotlib\u662f\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\uff0c\u9002\u5408\u521b\u5efa\u9ad8\u8d28\u91cf\u7684\u56fe\u5f62\u3002\u6b64\u5916\uff0cPandas\u5e93\u4e5f\u53ef\u4ee5\u7528\u6765\u5904\u7406\u548c\u7ba1\u7406\u91d1\u878d\u6570\u636e\uff0c\u5e2e\u52a9\u66f4\u597d\u5730\u5206\u6790\u548c\u53ef\u89c6\u5316\u6570\u636e\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u591a\u79cd\u8d44\u4ea7\u65f6\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<p><strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u65e0\u98ce\u9669\u6536\u76ca\u7387\u548c\u5e02\u573a\u7ec4\u5408\u6570\u636e\uff1f<\/strong><br \/>\u9009\u62e9\u65e0\u98ce\u9669\u6536\u76ca\u7387\u65f6\uff0c\u901a\u5e38\u4f1a\u53c2\u8003\u56fd\u503a\u6536\u76ca\u7387\uff0c\u56e0\u4e3a\u56fd\u503a\u88ab\u89c6\u4e3a\u98ce\u9669\u6700\u4f4e\u7684\u6295\u8d44\u3002\u800c\u5e02\u573a\u7ec4\u5408\u7684\u6570\u636e\u53ef\u4ee5\u901a\u8fc7\u5386\u53f2\u5e02\u573a\u6307\u6570\uff08\u5982\u6807\u51c6\u666e\u5c14500\u6307\u6570\uff09\u6765\u83b7\u5f97\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u91d1\u878d\u6570\u636e\u63d0\u4f9b\u5546\u6216\u4f7f\u7528Yahoo Finance\u3001Alpha Vantage\u7b49API\u6765\u83b7\u53d6\u8fd9\u4e9b\u6570\u636e\u3002\u786e\u4fdd\u6570\u636e\u7684\u65f6\u95f4\u8303\u56f4\u548c\u9891\u7387\u7b26\u5408\u60a8\u7684\u5206\u6790\u9700\u6c42\uff0c\u4ee5\u786e\u4fdd\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u51c6\u786e\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u89e3\u8bfb\u7ed8\u5236\u51fa\u7684\u8d44\u672c\u914d\u7f6e\u7ebf\uff1f<\/strong><br \/>\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u659c\u7387\u4ee3\u8868\u4e86\u5e02\u573a\u98ce\u9669\u6ea2\u4ef7\uff0c\u663e\u793a\u4e86\u6bcf\u5355\u4f4d\u98ce\u9669\u6240\u80fd\u83b7\u5f97\u7684\u989d\u5916\u6536\u76ca\u3002\u7ebf\u4e0a\u7684\u6bcf\u4e00\u70b9\u4ee3\u8868\u7740\u4e0d\u540c\u7684\u8d44\u4ea7\u7ec4\u5408\uff0c\u6295\u8d44\u8005\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u98ce\u9669\u627f\u53d7\u80fd\u529b\u9009\u62e9\u76f8\u5e94\u7684\u7ec4\u5408\u3002\u8d44\u672c\u914d\u7f6e\u7ebf\u7684\u8d8a\u9661\uff0c\u8868\u660e\u6bcf\u589e\u52a0\u5355\u4f4d\u98ce\u9669\u6240\u5e26\u6765\u7684\u6536\u76ca\u8d8a\u9ad8\uff0c\u8fd9\u4e3a\u6295\u8d44\u8005\u63d0\u4f9b\u4e86\u6743\u8861\u98ce\u9669\u4e0e\u6536\u76ca\u7684\u6709\u529b\u5de5\u5177\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf \u4f7f\u7528Python\u753b\u51fa\u8d44\u672c\u914d\u7f6e\u7ebf\u4e3b\u8981\u6d89\u53ca\uff1a\u5b9a\u4e49\u8d44\u672c\u914d\u7f6e\u7ebf\u3001\u8ba1\u7b97\u9884\u671f\u6536\u76ca\u548c\u98ce\u9669\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1082293,"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\/1082288"}],"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=1082288"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1082288\/revisions"}],"predecessor-version":[{"id":1082295,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1082288\/revisions\/1082295"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1082293"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1082288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1082288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1082288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}