{"id":409,"date":"2024-05-10T18:17:44","date_gmt":"2024-05-10T10:17:44","guid":{"rendered":"https:\/\/blog.alltick.co\/?p=409"},"modified":"2025-04-27T11:15:17","modified_gmt":"2025-04-27T03:15:17","slug":"george-soros-trend-following","status":"publish","type":"post","link":"https:\/\/blog.alltick.co\/zh-CN\/george-soros-trend-following\/","title":{"rendered":"George Soros \u7d22\u7f57\u65af\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565"},"content":{"rendered":"\n<p>\u4e54\u6cbb\u00b7\u7d22\u7f57\u65af\uff08George Soros\uff09\u662f\u4e00\u4f4d\u8457\u540d\u7684\u6295\u8d44\u8005\u548c\u6148\u5584\u5bb6\uff0c\u4ed6\u4ee5\u5176\u5728\u91d1\u878d\u5e02\u573a\u4e0a\u7684\u6210\u529f\u548c\u6148\u5584\u4e8b\u4e1a\u800c\u95fb\u540d\u3002\u514b\u62c9\u66fc\u4ee5\u5176\u5e94\u7528\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u800c\u5907\u53d7\u77a9\u76ee\uff0c\u8fd9\u4f7f\u4ed6\u6210\u4e3a\u4e86\u6295\u8d44\u754c\u7684\u91cd\u8981\u4eba\u7269\u4e4b\u4e00\u3002<\/p>\n\n\n\n<p>\u7d22\u7f57\u65af\u7684\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u57fa\u4e8e\u4ed6\u7684\u7406\u8bba\u89c2\u70b9\uff0c\u5373\u5e02\u573a\u7684\u4ef7\u683c\u4e0d\u4ec5\u53d7\u57fa\u672c\u9762\u56e0\u7d20\u5f71\u54cd\uff0c\u8fd8\u53d7\u5230\u6295\u8d44\u8005\u7684\u60c5\u7eea\u548c\u5e02\u573a\u9884\u671f\u7684\u5f71\u54cd\u3002\u4ed6\u8ba4\u4e3a\u5e02\u573a\u4e0a\u5b58\u5728\u7740\u975e\u7406\u6027\u7684\u6ce2\u52a8\u548c\u4ef7\u683c\u504f\u79bb\uff0c\u8fd9\u4e3a\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u63d0\u4f9b\u4e86\u673a\u4f1a\u3002<\/p>\n\n\n\n<p>\u7d22\u7f57\u65af\u7684\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u7684\u6838\u5fc3\u601d\u60f3\u662f\u5229\u7528\u5e02\u573a\u8d8b\u52bf\u7684\u5ef6\u7eed\u6027\uff0c\u5373\u5f53\u5e02\u573a\u5904\u4e8e\u4e0a\u5347\u8d8b\u52bf\u65f6\uff0c\u4ed6\u4f1a\u8fdb\u884c\u591a\u5934\u4ea4\u6613\uff08\u4e70\u5165\uff09\uff0c\u5f53\u5e02\u573a\u5904\u4e8e\u4e0b\u964d\u8d8b\u52bf\u65f6\uff0c\u4ed6\u4f1a\u8fdb\u884c\u7a7a\u5934\u4ea4\u6613\uff08\u5356\u7a7a\uff09\u3002\u4ed6\u76f8\u4fe1\uff0c\u8d8b\u52bf\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u5177\u6709\u60ef\u6027\uff0c\u5373\u8fc7\u53bb\u7684\u8d8b\u52bf\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4f1a\u5ef6\u7eed\u4e0b\u53bb\u3002<\/p>\n\n\n\n<p>\u7d22\u7f57\u65af\u7684\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u4e0d\u4ec5\u6d89\u53ca\u4e70\u5165\u548c\u5356\u51fa\u7684\u65f6\u673a\uff0c\u8fd8\u5305\u62ec\u98ce\u9669\u7ba1\u7406\u548c\u8d44\u91d1\u7ba1\u7406\u3002\u4ed6\u6ce8\u91cd\u8bbe\u7f6e\u6b62\u635f\u70b9\uff0c\u4ee5\u9650\u5236\u6f5c\u5728\u7684\u635f\u5931\uff0c\u5e76\u91c7\u7528\u4ed3\u4f4d\u7ba1\u7406\u6765\u63a7\u5236\u98ce\u9669\u548c\u8d44\u91d1\u5206\u914d\u3002<\/p>\n\n\n\n<p>\u7d22\u7f57\u65af\u7684\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u5728\u4ed6\u7684\u6295\u8d44\u57fa\u91d1Quantum Fund\u7684\u8868\u73b0\u4e0a\u53d6\u5f97\u4e86\u5de8\u5927\u6210\u529f\u3002\u4ed6\u57281980\u5e74\u4ee3\u7684\u4e00\u7cfb\u5217\u6210\u529f\u4ea4\u6613\u4e2d\u8d5a\u53d6\u4e86\u5927\u91cf\u56de\u62a5\uff0c\u5176\u4e2d\u6700\u8457\u540d\u7684\u662f1992\u5e74\u7684\u82f1\u9551\u7a7a\u5934\u4ea4\u6613\uff0c\u4ed6\u901a\u8fc7\u5bf9\u82f1\u56fd\u8d27\u5e01\u7684\u629b\u552e\u83b7\u5f97\u4e86\u6570\u5341\u4ebf\u7f8e\u5143\u7684\u5229\u6da6\u3002<\/p>\n\n\n\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u7d22\u7f57\u65af\u7684\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u5e76\u975e\u6ca1\u6709\u98ce\u9669\u3002\u5e02\u573a\u7684\u6ce2\u52a8\u548c\u4e0d\u786e\u5b9a\u6027\u53ef\u80fd\u5bfc\u81f4\u7b56\u7565\u7684\u5931\u8d25\uff0c\u5e76\u5e26\u6765\u6f5c\u5728\u7684\u635f\u5931\u3002\u56e0\u6b64\uff0c\u5982\u540c\u4efb\u4f55\u4ea4\u6613\u7b56\u7565\u4e00\u6837\uff0c\u98ce\u9669\u7ba1\u7406\u548c\u9002\u5f53\u7684\u8d44\u91d1\u5206\u914d\u5bf9\u4e8e\u5b9e\u65bd\u8d8b\u52bf\u8ffd\u8e2a\u7b56\u7565\u81f3\u5173\u91cd\u8981\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Java\u4ee3\u7801\u793a\u4f8b<\/strong><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import java.util.ArrayList;\nimport java.util.List;\n\npublic class TrendFollowingStrategy {\n    public static void main(String[] args) {\n        int length1 = 23;\n        int length2 = 30;\n        int filter = 10;\n        int units = 1;\n\n        List&lt;Double> ma1 = new ArrayList&lt;>();\n        List&lt;Double> ma2 = new ArrayList&lt;>();\n        List&lt;Boolean> cond1 = new ArrayList&lt;>();\n        List&lt;Boolean> cond2 = new ArrayList&lt;>();\n        List&lt;Integer> startbar1 = new ArrayList&lt;>();\n        List&lt;Integer> startbar2 = new ArrayList&lt;>();\n        List&lt;Double> tobuy = new ArrayList&lt;>();\n        List&lt;Double> tosell = new ArrayList&lt;>();\n\n        \/\/ Assuming you have the necessary data for calculations\n        List&lt;Double> close = new ArrayList&lt;>();\n\n        for (int i = 0; i &lt; close.size(); i++) {\n            double ma1Value = calculateAverage(close, i, length1);\n            double ma2Value = calculateAverage(close, i, length2);\n            ma1.add(ma1Value);\n            ma2.add(ma2Value);\n\n            if (close.get(i) > ma1Value &amp;&amp; close.get(i) > ma2Value &amp;&amp; close.get(i - 1) &lt; Math.max(ma1.get(i - 1), ma2.get(i - 1))) {\n                cond1.add(true);\n                startbar1.add(i);\n                tobuy.add(close.get(i));\n            }\n\n            if (close.get(i) &lt; ma1Value &amp;&amp; close.get(i) &lt; ma2Value &amp;&amp; close.get(i - 1) > Math.min(ma1.get(i - 1), ma2.get(i - 1))) {\n                cond2.add(true);\n                startbar2.add(i);\n                tosell.add(close.get(i));\n            }\n\n            if (i - startbar1.get(i) > filter) {\n                cond1.set(i, false);\n            }\n\n            if (i - startbar2.get(i) > filter) {\n                cond2.set(i, false);\n            }\n\n            if (MarketPosition != 1 &amp;&amp; cond1.get(i) &amp;&amp; high >= tobuy.get(i) &amp;&amp; i != startbar1.get(i)) {\n                Buy(units, Math.max(o, tobuy.get(i)));\n            }\n\n            if (MarketPosition != -1 &amp;&amp; cond2.get(i) &amp;&amp; low &lt;= tosell.get(i) &amp;&amp; i != startbar2.get(i)) {\n                SellShort(units, Math.min(o, tosell.get(i)));\n            }\n        }\n    }\n\n    private static double calculateAverage(List&lt;Double> data, int index, int length) {\n        double sum = 0.0;\n        for (int i = index; i > index - length; i--) {\n            sum += data.get(i);\n        }\n        return sum \/ length;\n    }\n\n    private static void Buy(int units, double price) {\n        \/\/ Implement your buy logic here\n    }\n\n    private static void SellShort(int units, double price) {\n        \/\/ Implement your sell short logic here\n    }\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Python\u4ee3\u7801\u793a\u4f8b<\/strong><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class TrendFollowingStrategy:\n    def __init__(self):\n        self.ma1 = []\n        self.ma2 = []\n        self.cond1 = []\n        self.cond2 = []\n        self.startbar1 = []\n        self.startbar2 = []\n        self.tobuy = []\n        self.tosell = []\n\n    def calculate_average(self, data, index, length):\n        if index &lt; length:\n            return None\n        return sum(data[index - length + 1: index + 1]) \/ length\n\n    def buy(self, units, price):\n        # Implement your buy logic here\n        pass\n\n    def sell_short(self, units, price):\n        # Implement your sell short logic here\n        pass\n\n    def execute_strategy(self, close, open, high, low):\n        length1 = 23\n        length2 = 30\n        filter = 10\n        units = 1\n\n        for i in range(len(close)):\n            ma1_value = self.calculate_average(close, i, length1)\n            ma2_value = self.calculate_average(close, i, length2)\n            self.ma1.append(ma1_value)\n            self.ma2.append(ma2_value)\n\n            if (\n                close[i] > ma1_value\n                and close[i] > ma2_value\n                and close[i - 1] &lt; max(self.ma1[i - 1], self.ma2[i - 1])\n            ):\n                self.cond1.append(True)\n                self.startbar1.append(i)\n                self.tobuy.append(high[i])\n\n            if (\n                close[i] &lt; ma1_value\n                and close[i] &lt; ma2_value\n                and close[i - 1] > min(self.ma1[i - 1], self.ma2[i - 1])\n            ):\n                self.cond2.append(True)\n                self.startbar2.append(i)\n                self.tosell.append(low[i])\n\n            if i - self.startbar1[i] > filter:\n                self.cond1[i] = False\n\n            if i - self.startbar2[i] > filter:\n                self.cond2[i] = False\n\n            if (\n                MarketPosition != 1\n                and self.cond1[i]\n                and high[i] >= self.tobuy[i]\n                and i != self.startbar1[i]\n            ):\n                self.buy(units, max(open[i], self.tobuy[i]))\n\n            if (\n                MarketPosition != -1\n                and self.cond2[i]\n                and low[i] &lt;= self.tosell[i]\n                and i != self.startbar2[i]\n            ):\n                self.sell_short(units, min(open[i], self.tosell[i]))<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e54\u6cbb\u00b7\u7d22\u7f57\u65af\uff08George Soros\uff09\u662f\u4e00\u4f4d\u8457\u540d\u7684\u6295\u8d44\u8005\u548c\u6148\u5584\u5bb6\uff0c\u4ed6\u4ee5\u5176\u5728\u91d1\u878d\u5e02\u573a\u4e0a\u7684\u6210\u529f\u548c\u6148\u5584\u4e8b\u4e1a\u800c\u95fb\u540d\u3002&#8230;<\/p>\n","protected":false},"author":1,"featured_media":411,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-409","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\/409","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":2,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/posts\/409\/revisions\/412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media\/411"}],"wp:attachment":[{"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alltick.co\/zh-CN\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}