{"id":1558,"date":"2024-10-28T07:36:00","date_gmt":"2024-10-27T23:36:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1558"},"modified":"2024-10-03T20:51:00","modified_gmt":"2024-10-03T12:51:00","slug":"%e6%9c%80%e9%80%82%e5%90%88%e5%88%9d%e7%ba%a7%e7%ae%97%e6%b3%95%e4%ba%a4%e6%98%93%e8%80%85%e7%9a%84-python-%e8%ae%a1%e7%ae%97%e5%ba%93","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/10\/28\/%e6%9c%80%e9%80%82%e5%90%88%e5%88%9d%e7%ba%a7%e7%ae%97%e6%b3%95%e4%ba%a4%e6%98%93%e8%80%85%e7%9a%84-python-%e8%ae%a1%e7%ae%97%e5%ba%93\/","title":{"rendered":"\u6700\u9002\u5408\u521d\u7ea7\u7b97\u6cd5\u4ea4\u6613\u8005\u7684 Python \u8ba1\u7b97\u5e93"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/1003.png\" alt=\"\" class=\"wp-image-2336\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u5728\u8bfb\u5b8c\u6211\u4e0a\u4e00\u7bc7\u300a<a href=\"https:\/\/blog.laoyulaoyu.top\/index.php\/2024\/09\/24\/2024-%e5%b9%b4%e9%9d%a2%e5%90%91%e7%ae%97%e6%b3%95%e4%ba%a4%e6%98%93%e8%80%85%e7%9a%84%e5%8d%81%e5%a4%a7%e5%bc%80%e6%ba%90-python-%e5%ba%93\/\" target=\"_blank\" rel=\"noreferrer noopener\">2024 \u5e74\u9762\u5411\u7b97\u6cd5\u4ea4\u6613\u8005\u7684\u5341\u5927\u5f00\u6e90 Python \u5e93<\/a>\u300b\u540e\uff0c\u6709\u8bfb\u8005\u5e0c\u671b\u6211\u4e13\u95e8\u5199\u4e00\u7bc7\u9002\u5408\u4e8e\u521d\u5b66\u8005\u4e14\u6613\u4e8e\u4e0a\u624b\u7684\u5e93\u3002\u6240\u4ee5\u4eca\u5929\u6211\u6765\u7ed9\u5927\u5bb6\u4ecb\u7ecd<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5f53\u4e0b\u6700\u53d7\u6b22\u8fce\u7684 Python \u8ba1\u7b97\u5e93\u2014\u2014Backtrader\uff0c\u5e76\u4f1a\u8be6\u7ec6\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u5b83\u6765\u5b9e\u73b0\u91cf\u5316\u4ea4\u6613\u7b56\u7565<\/mark>\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p>\u5728\u91cf\u5316\u4ea4\u6613\u7684\u4e16\u754c\u91cc\uff0c\u6bcf\u4e00\u6beb\u79d2\u90fd\u53ef\u80fd\u610f\u5473\u7740\u76c8\u5229\u4e0e\u4e8f\u635f\u7684\u5dee\u522b\uff0c\u56e0\u6b64\u62e5\u6709\u5408\u9002\u7684\u5de5\u5177\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u5c31\u50cf\u5728\u5176\u4ed6\u9886\u57df\u4e00\u6837\uff0c\u60a8\u53ef\u4ee5\u5b66\u4e60\u8bb8\u591a\u6709\u7528\u7684\u91cf\u5316\u4ea4\u6613\u5e93\uff0c\u4f46\u5982\u679c\u975e\u8981\u6211\u9009\u62e9\u4e00\u4e2a\u5728\u529f\u80fd\u5f3a\u5927\u7684\u57fa\u7840\u4e0a\u3001\u8fd8\u7b80\u5355\u6613\u7528\u7684\u5e93\uff0c\u90a3\u5c31\u662f <strong>Backtrader<\/strong>\u3002<\/p>\n\n\n\n<p><strong>\u5730\u5740\uff1a<\/strong><a href=\"https:\/\/www.backtrader.com\/\">Backtrader<\/a> \uff08<a href=\"https:\/\/www.backtrader.com\/\"><em>https:\/\/www.backtrader.com\/<\/em><\/a>\uff09<\/p>\n\n\n\n<p>\u5176\u4ed6\u9009\u62e9\u63a8\u8350\u770b\u8fd9\u7bc7\uff1a\u300a<a href=\"https:\/\/blog.laoyulaoyu.top\/index.php\/2024\/09\/24\/2024-%e5%b9%b4%e9%9d%a2%e5%90%91%e7%ae%97%e6%b3%95%e4%ba%a4%e6%98%93%e8%80%85%e7%9a%84%e5%8d%81%e5%a4%a7%e5%bc%80%e6%ba%90-python-%e5%ba%93\/\" target=\"_blank\" rel=\"noreferrer noopener\">2024 \u5e74\u9762\u5411\u7b97\u6cd5\u4ea4\u6613\u8005\u7684\u5341\u5927\u5f00\u6e90 Python \u5e93<\/a>\u300b<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u662f\u4e00\u540d\u4ece\u4e8b\u7b97\u6cd5\u4ea4\u6613\u7684 Python \u5f00\u53d1\u4eba\u5458\uff0c\u90a3\u4e48 Backtrader \u7edd\u5bf9\u662f\u60a8 2024 \u5e74\u7684\u5173\u6ce8\u91cd\u70b9\uff0c\u56e0\u4e3a\u5b83\u4ecd\u7136\u662f\u4e13\u4e3a\u8be5\u9886\u57df\u8bbe\u8ba1\u7684\u4f7f\u7528\u7387\u6700\u9ad8\u7684\u5e93\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u662f\u4ec0\u4e48\u8ba9 Backtrader \u6210\u4e3a\u5982\u6b64\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u5982\u4f55\u5229\u7528\u5b83\u6765\u589e\u5f3a\u4f60\u7684\u4ea4\u6613\u7b56\u7565\uff0c\u5e76\u901a\u8fc7\u4e00\u4e2a\u5e26\u6709 Python \u4ee3\u7801\u7684\u5b9e\u9645\u793a\u4f8b\u6765\u5e2e\u52a9\u4f60\u5165\u95e8\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u5b9e\u9645\u4f8b\u5b50\uff0c\u770b\u770b\u6211\u4eec\u80fd\u7528\u8fd9\u4e2a\u5de5\u5177\u505a\u4e9b\u4ec0\u4e48\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e00\u3001\u6570\u636e\u51c6\u5907<\/strong><\/h3>\n\n\n\n<p>\u8ba9\u6211\u4eec\u4ece\u96c5\u864e\u8d22\u7ecf\u83b7\u53d6\u4e00\u4e9b\u82f9\u679c\u80a1\u7968\u7684\u6bcf\u65e5\u6570\u636e\uff0c\u7528\u4e8e\u672c\u4f8b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/image-7.png\" alt=\"\" class=\"wp-image-2337\"\/><\/figure>\n\n\n\n<p>\u5c31\u50cf\u4f60\u770b\u5230\u7684\uff0c\u6211\u4eec\u628a\u6570\u636e\u5e27\u5b58\u5728 data_feed \u91cc\uff0c\u8fd9\u662f Backtracker \u7528\u7684\u6570\u636e\u5bf9\u8c61\uff0c\u80fd\u5b58\u597d\u591a\u6765\u6e90\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u786e\u5b9a\u6218\u7565<\/strong><\/h3>\n\n\n\n<p>\u4e3a\u4e86\u6f14\u793a Backtrader \u7684\u529f\u80fd\uff0c\u6211\u4eec\u5c06\u5b9e\u65bd\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u57fa\u4e8e\u52a8\u91cf\u7684\u4ea4\u6613\u7b56\u7565\u3002\u52a8\u91cf\u4ea4\u6613\u7b56\u7565\u6df1\u53d7\u91cf\u5316\u4ea4\u6613\u8005\u7684\u6b22\u8fce\uff0c\u56e0\u4e3a\u5b83\u4eec\u65e8\u5728\u5229\u7528\u5e02\u573a\u73b0\u6709\u8d8b\u52bf\u7684\u6301\u7eed\u6027\u3002\u5176\u7406\u5ff5\u662f\u5728\u8d44\u4ea7\u4ef7\u683c\u4e0a\u6da8\u65f6\u4e70\u5165\uff0c\u5728\u4ef7\u683c\u4e0b\u8dcc\u65f6\u5356\u51fa\uff0c\u9884\u671f\u8d8b\u52bf\u4f1a\u671d\u540c\u4e00\u65b9\u5411\u7ee7\u7eed\u53d1\u5c55\u3002<\/p>\n\n\n\n<p><strong>\u52a8\u91cf\u4ea4\u6613\u7b56\u7565<\/strong>\uff08Momentum Trading Strategy\uff09\u662f\u4e00\u79cd\u5728\u91d1\u878d\u5e02\u573a\uff0c\u7279\u522b\u662f\u80a1\u7968\u3001\u671f\u8d27\u4ee5\u53ca\u5dee\u4ef7\u5408\u7ea6\uff08CFD\uff09\u7b49\u4ea4\u6613\u5e02\u573a\u4e2d\u5e7f\u6cdb\u5e94\u7528\u7684\u6295\u8d44\u7b56\u7565\u3002\u8be5\u7b56\u7565\u7684\u6838\u5fc3\u601d\u60f3\u662f\u57fa\u4e8e\u8d44\u4ea7\u4ef7\u683c\u53d8\u52a8\u7684\u901f\u5ea6\uff08\u5373\u52a8\u91cf\uff09\u6765\u51b3\u5b9a\u4e70\u5165\u6216\u5356\u51fa\u7684\u65f6\u673a\uff0c\u4ece\u800c\u8ffd\u6c42\u5229\u6da6\u6700\u5927\u5316\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e09\u3001\u6218\u7565\u6267\u884c<\/strong><\/h3>\n\n\n\n<p id=\"05aa\">\u6218\u7565\u5c06\u9075\u5faa\u8fd9\u4e9b\u89c4\u5219\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Buy Signal<\/strong>\uff08\u4e70\u5165\u4fe1\u53f7\uff09\uff1a\u5982\u679c\u67d0\u9879\u8d44\u4ea7\u7684\u6536\u76d8\u4ef7\u5728\u4e00\u5206\u949f\u5185\u4e0b\u8dcc\u8d85\u8fc7\u4e86\u89c4\u5b9a\u7684\u9608\u503c\uff0c\u6211\u4eec\u5c31\u4f1a\u751f\u6210\u4e70\u5165\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>Sell Signal<\/strong>: \uff08\u5356\u51fa\u4fe1\u53f7\uff09\uff1a\u5982\u679c\u6536\u76d8\u4ef7\u6da8\u5e45\u8d85\u8fc7\u4e34\u754c\u503c\uff0c\u6211\u4eec\u5c31\u4f1a\u53d1\u51fa\u5356\u51fa\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>Position Management<\/strong>: \uff08\u4ed3\u4f4d\u7ba1\u7406\uff09\uff1a\u6211\u4eec\u5c06\u4fdd\u6301\u4ed3\u4f4d\uff0c\u76f4\u5230\u4ea7\u751f\u76f8\u53cd\u4fe1\u53f7\u6216\u6570\u636e\u96c6\u7ed3\u675f\u3002<\/li>\n<\/ul>\n\n\n\n<p id=\"d936\">\u6211\u4eec\u53ef\u4ee5\u7528 Backtracker \u8fd9\u6837\u505a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>class MomentumStrategy(bt.Strategy):\n    params = (\n        ('threshold', 0.001),  # Threshold for generating buy\/sell signals\n        ('size', 10),          # Number of shares to trade\n    )\n\n    def __init__(self):\n        self.data_close = self.data.close  # We will operate based on close prices\n        self.portfolio_values = &#91;]  # List to store portfolio values\n\n    def next(self):\n        # Append current portfolio value to the list\n        self.portfolio_values.append(self.broker.getvalue())\n        \n        if not self.position:  # Not in the market\n            if self.data_close&#91;-1] &lt; self.data_close&#91;-2] * (1 - self.params.threshold):\n                self.buy(size=self.params.size)\n        else:  # In the market\n            if self.data_close&#91;-1] &gt; self.data_close&#91;-2] * (1 + self.params.threshold):\n                self.sell(size=self.params.size)<\/code><\/code><\/pre>\n\n\n\n<p id=\"6214\">\u8bf7\u6ce8\u610f\uff0c\u6211\u5c06\u7ed3\u679c\u5b58\u50a8\u5728\u6295\u8d44\u7ec4\u5408\u503c\u5217\u8868\u4e2d\uff0c\u8fd9\u6837\u5c31\u80fd\u5728\u8fd0\u884c\u7b56\u7565\u540e\u8f7b\u677e\u8bbf\u95ee\u8fed\u4ee3\u7684\u6bcf\u4e00\u6b65\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"755c\"><br><strong>\u56db\u3001\u8fd0\u884c\u56de\u6eaf\u6d4b\u8bd5<\/strong><\/h3>\n\n\n\n<p id=\"380b\">\u73b0\u5728\u8ba9\u6211\u4eec\u5b9e\u9645\u8fd0\u884c\u56de\u6eaf\u6d4b\u8bd5\uff0c\u7531\u4e8e Backtracker \u5f15\u64ce Cerebro \u63d0\u4f9b\u4e86\u9ad8\u5ea6\u62bd\u8c61\u5316\u7684\u529f\u80fd\uff0c\u8fd9\u4e00\u5207\u90fd\u53d8\u5f97\u8d85\u7ea7\u7b80\u5355\u3002<\/p>\n\n\n\n<p id=\"df58\">\u770b\u770b\u4e0b\u9762\u8fd9\u4e2a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># Initialize Cerebro (the Backtrader engine)\ncerebro = bt.Cerebro()\n\n# Add the strategy\ncerebro.addstrategy(MomentumStrategy)\n\n# Add the data feed\ncerebro.adddata(data_feed)\n\n# Set the initial cash\ncerebro.broker.setcash(10000)\n\n# Run the backtest\nresults = cerebro.run()\n\n## Plot the results\ncerebro.plot()<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u6d4b\u8bd5\u8d85\u7ea7\u7b80\u5355\u5feb\u6377\u3002\u8fd9\u5c06\u8fd4\u56de\u4ee5\u4e0b\u56fe\u8868\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/image-8.png\" alt=\"\" class=\"wp-image-2338\"\/><\/figure>\n\n\n\n<p>Backtracker \u9ed8\u8ba4\u663e\u793a\u6295\u8d44\u7ec4\u5408\u7684\u6bcf\u65e5\u603b\u53d8\u5316\u3001\u5df2\u6267\u884c\u7684\u4ea4\u6613\u4ee5\u53ca\u6bcf\u7b14\u4ea4\u6613\u7684\u6b63\u8d1f\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u83b7\u53d6\u7ed3\u679c\uff0c\u6b63\u5982\u6211\u4e4b\u524d\u544a\u8bc9\u8fc7\u4f60\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u6211\u4eec\u7684\u5217\u8868\u83b7\u53d6\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># Get the portfolio values from the strategy\nportfolio_values = results&#91;0].portfolio_values\n\n# Print the portfolio values\nfor idx, value in enumerate(portfolio_values):\n    print(f\"Step {idx + 1}: Portfolio Value: {value:.2f}\")<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd9\u5c06\u8fd4\u56de\u6bcf\u4e00\u6b65\u7684\u6295\u8d44\u7ec4\u5408\u503c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/image-9.png\" alt=\"\" class=\"wp-image-2339\"\/><\/figure>\n\n\n\n<p id=\"e18d\">\u8ba9\u6211\u4eec\u5feb\u901f\u56de\u987e\u4e00\u4e0b\u300a\u51c6\u5219\u300b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Strategy Class<\/strong>\uff08\u7b56\u7565\u7c7b\uff09\uff1a\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a MomentumStrategy \u7c7b\uff0c\u8be5\u7c7b\u7ee7\u627f\u4e8e bt.Strategy\u3002\u8be5\u7c7b\u5305\u542b\u6211\u4eec\u4ea4\u6613\u7b56\u7565\u7684\u903b\u8f91\u3002<\/li>\n\n\n\n<li><strong>Threshold Parameter<\/strong>\uff08\u9608\u503c\u53c2\u6570\uff09\uff1a\u6211\u4eec\u4f7f\u7528\u9608\u503c\u53c2\u6570\u6765\u786e\u5b9a\u4e00\u5206\u949f\u5185\u4ef7\u683c\u9700\u8981\u53d8\u52a8\u591a\u5c11\u624d\u80fd\u751f\u6210\u4e70\u5165\u6216\u5356\u51fa\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>Position Management<\/strong>\uff08\u4ed3\u4f4d\u7ba1\u7406\uff09\uff1anext() \u65b9\u6cd5\u5305\u542b\u6838\u5fc3\u903b\u8f91\u3002\u5982\u679c\u6211\u4eec\u5c1a\u672a\u5efa\u4ed3\uff0c\u6211\u4eec\u5c31\u4f1a\u5bfb\u627e\u4e70\u5165\u673a\u4f1a\u3002\u5982\u679c\u5df2\u7ecf\u5efa\u4ed3\uff0c\u5219\u5bfb\u627e\u5356\u51fa\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>Data Feed<\/strong>\uff08\u6570\u636e\u53cd\u9988\uff09\uff1a\u6211\u4eec\u4ece CSV \u6587\u4ef6\u52a0\u8f7d\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a Backtrader \u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\u3002<\/li>\n\n\n\n<li><strong>Cerebro Engine<\/strong>\uff08Cerebro \u5f15\u64ce\uff09\uff1aBacktrader \u4f7f\u7528\u540d\u4e3a Cerebro \u7684\u5f15\u64ce\u6765\u8fd0\u884c\u56de\u6eaf\u6d4b\u8bd5\u3002\u6211\u4eec\u521d\u59cb\u5316\u8be5\u5f15\u64ce\uff0c\u6dfb\u52a0\u6211\u4eec\u7684\u7b56\u7565\u548c\u6570\u636e\u6e90\uff0c\u5e76\u8bbe\u7f6e\u521d\u59cb\u8d44\u91d1\u3002<\/li>\n\n\n\n<li><strong>Plotting<\/strong>\uff08\u7ed8\u56fe\uff09\uff1a\u8fd0\u884c\u56de\u6eaf\u6d4b\u8bd5\u540e\uff0c\u6211\u4eec\u5c06\u7ed8\u5236\u7ed3\u679c\u56fe\uff0c\u4ee5\u76f4\u89c2\u663e\u793a\u7b56\u7565\u7684\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e94\u3001\u89c2\u70b9\u56de\u987e<\/strong><\/h3>\n\n\n\n<p>\u5982\u60a8\u6240\u89c1\uff0c\u5229\u7528 Backtrader \u8fdb\u884c\u56de\u6eaf\u6d4b\u8bd5\uff0c\u8981\u6bd4\u81ea\u884c\u7f16\u5199\u56de\u6eaf\u6d4b\u8bd5\u4ee3\u7801\u6765\u5f97\u66f4\u5feb\u66f4\u7b80\u5355\u3002\u6b64\u7a0b\u5e8f\u8bbe\u8ba1\u5f97\u65e2\u5f3a\u5927\u53c8\u76f4\u89c2\uff0c\u4e3a\u60a8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u80fd\u6a21\u62df\u4ea4\u6613\u6784\u60f3\u7684\u5e73\u53f0\uff0c\u53ef\u8bbe\u5b9a\u521d\u59cb\u73b0\u91d1\u4e0e\u7ecf\u7eaa\u4eba\u8d39\u7528\u3002Backtrader \u5177\u5907\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u6db5\u76d6\u5185\u7f6e\u6307\u6807\u3001\u652f\u6301\u591a\u79cd\u6570\u636e\u6e90\u4ee5\u53ca\u4f18\u5316\u7b56\u7565\u7684\u80fd\u529b\uff0c\u5df2\u7136\u6210\u4e3a\u4f17\u591a\u91cf\u5316\u91d1\u878d\u754c\u4eba\u58eb\u7684\u9996\u9009\u5e93\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Backtrader \u7684\u91cd\u8981\u6027<\/strong>\uff1a\u5728\u91cf\u5316\u4ea4\u6613\u4e2d\uff0cBacktrader \u4f5c\u4e3a\u4e00\u4e2a\u5f3a\u5927\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u5de5\u5177\uff0c\u5bf9\u4e8e\u5b9e\u73b0\u4ea4\u6613\u7b56\u7565\u81f3\u5173\u91cd\u8981\u3002<\/li>\n\n\n\n<li><strong>\u6613\u7528\u6027\u548c\u5f3a\u5927\u529f\u80fd<\/strong>\uff1aBacktrader \u63d0\u4f9b\u4e86\u9ad8\u5ea6\u62bd\u8c61\u5316\u7684\u63a5\u53e3\uff0c\u7b80\u5316\u4e86\u56de\u6eaf\u6d4b\u8bd5\u7684\u8fc7\u7a0b\uff0c\u540c\u65f6\u62e5\u6709\u4e30\u5bcc\u7684\u5185\u7f6e\u6307\u6807\u548c\u591a\u6570\u636e\u6e90\u652f\u6301\u3002<\/li>\n\n\n\n<li><strong>\u4ece\u56de\u6eaf\u6d4b\u8bd5\u5230\u5b9e\u65f6\u4ea4\u6613<\/strong>\uff1aBacktrader \u53ef\u4ee5\u65e0\u7f1d\u96c6\u6210\u4e0e\u7ecf\u7eaa\u5546\uff0c\u4f7f\u5f97\u4ece\u56de\u6eaf\u6d4b\u8bd5\u5230\u5b9e\u65f6\u4ea4\u6613\u7684\u8fc7\u7a0b\u53d8\u5f97\u66f4\u52a0\u987a\u7545\uff0c\u51cf\u5c11\u4e86\u51fa\u9519\u7684\u53ef\u80fd\u6027\u3002<\/li>\n\n\n\n<li><strong>\u7b56\u7565\u5b9e\u65bd\u548c\u4f18\u5316<\/strong>\uff1a\u6587\u7ae0\u901a\u8fc7\u793a\u4f8b\u7b56\u7565\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5b9a\u4e49\u548c\u4f18\u5316\u4ea4\u6613\u7b56\u7565\uff0c\u4ee5\u53ca\u5982\u4f55\u901a\u8fc7\u56de\u6eaf\u6d4b\u8bd5\u6765\u8bc4\u4f30\u7b56\u7565\u7684\u6709\u6548\u6027\u3002<\/li>\n\n\n\n<li><strong>\u91cf\u5316\u4ea4\u6613\u793e\u533a\u7684\u9996\u9009<\/strong>\uff1aBacktrader \u56e0\u5176\u72ec\u7279\u7684\u529f\u80fd\u548c\u6613\u7528\u6027\uff0c\u5df2\u7ecf\u6210\u4e3a\u91cf\u5316\u4ea4\u6613\u793e\u533a\u4e2d\u8bb8\u591a\u4e13\u4e1a\u4eba\u58eb\u7684\u9996\u9009\u5e93\u3002<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u611f\u8c22\u60a8\u9605\u8bfb\u5230\u6700\u540e\u3002\u5982\u679c\u5bf9\u6587\u4e2d\u7684\u5185\u5bb9\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u7ed9\u6211\u7559\u8a00\uff0c\u5fc5\u590d\u3002<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c<\/mark><\/strong><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/mark><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2024\/10\/28\/%e6%9c%80%e9%80%82%e5%90%88%e5%88%9d%e7%ba%a7%e7%ae%97%e6%b3%95%e4%ba%a4%e6%98%93%e8%80%85%e7%9a%84-python-%e8%ae%a1%e7%ae%97%e5%ba%93\/\">Continue reading<span class=\"screen-reader-text\">\u6700\u9002\u5408\u521d\u7ea7\u7b97\u6cd5\u4ea4\u6613\u8005\u7684 Python \u8ba1\u7b97\u5e93<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3,5],"class_list":{"0":"post-1558","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","9":"entry"},"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1558"}],"version-history":[{"count":2,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1558\/revisions"}],"predecessor-version":[{"id":1561,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1558\/revisions\/1561"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}