{"id":1963,"date":"2025-03-13T07:35:00","date_gmt":"2025-03-12T23:35:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1963"},"modified":"2025-02-14T16:37:52","modified_gmt":"2025-02-14T08:37:52","slug":"%e8%b4%a2%e6%8a%a5%e5%ad%a3%e5%bf%85%e7%9c%8b%ef%bc%9a%e7%94%a8%e8%b7%a8%e5%bc%8f%e7%ad%96%e7%95%a5%e9%a2%84%e6%b5%8b%e8%8b%b9%e6%9e%9c%e8%82%a1%e4%bb%b7%ef%bc%8cpythonai-%e4%bb%a3%e7%a0%81%e5%ae%9e","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2025\/03\/13\/%e8%b4%a2%e6%8a%a5%e5%ad%a3%e5%bf%85%e7%9c%8b%ef%bc%9a%e7%94%a8%e8%b7%a8%e5%bc%8f%e7%ad%96%e7%95%a5%e9%a2%84%e6%b5%8b%e8%8b%b9%e6%9e%9c%e8%82%a1%e4%bb%b7%ef%bc%8cpythonai-%e4%bb%a3%e7%a0%81%e5%ae%9e\/","title":{"rendered":"\u8d22\u62a5\u5b63\u5fc5\u770b\uff1a\u7528\u8de8\u5f0f\u7b56\u7565\u9884\u6d4b\u82f9\u679c\u80a1\u4ef7\uff0cPython+AI \u4ee3\u7801\u5b9e\u6218"},"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\/2025\/02\/\u5fae\u4fe1\u56fe\u7247_20250214145924.png\" alt=\"\" class=\"wp-image-4274\"\/><\/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>\u8d22\u62a5\u5b63\u662f\u80a1\u5e02\u6ce2\u52a8\u6700\u5927\u7684\u65f6\u671f\uff0c\u80a1\u4ef7\u4f1a\u56e0\u4e1a\u7ee9\u8868\u73b0\u5267\u70c8\u6ce2\u52a8\u3002<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u79cd\u5229\u7528\u671f\u6743\u6570\u636e\uff08\u8de8\u5f0f\u7b56\u7565\uff09\u9884\u6d4b\u80a1\u4ef7\u8d70\u52bf\u7684\u65b9\u6cd5<\/mark>\u3002\u6587\u7ae0\u8be6\u7ec6\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528OpenBB SDK\u83b7\u53d6\u671f\u6743\u6570\u636e\uff0c\u5e76\u4ee5Costco\u548c\u82f9\u679c\u516c\u53f8\u80a1\u7968\u4e3a\u4f8b\uff0c\u901a\u8fc7Python+AI \u8ba1\u7b97\u8de8\u5f0f\u4ea4\u6613\u4ef7\u683c\uff0c\u4f30\u7b97\u80a1\u4ef7\u53d8\u52a8\u8303\u56f4\u3002\u6587\u672b\u8fd8\u63d0\u4f9b\u4e86\u7ed3\u5408\u5386\u53f2\u6ce2\u52a8\u7387\u548c\u9690\u542b\u6ce2\u52a8\u7387\u7684\u4ee3\u7801\u811a\u672c\uff0c\u5e2e\u52a9\u4ea4\u6613\u8005\u9884\u6d4b\u672a\u6765\u80a1\u4ef7\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p id=\"7833\">\u8d22\u62a5\u5b63\u662f\u80a1\u5e02\u6700\u6fc0\u52a8\u4eba\u5fc3\u7684\u65f6\u523b\u4e4b\u4e00\u3002\u6839\u636e\u516c\u53f8\u4e1a\u7ee9\u662f\u5426\u8d85\u51fa\u9884\u671f\uff0c\u80a1\u7968\u4ef7\u683c\u4f1a\u51fa\u73b0\u5267\u70c8\u6ce2\u52a8\u3002\u5bf9\u4e8e\u4ea4\u6613\u8005\u6765\u8bf4\uff0c\u9884\u6d4b\u8fd9\u4e9b\u8d70\u52bf\u53ef\u4ee5\u5e26\u6765\u5de8\u5927\u7684\u83b7\u5229\u673a\u4f1a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/02\/image-48.png\" alt=\"\" class=\"wp-image-4275\"\/><\/figure>\n\n\n\n<p id=\"7833\">\u516c\u53f8\u7684\u76c8\u5229\u62a5\u544a\u5c55\u793a\u4e86\u5176\u8d22\u52a1\u60c5\u51b5\u548c\u672a\u6765\u7684\u53d1\u5c55\u6f5c\u529b\u3002\u5e02\u573a\u7684\u9884\u6d4b\u548c\u5b9e\u9645\u516c\u5e03\u7684\u4e1a\u7ee9\u5e38\u5e38\u5b58\u5728\u5dee\u8ddd\uff0c\u8fd9\u4f1a\u5f15\u8d77\u80a1\u7968\u4ef7\u683c\u7684\u663e\u8457\u53d8\u52a8\u3002<\/p>\n\n\n\n<p id=\"1f2f\">\u719f\u6089\u5e02\u573a\u52a8\u6001\u7684\u4ea4\u6613\u8005\uff0c\u4ed6\u4eec\u7684\u9884\u6d4b\u5df2\u7ecf\u53cd\u6620\u5728\u671f\u6743\u4ef7\u683c\u91cc\u3002\u901a\u8fc7\u7814\u7a76\u8fd9\u4e9b\u4ef7\u683c\uff0c\u6211\u4eec\u53ef\u4ee5\u4e86\u89e3\u5e02\u573a\u5bf9\u4e8e\u516c\u53f8\u516c\u5e03\u4e1a\u7ee9\u540e\u80a1\u7968\u8d70\u52bf\u7684\u9884\u671f\u3002<\/p>\n\n\n\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u4e00\u79cd\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u5229\u7528\u671f\u6743\u6570\u636e\u9884\u6d4b\u80a1\u4ef7\u8d70\u52bf\uff0c\u7279\u522b\u662f\u901a\u8fc7\u4e00\u79cd\u53eb\u505a\u8de8\u5f0f\u7684\u7b56\u7565\u3002\u6700\u540e\u4f60\u8fd8\u5c06\u638c\u63e1\u4f7f\u7528\u4e34\u8fd1\u5230\u671f\u671f\u6743\u6765\u4f30\u8ba1\u76c8\u5229\u540e\u5e02\u573a\u9884\u671f\u4ef7\u683c\u8d70\u52bf\u7684 Python \u4ee3\u7801\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ff33\"><strong>\u4e00\u3001\u4ec0\u4e48\u662f\u8de8\u5f0f\u7b56\u7565 \uff1f<\/strong><\/h2>\n\n\n\n<p>\u5728\u91d1\u878d\u6295\u8d44\u4e2d\uff0c\u8de8\u5f0f\u7b56\u7565\uff08The Straddle Strategy\uff09\u662f\u4e00\u79cd\u671f\u6743\u4ea4\u6613\u7b56\u7565\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6295\u8d44\u8005\u53ef\u4ee5\u5728\u5e02\u573a\u4ef7\u683c\u5927\u5e45\u6ce2\u52a8\u65f6\u83b7\u5229\uff0c\u65e0\u8bba\u662f\u5411\u4e0a\u8fd8\u662f\u5411\u4e0b\u6ce2\u52a8\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.1 \u7b56\u7565\u4f7f\u7528\u73af\u5883\u4e0e\u65b9\u6cd5<\/strong><\/h3>\n\n\n\n<p>\u8de8\u5f0f\u7b56\u7565\u7684\u6838\u5fc3\u5728\u4e8e\u5bf9\u5e02\u573a\u6ce2\u52a8\u6027\u7684\u9884\u671f\u3002\u6295\u8d44\u8005\u901a\u5e38\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u4f7f\u7528\u6b64\u7b56\u7565\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/02\/image-49.png\" alt=\"\" class=\"wp-image-4276\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/02\/image-51.png\" alt=\"\" class=\"wp-image-4278\"\/><\/figure>\n\n\n\n<p id=\"0bc8\">\u8be5\u7b56\u7565\u6267\u884c\u4f1a\u540c\u65f6\u4e70\u5165\u5230\u671f\u65e5\u76f8\u540c\u7684\u4ef7\u5185\uff08ATM\uff09\u770b\u6da8\u671f\u6743\u548c\u4ef7\u5916\uff08ATM\uff09\u770b\u8dcc\u671f\u6743\uff0c\u4e14\u4e24\u8005\u7684\u6267\u884c\u4ef7\u683c\u548c\u5230\u671f\u65e5\u76f8\u540c\u3002\u539f\u56e0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5230\u671f\u65f6\uff0c\u671f\u6743\u7684\u4ef7\u503c\u4e3b\u8981\u57fa\u4e8e\u5176\u65f6\u95f4\u4ef7\u503c\uff0c\u5176\u4e2d\u5305\u62ec\u9884\u671f\u7684\u4ef7\u683c\u53d8\u52a8\u3002<\/li>\n\n\n\n<li>\u4ea4\u6613\u8005\u901a\u5e38\u4f1a\u9009\u62e9\u5728<strong>\u8d22\u62a5\u53d1\u5e03\u540e\u9a6c\u4e0a\u5230\u671f\u7684\u671f\u6743<\/strong>\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u7528\u5b83\u4eec\u7684\u4ef7\u683c\u6765\u8861\u91cf\u9884\u671f\u8d70\u52bf\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1.2 \u7b56\u7565\u7684\u98ce\u9669\u4e0e\u6536\u76ca<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2025\/02\/image-52.png\" alt=\"\" class=\"wp-image-4279\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"bh-nJmW1SojQo94VFiOvpE7g\"><strong>\u6536\u76ca<\/strong>\uff1a<\/h4>\n\n\n\n<ul id=\"bh-p--mhw8OJErbGYJqJIDz-\" class=\"wp-block-list\">\n<li><strong>\u65e0\u9650\u6536\u76ca\u6f5c\u529b<\/strong>\uff1a\u5982\u679c\u5e02\u573a\u4ef7\u683c\u5927\u5e45\u4e0a\u6da8\uff0c\u770b\u6da8\u671f\u6743\u7684\u6536\u76ca\u662f\u65e0\u9650\u7684\uff1b\u5982\u679c\u5e02\u573a\u4ef7\u683c\u5927\u5e45\u4e0b\u8dcc\uff0c\u770b\u8dcc\u671f\u6743\u7684\u6536\u76ca\u4e5f\u53ef\u4ee5\u662f\u65e0\u9650\u7684\u3002<\/li>\n\n\n\n<li><strong>\u6ce2\u52a8\u6027\u6536\u76ca<\/strong>\uff1a\u5373\u4f7f\u5e02\u573a\u4ef7\u683c\u5728\u77ed\u671f\u5185\u6ce2\u52a8\uff0c\u6295\u8d44\u8005\u4e5f\u53ef\u80fd\u4ece\u4e2d\u83b7\u5229\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"bh-8LqKvptU0wc5LrkuRej0K\"><strong>\u98ce\u9669<\/strong>\uff1a<\/h4>\n\n\n\n<ul id=\"bh-i6SUjvTBdjEPA0wTV8Rfu\" class=\"wp-block-list\">\n<li><strong>\u9ad8\u6210\u672c<\/strong>\uff1a\u540c\u65f6\u8d2d\u4e70\u4e24\u79cd\u671f\u6743\u610f\u5473\u7740\u9700\u8981\u652f\u4ed8\u4e24\u4efd\u671f\u6743\u7684\u6743\u5229\u91d1\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8f83\u9ad8\u7684\u521d\u59cb\u6295\u8d44\u6210\u672c\u3002<\/li>\n\n\n\n<li><strong>\u65f6\u95f4\u4ef7\u503c\u635f\u5931<\/strong>\uff1a\u5982\u679c\u5e02\u573a\u4ef7\u683c\u5728\u5230\u671f\u65e5\u9644\u8fd1\u6ca1\u6709\u663e\u8457\u6ce2\u52a8\uff0c\u6295\u8d44\u8005\u53ef\u80fd\u4f1a\u9762\u4e34\u65f6\u95f4\u4ef7\u503c\u7684\u635f\u5931\uff0c\u5bfc\u81f4\u671f\u6743\u5931\u6548\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8de8\u5f0f\u7b56\u7565\u662f\u4e00\u79cd\u7075\u6d3b\u4e14\u5177\u6709\u6f5c\u5728\u9ad8\u6536\u76ca\u7684\u671f\u6743\u4ea4\u6613\u7b56\u7565\uff0c\u975e\u5e38\u9002\u5408\u8d22\u62a5\u53d1\u5e03\u524d\uff0c\u56e0\u4e3a\u901a\u8fc7\u8d2d\u4e70\u76f8\u540c\u5230\u671f\u65e5\u7684\u4ef7\u5185\u770b\u6da8\u671f\u6743\u548c\u4ef7\u5916\u770b\u8dcc\u671f\u6743\uff0c\u53ef\u4ee5\u7528\u5206\u6790\u671f\u6743\u4ef7\u683c\u6765\u63a8\u65ad\u5e02\u573a\u9884\u671f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4f76\"><strong>\u4e8c\u3001\u7b56\u7565\u5b9e\u73b0<\/strong><\/h2>\n\n\n\n<p id=\"1a9e\">\u6211\u4eec\u5c06\u4f1a\u4f7f\u7528 OpenBB SDK \u6765\u83b7\u53d6\u548c\u5206\u6790\u671f\u6743\u6570\u636e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6697\"><strong>2.1 \u5bfc\u5165\u5e93\u548c\u8bbe\u7f6e<\/strong><\/h3>\n\n\n\n<p id=\"84e5\">\u9996\u5148\uff0c\u5b89\u88c5\u5e76\u8bbe\u7f6e OpenBB\u3002\u8fd8\u6dfb\u52a0 API \u5bc6\u94a5\uff0c\u7528\u6765\u83b7\u53d6\u80a1\u7968\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from datetime import datetime, timedelta\nimport pandas as pd\nfrom openbb import obb\n\n# Set preferences and API key\nobb.user.preferences.output_type = \"dataframe\"\nobb.user.credentials.nasdaq_api_key = \"PLACE_HOLDER\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"be48\"><strong>2.2 \u83b7\u53d6\u6536\u76ca\u516c\u544a<\/strong><\/h3>\n\n\n\n<p id=\"f0a3\">\u6211\u4eec\u5c06\u4e0b\u8f7d\u672a\u6765\u4e24\u5468\u5185\u5373\u5c06\u53d1\u5e03\u7684\u6536\u76ca\u516c\u544a\u5217\u8868\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get earnings calendar for the next 14 days\nearnings_calendar = obb.equity.calendar.earnings(\n    start_date=(datetime.now() + timedelta(days=1)).date(),\n    end_date=(datetime.now() + timedelta(days=14)).date(),\n    provider=\"nasdaq\"\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.3 \u9009\u62e9\u80a1\u7968<\/strong><\/h3>\n\n\n\n<p id=\"beb5\">\u68c0\u67e5&nbsp;<code>earnings_calendar<\/code>&nbsp;\u6570\u636e\u8868\uff0c\u5e76\u9009\u62e9\u4e00\u5bb6\u5373\u5c06\u5728\u5468\u56db\u516c\u5e03\u4e1a\u7ee9\u7684\u80a1\u7968\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528Costco\uff08COST\uff09\u516c\u53f8\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>symbol = \"COST\"\nlast_price = (\n    obb\n    .equity\n    .price\n    .quote(symbol, provider=\"yfinance\")\n    .T\n    .loc&#91;\"last_price\", 0]\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5a23\"><strong>2.4 \u4e0b\u8f7d\u671f\u6743\u94fe\u6570\u636e<\/strong><\/h3>\n\n\n\n<p id=\"111c\">\u83b7\u53d6\uff08COST\uff09\u5728\u4e1a\u7ee9\u53d1\u5e03\u540e\u5373\u5c06\u5230\u671f\u7684\u671f\u6743\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>options = obb.derivatives.options.chains(symbol, provider=\"cboe\")\nexpiration = datetime(2024, 3, 8).date()  # Adjust to match the earnings schedule\nchain = options.query(\"`expiration` == @expiration\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"37fe\"><strong>2.5 \u6784\u5efa\u8de8\u5f0f\u671f\u6743\u7ec4\u5408<\/strong><\/h3>\n\n\n\n<p id=\"a743\">\u627e\u5230\u5e73\u4ef7\u8ba4\u8d2d\u671f\u6743\u548c\u8ba4\u6cbd\u671f\u6743\uff0c\u7136\u540e\u8ba1\u7b97\u8de8\u5f0f\u671f\u6743\u7684\u4ef7\u683c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get ATM strike price\nstrikes = chain.strike.to_frame()\ncall_strike = (\n    strikes\n    .loc&#91;strikes.query(\"`strike` &gt; @last_price\").idxmin()]&#91;\"strike\"]\n    .iloc&#91;0]\n)\n\n# Filter ATM call and put options\natm_call = chain.query(\"`strike` == @call_strike and `option_type` == 'call'\")\natm_put = chain.query(\"`strike` == @call_strike and `option_type` == 'put'\")\n\n# Combine and calculate straddle price\natm = pd.concat(&#91;atm_call, atm_put])\nstraddle_price = round(atm.ask.sum(), 2)\nprint(f\"Straddle Price: {straddle_price}\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"292e\"><strong>2.6 \u8ba1\u7b97\u9690\u542b\u79fb\u52a8<\/strong><\/h3>\n\n\n\n<p id=\"aadf\">\u6700\u540e\uff0c\u6839\u636e\u8de8\u5f0f\u671f\u6743\u7684\u4ef7\u683c\u4f30\u7b97\u5e02\u573a\u9884\u671f\u7684\u4ef7\u683c\u6ce2\u52a8\u5e45\u5ea6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Calculate implied move\ndays = (atm.expiration.iloc&#91;0] - datetime.now().date()).days\nimplied_move = ((1 + straddle_price \/ last_price) ** (1 \/ days) - 1)\nprint(f\"Implied Move: {implied_move * 100:.2f}%\")<\/code><\/pre>\n\n\n\n<p id=\"10bf\">\u4f8b\u5982\uff0c\u5982\u679c\u8de8\u5f0f\u671f\u6743\u7684\u4ef7\u683c\u662f20\u7f8e\u5143\uff0c\u800c\u80a1\u7968\u7684\u6700\u65b0\u4ea4\u6613\u4ef7\u683c\u662f500\u7f8e\u5143\uff0c\u5e02\u573a\u53ef\u80fd\u9884\u671f\u5728\u4e1a\u7ee9\u516c\u5e03\u540e\u80a1\u4ef7\u4f1a\u67091.74%\u7684\u6ce2\u52a8\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"fb83\"><strong>\u4e09\u3001\u5b9e\u4f8b\u5206\u6790<\/strong><\/h2>\n\n\n\n<p id=\"6036\">\u73b0\u5728\u4f60\u5df2\u7ecf\u6709\u4e86\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u5c06\u5982\u4e0b\u5b9e\u4f8b\u5206\u6790\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5bf9\u591a\u53ea\u5177\u6709\u76f8\u540c\u5230\u671f\u65e5\u548c\u4e1a\u7ee9\u516c\u5e03\u65e5\u7684\u80a1\u7968\u8fdb\u884c\u5206\u6790\u3002<\/li>\n\n\n\n<li>\u5c06\u9690\u542b\u6ce2\u52a8\u4e0e\u4e1a\u7ee9\u516c\u5e03\u540e\u7684\u5b9e\u9645\u4ef7\u683c\u53d8\u52a8\u8fdb\u884c\u6bd4\u8f83\u3002<\/li>\n\n\n\n<li>\u4f18\u5316\u4f60\u7684\u7b56\u7565\uff0c\u4ee5\u53d1\u73b0\u6f5c\u5728\u7684\u76c8\u5229\u673a\u4f1a\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.1 \u82f9\u679c\u516c\u53f8\u5b9e\u4f8b<\/strong><\/h3>\n\n\n\n<p id=\"afa0\">\u622a\u81f3 2025 \u5e74 1 \u6708 16 \u65e5\uff0c\u82f9\u679c\u516c\u53f8\uff08AAPL\uff09\u7684\u4ea4\u6613\u4ef7\u683c\u4e3a 231.69 \u7f8e\u5143\uff0c\u6bd4\u524d\u4e00\u4ea4\u6613\u65e5\u6536\u76d8\u4ef7\u4e0b\u8dcc\u7ea6 2.6%\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"df2d\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/1*ARIk51iJh509ID2vROsAng.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"9bda\">\u4e3a\u4e86\u9884\u6d4b\u82f9\u679c\u516c\u53f8\uff08AAPL\uff09\u660e\u5929\u7684\u80a1\u4ef7\uff08\u57fa\u4e8e\u5f53\u524d\u4ef7\u683c231.69\u7f8e\u5143\uff09\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5386\u53f2\u6ce2\u52a8\u7387\uff08\u4f8b\u5982\u5e73\u5747\u771f\u5b9e\u6ce2\u52a8\u5e45\u5ea6\uff0cATR\uff09\u6216\u4ece\u671f\u6743\u5e02\u573a\u5f97\u51fa\u7684\u9690\u542b\u6ce2\u52a8\u7387\u3002<\/p>\n\n\n\n<p id=\"7c4b\">\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528ATR\u548c\u9690\u542b\u6ce2\u52a8\u7387\u6765\u4f30\u7b97\u660e\u5929\u80a1\u4ef7\u8303\u56f4\u7684Python\u811a\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import yfinance as yf\nfrom datetime import datetime, timedelta\n\n# Fetch historical data\nsymbol = \"AAPL\"\ndata = yf.download(symbol, start=datetime.now() - timedelta(days=30), end=datetime.now())\ndata&#91;'ATR'] = data&#91;'High'] - data&#91;'Low']\n\n# Calculate the Average True Range (ATR) for the last 14 days\natr = data&#91;'ATR']&#91;-14:].mean()\n\n# Current price\ncurrent_price = 231.69\n\n# Predict tomorrow's range using ATR\ntomorrow_high = round(current_price + atr, 2)\ntomorrow_low = round(current_price - atr, 2)\n\n# Display ATR-based range\nprint(f\"ATR-Based Prediction for Tomorrow ({symbol}):\")\nprint(f\"Low: ${tomorrow_low}\")\nprint(f\"High: ${tomorrow_high}\")\n\n# Optionally, include implied move from straddle\n# Assuming a straddle price (e.g., $10)\nstraddle_price = 10  # Replace this with actual straddle price from options data\nimplied_move_percent = straddle_price \/ current_price\nimplied_move = current_price * implied_move_percent\n\nprint(\"\\nIncluding Implied Move:\")\nprint(f\"Implied Move: \u00b1${round(implied_move, 2)}\")\nprint(f\"Low: ${round(current_price - implied_move, 2)}\")\nprint(f\"High: ${round(current_price + implied_move, 2)}\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3622\"><strong>3.3 \u8ba1\u7b97\u8fc7\u7a0b<\/strong><\/h3>\n\n\n\n<p><strong>\u57fa\u4e8e ATR \u7684\u9884\u6d4b\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u5386\u53f2\u4ef7\u683c\u6ce2\u52a8\u7387\uff08ATR\uff09\u6765\u4f30\u8ba1\u53ef\u80fd\u7684\u4ef7\u683c\u8303\u56f4\u3002<\/li>\n\n\n\n<li>\u4f8b\u5982\uff0c\u5982\u679c ATR \u4e3a 5 \u7f8e\u5143\uff0c\u5219\u8303\u56f4\u4e3a<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\" id=\"4f0f\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/1*239pU6dCrRXJARAcGW5S4Q.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"592e\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/1*lN2qWNGGQiYkl9cPCJ3Kiw.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u9884\u671f\u8f93\u51fa\u793a\u4f8b<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u4e8e ATR \u7684\u8303\u56f4\uff1a \u6700\u4f4e\u4ef7\uff1a226.69 \u7f8e\u5143 \u6700\u9ad8\u4ef7\uff1a236.69 \u7f8e\u5143<\/li>\n\n\n\n<li>\u9690\u542b\u53d8\u52a8\u533a\u95f4\uff1a \u6700\u4f4e\u4ef7\uff1a221.69 \u7f8e\u5143 \u6700\u9ad8\u4ef7\uff1a241.69 \u7f8e\u5143<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"c2c2\"><strong>3.4 \u8fd0\u4f5c\u539f\u7406<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5386\u53f2\u6570\u636e<\/strong>\uff1a\u4f7f\u7528&nbsp;<code>yfinance<\/code>&nbsp;\u83b7\u53d6\u82f9\u679c\u516c\u53f8\uff08AAPL\uff09\u8fc7\u53bb30\u5929\u7684\u4ea4\u6613\u6570\u636e\uff0c\u4ee5\u8ba1\u7b97\u5e73\u5747\u771f\u5b9e\u6ce2\u52a8\u5e45\u5ea6\uff08ATR\uff09\u3002<\/li>\n\n\n\n<li><strong>\u57fa\u4e8eATR\u7684\u9884\u6d4b<\/strong>\uff1a\u5229\u7528ATR\uff0c\u7ed3\u5408\u4eca\u65e5\u7684\u6536\u76d8\u4ef7\uff0c\u4f30\u7b97\u660e\u5929\u53ef\u80fd\u7684\u6700\u9ad8\u4ef7\u548c\u6700\u4f4e\u4ef7\u3002<\/li>\n\n\n\n<li><strong>\u671f\u6743\u5e02\u573a\u9690\u542b\u6ce2\u52a8<\/strong>\uff1a\u901a\u8fc7\u5047\u8bbe\u7684\u8de8\u5f0f\u671f\u6743\u4ef7\u683c\uff0c\u4f30\u7b97\u660e\u5929\u7684\u80a1\u4ef7\u6ce2\u52a8\u8303\u56f4\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u89c2\u70b9\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u8d22\u62a5\u5b63\u671f\u95f4\u80a1\u4ef7\u5e38\u56e0\u4e1a\u7ee9\u9884\u671f\u5267\u70c8\u6ce2\u52a8\u3002\u672c\u6587\u63d0\u51fa\u5229\u7528\u8de8\u5f0f\u671f\u6743\u7b56\u7565\u9884\u6d4b\u8d70\u52bf\uff0c\u901a\u8fc7OpenBB SDK\u83b7\u53d6\u671f\u6743\u6570\u636e\u3002\u6700\u540e\u7ed3\u5408\u5386\u53f2\u6ce2\u52a8\u7387\uff08ATR\uff09\u4e0e\u671f\u6743\u9690\u542b\u6ce2\u52a8\u7387\uff0c\u901a\u8fc7Python\u811a\u672c\u4f30\u7b97\u8d22\u62a5\u540e\u80a1\u4ef7\u6f5c\u5728\u6ce2\u52a8\u533a\u95f4\uff0c\u4e3a\u4ea4\u6613\u51b3\u7b56\u63d0\u4f9b\u91cf\u5316\u4f9d\u636e\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8d22\u62a5\u53d1\u5e03\u662f\u5f71\u54cd\u80a1\u4ef7\u7684\u5173\u952e\u4e8b\u4ef6\uff0c\u5e02\u573a\u5bf9\u516c\u53f8\u672a\u6765\u8868\u73b0\u7684\u9884\u671f\u4e0e\u5b9e\u9645\u4e1a\u7ee9\u4e4b\u95f4\u7684\u5dee\u8ddd\u5f80\u5f80\u4f1a\u5f15\u53d1\u80a1\u4ef7\u6ce2\u52a8\u3002<\/li>\n\n\n\n<li>\u671f\u6743\u4ea4\u6613\u8005\u7684\u9884\u671f\u5df2\u7ecf\u4f53\u73b0\u5728\u671f\u6743\u4ef7\u683c\u4e2d\uff0c\u901a\u8fc7\u5206\u6790\u8fd9\u4e9b\u4ef7\u683c\uff0c\u6211\u4eec\u53ef\u4ee5\u4e86\u89e3\u5e02\u573a\u5bf9\u8d22\u62a5\u53d1\u5e03\u540e\u80a1\u4ef7\u8d70\u52bf\u7684\u9884\u671f\u3002<\/li>\n\n\n\n<li>\u8de8\u5f0f\u671f\u6743\u7b56\u7565\u80fd\u591f\u6709\u6548\u5229\u7528\u671f\u6743\u6570\u636e\u6765\u9884\u6d4b\u80a1\u4ef7\u7684\u5927\u5e45\u6ce2\u52a8\uff0c\u5c24\u5176\u662f\u5728\u8d22\u62a5\u53d1\u5e03\u540e\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 Python \u548c OpenBB SDK \u53ef\u4ee5\u5e2e\u52a9\u4ea4\u6613\u8005\u81ea\u52a8\u83b7\u53d6\u671f\u6743\u6570\u636e\uff0c\u5e76\u901a\u8fc7\u7f16\u7a0b\u65b9\u5f0f\u5206\u6790\u548c\u9884\u6d4b\u80a1\u4ef7\u8d70\u52bf\u3002<\/li>\n\n\n\n<li>\u7ed3\u5408\u5386\u53f2\u6ce2\u52a8\u7387\uff08\u5982\u5e73\u5747\u771f\u5b9e\u6ce2\u52a8\u5e45\u5ea6\uff0cATR\uff09\u548c\u671f\u6743\u5e02\u573a\u7684\u9690\u542b\u6ce2\u52a8\u7387\uff0c\u53ef\u4ee5\u4e3a\u80a1\u4ef7\u9884\u6d4b\u63d0\u4f9b\u66f4\u5168\u9762\u7684\u89c6\u89d2\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><em>\u611f\u8c22\u60a8\u9605\u8bfb\u5230\u6700\u540e\uff0c\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u4e3a\u60a8\u5e26\u6765\u4e86\u65b0\u7684\u542f\u53d1\u548c\u5b9e\u7528\u7684\u77e5\u8bc6\uff01\u5982\u679c\u89c9\u5f97\u6709\u5e2e\u52a9\uff0c\u8bf7\u4e0d\u541d\u70b9\u8d5e\u548c\u5206\u4eab\uff0c\u60a8\u7684\u652f\u6301\u662f\u6211\u6301\u7eed\u521b\u4f5c\u7684\u52a8\u529b\u3002\u795d\u60a8\u6295\u8d44\u987a\u5229\uff0c\u6536\u76ca\u957f\u8679\uff01\u5982\u679c\u5bf9\u6587\u4e2d\u5185\u5bb9\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u6b22\u8fce\u7559\u8a00\uff0c\u6211\u4f1a\u5c3d\u5feb\u56de\u590d\uff01<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\" id=\"a1c6\">\u672c\u6587\u5185\u5bb9\u4ec5\u9650\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/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\/2025\/03\/13\/%e8%b4%a2%e6%8a%a5%e5%ad%a3%e5%bf%85%e7%9c%8b%ef%bc%9a%e7%94%a8%e8%b7%a8%e5%bc%8f%e7%ad%96%e7%95%a5%e9%a2%84%e6%b5%8b%e8%8b%b9%e6%9e%9c%e8%82%a1%e4%bb%b7%ef%bc%8cpythonai-%e4%bb%a3%e7%a0%81%e5%ae%9e\/\">Continue reading<span class=\"screen-reader-text\">\u8d22\u62a5\u5b63\u5fc5\u770b\uff1a\u7528\u8de8\u5f0f\u7b56\u7565\u9884\u6d4b\u82f9\u679c\u80a1\u4ef7\uff0cPython+AI \u4ee3\u7801\u5b9e\u6218<\/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":[5,14,6],"class_list":["post-1963","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","tag-14","tag-6","entry"],"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1963","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=1963"}],"version-history":[{"count":1,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1963\/revisions"}],"predecessor-version":[{"id":1964,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1963\/revisions\/1964"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}