{"id":10925,"date":"2026-05-21T16:16:55","date_gmt":"2026-05-21T08:16:55","guid":{"rendered":"https:\/\/blog.alltick.co\/zh-CN\/?p=10925"},"modified":"2026-05-21T16:16:55","modified_gmt":"2026-05-21T08:16:55","slug":"%e5%a4%9a%e8%b5%84%e4%ba%a7%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90%e4%b8%8e%e7%ad%96%e7%95%a5%e4%bc%98%e5%8c%96%ef%bc%9a%e7%94%a8-alltick-api-%e6%8e%a2%e7%b4%a2%e4%ba%a4%e6%98%93%e4%bf%a1%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/blog.alltick.co\/zh-CN\/%e5%a4%9a%e8%b5%84%e4%ba%a7%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90%e4%b8%8e%e7%ad%96%e7%95%a5%e4%bc%98%e5%8c%96%ef%bc%9a%e7%94%a8-alltick-api-%e6%8e%a2%e7%b4%a2%e4%ba%a4%e6%98%93%e4%bf%a1%e5%8f%b7\/","title":{"rendered":"\u591a\u8d44\u4ea7\u6570\u636e\u5206\u6790\u4e0e\u7b56\u7565\u4f18\u5316\uff1a\u7528 AllTick API \u63a2\u7d22\u4ea4\u6613\u4fe1\u53f7"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"380\" src=\"https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE.png?resize=800%2C380&#038;ssl=1\" alt=\"\" class=\"wp-image-10926\" srcset=\"https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?resize=1024%2C487&amp;ssl=1 1024w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?resize=300%2C143&amp;ssl=1 300w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?resize=768%2C365&amp;ssl=1 768w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?resize=1536%2C730&amp;ssl=1 1536w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?resize=2048%2C974&amp;ssl=1 2048w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?w=1600&amp;ssl=1 1600w, https:\/\/i0.wp.com\/blog.alltick.co\/zh-CN\/wp-content\/uploads\/2026\/05\/%E5%A4%9A%E8%B5%84%E4%BA%A7%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E4%B8%8E%E7%AD%96%E7%95%A5%E4%BC%98%E5%8C%96%E5%B0%81%E9%9D%A2%E5%9B%BE-scaled.png?w=2400&amp;ssl=1 2400w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>\u5728\u91cf\u5316\u4ea4\u6613\u548c\u8d44\u4ea7\u7ba1\u7406\u4e2d\uff0c\u4ec5\u4f9d\u9760\u5355\u4e00\u5e02\u573a\u7684\u6570\u636e\u5f80\u5f80\u96be\u4ee5\u63d0\u4f9b\u5b8c\u6574\u7684\u7b56\u7565\u89c6\u89d2\u3002\u901a\u8fc7\u591a\u8d44\u4ea7\u6570\u636e\u5206\u6790\uff0c\u53ef\u4ee5\u540c\u65f6\u89c2\u5bdf\u4e0d\u540c\u5e02\u573a\u7684\u4ef7\u683c\u6ce2\u52a8\u548c\u8d8b\u52bf\uff0c\u4ece\u800c\u66f4\u7cbe\u51c6\u5730\u53d1\u73b0\u6f5c\u5728\u4ea4\u6613\u673a\u4f1a\u3002\u672c\u6587\u4ee5 Python \u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u7ed3\u5408\u5386\u53f2\u884c\u60c5\u6570\u636e\u548c\u5b9e\u65f6 Tick \u6570\u636e\uff0c\u5bf9\u591a\u8d44\u4ea7\u8fdb\u884c\u6307\u6807\u5206\u6790\u548c\u7b56\u7565\u4f18\u5316\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u83b7\u53d6\u591a\u8d44\u4ea7\u5386\u53f2\u884c\u60c5<\/strong><\/h2>\n\n\n\n<p>\u591a\u8d44\u4ea7\u5206\u6790\u7684\u7b2c\u4e00\u6b65\u662f\u83b7\u53d6\u53ef\u9760\u7684\u5386\u53f2\u6570\u636e\u3002\u4ee5\u5916\u6c47\u548c\u52a0\u5bc6\u8d27\u5e01\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u901a\u8fc7 AllTick API \u83b7\u53d6 OHLC \u6570\u636e\uff0c\u5e76\u7edf\u4e00\u683c\u5f0f\uff0c\u65b9\u4fbf\u540e\u7eed\u5206\u6790\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>import requests<br>import pandas as pd<br><br>API_URL = &#8220;https:\/\/api.alltick.co\/forex\/history&#8221;<br>API_KEY = &#8220;your_api_key_here&#8221;<br><br>symbols = [&#8220;EURUSD&#8221;, &#8220;BTCUSD&#8221;, &#8220;ETHUSD&#8221;]<br>dfs = []<br><br>for symbol in symbols:<br>&nbsp; &nbsp; params = {<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;symbol&#8221;: symbol,<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;interval&#8221;: &#8220;1h&#8221;,<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;limit&#8221;: 500,<br>&nbsp; &nbsp; &nbsp; &nbsp; &#8220;apikey&#8221;: API_KEY<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; resp = requests.get(API_URL, params=params)<br>&nbsp; &nbsp; df = pd.DataFrame(resp.json())<br>&nbsp; &nbsp; df[&#8216;timestamp&#8217;] = pd.to_datetime(df[&#8216;timestamp&#8217;])<br>&nbsp; &nbsp; df[&#8216;symbol&#8217;] = symbol<br>&nbsp; &nbsp; dfs.append(df)<br><br>data = pd.concat(dfs)<br>print(data.head())<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u901a\u8fc7\u7edf\u4e00\u683c\u5f0f\u5904\u7406\u591a\u8d44\u4ea7\u6570\u636e\uff0c\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u6307\u6807\u8ba1\u7b97\u548c\u7b56\u7565\u5206\u6790\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5e38\u7528\u6307\u6807\u8ba1\u7b97<\/strong><\/h2>\n\n\n\n<p>\u5728\u591a\u8d44\u4ea7\u5206\u6790\u4e2d\uff0c\u5747\u7ebf\uff08MA\uff09\u3001\u6ce2\u52a8\u7387\uff08Volatility\uff09\u548c\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570\uff08RSI\uff09\u662f\u5e38\u7528\u5de5\u5177\uff0c\u5e2e\u52a9\u5224\u65ad\u8d8b\u52bf\u65b9\u5411\u3001\u5e02\u573a\u6ce2\u52a8\u5e45\u5ea6\u548c\u8d85\u4e70\u8d85\u5356\u60c5\u51b5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>def calculate_indicators(df):<br>&nbsp; &nbsp; df = df.copy()<br>&nbsp; &nbsp; df[&#8216;MA20&#8217;] = df[&#8216;close&#8217;].rolling(20).mean()<br>&nbsp; &nbsp; df[&#8216;MA50&#8217;] = df[&#8216;close&#8217;].rolling(50).mean()<br>&nbsp; &nbsp; df[&#8216;returns&#8217;] = df[&#8216;close&#8217;].pct_change()<br>&nbsp; &nbsp; df[&#8216;volatility&#8217;] = df[&#8216;returns&#8217;].rolling(20).std()<br>&nbsp; &nbsp;<br>&nbsp; &nbsp; delta = df[&#8216;close&#8217;].diff()<br>&nbsp; &nbsp; up, down = delta.clip(lower=0), -delta.clip(upper=0)<br>&nbsp; &nbsp; roll_up = up.rolling(14).mean()<br>&nbsp; &nbsp; roll_down = down.rolling(14).mean()<br>&nbsp; &nbsp; rs = roll_up \/ roll_down<br>&nbsp; &nbsp; df[&#8216;RSI&#8217;] = 100 &#8211; (100 \/ (1 + rs))<br>&nbsp; &nbsp;<br>&nbsp; &nbsp; return df<br><br>data = data.groupby(&#8216;symbol&#8217;).apply(calculate_indicators)<br>print(data[[&#8216;symbol&#8217;,&#8217;close&#8217;,&#8217;MA20&#8242;,&#8217;MA50&#8242;,&#8217;volatility&#8217;,&#8217;RSI&#8217;]].tail())<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u8fd9\u4e9b\u6307\u6807\u53ef\u4ee5\u63d0\u4f9b\u8d8b\u52bf\u5224\u65ad\u3001\u6ce2\u52a8\u89c2\u5bdf\u548c\u5e02\u573a\u5f3a\u5f31\u5206\u6790\u7684\u57fa\u7840\u6570\u636e\uff0c\u4e3a\u7b56\u7565\u4fe1\u53f7\u63d0\u4f9b\u53c2\u8003\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u591a\u8d44\u4ea7\u4ea4\u6613\u4fe1\u53f7\u63a2\u7d22<\/strong><\/h2>\n\n\n\n<p>\u5f53\u4e0d\u540c\u8d44\u4ea7\u7684\u6570\u636e\u90fd\u51c6\u5907\u597d\u540e\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u53d1\u73b0\u6f5c\u5728\u4ea4\u6613\u4fe1\u53f7\u3002\u4f8b\u5982\uff0c\u5f53\u67d0\u8d44\u4ea7\u5747\u7ebf\u4ea4\u53c9\uff0c\u540c\u65f6\u53e6\u4e00\u8d44\u4ea7 RSI \u663e\u793a\u8d85\u5356\u65f6\uff0c\u53ef\u80fd\u5f62\u6210\u8de8\u5e02\u573a\u5957\u5229\u6216\u5bf9\u51b2\u7b56\u7565\u4fe1\u53f7\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>def generate_signal(df):<br>&nbsp; &nbsp; df[&#8216;signal&#8217;] = 0<br>&nbsp; &nbsp; df.loc[df[&#8216;MA20&#8217;] &gt; df[&#8216;MA50&#8217;], &#8216;signal&#8217;] = 1<br>&nbsp; &nbsp; df.loc[df[&#8216;MA20&#8217;] &lt; df[&#8216;MA50&#8217;], &#8216;signal&#8217;] = -1<br>&nbsp; &nbsp; return df<br><br>signals = data.groupby(&#8216;symbol&#8217;).apply(generate_signal)<br>print(signals[[&#8216;symbol&#8217;,&#8217;close&#8217;,&#8217;MA20&#8242;,&#8217;MA50&#8242;,&#8217;RSI&#8217;,&#8217;signal&#8217;]].tail())<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u901a\u8fc7\u540c\u65f6\u5206\u6790\u591a\u8d44\u4ea7\u6307\u6807\uff0c\u53ef\u4ee5\u6316\u6398\u66f4\u7ec6\u5316\u7684\u4ea4\u6613\u673a\u4f1a\uff0c\u800c\u4e0d\u4ec5\u4ec5\u4f9d\u8d56\u5355\u4e00\u5e02\u573a\u8d8b\u52bf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b9e\u65f6 Tick \u6570\u636e\u6574\u5408<\/strong><\/h2>\n\n\n\n<p>\u5386\u53f2\u6570\u636e\u53ef\u4ee5\u63d0\u4f9b\u8d8b\u52bf\u53c2\u8003\uff0c\u4f46\u5b9e\u65f6 Tick \u6570\u636e\u80fd\u591f\u6355\u6349\u6bcf\u6b21\u4ef7\u683c\u6ce2\u52a8\uff0c\u4ece\u800c\u652f\u6301\u52a8\u6001\u7b56\u7565\u5206\u6790\u3002\u901a\u8fc7\u7a33\u5b9a\u7684 Tick \u6570\u636e\u6d41\uff0c\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52a8\u6001\u66f4\u65b0\u6307\u6807\u548c\u4ea4\u6613\u4fe1\u53f7<\/li>\n\n\n\n<li>\u5b9e\u65f6\u8c03\u6574\u7b56\u7565\u53c2\u6570<\/li>\n\n\n\n<li>\u4e3a\u53ef\u89c6\u5316\u4eea\u8868\u76d8\u63d0\u4f9b\u8fde\u7eed\u6570\u636e<\/li>\n<\/ul>\n\n\n\n<p>\u7ed3\u5408\u5386\u53f2\u6307\u6807\u548c\u5b9e\u65f6 Tick \u6570\u636e\uff0c\u53ef\u4ee5\u5f62\u6210\u5b8c\u6574\u7684\u591a\u8d44\u4ea7\u7b56\u7565\u5206\u6790\u95ed\u73af\uff0c\u4ece\u56de\u6d4b\u5ef6\u4f38\u5230\u5b9e\u65f6\u76d1\u63a7\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5206\u6790\u4e0e\u4f18\u5316\u601d\u8def<\/strong><\/h2>\n\n\n\n<p>\u591a\u8d44\u4ea7\u5206\u6790\u7684\u6838\u5fc3\u4ef7\u503c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8de8\u5e02\u573a\u4fe1\u53f7\u53d1\u73b0<\/strong>\uff1a\u5355\u4e00\u5e02\u573a\u96be\u4ee5\u663e\u73b0\u7684\u8d8b\u52bf\uff0c\u5728\u591a\u8d44\u4ea7\u5bf9\u6bd4\u4e2d\u66f4\u6e05\u6670\u3002<\/li>\n\n\n\n<li><strong>\u7b56\u7565\u4f18\u5316<\/strong>\uff1a\u6ce2\u52a8\u7387\u3001RSI \u548c\u5747\u7ebf\u7b49\u6307\u6807\u53ef\u8f85\u52a9\u4f18\u5316\u4ea4\u6613\u4ed3\u4f4d\u548c\u6b62\u635f\u7b56\u7565\u3002<\/li>\n\n\n\n<li><strong>\u5b9e\u65f6\u51b3\u7b56\u652f\u6301<\/strong>\uff1a\u5386\u53f2\u6570\u636e\u4e0e Tick \u6570\u636e\u7ed3\u5408\uff0c\u4e3a\u4ea4\u6613\u7b56\u7565\u63d0\u4f9b\u7cbe\u7ec6\u5165\u573a\u548c\u9000\u51fa\u4fe1\u53f7\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u901a\u8fc7\u5386\u53f2\u884c\u60c5\u548c\u5b9e\u65f6 Tick \u6570\u636e\u7684\u7ed3\u5408\uff0c\u53ef\u4ee5\u4ece\u7b56\u7565\u6d4b\u8bd5\u5230\u5b9e\u65f6\u76d1\u63a7\uff0c\u6784\u5efa\u5b8c\u6574\u7684\u591a\u8d44\u4ea7\u7b56\u7565\u4f18\u5316\u6d41\u7a0b\u3002\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u6570\u636e\u5229\u7528\u6548\u7387\uff0c\u4e5f\u4e3a\u590d\u6742\u7b56\u7565\u7684\u9a8c\u8bc1\u548c\u4f18\u5316\u63d0\u4f9b\u4e86\u53ef\u9760\u57fa\u7840\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u91cf\u5316\u4ea4\u6613\u548c\u8d44\u4ea7\u7ba1\u7406\u4e2d\uff0c\u4ec5\u4f9d\u9760\u5355\u4e00\u5e02\u573a\u7684\u6570\u636e\u5f80\u5f80\u96be\u4ee5\u63d0\u4f9b\u5b8c\u6574\u7684\u7b56\u7565\u89c6\u89d2\u3002\u901a\u8fc7\u591a\u8d44\u4ea7\u6570\u636e\u5206\u6790\uff0c\u53ef\u4ee5\u540c\u65f6\u89c2\u5bdf\u4e0d\u540c\u5e02&#8230;<\/p>\n","protected":false},"author":5,"featured_media":10926,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-10925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tick-data-wiki"],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/10925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/comments?post=10925"}],"version-history":[{"count":1,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/10925\/revisions"}],"predecessor-version":[{"id":10927,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/10925\/revisions\/10927"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media\/10926"}],"wp:attachment":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media?parent=10925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/categories?post=10925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/tags?post=10925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}