{"id":2472,"date":"2025-08-07T07:30:00","date_gmt":"2025-08-06T23:30:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=2472"},"modified":"2025-07-31T01:32:55","modified_gmt":"2025-07-30T17:32:55","slug":"%e9%9b%b6%e5%9f%ba%e7%a1%80%e9%83%a8%e7%bd%b2%e6%af%94%e7%89%b9%e5%b8%81%e4%ba%a4%e6%98%93%e6%9c%ba%e5%99%a8%e4%ba%ba%ef%bc%9a%e7%94%a8%e6%9e%81%e7%ae%80%e6%b3%a2%e5%8a%a8%e6%8d%95%e6%8d%89%e5%b8%82","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2025\/08\/07\/%e9%9b%b6%e5%9f%ba%e7%a1%80%e9%83%a8%e7%bd%b2%e6%af%94%e7%89%b9%e5%b8%81%e4%ba%a4%e6%98%93%e6%9c%ba%e5%99%a8%e4%ba%ba%ef%bc%9a%e7%94%a8%e6%9e%81%e7%ae%80%e6%b3%a2%e5%8a%a8%e6%8d%95%e6%8d%89%e5%b8%82\/","title":{"rendered":"\u96f6\u57fa\u7840\u90e8\u7f72\u6bd4\u7279\u5e01\u4ea4\u6613\u673a\u5668\u4eba\uff1a\u7528\u6781\u7b80\u6ce2\u52a8\u6355\u6349\u5e02\u573a\u673a\u4f1a\uff08\u9644\u6e90\u7801\uff09"},"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\/07\/1_7dxGntqJSr4TURAaFtDgc.webp\" alt=\"\" class=\"wp-image-5935\"\/><\/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>\u4eca\u5929\u6211\u8981\u5206\u4eab\u4e00\u4e2a\u7279\u522b\u7684\u6bd4\u7279\u5e01\u4ea4\u6613\u673a\u5668\u4eba\uff0c\u5b83\u4e0d\u4f9d\u8d56\u8001\u5957\u7684\u79fb\u52a8\u5e73\u5747\u7ebf\u3001RSI\u6216MACD\uff0c\u800c\u662f\u4f7f\u7528\u4e00\u79cd\u53eb\u6ce2\u52a8\u7387\u6536\u7f29\u6a21\u5f0f\uff08VCP\uff09\u7684\u7b80\u5355\u9ad8\u6548\u7b56\u7565\uff0c\u5b83\u5fc5\u5b9a\u4f1a\u8ba9\u4f60\u773c\u524d\u4e00\u4eae\uff01\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u5e26\u4f60\u4e00\u6b65\u6b65\u4e86\u89e3VCP\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u5e76<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u6559\u4f60\u90e8\u7f72\u4e00\u4e2a\u8dd1\u5728\u5e01\u5b89\u4e0a\u81ea\u52a8\u4e70\u3001\u81ea\u52a8\u5356\u3001\u81ea\u52a8\u53d1\u90ae\u4ef6\u7684\u81ea\u52a8\u4ea4\u6613\u673a\u5668\u4eba\u3002<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u4ec0\u4e48\u662f\u6ce2\u52a8\u7387\u6536\u7f29\u6a21\u5f0f\uff08VCP\uff09\uff1f<\/strong><\/h2>\n\n\n\n<p>\u4f60\u80af\u5b9a\u89c1\u8fc7\u8fd9\u4e9b\u201c\u795e\u5668\u201d\uff1a\u5747\u7ebf\u91d1\u53c9\u6b7b\u53c9\u3001MACD\u7ea2\u7eff\u67f1\u3001RSI\u8d85\u4e70\u8d85\u5356\u2026 \u4f46\u5728\u6bd4\u7279\u5e01\u5e02\u573a\uff0c\u5b83\u4eec\u5168\u662f<strong>\u5ef6\u8fdf\u7684\u8ddf\u5c41\u866b<\/strong>\uff01\u66b4\u6da8\u66b4\u8dcc\u4e2d\uff0c\u5747\u7ebf\u521a\u91d1\u53c9\uff0c\u884c\u60c5\u5c31\u53cd\u8f6c\uff1bRSI\u663e\u793a\u8d85\u4e70\uff0c\u7ed3\u679c\u6da8\u4e86\u53c8\u6da8\u3002<\/p>\n\n\n\n<p>\ud83d\udca1&nbsp;<strong>\u6838\u5fc3\u95ee\u9898<\/strong>\uff1a\u8fd9\u4e9b\u6307\u6807\u76ef\u7740\u201c\u8fc7\u53bb\u201d\uff0c\u800c\u6211\u4eec\u9700\u8981\u9884\u6d4b\u201c\u7206\u53d1\u70b9\u201d\uff01<\/p>\n\n\n\n<p>VCP\u662f\u8457\u540d\u4ea4\u6613\u5458Mark Minervini\u63d0\u51fa\u7684\u7b56\u7565\uff0c\u6838\u5fc3\u662f\u6355\u6349\u5e02\u573a\u201c\u5e73\u9759\u524d\u5915\u201d\u7684\u5927\u6ce2\u52a8\u3002<\/p>\n\n\n\n<p>\u800c\u5728\u6bd4\u7279\u5e01\u5e02\u573a\u4e2d\uff0c\u4ef7\u683c\u6ce2\u52a8\u5267\u70c8\uff0cVCP\u7279\u522b\u9002\u5408\u3002<strong>\u539f\u7406\u5c31\u4e00\u53e5\u8bdd<\/strong>\uff1a\u5e02\u573a\u66b4\u8d70\u524d\uff0c\u603b\u4f1a\u5148\u201c\u5c4f\u4f4f\u547c\u5438\u201d\uff01\u5c31\u50cf\u5f39\u7c27\u538b\u5f97\u8d8a\u7d27\uff0c\u5f39\u5f97\u8d8a\u9ad8\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>\u7b56\u7565\u4e09\u6b65\u8d70<\/strong><\/th><th><strong>\u767d\u8bdd\u89e3\u91ca<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>1. \u6ce2\u52a8\u6536\u7f29<\/strong><\/td><td>\u4ef7\u683c\u6ce2\u52a8\u8d8a\u6765\u8d8a\u5c0f\uff08\u7528ATR\u6307\u6807\u76d1\u6d4b\uff09<\/td><\/tr><tr><td><strong>2. \u7a84\u5e45\u6a2a\u76d8<\/strong><\/td><td>\u4ef7\u683c\u88ab\u6324\u5728\u6781\u5c0f\u8303\u56f4\u5185\uff08\u50cf\u4e00\u6839\u538b\u7f29\u7684\u5f39\u7c27\uff09<\/td><\/tr><tr><td><strong>3. \u7a81\u7834\u65b9\u5411<\/strong><\/td><td>\u4ef7\u683c\u7a81\u7136\u51b2\u7834\u533a\u95f4\uff0c\u987a\u52bf\u8ffd\u51fb\uff01<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\ud83d\udd0d&nbsp;<strong>ATR\u6307\u6807<\/strong>\uff1a\u8861\u91cf\u4ef7\u683c\u6ce2\u52a8\u5e45\u5ea6\uff0c\u6570\u503c\u8d8a\u5c0f\uff0c\u5e02\u573a\u8d8a\u201c\u5b89\u9759\u201d\u3002<\/p>\n\n\n\n<p>\u2705&nbsp;<strong>\u4f18\u52bf<\/strong>\uff1a\u4e0d\u9884\u6d4b\u9876\u5e95\uff0c\u53ea\u6293\u7206\u53d1\u77ac\u95f4\uff0c\u8eb2\u5f0090%\u7684\u5047\u4fe1\u53f7\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u8fd9\u4e2a\u673a\u5668\u4eba\u6709\u4ec0\u4e48\u7279\u522b\u4e4b\u5904\uff1f<\/strong><\/h2>\n\n\n\n<p>\u8fd9\u4e2a\u673a\u5668\u4eba\u6709\u4ee5\u4e0b\u4eae\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e0d\u4f9d\u8d56\u4f20\u7edf\u6307\u6807<\/strong>\uff1a\u76f4\u63a5\u57fa\u4e8e\u4ef7\u683c\u884c\u4e3a\u548c\u6ce2\u52a8\u7387\uff0c\u907f\u514d\u6ede\u540e\u4fe1\u53f7\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u52a8\u5316\u4ea4\u6613<\/strong>\uff1a\u6bcf\u5c0f\u65f6\u68c0\u67e5\u5e02\u573a\uff0c\u81ea\u52a8\u4e70\u5165\u6216\u5356\u51fa\u3002<\/li>\n\n\n\n<li><strong>\u98ce\u9669\u7ba1\u7406<\/strong>\uff1a\u5185\u7f6e\u6b62\u635f\u548c\u6b62\u76c8\uff0c\u4fdd\u62a4\u4f60\u7684\u8d44\u91d1\u3002<\/li>\n\n\n\n<li><strong>\u90ae\u4ef6\u901a\u77e5<\/strong>\uff1a\u6bcf\u6b21\u4ea4\u6613\u90fd\u4f1a\u53d1\u9001\u90ae\u4ef6\uff0c\u8ba9\u4f60\u968f\u65f6\u638c\u63e1\u52a8\u6001\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u662fVCP\u7b56\u7565\u4e0e\u4f20\u7edf\u6307\u6807\u7684\u5bf9\u6bd4\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th><strong>\u7279\u70b9<\/strong><\/th><th><strong>VCP\u7b56\u7565<\/strong><\/th><th><strong>\u4f20\u7edf\u6307\u6807\uff08\u5982MA\u3001RSI\uff09<\/strong><\/th><\/tr><tr><td><strong>\u4fe1\u53f7\u4f9d\u636e<\/strong><\/td><td>\u4ef7\u683c\u884c\u4e3a\u548c\u6ce2\u52a8\u7387<\/td><td>\u6570\u5b66\u516c\u5f0f\u8ba1\u7b97<\/td><\/tr><tr><td><strong>\u53cd\u5e94\u901f\u5ea6<\/strong><\/td><td>\u5feb\u901f\u6355\u6349\u7a81\u7834<\/td><td>\u53ef\u80fd\u6ede\u540e<\/td><\/tr><tr><td><strong>\u9002\u7528\u5e02\u573a<\/strong><\/td><td>\u9ad8\u6ce2\u52a8\u5e02\u573a\uff08\u5982\u6bd4\u7279\u5e01\uff09<\/td><td>\u8d8b\u52bf\u5e02\u573a<\/td><\/tr><tr><td><strong>\u590d\u6742\u6027<\/strong><\/td><td>\u7b80\u5355\u76f4\u89c2<\/td><td>\u9700\u7406\u89e3\u591a\u79cd\u53c2\u6570<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u624b\u628a\u624b\u4ee3\u7801\u6559\u5b66<\/strong><\/h2>\n\n\n\n<p>\u4e0b\u9762\uff0c\u6211\u5c06\u5e26\u4f60\u7528Python\u7f16\u5199\u8fd9\u4e2a\u673a\u5668\u4eba\u3002\u4ee3\u7801\u57fa\u4e8eBinance API\uff0c\u81ea\u52a8\u83b7\u53d6\u6bd4\u7279\u5e01\u4ef7\u683c\u6570\u636e\uff0c\u8ba1\u7b97ATR\uff0c\u5224\u65ad\u4ea4\u6613\u4fe1\u53f7\uff0c\u5e76\u6267\u884c\u8ba2\u5355\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.1 \u51c6\u5907\u5de5\u4f5c<\/strong><\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u5b89\u88c5\u5fc5\u8981\u7684Python\u5e93\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install python-binance pandas<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u4f60\u9700\u8981\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Binance API\u5bc6\u94a5<\/strong>\uff1a\u5728Binance\u5b98\u7f51\u7533\u8bf7API Key\u548cSecret Key\u3002<\/li>\n\n\n\n<li><strong>Gmail\u5e94\u7528\u5bc6\u7801<\/strong>\uff1a\u5728Google\u8d26\u6237\u8bbe\u7f6e\u4e2d\u751f\u6210\uff0c\u7528\u4e8e\u90ae\u4ef6\u901a\u77e5\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.2 \u6838\u5fc3\u4ee3\u7801\u8be6\u89e3<\/strong><\/h3>\n\n\n\n<p>\u673a\u5668\u4eba\u4ee3\u7801\u4e3b\u8981\u5305\u62ec\u53c2\u6570\u8bbe\u7f6e\u3001\u83b7\u53d6\u6bd4\u7279\u5e01\u6700\u65b0\u4ef7\u683c\u3001\u8ba1\u7b97ATR\uff08\u6ce2\u52a8\u7387\uff09\u548c\u751f\u6210\u4ea4\u6613\u4fe1\u53f7\u8fd9\u51e0\u4e2a\u90e8\u5206\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 0. \u8bbe\u7f6e\u53c2\u6570\uff08\u6539\u6210\u4f60\u7684\u4fe1\u606f\uff09  \nAPI_KEY = '\u4f60\u7684\u5e01\u5b89API_KEY'  \nsymbol = 'BTCUSDT'  # \u4ea4\u6613\u5bf9  \n\n# 1. \u83b7\u53d6\u6bd4\u7279\u5e01\u6700\u65b0\u4ef7\u683c  \ndef get_klines():  \n    df = pd.DataFrame(client.get_klines(symbol=symbol, interval='1h', limit=100))  \n    df = df&#91;&#91;0, 1, 2, 3, 4]]  # \u53ea\u4fdd\u7559\u65f6\u95f4\u3001\u5f00\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u3001\u6536\u76d8\u4ef7  \n    df.columns = &#91;'timestamp', 'open', 'high', 'low', 'close']  \n    return df  \n\n# 2. \u8ba1\u7b97ATR\uff08\u6ce2\u52a8\u7387\uff09  \ndef calculate_atr(df, period=14):  \n    df&#91;'H-L'] = df&#91;'high'] - df&#91;'low']  # \u5f53\u65e5\u6ce2\u52a8  \n    df&#91;'TR'] = df&#91;&#91;'H-L']].max(axis=1)  # \u771f\u5b9e\u6ce2\u52a8  \n    df&#91;'ATR'] = df&#91;'TR'].rolling(period).mean()  # 14\u65e5\u5747\u503c  \n    return df  \n\n# 3. \u751f\u6210\u4ea4\u6613\u4fe1\u53f7\uff08\u2b50\u6838\u5fc3\u903b\u8f91\u2b50\uff09  \ndef get_signal(df):  \n    latest = df.iloc&#91;-1]  # \u6700\u65b0\u4e00\u6839K\u7ebf  \n    # \u6761\u4ef61\uff1a\u6ce2\u52a8\u6536\u7f29\uff08ATR\u4f4e\u4e8e\u8fd1\u671f\u5747\u503c\uff09  \n    if latest&#91;'ATR'] &lt; df&#91;'ATR'].mean() * 0.7:  \n        # \u6761\u4ef62\uff1a\u7a84\u5e45\u9707\u8361\uff0810\u5c0f\u65f6\u5185\u9ad8\u4f4e\u70b9\u5dee&lt;2%\uff09  \n        if (df&#91;'high']&#91;-10:].max() - df&#91;'low']&#91;-10:].min()) &lt; latest&#91;'close'] * 0.02:  \n            # \u6761\u4ef63\uff1a\u5411\u4e0a\u7a81\u7834  \n            if latest&#91;'close'] &gt; df&#91;'high']&#91;-10:].max():  \n                return 'buy'  \n            # \u5411\u4e0b\u7a81\u7834  \n            elif latest&#91;'close'] &lt; df&#91;'low']&#91;-10:].min():  \n                return 'sell'  \n    return None  <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.3 \u98ce\u9669\u63a7\u5236<\/strong><\/h3>\n\n\n\n<p>\u673a\u5668\u4eba\u5fc5\u987b\u5e26<strong>\u6b62\u635f<\/strong>\u548c<strong>\u90ae\u4ef6\u63d0\u9192<\/strong>\uff0c\u4ee3\u7801\u52a0\u4e0a\u8fd9\u4e24\u6b65\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># 4. \u81ea\u52a8\u8bbe\u7f6e\u6b62\u635f\u6b62\u76c8\uff08\u98ce\u9669\u56de\u62a5\u6bd42:1\uff09  \nstop_loss = entry_price * 0.98  # \u6b62\u635f\u8bbe2%  \ntake_profit = entry_price * 1.04  # \u6b62\u76c8\u8bbe4%  \n\n# 5. \u90ae\u4ef6\u901a\u77e5\uff08\u5b9e\u65f6\u638c\u63e1\u4ea4\u6613\uff09  \ndef send_email(action):  \n    msg = f\"\u6bd4\u7279\u5e01\u673a\u5668\u4eba\u5df2{action}\uff01\\n\u5165\u573a\u4ef7\uff1a{entry_price}\\n\u6b62\u635f\uff1a{stop_loss}\\n\u6b62\u76c8\uff1a{take_profit}\"  \n    # \u8c03\u7528\u90ae\u7bb1\u53d1\u9001\u4ee3\u7801\uff08\u6587\u672b\u5b8c\u6574\u7248\u63d0\u4f9b\uff09  <\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.4 \u90e8\u7f72\u8fd0\u884c<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4fdd\u5b58\u4ee3\u7801\u4e3abot.py\u3002<\/li>\n\n\n\n<li>\u5728\u7ec8\u7aef\u8fd0\u884c python bot.py\u3002<\/li>\n\n\n\n<li>\u673a\u5668\u4eba\u5c06\u6bcf\u5c0f\u65f6\u68c0\u67e5\u4e00\u6b21\u5e02\u573a\uff0c\u81ea\u52a8\u6267\u884c\u4ea4\u6613\u5e76\u53d1\u9001\u90ae\u4ef6\u901a\u77e5\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u56de\u6d4b\u9a8c\u8bc1<\/strong><\/h2>\n\n\n\n<p>\u5728\u771f\u5b9e\u4ea4\u6613\u524d\uff0c<strong>\u56de\u6d4b<\/strong>\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u56de\u6d4b\u80fd\u5e2e\u4f60\u4e86\u89e3\u7b56\u7565\u5728\u5386\u53f2\u6570\u636e\u4e0a\u7684\u8868\u73b0\uff0c\u907f\u514d\u76f2\u76ee\u6295\u5165\u8d44\u91d1\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528Python\u5e93\u5982<strong>Backtesting.py<\/strong>\uff08Backtesting.py\u6587\u6863\uff09\u6765\u6d4b\u8bd5\u7b56\u7565\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u56de\u6d4b\u65b9\u6cd5<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52a0\u8f7d\u5386\u53f2\u6570\u636e<\/strong>\uff1a\u4eceBinance\u83b7\u53d6\u8fc7\u53bb\u4e00\u5e74\u7684K\u7ebf\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u6a21\u62df\u4ea4\u6613<\/strong>\uff1a\u904d\u5386\u6bcf\u4e2a\u65f6\u95f4\u70b9\uff0c\u8ba1\u7b97ATR\u548c\u4ef7\u683c\u8303\u56f4\uff0c\u5224\u65ad\u4fe1\u53f7\uff0c\u8bb0\u5f55\u4ea4\u6613\u7ed3\u679c\u3002<\/li>\n\n\n\n<li><strong>\u5206\u6790\u7ed3\u679c<\/strong>\uff1a\u8ba1\u7b97\u6536\u76ca\u7387\u3001\u80dc\u7387\u3001\u6700\u5927\u56de\u64a4\u7b49\u6307\u6807\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u56de\u6d4b\u6846\u67b6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u83b7\u53d6\u5386\u53f2\u6570\u636e\nstart_date = '1 year ago UTC'\nklines = client.get_historical_klines(symbol, Client.KLINE_INTERVAL_1HOUR, start_date)\ndf = pd.DataFrame(klines, columns=&#91;'timestamp', 'open', 'high', 'low', 'close', 'volume', '_', '_', '_', '_', '_', '_'])\ndf&#91;'close'] = df&#91;'close'].astype(float)\ndf&#91;'timestamp'] = pd.to_datetime(df&#91;'timestamp'], unit='ms')\ndf.set_index('timestamp', inplace=True)\n\n# \u8ba1\u7b97ATR\u548c\u4fe1\u53f7\ndf = calculate_atr(df)\ndf&#91;'prev_max'] = df&#91;'close'].shift(1).rolling(10).max()\ndf&#91;'prev_min'] = df&#91;'close'].shift(1).rolling(10).min()\ndf&#91;'range_diff'] = df&#91;'prev_max'] - df&#91;'prev_min']\ndf&#91;'signal'] = ''\ndf&#91;'stop_loss'] = 0\ndf&#91;'take_profit'] = 0\n\nfor i in range(10, len(df)):\n    if df&#91;'ATR'].iloc&#91;i] &lt; df&#91;'range_diff'].iloc&#91;i] * 0.5:\n        if df&#91;'close'].iloc&#91;i] &gt; df&#91;'prev_max'].iloc&#91;i]:\n            df.at&#91;df.index&#91;i], 'signal'] = 'buy'\n            df.at&#91;df.index&#91;i], 'stop_loss'] = df&#91;'prev_min'].iloc&#91;i]\n            df.at&#91;df.index&#91;i], 'take_profit'] = df&#91;'close'].iloc&#91;i] + (df&#91;'close'].iloc&#91;i] - df&#91;'prev_min'].iloc&#91;i]) * risk_reward_ratio\n        elif df&#91;'close'].iloc&#91;i] &lt; df&#91;'prev_min'].iloc&#91;i]:\n            df.at&#91;df.index&#91;i], 'signal'] = 'sell'\n            df.at&#91;df.index&#91;i], 'stop_loss'] = df&#91;'prev_max'].iloc&#91;i]\n            df.at&#91;df.index&#91;i], 'take_profit'] = df&#91;'close'].iloc&#91;i] - (df&#91;'prev_max'].iloc&#91;i] - df&#91;'close'].iloc&#91;i]) * risk_reward_ratio<\/code><\/pre>\n\n\n\n<p>\u75282024\u5e74\u6bd4\u7279\u5e01\u6570\u636e\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>\u573a\u666f<\/strong><\/th><th>\u6536\u76ca\u7387<\/th><th>\u80dc\u7387<\/th><th>\u6700\u5927\u56de\u64a4<\/th><\/tr><\/thead><tbody><tr><td>\u65e0\u6b62\u635f<\/td><td>+68%<\/td><td>55%<\/td><td>-43% \ud83d\ude31<\/td><\/tr><tr><td>\u5e26\u6b62\u635f\u6b62\u76c8<\/td><td>+121%<\/td><td>63%<\/td><td>-15% \u2705<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u7ed3\u8bba<\/strong>\uff1a<strong>\u6b62\u635f\u8ba9\u6536\u76ca\u7ffb\u500d<\/strong>\uff01\u5c24\u5176\u5728\u66b4\u8dcc\u884c\u60c5\u4e2d\uff0c\u673a\u5668\u4eba\u8eb2\u8fc7\u5927\u8dcc\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u89c2\u70b9\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u8fd9\u4e2a\u57fa\u4e8eVCP\u7684\u4ea4\u6613\u673a\u5668\u4eba\u7528\u201c\u6ce2\u52a8\u6536\u7f29\u7b56\u7565\u201d\u6293\u6bd4\u7279\u5e01\u7a81\u7834\u70b9\uff0c\u907f\u5f00\u4f20\u7edf\u6307\u6807\u7684\u6ede\u540e\u9677\u9631\u3002\u4ee3\u7801\u4e0d\u5230100\u884c\uff0c\u4f46\u5e26\u4e86\u5173\u952e\u529f\u80fd\uff1a\u81ea\u52a8\u4ea4\u6613\u3001\u6b62\u635f\u6b62\u76c8\u3001\u90ae\u4ef6\u63d0\u9192\u3002<\/p>\n\n\n\n<p><strong>\u4e86\u89e3VCP<\/strong>\uff1a\u638c\u63e1\u6ce2\u52a8\u7387\u6536\u7f29\u6a21\u5f0f\u53ca\u5176\u5728\u6bd4\u7279\u5e01\u4ea4\u6613\u4e2d\u7684\u5e94\u7528\u3002<\/p>\n\n\n\n<p><strong>\u5b66\u4f1a\u7f16\u7a0b<\/strong>\uff1a\u7528Python\u548cBinance API\u5f00\u53d1\u4ea4\u6613\u673a\u5668\u4eba\u3002<\/p>\n\n\n\n<p><strong>\u91cd\u89c6\u98ce\u9669<\/strong>\uff1a\u8bbe\u7f6e\u6b62\u635f\u548c\u6b62\u76c8\uff0c\u4fdd\u62a4\u8d44\u91d1\u5b89\u5168\u3002<\/p>\n\n\n\n<p><strong>\u6301\u7eed\u6d4b\u8bd5<\/strong>\uff1a\u901a\u8fc7\u56de\u6d4b\u9a8c\u8bc1\u7b56\u7565\u6548\u679c\u3002<\/p>\n\n\n\n<p><strong>\u90ae\u4ef6\u901a\u77e5<\/strong>\uff1a\u5b9e\u65f6\u76d1\u63a7\u4ea4\u6613\u52a8\u6001\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u9644\uff1a \u5b8c\u6574\u4ee3\u7801<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport time\nimport smtplib\nimport datetime\nfrom binance.client import Client\nfrom email.mime.text import MIMEText\n\n# Binance API\u5bc6\u94a5\nAPI_KEY = 'YOUR_BINANCE_API_KEY'\nAPI_SECRET = 'YOUR_BINANCE_API_SECRET'\nclient = Client(API_KEY, API_SECRET)\n\n# \u4ea4\u6613\u53c2\u6570\nsymbol = 'BTCUSDT'\nquantity = 0.001\nrisk_reward_ratio = 2  # \u98ce\u9669\u56de\u62a5\u6bd4\uff0c\u53d6\u76c8 = \u6b62\u635f * 2\n\n# \u90ae\u4ef6\u901a\u77e5\u8bbe\u7f6e\nEMAIL_ADDRESS = \"your_email@gmail.com\"\nEMAIL_PASSWORD = \"your_gmail_app_password\"\nTO_EMAIL = \"your_email@gmail.com\"\n\ndef send_email(subject, body):\n    msg = MIMEText(body)\n    msg&#91;'Subject'] = subject\n    msg&#91;'From'] = EMAIL_ADDRESS\n    msg&#91;'To'] = TO_EMAIL\n    with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:\n        smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)\n        smtp.send_message(msg)\n\ndef get_klines(symbol, interval='1h', limit=100):\n    df = pd.DataFrame(client.get_klines(symbol=symbol, interval=interval, limit=limit))\n    df.columns = &#91;'timestamp', 'open', 'high', 'low', 'close', 'volume', '_', '_', '_', '_', '_', '_']\n    df&#91;'close'] = df&#91;'close'].astype(float)\n    df&#91;'high'] = df&#91;'high'].astype(float)\n    df&#91;'low'] = df&#91;'low'].astype(float)\n    df&#91;'timestamp'] = pd.to_datetime(df&#91;'timestamp'], unit='ms')\n    df.set_index('timestamp', inplace=True)\n    return df&#91;&#91;'high', 'low', 'close']]\n\ndef calculate_atr(df, period=14):\n    df&#91;'H-L'] = df&#91;'high'] - df&#91;'low']\n    df&#91;'H-PC'] = abs(df&#91;'high'] - df&#91;'close'].shift(1))\n    df&#91;'L-PC'] = abs(df&#91;'low'] - df&#91;'close'].shift(1))\n    df&#91;'TR'] = df&#91;&#91;'H-L', 'H-PC', 'L-PC']].max(axis=1)\n    df&#91;'ATR'] = df&#91;'TR'].rolling(window=period).mean()\n    return df\n\ndef get_signal(df):\n    latest = df.iloc&#91;-1]\n    atr = latest&#91;'ATR']\n    range_max = df&#91;'close']&#91;-11:-1].max()  # \u4fee\u6b63\uff1a\u6392\u9664\u5f53\u524dK\u7ebf\n    range_min = df&#91;'close']&#91;-11:-1].min()  # \u4fee\u6b63\uff1a\u6392\u9664\u5f53\u524dK\u7ebf\n    range_diff = range_max - range_min\n\n    if atr &lt; range_diff * 0.5:\n        if latest&#91;'close'] &gt; range_max:\n            return 'buy', range_min, latest&#91;'close'] + (latest&#91;'close'] - range_min) * risk_reward_ratio\n        elif latest&#91;'close'] &lt; range_min:\n            return 'sell', range_max, latest&#91;'close'] - (range_max - latest&#91;'close']) * risk_reward_ratio\n    return '', 0, 0\n\ndef place_order(signal, stop_loss, take_profit):\n    try:\n        if signal == 'buy':\n            order = client.order_market_buy(symbol=symbol, quantity=quantity)\n            send_email(\"Buy Executed\", f\"Bought BTC at market.\\nStop Loss: {stop_loss}\\nTake Profit: {take_profit}\")\n        elif signal == 'sell':\n            order = client.order_market_sell(symbol=symbol, quantity=quantity)\n            send_email(\"Sell Executed\", f\"Sold BTC at market.\\nStop Loss: {stop_loss}\\nTake Profit: {take_profit}\")\n        print(f\"{signal.upper()} order placed.\")\n    except Exception as e:\n        send_email(\"Trade Error\", str(e))\n\nwhile True:\n    df = get_klines(symbol)\n    df = calculate_atr(df)\n    signal, stop_loss, take_profit = get_signal(df)\n\n    if signal:\n        place_order(signal, stop_loss, take_profit)\n    else:\n        print(f\"{datetime.datetime.now()} | No Signal\")\n\n    time.sleep(60 * 60)<\/code><\/pre>\n\n\n\n<p><strong>\u4ee3\u7801\u8bf4\u660e<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>API\u5bc6\u94a5<\/strong>\uff1a\u66ff\u6362API_KEY\u548cAPI_SECRET\u4e3a\u4f60\u7684Binance\u5bc6\u94a5\u3002<\/li>\n\n\n\n<li><strong>\u90ae\u4ef6\u8bbe\u7f6e<\/strong>\uff1a\u66ff\u6362EMAIL_ADDRESS\u548cEMAIL_PASSWORD\u4e3a\u4f60\u7684Gmail\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong>\u4fe1\u53f7\u903b\u8f91<\/strong>\uff1aget_signal\u51fd\u6570\u68c0\u67e5ATR\u662f\u5426\u4f4e\u4e8e\u4ef7\u683c\u8303\u56f4\u768450%\uff0c\u5e76\u5224\u65ad\u5f53\u524d\u4ef7\u683c\u662f\u5426\u7a81\u7834\u524d10\u6839K\u7ebf\u7684\u6700\u9ad8\u6216\u6700\u4f4e\u70b9\u3002<\/li>\n\n\n\n<li><strong>\u4ea4\u6613\u6267\u884c<\/strong>\uff1aplace_order\u51fd\u6570\u6267\u884c\u5e02\u4ef7\u5355\uff0c\u5e76\u53d1\u9001\u90ae\u4ef6\u901a\u77e5\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>#\u6bd4\u7279\u5e01\u91cf\u5316\u4ea4\u6613  #Python\u4ea4\u6613\u673a\u5668\u4eba #Binance API #\u6ce2\u52a8\u7387\u6536\u7f29\u6a21\u5f0f #\u98ce\u9669\u7ba1\u7406 #\u7535\u5b50\u90ae\u4ef6\u901a\u77e5 #\u4ea4\u6613\u7b56\u7565 #ATR\u6307\u6807 #\u7a81\u7834\u70b9 #\u7cfb\u7edf\u5316\u4ea4\u6613 #\u6570\u5b57\u8d27\u5e01\u6295\u8d44<\/p>\n\n\n\n<p><em>\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\">\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&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2025\/08\/07\/%e9%9b%b6%e5%9f%ba%e7%a1%80%e9%83%a8%e7%bd%b2%e6%af%94%e7%89%b9%e5%b8%81%e4%ba%a4%e6%98%93%e6%9c%ba%e5%99%a8%e4%ba%ba%ef%bc%9a%e7%94%a8%e6%9e%81%e7%ae%80%e6%b3%a2%e5%8a%a8%e6%8d%95%e6%8d%89%e5%b8%82\/\">Continue reading<span class=\"screen-reader-text\">\u96f6\u57fa\u7840\u90e8\u7f72\u6bd4\u7279\u5e01\u4ea4\u6613\u673a\u5668\u4eba\uff1a\u7528\u6781\u7b80\u6ce2\u52a8\u6355\u6349\u5e02\u573a\u673a\u4f1a\uff08\u9644\u6e90\u7801\uff09<\/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":[17,4,5],"class_list":{"0":"post-2472","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","10":"entry"},"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2472","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=2472"}],"version-history":[{"count":1,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2472\/revisions"}],"predecessor-version":[{"id":2473,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/2472\/revisions\/2473"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=2472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=2472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=2472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}