{"id":937626,"date":"2024-12-26T19:55:37","date_gmt":"2024-12-26T11:55:37","guid":{"rendered":""},"modified":"2024-12-26T19:55:39","modified_gmt":"2024-12-26T11:55:39","slug":"%e6%9c%9f%e8%b4%a7%e5%a6%82%e4%bd%95%e9%87%8f%e5%8c%96-python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/937626.html","title":{"rendered":"\u671f\u8d27\u5982\u4f55\u91cf\u5316 python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25073405\/256b72e7-878b-4cd3-ae8d-662f51e72420.webp\" alt=\"\u671f\u8d27\u5982\u4f55\u91cf\u5316 python\" \/><\/p>\n<p><p> <strong>\u91cf\u5316\u671f\u8d27\u4ea4\u6613\u4f7f\u7528Python\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u5206\u6790\u3001\u81ea\u52a8\u5316\u4ea4\u6613\u548c\u98ce\u9669\u7ba1\u7406\u7b49\u6280\u672f\u624b\u6bb5\u5b9e\u73b0\u3002\u901a\u8fc7Python\u7f16\u5199\u7a0b\u5e8f\uff0c\u80fd\u591f\u5206\u6790\u5927\u91cf\u7684\u5e02\u573a\u6570\u636e\u3001\u5efa\u7acb\u91cf\u5316\u7b56\u7565\u6a21\u578b\u3001\u5b9e\u73b0\u81ea\u52a8\u5316\u4ea4\u6613\u6267\u884c\u3001\u7ba1\u7406\u548c\u63a7\u5236\u98ce\u9669\u3002<\/strong>\u5176\u4e2d\uff0c\u6570\u636e\u5206\u6790\u662f\u91cf\u5316\u4ea4\u6613\u7684\u57fa\u7840\uff0c\u5229\u7528Python\u7684\u5f3a\u5927\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u53ef\u4ee5\u5feb\u901f\u63d0\u53d6\u3001\u6e05\u6d17\u3001\u5206\u6790\u5e02\u573a\u6570\u636e\uff0c\u4ece\u4e2d\u6316\u6398\u51fa\u6f5c\u5728\u7684\u4ea4\u6613\u673a\u4f1a\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7Python\u5b9e\u73b0\u671f\u8d27\u91cf\u5316\u4ea4\u6613\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u6570\u636e\u83b7\u53d6\u4e0e\u5904\u7406<\/p>\n<\/p>\n<p><p>\u5728\u91cf\u5316\u4ea4\u6613\u4e2d\uff0c\u6570\u636e\u662f\u6700\u4e3a\u91cd\u8981\u7684\u8d44\u6e90\u3002\u671f\u8d27\u5e02\u573a\u7684\u6570\u636e\u53ef\u4ee5\u5206\u4e3a\u5386\u53f2\u6570\u636e\u548c\u5b9e\u65f6\u6570\u636e\u4e24\u7c7b\u3002<\/p>\n<\/p>\n<ol>\n<li>\u83b7\u53d6\u5386\u53f2\u6570\u636e<\/li>\n<\/ol>\n<p><p>\u8981\u8fdb\u884c\u91cf\u5316\u5206\u6790\uff0c\u9996\u5148\u9700\u8981\u83b7\u53d6\u5386\u53f2\u6570\u636e\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cd\u83b7\u53d6\u91d1\u878d\u6570\u636e\u7684\u5e93\uff0c\u5982<code>pandas_datareader<\/code>\u3001<code>yfinance<\/code>\u7b49\uff0c\u53ef\u4ee5\u4eceYahoo Finance\u3001Google Finance\u7b49\u5e73\u53f0\u83b7\u53d6\u671f\u8d27\u5386\u53f2\u6570\u636e\u3002\u4f7f\u7528\u8fd9\u4e9b\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u83b7\u53d6\u5230\u4e0d\u540c\u671f\u8d27\u54c1\u79cd\u7684\u5386\u53f2\u4ef7\u683c\u3001\u4ea4\u6613\u91cf\u7b49\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import yfinance as yf<\/p>\n<h2><strong>\u4e0b\u8f7d\u671f\u8d27\u5386\u53f2\u6570\u636e<\/strong><\/h2>\n<p>data = yf.download(&#39;GC=F&#39;, start=&#39;2020-01-01&#39;, end=&#39;2021-01-01&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u6570\u636e\u6e05\u6d17\u4e0e\u9884\u5904\u7406<\/li>\n<\/ol>\n<p><p>\u83b7\u53d6\u5230\u6570\u636e\u540e\uff0c\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u9884\u5904\u7406\uff0c\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u53bb\u9664\u5f02\u5e38\u6570\u636e\u3001\u6807\u51c6\u5316\u5904\u7406\u7b49\u3002Python\u7684<code>pandas<\/code>\u5e93\u5728\u6570\u636e\u9884\u5904\u7406\u65b9\u9762\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u7684\u6e05\u6d17\u548c\u6807\u51c6\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u5904\u7406\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>data.fillna(method=&#39;ffill&#39;, inplace=True)<\/p>\n<h2><strong>\u53bb\u9664\u5f02\u5e38\u503c<\/strong><\/h2>\n<p>data = data[(data[&#39;Close&#39;] &gt; data[&#39;Close&#39;].quantile(0.01)) &amp; (data[&#39;Close&#39;] &lt; data[&#39;Close&#39;].quantile(0.99))]<\/p>\n<h2><strong>\u6807\u51c6\u5316\u5904\u7406<\/strong><\/h2>\n<p>data[&#39;Normalized&#39;] = (data[&#39;Close&#39;] - data[&#39;Close&#39;].mean()) \/ data[&#39;Close&#39;].std()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u91cf\u5316\u7b56\u7565\u5f00\u53d1<\/p>\n<\/p>\n<p><p>\u5728\u6570\u636e\u51c6\u5907\u597d\u4e4b\u540e\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u5f00\u53d1\u91cf\u5316\u7b56\u7565\u3002\u91cf\u5316\u7b56\u7565\u662f\u5229\u7528\u6570\u5b66\u6a21\u578b\u548c\u7b97\u6cd5\u5bf9\u5e02\u573a\u8fdb\u884c\u5206\u6790\u548c\u51b3\u7b56\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6280\u672f\u6307\u6807\u5206\u6790<\/li>\n<\/ol>\n<p><p>\u6280\u672f\u6307\u6807\u662f\u91cf\u5316\u7b56\u7565\u4e2d\u5e38\u7528\u7684\u5de5\u5177\u3002\u901a\u8fc7\u6280\u672f\u6307\u6807\uff0c\u53ef\u4ee5\u5206\u6790\u5e02\u573a\u7684\u8d70\u52bf\u548c\u8d8b\u52bf\uff0c\u53d1\u73b0\u6f5c\u5728\u7684\u4ea4\u6613\u673a\u4f1a\u3002Python\u4e2d\u7684<code>ta<\/code>\uff08technical analysis\uff09\u5e93\u63d0\u4f9b\u4e86\u5404\u79cd\u5e38\u7528\u7684\u6280\u672f\u6307\u6807\uff0c\u5982\u79fb\u52a8\u5e73\u5747\u7ebf\u3001\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570\uff08RSI\uff09\u3001MACD\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import ta<\/p>\n<h2><strong>\u8ba1\u7b97\u79fb\u52a8\u5e73\u5747\u7ebf<\/strong><\/h2>\n<p>data[&#39;SMA&#39;] = ta.trend.sma_indicator(data[&#39;Close&#39;], window=20)<\/p>\n<h2><strong>\u8ba1\u7b97\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570<\/strong><\/h2>\n<p>data[&#39;RSI&#39;] = ta.momentum.rsi(data[&#39;Close&#39;], window=14)<\/p>\n<h2><strong>\u8ba1\u7b97MACD<\/strong><\/h2>\n<p>data[&#39;MACD&#39;], data[&#39;MACD_signal&#39;], _ = ta.trend.macd(data[&#39;Close&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u7b56\u7565\u6784\u5efa\u4e0e\u56de\u6d4b<\/li>\n<\/ol>\n<p><p>\u57fa\u4e8e\u6280\u672f\u6307\u6807\uff0c\u53ef\u4ee5\u6784\u5efa\u4ea4\u6613\u7b56\u7565\uff0c\u5e76\u4f7f\u7528\u5386\u53f2\u6570\u636e\u5bf9\u7b56\u7565\u8fdb\u884c\u56de\u6d4b\uff0c\u4ee5\u8bc4\u4f30\u7b56\u7565\u7684\u6709\u6548\u6027\u548c\u7a33\u5b9a\u6027\u3002<code>backtrader<\/code>\u662fPython\u4e2d\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u56de\u6d4b\u6846\u67b6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u7b56\u7565\u56de\u6d4b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import backtrader as bt<\/p>\n<p>class MyStrategy(bt.Strategy):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        self.sma = bt.indicators.SimpleMovingAverage(self.data.close, period=20)<\/p>\n<p>        self.rsi = bt.indicators.RSI(self.data.close, period=14)<\/p>\n<p>    def next(self):<\/p>\n<p>        if not self.position:<\/p>\n<p>            if self.data.close[0] &gt; self.sma[0] and self.rsi[0] &lt; 30:<\/p>\n<p>                self.buy()<\/p>\n<p>        elif self.data.close[0] &lt; self.sma[0] or self.rsi[0] &gt; 70:<\/p>\n<p>            self.sell()<\/p>\n<p>cerebro = bt.Cerebro()<\/p>\n<p>cerebro.addstrategy(MyStrategy)<\/p>\n<p>cerebro.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u81ea\u52a8\u5316\u4ea4\u6613\u6267\u884c<\/p>\n<\/p>\n<p><p>\u5728\u91cf\u5316\u7b56\u7565\u7ecf\u8fc7\u56de\u6d4b\u9a8c\u8bc1\u540e\uff0c\u53ef\u4ee5\u8fdb\u884c\u81ea\u52a8\u5316\u4ea4\u6613\u6267\u884c\u3002\u81ea\u52a8\u5316\u4ea4\u6613\u9700\u8981\u4e0e\u4ea4\u6613\u6240\u7684API\u8fdb\u884c\u5bf9\u63a5\uff0c\u901a\u8fc7\u7a0b\u5e8f\u5316\u7684\u65b9\u5f0f\u5b9e\u73b0\u4ea4\u6613\u6307\u4ee4\u7684\u4e0b\u8fbe\u548c\u6267\u884c\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4ea4\u6613API\u5bf9\u63a5<\/li>\n<\/ol>\n<p><p>Python\u53ef\u4ee5\u901a\u8fc7\u5404\u79cdAPI\u5e93\u4e0e\u4ea4\u6613\u6240\u8fdb\u884c\u5bf9\u63a5\uff0c\u5982<code>ccxt<\/code>\u5e93\u652f\u6301\u5bf9\u63a5\u591a\u4e2a\u4ea4\u6613\u6240\u7684API\uff0c\u901a\u8fc7API\uff0c\u53ef\u4ee5\u83b7\u53d6\u5e02\u573a\u884c\u60c5\u3001\u4e0b\u5355\u3001\u67e5\u8be2\u8ba2\u5355\u72b6\u6001\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import ccxt<\/p>\n<p>exchange = ccxt.binance({<\/p>\n<p>    &#39;apiKey&#39;: &#39;YOUR_API_KEY&#39;,<\/p>\n<p>    &#39;secret&#39;: &#39;YOUR_SECRET_KEY&#39;,<\/p>\n<p>})<\/p>\n<h2><strong>\u83b7\u53d6\u5e02\u573a\u884c\u60c5<\/strong><\/h2>\n<p>ticker = exchange.fetch_ticker(&#39;BTC\/USDT&#39;)<\/p>\n<h2><strong>\u4e0b\u5355<\/strong><\/h2>\n<p>order = exchange.create_market_buy_order(&#39;BTC\/USDT&#39;, 1)<\/p>\n<h2><strong>\u67e5\u8be2\u8ba2\u5355\u72b6\u6001<\/strong><\/h2>\n<p>order_status = exchange.fetch_order(order[&#39;id&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u5b9e\u65f6\u76d1\u63a7\u4e0e\u8c03\u6574<\/li>\n<\/ol>\n<p><p>\u81ea\u52a8\u5316\u4ea4\u6613\u7cfb\u7edf\u9700\u8981\u5b9e\u65f6\u76d1\u63a7\u5e02\u573a\u53d8\u5316\uff0c\u6839\u636e\u7b56\u7565\u89c4\u5219\u8fdb\u884c\u52a8\u6001\u8c03\u6574\u3002Python\u7684\u591a\u7ebf\u7a0b\u548c\u5f02\u6b65\u7f16\u7a0b\u7279\u6027\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u7684\u76d1\u63a7\u548c\u7b56\u7565\u7684\u8c03\u6574\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import asyncio<\/p>\n<p>async def monitor_market():<\/p>\n<p>    while True:<\/p>\n<p>        # \u83b7\u53d6\u5b9e\u65f6\u5e02\u573a\u6570\u636e<\/p>\n<p>        ticker = aw<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t exchange.fetch_ticker(&#39;BTC\/USDT&#39;)<\/p>\n<p>        # \u6839\u636e\u7b56\u7565\u8fdb\u884c\u5224\u65ad\u548c\u8c03\u6574<\/p>\n<p>        # ...<\/p>\n<p>        await asyncio.sleep(1)<\/p>\n<p>loop = asyncio.get_event_loop()<\/p>\n<p>loop.run_until_complete(monitor_market())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u98ce\u9669\u7ba1\u7406\u4e0e\u63a7\u5236<\/p>\n<\/p>\n<p><p>\u5728\u91cf\u5316\u4ea4\u6613\u4e2d\uff0c\u98ce\u9669\u7ba1\u7406\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u73af\u3002\u6709\u6548\u7684\u98ce\u9669\u7ba1\u7406\u80fd\u591f\u5728\u5e02\u573a\u6ce2\u52a8\u4e2d\u4fdd\u62a4\u6295\u8d44\u8d44\u672c\uff0c\u786e\u4fdd\u4ea4\u6613\u7b56\u7565\u7684\u957f\u671f\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\u98ce\u9669\u63a7\u5236\u7b56\u7565<\/li>\n<\/ol>\n<p><p>\u5e38\u7528\u7684\u98ce\u9669\u63a7\u5236\u7b56\u7565\u5305\u62ec\u6b62\u635f\u3001\u6b62\u76c8\u3001\u4ed3\u4f4d\u7ba1\u7406\u7b49\u3002\u901a\u8fc7\u8bbe\u5b9a\u5408\u7406\u7684\u6b62\u635f\u6b62\u76c8\u70b9\uff0c\u53ef\u4ee5\u6709\u6548\u964d\u4f4e\u4ea4\u6613\u98ce\u9669\uff1b\u901a\u8fc7\u52a8\u6001\u8c03\u6574\u4ed3\u4f4d\uff0c\u53ef\u4ee5\u5728\u5e02\u573a\u6ce2\u52a8\u4e2d\u4fdd\u6301\u8d44\u91d1\u5b89\u5168\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class RiskManagementStrategy(bt.Strategy):<\/p>\n<p>    params = ((&#39;stop_loss&#39;, 0.02), (&#39;take_profit&#39;, 0.05))<\/p>\n<p>    def __init__(self):<\/p>\n<p>        self.buy_price = None<\/p>\n<p>    def next(self):<\/p>\n<p>        if not self.position:<\/p>\n<p>            self.buy_price = self.data.close[0]<\/p>\n<p>            self.buy()<\/p>\n<p>        else:<\/p>\n<p>            if self.data.close[0] &lt;= self.buy_price * (1 - self.params.stop_loss):<\/p>\n<p>                self.sell()<\/p>\n<p>            elif self.data.close[0] &gt;= self.buy_price * (1 + self.params.take_profit):<\/p>\n<p>                self.sell()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u8d44\u91d1\u66f2\u7ebf\u5206\u6790<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u5206\u6790\u8d44\u91d1\u66f2\u7ebf\uff0c\u53ef\u4ee5\u8bc4\u4f30\u7b56\u7565\u7684\u6536\u76ca\u98ce\u9669\u6bd4\u3001\u6700\u5927\u56de\u64a4\u3001\u80dc\u7387\u7b49\u6307\u6807\uff0c\u4ee5\u4f18\u5316\u548c\u8c03\u6574\u7b56\u7565\u3002<code>matplotlib<\/code>\u662fPython\u4e2d\u5e38\u7528\u7684\u6570\u636e\u53ef\u89c6\u5316\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u7ed8\u5236\u8d44\u91d1\u66f2\u7ebf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u8d44\u91d1\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.plot(strategy.broker.getvalue())<\/p>\n<p>plt.title(&#39;Equity Curve&#39;)<\/p>\n<p>plt.xlabel(&#39;Time&#39;)<\/p>\n<p>plt.ylabel(&#39;Equity&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u7b56\u7565\u4f18\u5316\u4e0e\u6539\u8fdb<\/p>\n<\/p>\n<p><p>\u91cf\u5316\u4ea4\u6613\u662f\u4e00\u4e2a\u52a8\u6001\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u4e0d\u65ad\u5730\u4f18\u5316\u548c\u6539\u8fdb\u7b56\u7565\uff0c\u4ee5\u9002\u5e94\u5e02\u573a\u7684\u53d8\u5316\u3002<\/p>\n<\/p>\n<ol>\n<li>\u53c2\u6570\u4f18\u5316<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u53c2\u6570\u4f18\u5316\uff0c\u53ef\u4ee5\u627e\u5230\u7b56\u7565\u7684\u6700\u4f18\u53c2\u6570\u7ec4\u5408\uff0c\u63d0\u9ad8\u7b56\u7565\u7684\u6536\u76ca\u98ce\u9669\u6bd4\u3002<code>optuna<\/code>\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u8d85\u53c2\u6570\u4f18\u5316\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u7b56\u7565\u53c2\u6570\u7684\u4f18\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import optuna<\/p>\n<p>def objective(trial):<\/p>\n<p>    sma_period = trial.suggest_int(&#39;sma_period&#39;, 10, 50)<\/p>\n<p>    rsi_period = trial.suggest_int(&#39;rsi_period&#39;, 10, 50)<\/p>\n<p>    # \u56de\u6d4b\u7b56\u7565\u5e76\u8fd4\u56de\u6536\u76ca\u7387\u4f5c\u4e3a\u4f18\u5316\u76ee\u6807<\/p>\n<p>    return backtest_strategy(sma_period, rsi_period)<\/p>\n<p>study = optuna.create_study(direction=&#39;maximize&#39;)<\/p>\n<p>study.optimize(objective, n_trials=100)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u7b56\u7565\u7ec4\u5408<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u6784\u5efa\u7b56\u7565\u7ec4\u5408\uff0c\u53ef\u4ee5\u5206\u6563\u98ce\u9669\uff0c\u63d0\u9ad8\u6536\u76ca\u7684\u7a33\u5b9a\u6027\u3002\u7b56\u7565\u7ec4\u5408\u53ef\u4ee5\u901a\u8fc7\u5bf9\u4e0d\u540c\u5e02\u573a\u3001\u4e0d\u540c\u54c1\u79cd\u3001\u4e0d\u540c\u7b56\u7565\u8fdb\u884c\u7ec4\u5408\uff0c\u5b9e\u73b0\u591a\u5143\u5316\u6295\u8d44\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class StrategyA(bt.Strategy):<\/p>\n<p>    # \u7b56\u7565A\u7684\u5b9e\u73b0<\/p>\n<p>class StrategyB(bt.Strategy):<\/p>\n<p>    # \u7b56\u7565B\u7684\u5b9e\u73b0<\/p>\n<p>cerebro = bt.Cerebro()<\/p>\n<p>cerebro.addstrategy(StrategyA)<\/p>\n<p>cerebro.addstrategy(StrategyB)<\/p>\n<p>cerebro.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0cPython\u5728\u91cf\u5316\u671f\u8d27\u4ea4\u6613\u4e2d\u5177\u6709\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u3001\u7b56\u7565\u5f00\u53d1\u3001\u81ea\u52a8\u5316\u4ea4\u6613\u548c\u98ce\u9669\u7ba1\u7406\u80fd\u529b\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u4f18\u5316\u548c\u6539\u8fdb\uff0c\u53ef\u4ee5\u6784\u5efa\u51fa\u7a33\u5b9a\u9ad8\u6548\u7684\u91cf\u5316\u4ea4\u6613\u7cfb\u7edf\uff0c\u5b9e\u73b0\u6301\u7eed\u7684\u76c8\u5229\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u91cf\u5316\u4ea4\u6613\u5728\u671f\u8d27\u5e02\u573a\u4e2d\u6709\u4ec0\u4e48\u4f18\u52bf\uff1f<\/strong><br \/>\u91cf\u5316\u4ea4\u6613\u5229\u7528\u6570\u5b66\u6a21\u578b\u548c\u7b97\u6cd5\u5206\u6790\u5e02\u573a\u6570\u636e\uff0c\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u6355\u6349\u5e02\u573a\u673a\u4f1a\u3002\u76f8\u6bd4\u4e8e\u4f20\u7edf\u7684\u624b\u52a8\u4ea4\u6613\uff0c\u91cf\u5316\u4ea4\u6613\u80fd\u591f\u6d88\u9664\u60c5\u7eea\u56e0\u7d20\uff0c\u63d0\u9ad8\u4ea4\u6613\u51b3\u7b56\u7684\u5ba2\u89c2\u6027\u3002\u540c\u65f6\uff0c\u901a\u8fc7\u81ea\u52a8\u5316\u4ea4\u6613\u7b56\u7565\uff0c\u4ea4\u6613\u8005\u53ef\u4ee5\u5728\u66f4\u77ed\u7684\u65f6\u95f4\u5185\u5904\u7406\u5927\u91cf\u6570\u636e\uff0c\u4ece\u800c\u83b7\u5f97\u66f4\u9ad8\u7684\u6536\u76ca\u7387\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u671f\u8d27\u91cf\u5316\u5206\u6790\uff1f<\/strong><br \/>Python\u4f5c\u4e3a\u4e00\u79cd\u5f3a\u5927\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u91cf\u5316\u5206\u6790\u4e2d\u3002\u4ea4\u6613\u8005\u53ef\u4ee5\u5229\u7528\u5982Pandas\u3001NumPy\u7b49\u5e93\u8fdb\u884c\u6570\u636e\u5904\u7406\uff0c\u4f7f\u7528Matplotlib\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\uff0c\u5e76\u901a\u8fc7Backtrader\u7b49\u6846\u67b6\u8fdb\u884c\u7b56\u7565\u56de\u6d4b\u3002\u901a\u8fc7\u7f16\u5199Python\u4ee3\u7801\uff0c\u7528\u6237\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u671f\u8d27\u5e02\u573a\u6570\u636e\u7684\u5b9e\u65f6\u5206\u6790\u548c\u7b56\u7565\u6267\u884c\u3002<\/p>\n<p><strong>\u91cf\u5316\u4ea4\u6613\u7684\u57fa\u672c\u7b56\u7565\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728\u671f\u8d27\u5e02\u573a\u4e2d\uff0c\u5e38\u89c1\u7684\u91cf\u5316\u4ea4\u6613\u7b56\u7565\u5305\u62ec\u8d8b\u52bf\u8ddf\u8e2a\u3001\u5747\u503c\u56de\u5f52\u3001\u5957\u5229\u7b56\u7565\u548c\u4e8b\u4ef6\u9a71\u52a8\u7b56\u7565\u3002\u8d8b\u52bf\u8ddf\u8e2a\u7b56\u7565\u4f9d\u8d56\u4e8e\u6280\u672f\u6307\u6807\u8bc6\u522b\u5e02\u573a\u8d8b\u52bf\uff0c\u800c\u5747\u503c\u56de\u5f52\u7b56\u7565\u5219\u662f\u57fa\u4e8e\u4ef7\u683c\u6ce2\u52a8\u56de\u5f52\u5230\u5e73\u5747\u6c34\u5e73\u7684\u5047\u8bbe\u3002\u5957\u5229\u7b56\u7565\u5219\u662f\u5229\u7528\u5e02\u573a\u95f4\u7684\u4ef7\u683c\u5dee\u5f02\u8fdb\u884c\u4ea4\u6613\uff0c\u800c\u4e8b\u4ef6\u9a71\u52a8\u7b56\u7565\u5219\u662f\u57fa\u4e8e\u7279\u5b9a\u4e8b\u4ef6\uff08\u5982\u7ecf\u6d4e\u6570\u636e\u53d1\u5e03\uff09\u8fdb\u884c\u4ea4\u6613\u51b3\u7b56\u3002\u901a\u8fc7Python\u7f16\u7a0b\uff0c\u4ea4\u6613\u8005\u53ef\u4ee5\u5b9e\u73b0\u548c\u4f18\u5316\u8fd9\u4e9b\u7b56\u7565\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u91cf\u5316\u671f\u8d27\u4ea4\u6613\u4f7f\u7528Python\u53ef\u4ee5\u901a\u8fc7\u6570\u636e\u5206\u6790\u3001\u81ea\u52a8\u5316\u4ea4\u6613\u548c\u98ce\u9669\u7ba1\u7406\u7b49\u6280\u672f\u624b\u6bb5\u5b9e\u73b0\u3002\u901a\u8fc7Python\u7f16\u5199\u7a0b\u5e8f\uff0c\u80fd [&hellip;]","protected":false},"author":3,"featured_media":937631,"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\/937626"}],"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=937626"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/937626\/revisions"}],"predecessor-version":[{"id":937632,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/937626\/revisions\/937632"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/937631"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=937626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=937626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=937626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}