{"id":1173394,"date":"2025-01-15T17:02:33","date_gmt":"2025-01-15T09:02:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1173394.html"},"modified":"2025-01-15T17:02:36","modified_gmt":"2025-01-15T09:02:36","slug":"python%e5%a6%82%e4%bd%95%e5%88%86%e6%9e%90%e5%9c%b0%e4%ba%a7%e8%82%a1","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1173394.html","title":{"rendered":"Python\u5982\u4f55\u5206\u6790\u5730\u4ea7\u80a1"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26075206\/3aa4c09a-5d3d-42c1-909a-7cffadb7cd15.webp\" alt=\"Python\u5982\u4f55\u5206\u6790\u5730\u4ea7\u80a1\" \/><\/p>\n<p><p> <strong>Python\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u83b7\u53d6\u3001\u6570\u636e\u6e05\u6d17\u3001\u6570\u636e\u5206\u6790\u3001\u6570\u636e\u53ef\u89c6\u5316\u7b49\u6b65\u9aa4\u6765\u5206\u6790\u5730\u4ea7\u80a1\u3002<\/strong> \u5176\u4e2d\uff0c\u6570\u636e\u83b7\u53d6\u662f\u57fa\u7840\uff0c\u53ef\u4ee5\u901a\u8fc7API\u6216\u722c\u866b\u6280\u672f\u4ece\u91d1\u878d\u7f51\u7ad9\u83b7\u53d6\u80a1\u7968\u6570\u636e\uff1b\u6570\u636e\u6e05\u6d17\u662f\u5173\u952e\uff0c\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u5f02\u5e38\u503c\u7b49\uff1b\u6570\u636e\u5206\u6790\u53ef\u4ee5\u4f7f\u7528Pandas\u7b49\u5e93\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\uff0c\u8ba1\u7b97\u80a1\u7968\u7684\u6536\u76ca\u7387\u3001\u6ce2\u52a8\u7387\u7b49\u6307\u6807\uff1b\u6570\u636e\u53ef\u89c6\u5316\u5219\u53ef\u4ee5\u4f7f\u7528Matplotlib\u3001Seaborn\u7b49\u5e93\u6765\u5c55\u793a\u5206\u6790\u7ed3\u679c\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u6570\u636e\u83b7\u53d6\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u6570\u636e\u83b7\u53d6<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6\u5730\u4ea7\u80a1\u7684\u6570\u636e\u662f\u5206\u6790\u7684\u7b2c\u4e00\u6b65\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u91d1\u878d\u6570\u636eAPI<\/h4>\n<\/p>\n<p><p>\u91d1\u878d\u6570\u636eAPI\u662f\u83b7\u53d6\u80a1\u7968\u6570\u636e\u7684\u5e38\u89c1\u65b9\u5f0f\uff0c\u4f8b\u5982Yahoo Finance\u3001Alpha Vantage\u7b49\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u80a1\u7968\u6570\u636e\u63a5\u53e3\u3002\u4f7f\u7528\u8fd9\u4e9bAPI\u9700\u8981\u6ce8\u518c\u5e76\u83b7\u53d6API\u5bc6\u94a5\uff0c\u7136\u540e\u901a\u8fc7HTTP\u8bf7\u6c42\u83b7\u53d6\u6570\u636e\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Alpha Vantage\u7684Python\u5e93\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u80a1\u7968\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>api_key = &#39;your_api_key&#39;<\/p>\n<p>symbol = &#39;AAPL&#39;<\/p>\n<p>url = f&#39;https:\/\/www.alphavantage.co\/query?function=TIME_SERIES_D<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>LY&amp;symbol={symbol}&amp;apikey={api_key}&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>data = response.json()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u722c\u866b\u6280\u672f<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u83b7\u53d6\u81ea\u5b9a\u4e49\u683c\u5f0f\u7684\u6570\u636e\u6216API\u4e0d\u6ee1\u8db3\u9700\u6c42\uff0c\u53ef\u4ee5\u4f7f\u7528\u722c\u866b\u6280\u672f\u4ece\u91d1\u878d\u7f51\u7ad9\u83b7\u53d6\u6570\u636e\u3002\u5e38\u7528\u7684\u722c\u866b\u5e93\u6709BeautifulSoup\u548cScrapy\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528BeautifulSoup\u4eceYahoo Finance\u83b7\u53d6\u80a1\u7968\u6570\u636e\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>url = &#39;https:\/\/finance.yahoo.com\/quote\/AAPL\/history?p=AAPL&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u6570\u636e<\/strong><\/h2>\n<p>table = soup.find(&#39;table&#39;, {&#39;data-test&#39;: &#39;historical-prices&#39;})<\/p>\n<p>rows = table.find_all(&#39;tr&#39;)<\/p>\n<p>for row in rows[1:]:<\/p>\n<p>    cols = row.find_all(&#39;td&#39;)<\/p>\n<p>    print([col.text for col in cols])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u6570\u636e\u6e05\u6d17<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6\u5230\u7684\u6570\u636e\u901a\u5e38\u9700\u8981\u8fdb\u884c\u6e05\u6d17\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u8d28\u91cf\u548c\u4e00\u81f4\u6027\u3002\u6570\u636e\u6e05\u6d17\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u5f02\u5e38\u503c\u4ee5\u53ca\u8f6c\u6362\u6570\u636e\u683c\u5f0f\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5904\u7406\u7f3a\u5931\u503c<\/h4>\n<\/p>\n<p><p>\u7f3a\u5931\u503c\u662f\u6570\u636e\u5206\u6790\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\uff0c\u53ef\u4ee5\u901a\u8fc7\u5220\u9664\u7f3a\u5931\u503c\u3001\u586b\u5145\u7f3a\u5931\u503c\u7b49\u65b9\u6cd5\u5904\u7406\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Pandas\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u5904\u7406\u7f3a\u5931\u503c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u8bfb\u53d6\u6570\u636e<\/strong><\/h2>\n<p>df = pd.read_csv(&#39;stock_data.csv&#39;)<\/p>\n<h2><strong>\u5220\u9664\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>df.dropna(inplace=True)<\/p>\n<h2><strong>\u586b\u5145\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>df.fillna(method=&#39;ffill&#39;, inplace=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5904\u7406\u5f02\u5e38\u503c<\/h4>\n<\/p>\n<p><p>\u5f02\u5e38\u503c\u662f\u6307\u504f\u79bb\u6b63\u5e38\u8303\u56f4\u7684\u6570\u636e\u70b9\uff0c\u53ef\u4ee5\u901a\u8fc7\u7edf\u8ba1\u5206\u6790\u65b9\u6cd5\u68c0\u6d4b\u548c\u5904\u7406\u5f02\u5e38\u503c\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Z-score\u65b9\u6cd5\u68c0\u6d4b\u5f02\u5e38\u503c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u8ba1\u7b97Z-score<\/strong><\/h2>\n<p>df[&#39;z_score&#39;] = (df[&#39;Close&#39;] - df[&#39;Close&#39;].mean()) \/ df[&#39;Close&#39;].std()<\/p>\n<h2><strong>\u8fc7\u6ee4\u5f02\u5e38\u503c<\/strong><\/h2>\n<p>df = df[np.abs(df[&#39;z_score&#39;]) &lt; 3]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u6570\u636e\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u5206\u6790\u662f\u5bf9\u6e05\u6d17\u540e\u7684\u6570\u636e\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u548c\u5efa\u6a21\uff0c\u4ee5\u63ed\u793a\u6570\u636e\u4e2d\u7684\u89c4\u5f8b\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8ba1\u7b97\u80a1\u7968\u6536\u76ca\u7387<\/h4>\n<\/p>\n<p><p>\u80a1\u7968\u6536\u76ca\u7387\u662f\u8861\u91cf\u80a1\u7968\u8868\u73b0\u7684\u91cd\u8981\u6307\u6807\uff0c\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387\u548c\u7d2f\u8ba1\u6536\u76ca\u7387\u6765\u5206\u6790\u80a1\u7968\u7684\u8868\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u6bcf\u65e5\u6536\u76ca\u7387<\/p>\n<p>df[&#39;daily_return&#39;] = df[&#39;Close&#39;].pct_change()<\/p>\n<h2><strong>\u8ba1\u7b97\u7d2f\u8ba1\u6536\u76ca\u7387<\/strong><\/h2>\n<p>df[&#39;cumulative_return&#39;] = (1 + df[&#39;daily_return&#39;]).cumprod() - 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u8ba1\u7b97\u6ce2\u52a8\u7387<\/h4>\n<\/p>\n<p><p>\u6ce2\u52a8\u7387\u662f\u8861\u91cf\u80a1\u7968\u4ef7\u683c\u6ce2\u52a8\u7a0b\u5ea6\u7684\u6307\u6807\uff0c\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u6807\u51c6\u5dee\u6765\u8861\u91cf\u6ce2\u52a8\u7387\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u6ce2\u52a8\u7387<\/p>\n<p>df[&#39;volatility&#39;] = df[&#39;daily_return&#39;].rolling(window=30).std() * np.sqrt(252)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u6570\u636e\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u53ef\u89c6\u5316\u662f\u5c55\u793a\u6570\u636e\u5206\u6790\u7ed3\u679c\u7684\u91cd\u8981\u624b\u6bb5\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ed8\u5236\u56fe\u8868\u6765\u76f4\u89c2\u5c55\u793a\u80a1\u7968\u7684\u8868\u73b0\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7ed8\u5236\u80a1\u7968\u4ef7\u683c\u8d70\u52bf<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u7ed8\u5236\u80a1\u7968\u4ef7\u683c\u8d70\u52bf\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(df[&#39;Date&#39;], df[&#39;Close&#39;], label=&#39;Close Price&#39;)<\/p>\n<p>plt.title(&#39;Stock Price Trend&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Price&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u7ed8\u5236\u6536\u76ca\u7387\u548c\u6ce2\u52a8\u7387<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5206\u522b\u7ed8\u5236\u80a1\u7968\u7684\u6536\u76ca\u7387\u548c\u6ce2\u52a8\u7387\u56fe\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u6536\u76ca\u7387<\/p>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(df[&#39;Date&#39;], df[&#39;cumulative_return&#39;], label=&#39;Cumulative Return&#39;)<\/p>\n<p>plt.title(&#39;Cumulative Return&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Return&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u7ed8\u5236\u6ce2\u52a8\u7387<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(df[&#39;Date&#39;], df[&#39;volatility&#39;], label=&#39;Volatility&#39;)<\/p>\n<p>plt.title(&#39;Volatility&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Volatility&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6570\u636e\u5efa\u6a21\u4e0e\u9884\u6d4b<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u5efa\u6a21\u4e0e\u9884\u6d4b\u662f\u9ad8\u7ea7\u6570\u636e\u5206\u6790\u7684\u5173\u952e\u6b65\u9aa4\uff0c\u53ef\u4ee5\u4f7f\u7528<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c\u7edf\u8ba1\u5efa\u6a21\u65b9\u6cd5\u5bf9\u80a1\u7968\u4ef7\u683c\u8fdb\u884c\u9884\u6d4b\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u65f6\u95f4\u5e8f\u5217\u6a21\u578b<\/h4>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u662f\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u7684\u5e38\u7528\u65b9\u6cd5\uff0c\u4f8b\u5982ARIMA\u6a21\u578b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.arima_model import ARIMA<\/p>\n<h2><strong>\u62c6\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>train, test = df[&#39;Close&#39;][:int(0.8*len(df))], df[&#39;Close&#39;][int(0.8*len(df)):]<\/p>\n<h2><strong>\u8bad\u7ec3ARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = ARIMA(train, order=(5, 1, 0))<\/p>\n<p>model_fit = model.fit(disp=0)<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>forecast, stderr, conf_int = model_fit.forecast(steps=len(test))<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(test.index, test, label=&#39;Actual Price&#39;)<\/p>\n<p>plt.plot(test.index, forecast, label=&#39;Forecasted Price&#39;)<\/p>\n<p>plt.fill_between(test.index, conf_int[:, 0], conf_int[:, 1], color=&#39;k&#39;, alpha=0.1)<\/p>\n<p>plt.title(&#39;Stock Price Prediction&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Price&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b\u5982\u968f\u673a\u68ee\u6797\u3001\u652f\u6301\u5411\u91cf\u673a\u7b49\u5bf9\u80a1\u7968\u4ef7\u683c\u8fdb\u884c\u9884\u6d4b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.ensemble import RandomForestRegressor<\/p>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>from sklearn.metrics import mean_squared_error<\/p>\n<h2><strong>\u51c6\u5907\u7279\u5f81\u548c\u76ee\u6807<\/strong><\/h2>\n<p>X = df[[&#39;Open&#39;, &#39;High&#39;, &#39;Low&#39;, &#39;Volume&#39;]]<\/p>\n<p>y = df[&#39;Close&#39;]<\/p>\n<h2><strong>\u62c6\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/p>\n<h2><strong>\u8bad\u7ec3\u968f\u673a\u68ee\u6797\u6a21\u578b<\/strong><\/h2>\n<p>model = RandomForestRegressor(n_estimators=100, random_state=42)<\/p>\n<p>model.fit(X_train, y_train)<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = model.predict(X_test)<\/p>\n<h2><strong>\u8ba1\u7b97\u8bef\u5dee<\/strong><\/h2>\n<p>mse = mean_squared_error(y_test, y_pred)<\/p>\n<p>print(f&#39;Mean Squared Error: {mse}&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(y_test.index, y_test, label=&#39;Actual Price&#39;)<\/p>\n<p>plt.plot(y_test.index, y_pred, label=&#39;Predicted Price&#39;)<\/p>\n<p>plt.title(&#39;Stock Price Prediction&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Price&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5206\u6790\u5730\u4ea7\u80a1\u7684\u6570\u636e\uff0c\u5305\u62ec\u83b7\u53d6\u6570\u636e\u3001\u6e05\u6d17\u6570\u636e\u3001\u5206\u6790\u6570\u636e\u3001\u53ef\u89c6\u5316\u6570\u636e\u4ee5\u53ca\u8fdb\u884c\u6570\u636e\u5efa\u6a21\u4e0e\u9884\u6d4b\u3002\u6bcf\u4e2a\u6b65\u9aa4\u90fd\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u548c\u5de5\u5177\uff0c\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5168\u9762\u5206\u6790\u5730\u4ea7\u80a1\u7684\u8868\u73b0\u548c\u8d8b\u52bf\uff0c\u4e3a\u6295\u8d44\u51b3\u7b56\u63d0\u4f9b\u79d1\u5b66\u4f9d\u636e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>1. \u5982\u4f55\u5229\u7528Python\u83b7\u53d6\u5730\u4ea7\u80a1\u7684\u5b9e\u65f6\u6570\u636e\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528\u591a\u79cdPython\u5e93\u6765\u83b7\u53d6\u5730\u4ea7\u80a1\u7684\u5b9e\u65f6\u6570\u636e\uff0c\u6bd4\u5982<code>pandas_datareader<\/code>\u548c<code>yfinance<\/code>\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u7528\u6237\u53ef\u4ee5\u4eceYahoo Finance\u3001Google Finance\u7b49\u5e73\u53f0\u83b7\u53d6\u80a1\u7968\u7684\u5386\u53f2\u548c\u5b9e\u65f6\u4ef7\u683c\u3002\u53ea\u9700\u5b89\u88c5\u76f8\u5e94\u5e93\u5e76\u7f16\u5199\u7b80\u5355\u7684\u4ee3\u7801\uff0c\u5373\u53ef\u5b9e\u73b0\u6570\u636e\u7684\u6293\u53d6\u548c\u5904\u7406\u3002<\/p>\n<p><strong>2. \u5728\u5206\u6790\u5730\u4ea7\u80a1\u65f6\uff0cPython\u80fd\u63d0\u4f9b\u54ea\u4e9b\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u591a\u79cd\u5f3a\u5927\u7684\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u5982<code>Matplotlib<\/code>\u3001<code>Seaborn<\/code>\u548c<code>Plotly<\/code>\u3002\u8fd9\u4e9b\u5e93\u5141\u8bb8\u7528\u6237\u521b\u5efa\u5404\u79cd\u56fe\u8868\uff0c\u5982\u6298\u7ebf\u56fe\u3001\u67f1\u72b6\u56fe\u548c\u70ed\u56fe\uff0c\u4ece\u800c\u4f7f\u5730\u4ea7\u80a1\u7684\u8d8b\u52bf\u548c\u6ce2\u52a8\u66f4\u52a0\u76f4\u89c2\u3002\u901a\u8fc7\u7ed3\u5408\u8fd9\u4e9b\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u5206\u6790\u5e08\u53ef\u4ee5\u8f7b\u677e\u8bc6\u522b\u5e02\u573a\u6a21\u5f0f\u548c\u6f5c\u5728\u6295\u8d44\u673a\u4f1a\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u5730\u4ea7\u80a1\u7684\u57fa\u672c\u9762\u5206\u6790\uff1f<\/strong><br \/>\u57fa\u672c\u9762\u5206\u6790\u6d89\u53ca\u8bc4\u4f30\u516c\u53f8\u7684\u8d22\u52a1\u5065\u5eb7\u72b6\u51b5\u3002\u4f7f\u7528Python\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pandas<\/code>\u5e93\u8bfb\u53d6\u548c\u5904\u7406\u8d22\u52a1\u62a5\u8868\u6570\u636e\uff0c\u5305\u62ec\u5229\u6da6\u8868\u3001\u8d44\u4ea7\u8d1f\u503a\u8868\u548c\u73b0\u91d1\u6d41\u91cf\u8868\u3002\u5206\u6790\u5e08\u53ef\u4ee5\u8ba1\u7b97\u5404\u79cd\u8d22\u52a1\u6bd4\u7387\uff0c\u5982\u5e02\u76c8\u7387\uff08P\/E\uff09\u3001\u5e02\u51c0\u7387\uff08P\/B\uff09\u548c\u8d1f\u503a\u7387\u7b49\uff0c\u4ee5\u5e2e\u52a9\u5224\u65ad\u5730\u4ea7\u80a1\u7684\u6295\u8d44\u4ef7\u503c\u3002\u7ed3\u5408\u6570\u636e\u5206\u6790\u548c\u53ef\u89c6\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u7406\u89e3\u516c\u53f8\u7684\u8d22\u52a1\u72b6\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u83b7\u53d6\u3001\u6570\u636e\u6e05\u6d17\u3001\u6570\u636e\u5206\u6790\u3001\u6570\u636e\u53ef\u89c6\u5316\u7b49\u6b65\u9aa4\u6765\u5206\u6790\u5730\u4ea7\u80a1\u3002 \u5176\u4e2d\uff0c\u6570\u636e\u83b7\u53d6\u662f\u57fa\u7840\uff0c\u53ef\u4ee5\u901a [&hellip;]","protected":false},"author":3,"featured_media":1173396,"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\/1173394"}],"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=1173394"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1173394\/revisions"}],"predecessor-version":[{"id":1173401,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1173394\/revisions\/1173401"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1173396"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1173394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1173394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1173394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}