Thursday 22 February 2018

نظام التداول تعلم الآلة


جيسي سبولدينغ.


كيف جعلت 500K $ مع تعلم الآلة و هفت (تجارة عالية التردد)


هذه الوظيفة سوف تفاصيل ما فعلت لجعل تقريبا. 500k من تجارة عالية التردد من 2009 إلى 2010. منذ كنت تتداول بشكل مستقل تماما وأنا لم يعد تشغيل برنامج أنا & [رسقوو]؛ م سعيد أن أقول كل شيء. كان تداولي في معظمه في عقود راسل 2000 و داكس المستقبلية.


مفتاح نجاحي، أعتقد، لم يكن في معادلة مالية متطورة بل بالأحرى في تصميم الخوارزمية الشاملة التي ربطت معا العديد من المكونات البسيطة واستخدمت آلة التعلم لتحسين لأقصى قدر من الربحية. لن تحتاج إلى معرفة أي مصطلحات متطورة هنا لأنه عند إعداد برنامجي كان كل ذلك يعتمد على الحدس. (أندرو نغ و رسكو؛ ق مذهلة آلة التعلم بالطبع لم تكن متاحة بعد - راجع للشغل إذا قمت بالنقر فوق هذا الارتباط سوف يتم اتخاذها إلى مشروعي الحالي: كورستالك، موقع مراجعة ل موكس)


أولا، أريد فقط أن أثبت أن نجاحي لم يكن مجرد نتيجة لحظ. برنامجي جعل 1000-4000 الصفقات في اليوم الواحد (نصف طويلة، نصف قصيرة) ولم يحصل في مواقف أكثر من عدد قليل من العقود في وقت واحد. وهذا يعني أن حظا عشوائيا من أي تجارة معينة كان متوسطها سريعا جدا. وكانت النتيجة أنني لم أكن فقدت أكثر من 2000 دولار في يوم واحد ولم يكن يوما خاسرا:


(إديت: هذه الأرقام هي بعد دفع العمولات)


وهنا [رسقوو]؛ s الرسم البياني لتعطيك شعورا الاختلاف اليومي. لاحظ هذا يستبعد آخر 7 أشهر لأنه - كما توقفت الأرقام تصعد - لقد فقدت الدافع للدخول لهم.


قبل إعداد بلدي برنامج التداول الآلي أنا و [رسقوو]؛ د كان 2 سنوات الخبرة كدليل & لدكو؛ رديقو؛ يوم تاجر. هذا كان مرة أخرى في عام 2001 - كانت الأيام الأولى للتجارة الإلكترونية وكانت هناك فرص ل & لدكو؛ السماسرة & رديقو؛ لكسب المال. أستطيع أن أصف فقط ما كنت أفعله أقرب إلى لعب لعبة فيديو / القمار مع حافة المفترض. كونها ناجحة يعني أن تكون سريعة، يجري منضبطة، وجود قدرات التعرف على نمط بديهية جيدة. كنت قادرا على جعل حوالي 250K $، تسديد القروض الطلابية والمال قد غادر. يفوز!


على مدى السنوات الخمس المقبلة وأود أن إطلاق اثنين من الشركات الناشئة، والتقاط بعض المهارات البرمجة على طول الطريق. لن يكون حتى أواخر عام 2008 أن أعود إلى التداول. مع انخفاض المال من بيع أول شركة ناشئة، عرضت التجارة آمال بعض النقد السريع بينما أحسبت الخطوة التالية.


في عام 2008 كنت & لدكو؛ يدويا & رديقو؛ تداول العقود الآجلة باستخدام برنامج يسمى T4. لقد كان يريد بعض مفاتيح الاختصار إدخال أمر مخصص، وذلك بعد اكتشاف T4 كان أبي، أخذت على التحدي المتمثل في تعلم C # (لغة البرمجة المطلوبة لاستخدام أبي) وذهب قدما وبناه بنفسي بعض مفاتيح الاختصار.


بعد الحصول على قدمي الرطب مع أبي سرعان ما كان تطلعات أكبر: أردت تعليم الكمبيوتر للتجارة بالنسبة لي. قدمت أبي كل من تيار بيانات السوق وطريقة سهلة لإرسال أوامر إلى الصرف - كل ما كان علي القيام به هو خلق المنطق في الوسط.


في ما يلي لقطة شاشة لنافذة تداول T4. ما كان باردا هو أنه عندما حصلت على برنامج عملي كنت قادرا على مشاهدة تجارة الكمبيوتر على هذه الواجهة نفسها بالضبط. مشاهدة أوامر حقيقية ظهرت داخل وخارج (من تلقاء أنفسهم مع بلدي المال الحقيقي) كان على حد سواء مثيرة ومخيفة.


تصميم خوارزمي.


منذ البداية كان هدفي لإعداد نظام مثل أنني يمكن أن تكون واثقة إلى حد معقول أنا & رسكو؛ د كسب المال قبل أي وقت مضى جعل أي الصفقات الحية. ولتحقيق ذلك، كنت بحاجة لبناء إطار محاكاة التداول الذي من شأنه - بأكبر قدر ممكن - محاكاة التداول المباشر.


في حين أن التداول في الوضع الحي يتطلب تحديثات السوق المعالجة المتدفقة من خلال أبي، يتطلب وضع المحاكاة تحديثات سوق القراءة من ملف البيانات. لجمع هذه البيانات أنا إعداد النسخة الأولى من برنامجي للاتصال ببساطة إلى أبي وتسجيل التحديثات السوق مع الطوابع الزمنية. انتهى بي الأمر باستخدام 4 أسابيع بقيمة بيانات السوق الأخيرة لتدريب واختبار النظام الخاص بي على.


مع وجود إطار أساسي في مكان لا يزال لديه مهمة معرفة كيفية جعل نظام التداول مربحة. كما اتضح لي خوارزمية سوف تنهار إلى عنصرين متميزين، والتي سوف تستكشف بدورها:


التنبؤ بتحركات الأسعار؛ وجعل الصفقات المربحة.


توقع تحركات الأسعار.


ولعل أحد المكونات الواضحة لأي نظام تجاري قادر على التنبؤ بأين تتحرك الأسعار. ولم يكن الألغام استثناء. عرفت السعر الحالي كمتوسط ​​العرض الداخلي والعرض الداخلي، وقمت بتعيين هدف التنبؤ بأين سيكون السعر في الثواني العشر القادمة. سوف خوارزمي بلدي في حاجة إلى الخروج مع هذا التنبؤ لحظة تلو لحظة طوال يوم التداول.


إنشاء & أمب؛ تحسين المؤشرات.


أنا خلقت حفنة من المؤشرات التي ثبت أن لديها قدرة ذات مغزى للتنبؤ تحركات الأسعار على المدى القصير. وأنتج كل مؤشر عددا كان إيجابيا أو سلبيا. وكان المؤشر مفيدا إذا كان عدد إيجابي في معظم الأحيان لا يتطابق مع ارتفاع السوق ورقم سلبي يتوافق مع تراجع السوق.


نظام بلدي يسمح لي لتحديد بسرعة كم القدرة التنبؤية أي مؤشر كان ذلك كنت قادرا على تجربة مع الكثير من المؤشرات المختلفة لمعرفة ما عملت. كان للكثير من المؤشرات متغيرات في الصيغ التي أنتجتها، وكنت قادرا على إيجاد القيم المثلى لتلك المتغيرات من خلال إجراء مقارنات جنبا إلى جنب للنتائج التي تحققت مع قيم متفاوتة.


وكانت المؤشرات الأكثر فائدة كلها بسيطة نسبيا واستندت إلى الأحداث الأخيرة في السوق كنت التداول وكذلك أسواق الأوراق المالية المترابطة.


مما يجعل التنبؤات بالضبط سعر الخطوة.


وجود مؤشرات تتوقع ببساطة حركة سعر أعلى أو لأسفل لم تكن كافية. كنت بحاجة لمعرفة بالضبط كم حركة السعر كان متوقعا من قبل كل قيمة ممكنة من كل مؤشر. كنت في حاجة إلى صيغة من شأنها تحويل قيمة المؤشر إلى التنبؤ السعر.


ولتحقيق ذلك، تعقبت تحركات السعر المتوقعة في 50 دلو تعتمد على النطاق الذي انخفضت فيه قيمة المؤشر. وقد أنتج ذلك تنبؤات فريدة لكل مجموعة كانت قادرا على الرسم البياني في إكسيل. كما ترون ارتفاع السعر المتوقع مع زيادة قيمة المؤشر.


استنادا إلى الرسم البياني مثل هذا كنت قادرا على جعل صيغة لتناسب منحنى. في البداية فعلت هذا & لدكو؛ منحنى المناسب & رديقو؛ يدويا ولكن سرعان ما كتبت بعض التعليمات البرمجية لأتمتة هذه العملية.


لاحظ أنه ليس كل منحنيات المؤشر لها نفس الشكل. نلاحظ أيضا تم توزيع الدلاء لوغاريتميا وذلك لنشر نقاط البيانات بالتساوي. وأخيرا نلاحظ أن قيم المؤشر السلبي (والتنبؤات المناظرة لأسعارها المناظرة) قد انقلبت مع القيم الإيجابية. (تعاملت خوارزمي مع صعودا وهبوطا بالضبط نفس الشيء).


الجمع بين المؤشرات للتنبؤ واحد.


ومن الأمور الهامة التي ينبغي مراعاتها أن كل مؤشر ليس مستقلا تماما. لم أكن ببساطة مجرد إضافة ما يصل كل التوقعات التي كل مؤشر جعل بشكل فردي. وكان المفتاح هو معرفة القيمة التنبؤية الإضافية التي يتخطى كل مؤشر ما كان متوقعا بالفعل. لم يكن هذا صعب التنفيذ ولكن لم يعني أنه إذا كنت & لدكو؛ منحنى المناسب & رديقو؛ مؤشرات متعددة في نفس الوقت كان لي أن نكون حذرين. تغيير واحد من شأنه أن يؤثر على توقعات أخرى.


من أجل & لدكو؛ منحنى صالح & رديقو؛ كل من المؤشرات في نفس الوقت أنا إعداد محسن خطوة 30٪ فقط من الطريق نحو منحنيات التنبؤ الجديدة مع كل تمريرة. مع هذه القفزة 30٪ وجدت أن منحنيات التنبؤ ستستقر في غضون عدد قليل من يمر.


مع كل مؤشر الآن يعطي لنا انها التنبؤ السعر إضافية يمكن ببساطة إضافتها إلى إنتاج التنبؤ واحد من حيث أن السوق سيكون في 10 ثانية.


لماذا التنبؤ الأسعار ليست كافية.


قد تعتقد أنه مع هذه الحافة في السوق كنت ذهبية. ولكن يجب أن نضع في اعتبارنا أن السوق يتكون من عروض الأسعار والعروض - إنه ليس سعر سوق واحد فقط. النجاح في تجارة عالية التردد يأتي إلى الحصول على أسعار جيدة وانها ليست سهلة.


العوامل التالية تجعل خلق نظام مربح صعبا:


مع كل التجارة اضطررت لدفع عمولات لكل من وسيط بلدي وتبادل. انتشار (الفرق بين أعلى عرض وأقل عرض) يعني أنه إذا كنت لمجرد شراء وبيع عشوائيا أنا & رسقوو؛ ر يكون فقدان طن من المال. وكان معظم حجم السوق السير الأخرى التي من شأنها أن تنفذ فقط التجارة معي إذا كانوا يعتقدون أن لديهم بعض الحافة الإحصائية. رؤية عرض لا يضمن أن أتمكن من شرائه. وبحلول الوقت الذي حصلت طلبي شراء إلى تبادل كان من الممكن جدا أن هذا العرض قد تم إلغاء. كاعب سوق صغير لم يكن هناك أي وسيلة يمكن أن تتنافس على السرعة وحدها.


بناء محاكاة التداول الكاملة.


لذلك كان لدي إطار يسمح لي بمراجعة النتائج وتحسين المؤشرات. ولكن كان علي أن أبعد من ذلك - كنت في حاجة إلى إطار من شأنه أن يسمح لي أن باكتست وتحسين نظام التداول الكامل؛ واحد حيث كنت إرسال أوامر والحصول على المناصب. في هذه الحالة، يتم تحسين المبلغ الإجمالي لل & أمب؛ L وإلى حد ما متوسط ​​P & أمب؛ L لكل صفقة.


وهذا سيكون أكثر صعوبة، وفي بعض النواحي من المستحيل أن نموذج بالضبط ولكن أنا فعلت أفضل ما أستطيع. وفيما يلي بعض القضايا التي تعين علي التعامل معها:


عندما تم إرسال أمر إلى السوق في محاكاة كان علي أن نموذج الوقت تأخر. وكون نظامي رأى عرضا لا يعني أنه يمكن أن يشتريه على الفور. سيقوم النظام بإرسال النظام، والانتظار حوالي 20 ميلي ثانية، ثم فقط إذا كان العرض لا يزال هناك كان يعتبر التجارة المنفذة. وكان هذا غير دقيق لأن الوقت الحقيقي تأخر كان غير متناسقة وغير المبلغ عنها. عندما وضعت عروض الأسعار أو العروض كان علي أن ألقي نظرة على تدفق تنفيذ التجارة (التي تقدمها أبي) واستخدام تلك لقياس عندما طلبي قد حصلت أعدم ضد. للقيام بهذا الحق اضطررت إلى تتبع موقف طلبي في قائمة الانتظار. (لأول مرة في أول نظام الخروج). مرة أخرى، لا يمكن أن تفعل هذا تماما ولكن أنا جعلت أفضل تقريب.


لتنقيح بلدي تنفيذ أوامر المحاكاة ما فعلته كان أخذ ملفات السجل من التداول المباشر من خلال أبي ومقارنتها لتسجيل الملفات التي تنتجها محاكاة التداول من نفس الفترة الزمنية بالضبط. تمكنت من الحصول على المحاكاة الخاصة بي إلى درجة أنه كان دقيقا جدا وللأجزاء التي كان من المستحيل أن نموذج بالضبط تأكدت من أن تنتج على الأقل نتائج كانت مشابهة إحصائيا (في المقاييس اعتقدت كانت مهمة).


جعل الصفقات مربحة.


مع نموذج محاكاة النظام في مكان يمكنني الآن إرسال أوامر في وضع المحاكاة ونرى محاكاة P & أمب؛ L. ولكن كيف يمكن لنظام بلدي معرفة متى وأين لشراء وبيع؟


وكانت توقعات حركة الأسعار نقطة انطلاق ولكن ليس القصة بأكملها. ما فعلته هو إنشاء نظام التهديف لكل من مستويات الأسعار 5 على العرض والعرض. وشمل ذلك مستوى واحدا فوق العرض الداخلي (لأمر شراء) ومستوى أقل من العرض الداخلي (لأمر بيع).


إذا كانت النتيجة في أي مستوى سعر معين فوق عتبة معينة مما يعني أن نظامي يجب أن يكون عرض تسعير / عرض نشط هناك - أقل من الحد الأدنى ثم أي أوامر نشطة ينبغي إلغاؤها. وبناء على هذا لم يكن من غير المألوف أن نظام بلدي فلاش عرض في السوق ثم إلغاء ذلك فورا. (على الرغم من أنني حاولت تقليل هذا كما انها مزعج كما هيك لأي شخص يبحث في الشاشة مع عيون البشرية - بما في ذلك لي.)


تم احتساب درجات مستوى السعر بناء على العوامل التالية:


توقعات حركة السعر (التي ناقشناها سابقا). مستوى السعر في السؤال. (المستويات الداخلية يعني كان هناك حاجة إلى مزيد من التنبؤات حركة السعر.) عدد العقود أمام طلبي في قائمة الانتظار. (أقل كان أفضل.) عدد العقود وراء طلبي في قائمة الانتظار. (كان أكثر أفضل.)


أساسا هذه العوامل خدمت لتحديد & لدكو؛ آمنة & رديقو؛ أماكن لتقديم العطاءات / العرض. وكان التنبؤ حركة السعر وحده غير كاف لأنه لم يكن يفسر حقيقة أنه عند وضع محاولة لم يكن شغلها تلقائيا - أنا فقط حصلت على شغل إذا كان شخص ما بيعت لي هناك. والواقع أن مجرد شخص يبيع لي بسعر معين قد غير الاحتمالات الإحصائية للتجارة.


وكانت المتغيرات المستخدمة في هذه الخطوة كلها تخضع للتحسين. وقد تم ذلك بالطريقة نفسها كما أنني الأمثل المتغيرات في مؤشرات التحرك السعر إلا في هذه الحالة كنت الأمثل ل خط الأساس P & أمب؛ L.


عند التداول كبشر غالبا ما يكون لدينا مشاعر قوية والتحيزات التي يمكن أن تؤدي إلى أقل من القرارات المثلى. ومن الواضح أنني لم أكن أريد تدوين هذه التحيزات. في ما يلي بعض العوامل التي تجاهلها نظامي:


السعر الذي تم إدخاله - في مكتب التداول من الشائع جدا أن نسمع محادثة حول السعر الذي شخص ما طويلة أو قصيرة كما لو كان ذلك ينبغي أن تؤثر على اتخاذ القرارات في المستقبل. في حين أن هذا له بعض الصفة كجزء من استراتيجية الحد من المخاطر فإنه حقا ليس له تأثير على مسار المستقبل للأحداث في السوق. لذلك برنامج بلدي تجاهل تماما هذه المعلومات. إنه نفس المفهوم الذي يتجاهل التكاليف الغارقة. الذهاب قصيرة مقابل الخروج من موقف طويل - عادة ما يكون المتداول معايير مختلفة التي تحدد مكان لبيع موقف طويل مقابل أين تذهب قصيرة. ولكن من وجهة نظري الخوارزميات لم يكن هناك سبب للتمييز. إذا توقعت خوارزمي أن عملية البيع الهبوطية كانت فكرة جيدة بغض النظر عما إذا كانت طويلة أو قصيرة أم مسطحة. A & لدكو؛ مضاعفة تصل & رديقو؛ استراتيجية - هذه هي استراتيجية مشتركة حيث التجار سوف شراء المزيد من الأسهم في حال أن هناك التجارة الأصلية يتعارض معها. يؤدي ذلك إلى انخفاض متوسط ​​سعر الشراء ويعني متى (أو إذا) يتحول السهم من حولك وسيتم تعيين لك لجعل أموالك في أي وقت من الأوقات. في رأيي هذا هو حقا استراتيجية رهيبة إلا إذا كنت و رسكو؛ بوفيه وارن. أنت خداع في التفكير بأنك تقوم بعمل جيد لأن معظم الصفقات الخاصة بك ستكون الفائزين. المشكلة هي عندما تخسر تفقد كبيرة. التأثير الآخر هو أنه يجعل من الصعب الحكم إذا كان لديك فعلا ميزة في السوق أو مجرد الحصول على الحظ. أن تكون قادرة على رصد وتأكيد أن برنامجي لم يكن في الواقع لديها ميزة كان هدفا هاما.


وبما أن خوارزمي اتخذت القرارات بنفس الطريقة بغض النظر عن مكان دخولها في التجارة أو إذا كانت طويلة أو قصيرة في الوقت الحالي، فإنها تجلس أحيانا في بعض الصفقات الكبيرة الخاسرة (بالإضافة إلى بعض الصفقات الفائزة الكبيرة). ولكن، يجب ألا تعتقد أنه لم يكن هناك أي إدارة للمخاطر.


لإدارة المخاطر فرضت الحد الأقصى لحجم الموقع من عقدين في وقت واحد، تصطدم أحيانا في أيام عالية الحجم. كما كان لدي حد أقصى للحد اليومي للوقاية من أي ظروف سوق غير متوقعة أو خلل في برنامجي. تم فرض هذه الحدود في التعليمات البرمجية ولكن أيضا في الخلفية من خلال وسيط بلدي. كما حدث أنا لم تواجه أي مشاكل كبيرة.


منذ اللحظة التي بدأت العمل على برنامجي استغرق مني حوالي 6 أشهر قبل أن حصلت على نقطة الربحية وبدأ تشغيله على الهواء مباشرة. على الرغم من أن تكون عادلة قدرا كبيرا من الوقت كان تعلم لغة برمجة جديدة. كما عملت على تحسين البرنامج رأيت زيادة الأرباح لكل من الأشهر الأربعة المقبلة.


كل أسبوع أود إعادة تدريب النظام الخاص بي على أساس 4 أسابيع السابقة يستحق البيانات. لقد وجدت هذا ضرب التوازن الصحيح بين التقاط الاتجاهات السلوكية السوق الأخيرة والتأمين على خوارزمي بلدي كان لديه ما يكفي من البيانات لإنشاء أنماط ذات مغزى. كما بدأ التدريب أخذ المزيد والمزيد من الوقت أنا تقسيمه بحيث يمكن أن يؤديها 8 أجهزة افتراضية باستخدام الأمازون EC2. ثم تم تجميع النتائج على الجهاز المحلي.


وكانت نقطة عالية من التداول بلدي أكتوبر 2009 عندما جعلت ما يقرب من 100K. بعد ذلك واصلت لقضاء الأشهر الأربعة المقبلة في محاولة لتحسين برنامجي على الرغم من انخفاض الأرباح كل شهر. للأسف من هذه النقطة أعتقد أنني & أمب؛ د نفذت كل ما عندي أفضل الأفكار لأن شيئا حاولت يبدو أن يساعد كثيرا.


مع الإحباط من عدم القدرة على إجراء تحسينات وعدم وجود شعور النمو بدأت التفكير في اتجاه جديد. أنا إد 6 شركات تجارية عالية التردد المختلفة لمعرفة ما إذا كانت مهتمة بشراء برنامجي والتعاقد معي للعمل من أجلهم. لم يرد أحد. كان لدي بعض الأفكار بدء التشغيل الجديدة أردت أن أعمل على ذلك لم أكن متابعة.


أوبديت - لقد نشرت هذا على هاكر الأخبار وأنها قد حصلت على الكثير من الاهتمام. أريد فقط أن أقول إنني لا أدافع عن أي شخص يحاول أن يفعل شيئا من هذا القبيل بأنفسهم الآن. كنت في حاجة الى فريق من الناس الذكية حقا مع مجموعة من الخبرات لديهم أي أمل في المنافسة. حتى عندما كنت أفعل هذا أعتقد أنه كان من النادر جدا للأفراد لتحقيق النجاح (على الرغم من أنني قد سمعت من الآخرين.)


هناك تعليق في الجزء العلوي من الصفحة التي تشير إلى "الإحصاءات التلاعب" ويشير لي باعتباره & لدكو؛ المستثمر التجزئة & رديقو؛ أن كوانتس من شأنه أن & لدكو؛ اختيار بسعادة قبالة & رديقو؛. هذا تعليق مؤسف إلى حد ما أن ببساطة لا يستند في الواقع. وضع ذلك جانبا هناك بعض التعليقات المثيرة للاهتمام: news. ycombinator / البند؟ إد = 4748624.


أوبديت # 2 - لقد نشرت سؤالا متابعا للمتابعة يجيب عن بعض الأسئلة الشائعة التي تلقيتها من التجار حول هذه المشاركة.


ديليديفيانت معجب بهذا.


مرحبا، أنا جيسي، مؤسس ثينكلاب. أعيش واللعب في سان فرانسيسكو. لقد وجدت بيتي على شبكة الإنترنت .. أهلا وسهلا بك!


بناء استراتيجيات أفضل! الجزء الرابع: تعلم الآلة.


وكان الأزرق العميق أول كمبيوتر فاز في بطولة العالم الشطرنج. كان ذلك عام 1996، واستغرق الأمر 20 عاما حتى برنامج آخر، ألفاغو، يمكن أن هزيمة أفضل لاعب غو الإنسان. كان الأزرق العميق نظاما يستند إلى نموذج مع قواعد الشطرنج هاردويريد. ألفاغو هو نظام استخراج البيانات، شبكة العصبية العميقة المدربة مع الآلاف من الألعاب الذهاب. لم تتحسن الأجهزة، ولكن انفراجة في البرنامج كان ضروريا لخطوة من الضرب كبار لاعبي الشطرنج لضرب كبار اللاعبين الذهاب.


في هذا الجزء 4 من سلسلة مصغرة نحن & # 8217؛ سوف ننظر في نهج استخراج البيانات لتطوير استراتيجيات التداول. هذا الأسلوب لا يهتم بآليات السوق. انها مجرد مسح منحنيات السعر أو مصادر البيانات الأخرى للنماذج التنبؤية. تعلم الآلة أو & # 8220؛ الذكاء الاصطناعي & # 8221؛ لا تشارك دائما في استراتيجيات استخراج البيانات. في الواقع الأكثر شعبية & # 8211؛ والمربحة بشكل مثير للدهشة & # 8211؛ طريقة استخراج البيانات يعمل دون أي الشبكات العصبية الهوى أو آلات ناقلات الدعم.


مبادئ التعلم الآلي.


يتم تغذية خوارزمية التعلم مع عينات البيانات، وعادة ما تستمد بطريقة ما من الأسعار التاريخية. تتكون كل عينة من متغيرات n × 1 .. × n، وتسمى التنبئ أو الميزات. يمكن التنبؤات يمكن أن تكون عائدات السعر من آخر ن القضبان، أو مجموعة من المؤشرات الكلاسيكية، أو أي وظائف أخرى يمكن تخيلها من منحنى السعر (I & # 8217؛ حتى رأيت بكسل من صورة الرسم البياني السعر المستخدمة كمنبؤات لعصبية شبكة الاتصال!). كل عينة تشمل عادة متغير الهدف y، مثل عودة التجارة المقبلة بعد أخذ العينة، أو حركة السعر المقبل. في عملية التدريب، والخوارزمية يتعلم التنبؤ الهدف ذ من التنبؤات × 1 .. س ن. الذاكرة & # 8216؛ الذاكرة & # 8217؛ يتم تخزينها في بنية بيانات اسمها نموذج خاص بالخوارزمية. يمكن أن يكون هذا النموذج وظيفة مع قواعد التنبؤ في كود C، التي تم إنشاؤها بواسطة عملية التدريب. أو يمكن أن يكون مجموعة من أوزان الاتصال للشبكة العصبية.


يجب على المتنبئين تحمل معلومات كافية للتنبؤ الهدف ذ مع بعض الدقة. كما أنها غالبا ما تفي بمتطلبين رسميين. أولا، يجب أن تكون جميع قيم التنبؤ في نفس النطاق، مثل -1 .. +1 (لمعظم خوارزميات R) أو -100 .. +100 (لخوارزميات زورو أو تسب). لذلك تحتاج إلى تطبيع لهم في بعض الطريق قبل إرسالها إلى الجهاز. ثانيا، يجب أن تكون العينات متوازنة، أي موزعة بالتساوي على جميع قيم المتغير المستهدف. لذلك يجب أن يكون هناك حول العديد من الفوز كما تفقد العينات. إذا لم تلاحظ هذين الشرطين، فإنك تتساءل عن سبب حصولك على نتائج سيئة من خوارزمية تعلم الآلة.


تتوقع خوارزميات الانحدار قيمة رقمية، مثل حجم وعلامة حركة السعر التالية. تتنبأ خوارزميات التصنيف بفئة عينة نوعية، على سبيل المثال، ما إذا كانت النتيجة تسبق الفوز أو الخسارة. بعض الخوارزميات، مثل الشبكات العصبية، أشجار القرار، أو دعم ناقلات الآلات، يمكن تشغيلها في كلا الوضعين.


وهناك عدد قليل من الخوارزميات تعلم تقسيم العينات إلى فئات دون الحاجة إلى أي هدف ذ. هذا التعلم غير الخاضع للرقابة، بدلا من التعلم تحت الإشراف باستخدام الهدف. في مكان ما في المنتصف هو التعلم التعزيز، حيث يقوم النظام بتدريب نفسه عن طريق تشغيل المحاكاة مع ميزات معينة، واستخدام النتيجة كهدف التدريب. ألفازيرو، خليفة ألفاغو، استخدم التعلم التعزيز من خلال اللعب الملايين من ألعاب الذهاب ضد نفسها. في مجال التمويل هناك عدد قليل من التطبيقات للتعلم غير الخاضعة للرقابة أو التعزيز. 99٪ من استراتيجيات التعلم الآلي تستخدم التعلم تحت الإشراف.


أيا كانت الإشارات التي نستخدمها للتنبؤات في التمويل، فإنها على الأرجح تحتوي على الكثير من الضجيج وقليل من المعلومات، وسوف تكون غير مستقرة على رأسها. لذلك التنبؤ المالي هو واحد من أصعب المهام في التعلم الآلي. الخوارزميات الأكثر تعقيدا لا تحقق بالضرورة نتائج أفضل. اختيار التنبؤات أمر بالغ الأهمية للنجاح. ليست فكرة جيدة لاستخدام الكثير من التنبؤات، لأن هذا يسبب ببساطة الإفراط في الفشل والفشل في الخروج من عملية العينة. لذلك استراتيجيات استخراج البيانات غالبا ما تطبق خوارزمية الاختيار الأولي الذي يحدد عدد قليل من التنبؤات من مجموعة من العديد. ويمكن أن يستند الاختيار المسبق إلى العلاقة بين المتنبئات، وعلى الأهمية، على محتوى المعلومات، أو ببساطة على النجاح التنبؤ مع مجموعة اختبار. التجارب العملية مع اختيار ميزة يمكن العثور عليها في مقالة حديثة عن بلوق روبوت الثروة.


هنا & # 8217؛ s قائمة من الأكثر شعبية استخراج البيانات الطرق المستخدمة في التمويل.


1. حساء المؤشر.


معظم النظم التجارية نحن & # 8217؛ إعادة البرمجة للعملاء لا تستند إلى نموذج مالي. العميل يريد فقط إشارات التجارة من بعض المؤشرات الفنية، تصفيتها مع المؤشرات الفنية الأخرى في تركيبة مع المزيد من المؤشرات الفنية. وعندما سئل عن كيف يمكن لهذا الخليط من المؤشرات أن يكون استراتيجية مربحة، أجاب عادة: & # 8220؛ ثق بي. I & # 8217؛ م التداول يدويا، وأنه يعمل. & # 8221؛


لقد فعلت ذلك بالفعل. على الأقل في بعض الأحيان. على الرغم من أن معظم تلك النظم لم يمر اختبار وفا (وبعض حتى لا باكتست بسيط)، وعدد كبير من المستغرب فعلت. وكانت تلك أيضا في كثير من الأحيان مربحة في التداول الحقيقي. وقد أجرى العميل تجربة منهجية للمؤشرات الفنية حتى وجد مزيجا يعمل في التداول المباشر مع أصول معينة. هذه الطريقة من التحليل الفني التجريبي والخطأ هو نهج استخراج البيانات الكلاسيكية، مجرد إعدام من قبل الإنسان وليس من قبل آلة. لا أستطيع حقا أن أوصي هذا الأسلوب & # 8211؛ والكثير من الحظ، لا الكلام عن المال، وربما تشارك & # 8211؛ ولكن يمكنني أن أشهد أنه يؤدي أحيانا إلى أنظمة مربحة.


2. أنماط شمعة.


لا ينبغي الخلط مع تلك أنماط الشموع اليابانية التي كان لها أفضل قبل تاريخ طويل، منذ فترة طويلة. المعادل الحديث هو تداول حركة السعر. أنت & # 8217؛ لا تزال تبحث في مفتوحة، عالية، منخفضة، وإغلاق الشموع. أنت & # 8217؛ لا تزال تأمل في العثور على نمط يتنبأ بإتجاه السعر. ولكن أنت & # 8217؛ الآن استخراج البيانات المعاصرة السعر المنحنيات لجمع تلك الأنماط. وهناك حزم برامج لهذا الغرض. يبحثون عن أنماط مربحة من قبل بعض المعايير المعرفة من قبل المستخدم، واستخدامها لبناء وظيفة كشف نمط معين. يمكن أن يبدو مثل هذا واحد (من زورو & # 8217؛ ق نمط محلل):


ترجع الدالة C 1 عندما تطابق الإشارات أحد الأنماط، وإلا 0. يمكنك أن ترى من الشفرة الطويلة أن هذه ليست أسرع طريقة للكشف عن الأنماط. طريقة أفضل، التي يستخدمها زورو عندما لا يتم تصدير وظيفة الكشف، هو فرز الإشارات من حيث حجمها والتحقق من ترتيب الفرز. ومثال على هذا النظام يمكن العثور عليها هنا.


يمكن سعر التداول العمل حقا العمل؟ تماما مثل حساء المؤشر، فإنه لا يستند إلى أي نموذج مالي عقلاني. يمكن للمرء أن يتصور في أفضل الأحوال أن تسلسل تحركات الأسعار يسبب المشاركين في السوق للرد بطريقة معينة، وبهذه الطريقة إنشاء نمط تنبؤي مؤقت. ومع ذلك فإن عدد من أنماط محدودة جدا عند النظر فقط في تسلسل عدد قليل من الشموع المتجاورة. الخطوة التالية هي مقارنة الشموع التي ليست متاخمة، ولكن يتم اختيارها بشكل تعسفي خلال فترة زمنية أطول. وبهذه الطريقة يمكنك الحصول على عدد غير محدود تقريبا من الأنماط & # 8211؛ ولكن على حساب ترك أخيرا مجال العقلاني. من الصعب أن نتخيل كيف يمكن توقع حركة السعر من قبل بعض أنماط الشموع منذ أسابيع.


ومع ذلك، هناك الكثير من الجهد في ذلك. يدير زميل المدون، دانيال فرنانديز، موقع الاشتراك على الانترنت (أسيريكوي) المتخصصة في استخراج البيانات أنماط شمعة. انه صقل نمط التداول وصولا الى أصغر التفاصيل، وإذا كان أي شخص من أي وقت مضى تحقيق أي ربح بهذه الطريقة، سيكون له. ولكن لمشتركيه & # 8217؛ خيبة أمل، تداول أنماطه الحية (كوريكوانت) أنتج نتائج مختلفة جدا من له باكتيستس رائعة. إذا كانت أنظمة العمل السعر مربحة موجودة حقا، على ما يبدو لا أحد قد وجدت لهم حتى الآن.


3. الانحدار الخطي.


أساس بسيط من العديد من خوارزميات التعلم الآلي المعقدة: التنبؤ المتغير الهدف ذ من قبل مزيج خطي من التنبؤات × 1 .. س ن.


والمعاملات a هي النموذج. يتم حسابها لتقليل مجموع الاختلافات المربعة بين القيم الحقيقية y من عينات التدريب وتوقعها y من الصيغة أعلاه:


للعينات الموزعة العادية، والتقليل من الممكن مع بعض الحساب المصفوفة، لذلك لا حاجة التكرارات. في الحالة n = 1 & # 8211؛ مع متغير واحد فقط متغير x & # 8211؛ يتم تقليل صيغة الانحدار إلى.


وهو الانحدار الخطي البسيط، بدلا من الانحدار الخطي متعدد المتغيرات حيث n & غ؛ 1 - الانحدار الخطي البسيط متوفر في معظم منصات التداول، f. i. مع مؤشر لينريغ في تا-ليب. مع y = برايس و x = تايم & # 8217؛ s غالبا ما تستخدم كبديل للمتوسط ​​المتحرك. الانحدار الخطي متعدد المتغيرات متاح في منصة R من خلال الدالة (..) التي تأتي مع التثبيت القياسي. البديل هو الانحدار متعدد الحدود. مثل الانحدار البسيط فإنه يستخدم متغير واحد فقط متغير x، ولكن أيضا مربعه ودرجاته العليا، بحيث x n == x n:


مع n = 2 أو n = 3، غالبا ما يستخدم الانحدار متعدد الحدود للتنبؤ بالسعر المتوسط ​​التالي من الأسعار المسطحة للأشرطة الأخيرة. وظيفة بوليفيت من ماتلاب، R، زورو، والعديد من المنصات الأخرى يمكن أن تستخدم لانحدار متعدد الحدود.


4. بيرسيبترون.


غالبا ما يشار إليها باسم الشبكة العصبية مع واحد فقط من الخلايا العصبية. في الواقع بيرسيبترون هو وظيفة الانحدار مثل أعلاه، ولكن مع نتيجة ثنائية، مما يسمى الانحدار اللوجستي. انها & # 8217؛ s لا الانحدار الرغم من ذلك، انها & # 8217؛ s خوارزمية التصنيف. تولد الدالة زورو & # 8217 s (بيرسيبترون، & # 8230؛) شفرة C ترجع إما 100 أو -100، وتعتمد على ما إذا كانت النتيجة المتوقعة أعلى من عتبة أم لا:


يمكنك أن ترى أن صفيف سيغ يعادل الميزات x n في صيغة الانحدار، والعوامل الرقمية هي المعاملات n.


5. الشبكات الإلكترونية N.


الانحدار الخطي أو اللوجستي يمكن أن تحل المشاكل الخطية فقط. العديد من لا تقع في هذه الفئة & # 8211؛ مثال مشهور هو التنبؤ الناتج من وظيفة شور بسيطة. وعلى الأرجح أيضا التنبؤ الأسعار أو عائدات التجارة. يمكن للشبكة العصبية الاصطناعية (أن) معالجة المشاكل غير الخطية. انها مجموعة من بيرسيبترونس التي ترتبط معا في مجموعة من الطبقات. أي بيرسيبترون هو الخلايا العصبية من الشبكة. خرجها يذهب إلى مدخلات جميع الخلايا العصبية من الطبقة التالية، مثل هذا:


وكما هو الحال في المنظور، تتعلم الشبكة العصبية أيضا من خلال تحديد المعاملات التي تقلل من الخطأ بين التنبؤ بالعينة وهدف العينة. ولكن هذا يتطلب الآن عملية تقريب، وعادة مع باكبروباغاتينغ الخطأ من الإخراج إلى المدخلات، وتحسين الأوزان في طريقها. وتفرض هذه العملية قيادتين. أولا، يجب أن تكون مخرجات الخلايا العصبية الآن وظائف مختلفة بشكل مستمر بدلا من عتبة الإدراك الحسي البسيط. ثانيا، يجب ألا تكون الشبكة عميقة جدا & # 8211؛ يجب ألا يحتوي على عدد كبير جدا من & # 8216؛ الطبقات المخفية & # 8217؛ من الخلايا العصبية بين المدخلات والمخرجات. هذا التقييد الثاني يحد من تعقيد المشاكل التي يمكن أن تحلها الشبكة العصبية القياسية.


عند استخدام الشبكة العصبية للتنبؤ بالصفقات، لديك الكثير من المعلمات التي يمكنك اللعب حولها، وإذا كنت & # 8217؛ لا حذرا، تنتج الكثير من التحيز الاختيار:


عدد الطبقات المخفية عدد الخلايا العصبية في طبقة مخفية عدد دورات باكبروباغاتيون، وعناوين اسمه معدل التعلم، وعرض خطوة من عصر الزخم، عامل الجمود للأوزان التكيف وظيفة التنشيط.


وظيفة التنشيط يحاكي عتبة بيرسيبترون. ل باكبروباغاتيون تحتاج إلى وظيفة التفريق بشكل مستمر أن يولد & # 8216؛ لينة & # 8217؛ خطوة على قيمة x معينة. عادة يتم استخدام وظيفة السيني، تانه، أو سوفتماكس. في بعض الأحيان انها أيضا وظيفة خطية التي ترجع فقط المبلغ المرجح لجميع المدخلات. في هذه الحالة يمكن استخدام الشبكة للانحدار، للتنبؤ بقيمة رقمية بدلا من نتيجة ثنائية.


الشبكات العصبية متوفرة في تركيب R القياسية (نيت، شبكة طبقة مخفية واحدة) وفي العديد من الحزم، على سبيل المثال رسنس و FCNN4R.


6. التعلم العميق.


تستخدم طرق التعلم العميق الشبكات العصبية مع العديد من الطبقات الخفية والآلاف من الخلايا العصبية، والتي لا يمكن تدريبها بشكل فعال بعد الآن من قبل باكبروباغاتيون التقليدية. أصبحت عدة طرق شعبية في السنوات الأخيرة لتدريب مثل هذه الشبكات الضخمة. وهم عادة ما قبل تدريب طبقات الخلايا العصبية الخفية لتحقيق عملية التعلم أكثر فعالية. A بولتزمان مقيدة آلة (ربم) هو خوارزمية تصنيف غير خاضعة للرقابة مع بنية شبكة خاصة لا يوجد لديه اتصالات بين الخلايا العصبية الخفية. يستخدم جهاز الاشتعال المتفرق (ساي) بنية الشبكة التقليدية، ولكن قبل القطارات الطبقات المخفية بطريقة ذكية من خلال إعادة إنتاج إشارات الإدخال على مخرجات الطبقة مع عدد قليل من الاتصالات النشطة ممكن. وتتيح هذه الأساليب لشبكات معقدة جدا لمعالجة مهام التعلم المعقدة للغاية. مثل الضرب العالم & # 8217؛ لاعب أفضل الإنسان الذهاب.


شبكات التعلم العميق متوفرة في حزم ديبنيت و دارتش R. يوفر ديبنيت أوتوينكودر، دارتش آلة بولتزمان مقيدة. أنا لم تجرب حتى الآن مع دارتش، ولكن هنا & # 8217؛ s مثال النصي R باستخدام ديبنيت أوتوينكودر مع 3 طبقات مخفية لإشارات التجارة من خلال زورو & # 8217؛ s العصبية () وظيفة:


7. دعم ناقلات الآلات.


مثل شبكة العصبية، آلة ناقلات الدعم (سفم) هو امتداد آخر للانحدار الخطي. عندما ننظر إلى صيغة الانحدار مرة أخرى،


يمكننا تفسير ملامح x ن كإحداثيات مساحة ميزة n - dimensional. تحديد المتغير الهدف y إلى قيمة ثابتة يحدد مستوي في تلك المساحة، يسمى هبربلان لأنه يحتوي على أكثر من اثنين (في الواقع، ن -1) أبعاد. تفصل اللوحة المفرطة العينات مع y & غ؛ o من العينات مع y & لوت؛ 0. ويمكن حساب المعاملات n بطريقة تجعل مسافات الطائرة أقرب العينات & # 8211؛ والتي تسمى & # 8216؛ ناقلات الدعم & # 8217؛ من الطائرة، وبالتالي اسم الخوارزمية & # 8211؛ هو الحد الأقصى. بهذه الطريقة لدينا المصنف ثنائي مع الفصل الأمثل من العينات الفائزة والخاسرة.


المشكلة: عادة لا تكون هذه العينات قابلة للفصل خطيا & # 8211؛ فهي متناثرة حول بشكل غير منتظم في الفضاء ميزة. No flat plane can be squeezed between winners and losers. If it could, we had simpler methods to calculate that plane, f. i. linear discriminant analysis . But for the common case we need the SVM trick: Adding more dimensions to the feature space. For this the SVM algorithm produces more features with a kernel function that combines any two existing predictors to a new feature. This is analogous to the step above from the simple regression to polynomial regression, where also more features are added by taking the sole predictor to the n-th power. The more dimensions you add, the easier it is to separate the samples with a flat hyperplane. This plane is then transformed back to the original n-dimensional space, getting wrinkled and crumpled on the way. By clever selecting the kernel function, the process can be performed without actually computing the transformation.


Like neural networks, SVMs can be used not only for classification, but also for regression. They also offer some parameters for optimizing and possibly overfitting the prediction process:


Kernel function. You normally use a RBF kernel (radial basis function, a symmetric kernel), but you also have the choice of other kernels, such as sigmoid, polynomial, and linear. Gamma, the width of the RBF kernel Cost parameter C, the ‘penalty’ for wrong classifications in the training samples.


An often used SVM is the libsvm library. It’s also available in R in the e1071 package. In the next and final part of this series I plan to describe a trading strategy using this SVM.


8. K-Nearest neighbor.


Compared with the heavy ANN and SVM stuff, that’s a nice simple algorithm with a unique property: It needs no training. So the samples are the model. You could use this algorithm for a trading system that learns permanently by simply adding more and more samples. The nearest neighbor algorithm computes the distances in feature space from the current feature values to the k nearest samples. A distance in n-dimensional space between two feature sets (x 1 .. x n ) and (y 1 .. y n ) is calculated just as in 2 dimensions:


The algorithm simply predicts the target from the average of the k target variables of the nearest samples, weighted by their inverse distances. It can be used for classification as well as for regression. Software tricks borrowed from computer graphics, such as an adaptive binary tree (ABT), can make the nearest neighbor search pretty fast. In my past life as computer game programmer, we used such methods in games for tasks like self-learning enemy intelligence. You can call the knn function in R for nearest neighbor prediction – or write a simple function in C for that purpose.


This is an approximation algorithm for unsupervised classification. It has some similarity, not only its name, to k-nearest neighbor. For classifying the samples, the algorithm first places k random points in the feature space. Then it assigns to any of those points all the samples with the smallest distances to it. The point is then moved to the mean of these nearest samples. This will generate a new samples assignment, since some samples are now closer to another point. The process is repeated until the assignment does not change anymore by moving the points, i. e. each point lies exactly at the mean of its nearest samples. We now have k classes of samples, each in the neighborhood of one of the k points.


This simple algorithm can produce surprisingly good results. In R, the kmeans function does the trick. An example of the k-means algorithm for classifying candle patterns can be found here: Unsupervised candlestick classification for fun and profit.


10. Naive Bayes.


This algorithm uses Bayes’ Theorem for classifying samples of non-numeric features (i. e. events ), such as the above mentioned candle patterns . Suppose that an event X (for instance, that the Open of the previous bar is below the Open of the current bar) appears in 80% of all winning samples. What is then the probability that a sample is winning when it contains event X ? It’s not 0.8 as you might think. The probability can be calculated with Bayes’ Theorem:


P(Y|X) is the probability that event Y (f. i. winning) occurs in all samples containing event X (in our example, Open(1) < Open(0) ). According to the formula, it is equal to the probability of X occurring in all winning samples (here, 0.8), multiplied by the probability of Y in all samples (around 0.5 when you were following my above advice of balanced samples) and divided by the probability of X in all samples.


If we are naive and assume that all events X are independent of each other, we can calculate the overall probability that a sample is winning by simply multiplying the probabilities P (X|winning) for every event X . This way we end up with this formula:


with a scaling factor s . For the formula to work, the features should be selected in a way that they are as independent as possible, which imposes an obstacle for using Naive Bayes in trading. For instance, the two events Close(1) < Close(0) and Open(1) < Open(0) are most likely not independent of each other. Numerical predictors can be converted to events by dividing the number into separate ranges.


The Naive Bayes algorithm is available in the ubiquitous e1071 R package.


11. Decision and regression trees.


Those trees predict an outcome or a numeric value based on a series of yes/no decisions, in a structure like the branches of a tree. Any decision is either the presence of an event or not (in case of non-numerical features) or a comparison of a feature value with a fixed threshold. A typical tree function, generated by Zorro’s tree builder, looks like this:


How is such a tree produced from a set of samples? There are several methods; Zorro uses the Shannon i nformation entropy , which already had an appearance on this blog in the Scalping article. At first it checks one of the features, let’s say x 1 . It places a hyperplane with the plane formula x 1 = t into the feature space. This hyperplane separates the samples with x 1 > t from the samples with x 1 < t . The dividing threshold t is selected so that the information gain – the difference of information entropy of the whole space, to the sum of information entropies of the two divided sub-spaces – is maximum. This is the case when the samples in the subspaces are more similar to each other than the samples in the whole space.


This process is then repeated with the next feature x 2 and two hyperplanes splitting the two subspaces. Each split is equivalent to a comparison of a feature with a threshold. By repeated splitting, we soon get a huge tree with thousands of threshold comparisons. Then the process is run backwards by pruning the tree and removing all decisions that do not lead to substantial information gain. Finally we end up with a relatively small tree as in the code above.


Decision trees have a wide range of applications. They can produce excellent predictions superior to those of neural networks or support vector machines. But they are not a one-fits-all solution, since their splitting planes are always parallel to the axes of the feature space. This somewhat limits their predictions. They can be used not only for classification, but also for regression, for instance by returning the percentage of samples contributing to a certain branch of the tree. Zorro’s tree is a regression tree. The best known classification tree algorithm is C5.0 , available in the C50 package for R.


For improving the prediction even further or overcoming the parallel-axis-limitation, an ensemble of trees can be used, called a random forest . The prediction is then generated by averaging or voting the predictions from the single trees. Random forests are available in R packages randomForest , ranger and Rborist .


استنتاج.


There are many different data mining and machine learning methods at your disposal. The critical question: what is better, a model-based or a machine learning strategy? There is no doubt that machine learning has a lot of advantages. You don’t need to care about market microstructure, economy, trader psychology, or similar soft stuff. You can concentrate on pure mathematics. Machine learning is a much more elegant, more attractive way to generate trade systems. It has all advantages on its side but one. Despite all the enthusiastic threads on trader forums, it tends to mysteriously fail in live trading.


Every second week a new paper about trading with machine learning methods is published (a few can be found below). Please take all those publications with a grain of salt. According to some papers, phantastic win rates in the range of 70%, 80%, or even 85% have been achieved. Although win rate is not the only relevant criterion – you can lose even with a high win rate – 85% accuracy in predicting trades is normally equivalent to a profit factor above 5. With such a system the involved scientists should be billionaires meanwhile. Unfortunately I never managed to reproduce those win rates with the described method, and didn’t even come close. So maybe a lot of selection bias went into the results. Or maybe I’m just too stupid.


Compared with model based strategies, I’ve seen not many successful machine learning systems so far. And from what one hears about the algorithmic methods by successful hedge funds, machine learning seems still rarely to be used. But maybe this will change in the future with the availability of more processing power and the upcoming of new algorithms for deep learning.


Classification using deep neural networks: Dixon. et. al.2016 Predicting price direction using ANN & SVM: Kara. et. al.2011 Empirical comparison of learning algorithms: Caruana. et. al.2006 Mining stock market tendency using GA & SVM: Yu. Wang. Lai.2005.


The next part of this series will deal with the practical development of a machine learning strategy.


30 thoughts on “Build Better Strategies! Part 4: Machine Learning”


مشاركة لطيفة. There is a lot of potential in these approach towards the market.


Btw are you using the code editor which comes with zorro? how is it possible to get such a colour configuration?


The colorful script is produced by WordPress. You can’t change the colors in the Zorro editor, but you can replace it with other editors that support individual colors, for instance Notepad++.


Is it then possible that notepad detects the zorro variables in the scripts? I mean that BarPeriod is remarked as it is with the zorro editor?


Theoretically yes, but for this you had to configure the syntax highlighting of Notepad++, and enter all variables in the list. As far as I know Notepad++ can also not be configured to display the function description in a window, as the Zorro editor does. There’s no perfect tool…


Concur with the final paragraph. I have tried many machine learning techniques after reading various ‘peer reviewed’ papers. But reproducing their results remains elusive. When I live test with ML I can’t seem to outperform random entry.


ML fails in live? Maybe the training of the ML has to be done with price data that include as well historical spread, roll, tick and so on?


I think reason #1 for live failure is data mining bias, caused by biased selection of inputs and parameters to the algo.


Thanks to the author for the great series of articles.


However, it should be noted that we don’t need to narrow our view with predicting only the next price move. It may happen that the next move goes against our trade in 70% of cases but it still worth making a trade. This happens when the price finally does go to the right direction but before that it may make some steps against us. If we delay the trade by one price step we will not enter the mentioned 30% of trades but for that we will increase the result of the remained 70% by one price step. So the criteria is which value is higher: N*average_result or 0.7*N*(avergae_result + price_step).


مشاركة لطيفة. If you just want to play around with some machine learning, I implemented a very simple ML tool in python and added a GUI. It’s implemented to predict time series.


Thanks JCL I found very interesting your article. I would like to ask you, from your expertise in trading, where can we download reliable historical forex data? I consider it very important due to the fact that Forex market is decentralized.


شكرا مقدما!


There is no really reliable Forex data, since every Forex broker creates their own data. They all differ slightly dependent on which liquidity providers they use. FXCM has relatively good M1 and tick data with few gaps. You can download it with Zorro.


Thanks for writing such a great article series JCL… a thoroughly enjoyable read!


I have to say though that I don’t view model-based and machine learning strategies as being mutually exclusive; I have had some OOS success by using a combination of the elements you describe.


To be more exact, I begin the system generation process by developing a ‘traditional’ mathematical model, but then use a set of online machine learning algorithms to predict the next terms of the various different time series (not the price itself) that are used within the model. The actual trading rules are then derived from the interactions between these time series. So in essence I am not just blindly throwing recent market data into an ML model in an effort to predict price action direction, but instead develop a framework based upon sound investment principles in order to point the models in the right direction. I then data mine the parameters and measure the level of data-mining bias as you’ve described also.


It’s worth mentioning however that I’ve never had much success with Forex.


Anyway, best of luck with your trading and keep up the great articles!


Thanks for posting this great mini series JCL.


I recently studied a few latest papers about ML trading, deep learning especially. Yet I found that most of them valuated the results without risk-adjusted index, i. e., they usually used ROC curve, PNL to support their experiment instead of Sharpe Ratio, for example.


Also, they seldom mentioned about the trading frequency in their experiment results, making it hard to valuate the potential profitability of those methods. لماذا هذا؟ Do you have any good suggestions to deal with those issues?


ML papers normally aim for high accuracy. Equity curve variance is of no interest. This is sort of justified because the ML prediction quality determines accuracy, not variance.


Of course, if you want to really trade such a system, variance and drawdown are important factors. A system with lower accuracy and worse prediction can in fact be preferable when it’s less dependent on market condictions.


“In fact the most popular – and surprisingly profitable – data mining method works without any fancy neural networks or support vector machines.”


Would you please name those most popular & surprisingly profitable ones. So I could directly use them.


I was referring to the Indicator Soup strategies. For obvious reasons I can’t disclose details of such a strategy, and have never developed such systems myself. We’re merely coding them. But I can tell that coming up with a profitable Indicator Soup requires a lot of work and time.


Well, i am just starting a project which use simple EMAs to predict price, it just select the correct EMAs based on past performance and algorithm selection that make some rustic degree of intelligence.


Jonathan. orregogmail offers services as MT4 EA programmer.


شكرا على writeup جيد. It in reality used to be a leisure account it.


Look complicated to more delivered agreeable from you!


By the way, how could we be in contact?


There are following issues with ML and with trading systems in general which are based on historical data analysis:


1) Historical data doesn’t encode information about future price movements.


Future price movement is independent and not related to the price history. There is absolutely no reliable pattern which can be used to systematically extract profits from the market. Applying ML methods in this domain is simply pointless and doomed to failure and is not going to work if you search for a profitable system. Of course you can curve fit any past period and come up with a profitable system for it.


The only thing which determines price movement is demand and supply and these are often the result of external factors which cannot be predicted. For example: a war breaks out somewhere or other major disaster strikes or someone just needs to buy a large amount of a foreign currency for some business/investment purpose. These sort of events will cause significant shifts in the demand supply structure of the FX market . As a consequence, prices begin to move but nobody really cares about price history just about the execution of the incoming orders. An automated trading system can only be profitable if it monitors a significant portion of the market and takes the supply and demand into account for making a trading decision. But this is not the case with any of the systems being discussed here.


2) Race to the bottom.


Even if (1) wouldn’t be true and there would be valuable information encoded in historical price data, you would still face following problem: there are thousands of gold diggers out there, all of them using similar methods and even the same tools to search for profitable systems and analyze the same historical price data. As a result, many of them will discover the same or very similar “profitable” trading systems and when they begin actually trading those systems, they will become less and less profitable due to the nature of the market.


The only sure winners in this scenario will be the technology and tool vendors.


I will be still keeping an eye on your posts as I like your approach and the scientific vigor you apply. Your blog is the best of its kind – keep the good work!


One hint: there are profitable automated systems, but they are not based on historical price data but on proprietary knowledge about the market structure and operations of the major institutions which control these markets. Let’s say there are many inefficiencies in the current system but you absolutely have no chance to find the information about those by analyzing historical price data. Instead you have to know when and how the institutions will execute market moving orders and front run them.


Thanks for the extensive comment. I often hear these arguments and they sound indeed intuitive, only problem is that they are easily proven wrong. The scientific way is experiment, not intuition. Simple tests show that past and future prices are often correlated – otherwise every second experiment on this blog had a very different outcome. Many successful funds, for instance Jim Simon’s Renaissance fund, are mainly based on algorithmic prediction.


One more thing: in my comment I have been implicitly referring to the buy side (hedge funds, traders etc) not to the sell side (market makers, banks). The second one has always the edge because they sell at the ask and buy at the bid, pocketing the spread as an additional profit to any strategy they might be running. Regarding Jim Simon’s Renaissance: I am not so sure if they have not transitioned over the time to the sell side in order to stay profitable. There is absolutely no information available about the nature of their business besides the vague statement that they are using solely quantitative algorithmic trading models…


Thanks for the informative post!


Regarding the use of some of these algorithms, a common complaint which is cited is that financial data is non-stationary…Do you find this to be a problem? Couldn’t one just use returns data instead which is (I think) stationary?


Yes, this is a problem for sure. If financial data were stationary, we’d all be rich. I’m afraid we have to live with what it is. Returns are not any more stationary than other financial data.


Hello sir, I developed some set of rules for my trading which identifies supply demand zones than volume and all other criteria. Can you help me to make it into automated system ?? If i am gonna do that myself then it can take too much time. Please contact me at svadukiagmail if you are interested.


Sure, please contact my employer at infoopgroup. de. They’ll help.


لقد لاحظت أنك لا تستثمر صفحتك، ولا تهدر حركة المرور،


يمكنك كسب مبالغ إضافية كل شهر لأنك حصلت على محتوى عالي الجودة.


If you want to know how to make extra $$$, search for: Mrdalekjd methods for $$$


Technical analysis has always been rejected and looked down upon by quants, academics, or anyone who has been trained by traditional finance theories. I have worked for proprietary trading desk of a first tier bank for a good part of my career, and surrounded by those ivy-league elites with background in finance, math, or financial engineering. I must admit none of those guys knew how to trade directions. They were good at market making, product structures, index arb, but almost none can making money trading directions. لماذا ا؟ Because none of these guys believed in technical analysis. Then again, if you are already making your millions why bother taking the risk of trading direction with your own money. For me luckily my years of training in technical analysis allowed me to really retire after laying off from the great recession. I look only at EMA, slow stochastics, and MACD; and I have made money every year since started in 2009. Technical analysis works, you just have to know how to use it!!


استراتيجيات أفضل 5: نظام التعلم آلة قصيرة الأجل.


It’s time for the 5th and final part of the Build Better Strategies series. In part 3 we’ve discussed the development process of a model-based system, and consequently we’ll conclude the series with developing a data-mining system. كانت مبادئ استخراج البيانات والتعلم الآلي موضوع الجزء 4. بالنسبة لنا على سبيل المثال التداول على المدى القصير ونحن سوف تستخدم خوارزمية التعلم العميق، أوتوينكودر مكدسة، لكنها سوف تعمل في نفس الطريق مع العديد من آلة أخرى خوارزميات التعلم. مع أدوات البرمجيات اليوم، لا يحتاج سوى 20 سطر من التعليمات البرمجية لاستراتيجية التعلم الآلي. I’ll try to explain all steps in detail.


Our example will be a research project – a machine learning experiment for answering two questions. Does a more complex algorithm – such as, more neurons and deeper learning – produce a better prediction? And are short-term price moves predictable by short-term price history? The last question came up due to my scepticism about price action trading in the previous part of this series. I got several s asking about the “trading system generators” or similar price action tools that are praised on some websites. There is no hard evidence that such tools ever produced any profit (except for their vendors) – but does this mean that they all are garbage? سنرى & # 8217.


Our experiment is simple: We collect information from the last candles of a price curve, feed it in a deep learning neural net, and use it to predict the next candles. My hypothesis is that a few candles don’t contain any useful predictive information. Of course, a nonpredictive outcome of the experiment won’t mean that I’m right, since I could have used wrong parameters or prepared the data badly. But a predictive outcome would be a hint that I’m wrong and price action trading can indeed be profitable.


Machine learning strategy development.


Step 1: The target variable.


To recap the previous part: a supervised learning algorithm is trained with a set of features in order to predict a target variable . So the first thing to determine is what this target variable shall be. A popular target, used in most papers, is the sign of the price return at the next bar. Better suited for prediction, since less susceptible to randomness, is the price difference to a more distant prediction horizon , like 3 bars from now, or same day next week. Like almost anything in trading systems, the prediction horizon is a compromise between the effects of randomness (less bars are worse) and predictability (less bars are better).


Sometimes you’re not interested in directly predicting price, but in predicting some other parameter – such as the current leg of a Zigzag indicator – that could otherwise only be determined in hindsight. Or you want to know if a certain market inefficiency will be present in the next time, especially when you’re using machine learning not directly for trading, but for filtering trades in a model-based system. Or you want to predict something entirely different, for instance the probability of a market crash tomorrow. All this is often easier to predict than the popular tomorrow’s return.


In our price action experiment we’ll use the return of a short-term price action trade as target variable. Once the target is determined, next step is selecting the features.


Step 2: The features.


A price curve is the worst case for any machine learning algorithm. Not only does it carry little signal and mostly noise , it is also nonstationary and the signal/noise ratio changes all the time. The exact ratio of signal and noise depends on what is meant with “signal”, but it is normally too low for any known machine learning algorithm to produce anything useful. So we must derive features from the price curve that contain more signal and less noise. Signal, in that context, is any information that can be used to predict the target, whatever it is. All the rest is noise.


Thus, selecting the features is critical for success – much more critical than deciding which machine learning algorithm you’re going to use. There are two approaches for selecting features. The first and most common is extracting as much information from the price curve as possible. Since you do not know where the information is hidden, you just generate a wild collection of indicators with a wide range of parameters, and hope that at least a few of them will contain the information that the algorithm needs. This is the approach that you normally find in the literature. The problem of this method: Any machine learning algorithm is easily confused by nonpredictive predictors. So it won’t do to just throw 150 indicators at it. You need some preselection algorithm that determines which of them carry useful information and which can be omitted. Without reducing the features this way to maybe eight or ten, even the deepest learning algorithm won’t produce anything useful.


The other approach, normally for experiments and research, is using only limited information from the price curve. This is the case here: Since we want to examine price action trading, we only use the last few prices as inputs, and must discard all the rest of the curve. This has the advantage that we don’t need any preselection algorithm since the number of features is limited anyway. Here are the two simple predictor functions that we use in our experiment (in C):


The two functions are supposed to carry the necessary information for price action: per-bar movement and volatility. The change function is the difference of the current price to the price of n bars before, divided by the current price. The range function is the total high-low distance of the last n candles, also in divided by the current price. And the scale function centers and compresses the values to the +/-100 range, so we divide them by 100 for getting them normalized to +/-1 . We remember that normalizing is needed for machine learning algorithms.


Step 3: Preselecting/preprocessing predictors.


When you have selected a large number of indicators or other signals as features for your algorithm, you must determine which of them is useful and which not. There are many methods for reducing the number of features, for instance:


Determine the correlations between the signals. Remove those with a strong correlation to other signals, since they do not contribute to the information. Compare the information content of signals directly, with algorithms like information entropy or decision trees. Determine the information content indirectly by comparing the signals with randomized signals; there are some software libraries for this, such as the R Boruta package. Use an algorithm like Principal Components Analysis (PCA) for generating a new signal set with reduced dimensionality. Use genetic optimization for determining the most important signals just by the most profitable results from the prediction process. Great for curve fitting if you want to publish impressive results in a research paper.


For our experiment we do not need to preselect or preprocess the features, but you can find useful information about this in articles (1), (2), and (3) listed at the end of the page.


Step 4: Select the machine learning algorithm.


R offers many different ML packages, and any of them offers many different algorithms with many different parameters. Even if you already decided about the method – here, deep learning – you have still the choice among different approaches and different R packages. Most are quite new, and you can find not many empirical information that helps your decision. You have to try them all and gain experience with different methods. For our experiment we’ve choosen the Deepnet package, which is probably the simplest and easiest to use deep learning library. This keeps our code short. We’re using its Stacked Autoencoder ( SAE ) algorithm for pre-training the network. Deepnet also offers a Restricted Boltzmann Machine ( RBM ) for pre-training, but I could not get good results from it. There are other and more complex deep learning packages for R, so you can spend a lot of time checking out all of them.


How pre-training works is easily explained, but why it works is a different matter. As to my knowledge, no one has yet come up with a solid mathematical proof that it works at all. Anyway, imagine a large neural net with many hidden layers:


Training the net means setting up the connection weights between the neurons. The usual method is error backpropagation. But it turns out that the more hidden layers you have, the worse it works. The backpropagated error terms get smaller and smaller from layer to layer, causing the first layers of the net to learn almost nothing. Which means that the predicted result becomes more and more dependent of the random initial state of the weights. This severely limited the complexity of layer-based neural nets and therefore the tasks that they can solve. At least until 10 years ago.


In 2006 scientists in Toronto first published the idea to pre-train the weights with an unsupervised learning algorithm, a restricted Boltzmann machine. This turned out a revolutionary concept. It boosted the development of artificial intelligence and allowed all sorts of new applications from Go-playing machines to self-driving cars. In the case of a stacked autoencoder, it works this way:


Select the hidden layer to train; begin with the first hidden layer. Connect its outputs to a temporary output layer that has the same structure as the network’s input layer. Feed the network with the training samples, but without the targets. Train it so that the first hidden layer reproduces the input signal – the features – at its outputs as exactly as possible. The rest of the network is ignored. During training, apply a ‘weight penalty term’ so that as few connection weights as possible are used for reproducing the signal. Now feed the outputs of the trained hidden layer to the inputs of the next untrained hidden layer, and repeat the training process so that the input signal is now reproduced at the outputs of the next layer. Repeat this process until all hidden layers are trained. We have now a ‘sparse network’ with very few layer connections that can reproduce the input signals. Now train the network with backpropagation for learning the target variable, using the pre-trained weights of the hidden layers as a starting point.


The hope is that the unsupervised pre-training process produces an internal noise-reduced abstraction of the input signals that can then be used for easier learning the target. And this indeed appears to work. No one really knows why, but several theories – see paper (4) below – try to explain that phenomenon.


Step 5: Generate a test data set.


We first need to produce a data set with features and targets so that we can test our prediction process and try out parameters. The features must be based on the same price data as in live trading, and for the target we must simulate a short-term trade. So it makes sense to generate the data not with R, but with our trading platform, which is anyway a lot faster. Here’s a small Zorro script for this, DeepSignals. c :


We’re generating 2 years of data with features calculated by our above defined change and range functions. Our target is the result of a trade with 3 bars life time. Trading costs are set to zero, so in this case the result is equivalent to the sign of the price difference at 3 bars in the future. The adviseLong function is described in the Zorro manual; it is a mighty function that automatically handles training and predicting and allows to use any R-based machine learning algorithm just as if it were a simple indicator.


In our code, the function uses the next trade return as target, and the price changes and ranges of the last 4 bars as features. The SIGNALS flag tells it not to train the data, but to export it to a. csv file. The BALANCED flag makes sure that we get as many positive as negative returns; this is important for most machine learning algorithms. Run the script in [Train] mode with our usual test asset EUR/USD selected. It generates a spreadsheet file named DeepSignalsEURUSD_L. csv that contains the features in the first 8 columns, and the trade return in the last column.


Step 6: Calibrate the algorithm.


Complex machine learning algorithms have many parameters to adjust. Some of them offer great opportunities to curve-fit the algorithm for publications. Still, we must calibrate parameters since the algorithm rarely works well with its default settings. For this, here’s an R script that reads the previously created data set and processes it with the deep learning algorithm ( DeepSignal. r ):


We’ve defined three functions neural. train , neural. predict , and neural. init for training, predicting, and initializing the neural net. The function names are not arbitrary, but follow the convention used by Zorro’s advise(NEURAL. ) function. It doesn’t matter now, but will matter later when we use the same R script for training and trading the deep learning strategy. A fourth function, TestOOS , is used for out-of-sample testing our setup.


The function neural. init seeds the R random generator with a fixed value (365 is my personal lucky number). Otherwise we would get a slightly different result any time, since the neural net is initialized with random weights. It also creates a global R list named “Models”. Most R variable types don’t need to be created beforehand, some do (don’t ask me why). The ‘<<-‘ operator is for accessing a global variable from within a function.


The function neural. train takes as input a model number and the data set to be trained. The model number identifies the trained model in the “ Models ” قائمة. A list is not really needed for this test, but we’ll need it for more complex strategies that train more than one model. The matrix containing the features and target is passed to the function as second parameter. If the XY data is not a proper matrix, which frequently happens in R depending on how you generated it, it is converted to one. Then it is split into the features ( X ) and the target ( Y ), and finally the target is converted to 1 for a positive trade outcome and 0 for a negative outcome.


The network parameters are then set up. Some are obvious, others are free to play around with:


The network structure is given by the hidden vector: c(50,100,50) defines 3 hidden layers, the first with 50, second with 100, and third with 50 neurons. That’s the parameter that we’ll later modify for determining whether deeper is better. The activation function converts the sum of neuron input values to the neuron output; most often used are sigmoid that saturates to 0 or 1, or tanh that saturates to -1 or +1.


We use tanh here since our signals are also in the +/-1 range. The output of the network is a sigmoid function since we want a prediction in the 0..1 range. But the SAE output must be “linear” so that the Stacked Autoencoder can reproduce the analog input signals on the outputs.


The learning rate controls the step size for the gradient descent in training; a lower rate means finer steps and possibly more precise prediction, but longer training time. Momentum adds a fraction of the previous step to the current one. It prevents the gradient descent from getting stuck at a tiny local minimum or saddle point. The learning rate scale is a multiplication factor for changing the learning rate after each iteration (I am not sure for what this is good, but there may be tasks where a lower learning rate on higher epochs improves the training). An epoch is a training iteration over the entire data set. Training will stop once the number of epochs is reached. More epochs mean better prediction, but longer training. The batch size is a number of random samples – a mini batch – taken out of the data set for a single training run. Splitting the data into mini batches speeds up training since the weight gradient is then calculated from fewer samples. The higher the batch size, the better is the training, but the more time it will take. The dropout is a number of randomly selected neurons that are disabled during a mini batch. This way the net learns only with a part of its neurons. This seems a strange idea, but can effectively reduce overfitting.


All these parameters are common for neural networks. Play around with them and check their effect on the result and the training time. Properly calibrating a neural net is not trivial and might be the topic of another article. The parameters are stored in the model together with the matrix of trained connection weights. So they need not to be given again in the prediction function, neural. predict . It takes the model and a vector X of features, runs it through the layers, and returns the network output, the predicted target Y . Compared with training, prediction is pretty fast since it only needs a couple thousand multiplications. If X was a row vector, it is transposed and this way converted to a column vector, otherwise the nn. predict function won’t accept it.


Use RStudio or some similar environment for conveniently working with R. Edit the path to the. csv data in the file above, source it, install the required R packages (deepnet, e1071, and caret), then call the TestOOS function from the command line. If everything works, it should print something like that:


TestOOS reads first our data set from Zorro’s Data folder. It splits the data in 80% for training ( XY. tr ) and 20% for out-of-sample testing ( XY. ts ). The training set is trained and the result stored in the Models list at index 1. The test set is further split in features ( X ) and targets ( Y ). Y is converted to binary 0 or 1 and stored in Y. ob , our vector of observed targets. We then predict the targets from the test set, convert them again to binary 0 or 1 and store them in Y. pr . For comparing the observation with the prediction, we use the confusionMatrix function from the caret package.


A confusion matrix of a binary classifier is simply a 2×2 matrix that tells how many 0’s and how many 1’s had been predicted wrongly and correctly. A lot of metrics are derived from the matrix and printed in the lines above. The most important at the moment is the 62% prediction accuracy . This may hint that I bashed price action trading a little prematurely. But of course the 62% might have been just luck. We’ll see that later when we run a WFO test.


A final advice: R packages are occasionally updated, with the possible consequence that previous R code suddenly might work differently, or not at all. This really happens, so test carefully after any update.


Step 7: The strategy.


Now that we’ve tested our algorithm and got some prediction accuracy above 50% with a test data set, we can finally code our machine learning strategy. In fact we’ve already coded most of it, we just must add a few lines to the above Zorro script that exported the data set. This is the final script for training, testing, and (theoretically) trading the system ( DeepLearn. c ):


We’re using a WFO cycle of one year, split in a 90% training and a 10% out-of-sample test period. You might ask why I have earlier used two year’s data and a different split, 80/20, for calibrating the network in step 5. This is for using differently composed data for calibrating and for walk forward testing. If we used exactly the same data, the calibration might overfit it and compromise the test.


The selected WFO parameters mean that the system is trained with about 225 days data, followed by a 25 days test or trade period. Thus, in live trading the system would retrain every 25 days, using the prices from the previous 225 days. In the literature you’ll sometimes find the recommendation to retrain a machine learning system after any trade, or at least any day. But this does not make much sense to me. When you used almost 1 year’s data for training a system, it can obviously not deteriorate after a single day. Or if it did, and only produced positive test results with daily retraining, I would strongly suspect that the results are artifacts by some coding mistake.


Training a deep network takes really a long time, in our case about 10 minutes for a network with 3 hidden layers and 200 neurons. In live trading this would be done by a second Zorro process that is automatically started by the trading Zorro. In the backtest, the system trains at any WFO cycle. Therefore using multiple cores is recommended for training many cycles in parallel. The NumCores variable at -1 activates all CPU cores but one. Multiple cores are only available in Zorro S, so a complete walk forward test with all WFO cycles can take several hours with the free version.


In the script we now train both long and short trades. For this we have to allow hedging in Training mode, since long and short positions are open at the same time. Entering a position is now dependent on the return value from the advise function, which in turn calls either the neural. train or the neural. predict function from the R script. So we’re here entering positions when the neural net predicts a result above 0.5.


The R script is now controlled by the Zorro script (for this it must have the same name, NeuralLearn. r , only with different extension). It is identical to our R script above since we’re using the same network parameters. Only one additional function is needed for supporting a WFO test:


The neural. save function stores the Models list – it now contains 2 models for long and for short trades – after every training run in Zorro’s Data folder. Since the models are stored for later use, we do not need to train them again for repeated test runs.


This is the WFO equity curve generated with the script above (EUR/USD, without trading costs):


EUR/USD equity curve with 50-100-50 network structure.


Although not all WFO cycles get a positive result, it seems that there is some predictive effect. The curve is equivalent to an annual return of 89%, achieved with a 50-100-50 hidden layer structure. We’ll check in the next step how different network structures affect the result.


Since the neural. init , neural. train , neural. predict , and neural. save functions are automatically called by Zorro’s adviseLong/adviseShort functions, there are no R functions directly called in the Zorro script. Thus the script can remain unchanged when using a different machine learning method. Only the DeepLearn. r script must be modified and the neural net, for instance, replaced by a support vector machine. For trading such a machine learning system live on a VPS, make sure that R is also installed on the VPS, the needed R packages are installed, and the path to the R terminal set up in Zorro’s ini file. Otherwise you’ll get an error message when starting the strategy.


Step 8: The experiment.


If our goal had been developing a strategy, the next steps would be the reality check, risk and money management, and preparing for live trading just as described under model-based strategy development. But for our experiment we’ll now run a series of tests, with the number of neurons per layer increased from 10 to 100 in 3 steps, and 1, 2, or 3 hidden layers (deepnet does not support more than 3). So we’re looking into the following 9 network structures: c(10), c(10,10), c(10,10,10), c(30), c(30,30), c(30,30,30), c(100), c(100,100), c(100,100,100). For this experiment you need an afternoon even with a fast PC and in multiple core mode. Here are the results (SR = Sharpe ratio, R2 = slope linearity):


We see that a simple net with only 10 neurons in a single hidden layer won’t work well for short-term prediction. Network complexity clearly improves the performance, however only up to a certain point. A good result for our system is already achieved with 3 layers x 30 neurons. Even more neurons won’t help much and sometimes even produce a worse result. This is no real surprise, since for processing only 8 inputs, 300 neurons can likely not do a better job than 100.


استنتاج.


Our goal was determining if a few candles can have predictive power and how the results are affected by the complexity of the algorithm. The results seem to suggest that short-term price movements can indeed be predicted sometimes by analyzing the changes and ranges of the last 4 candles. The prediction is not very accurate – it’s in the 58%..60% range, and most systems of the test series become unprofitable when trading costs are included. Still, I have to reconsider my opinion about price action trading. The fact that the prediction improves with network complexity is an especially convincing argument for short-term price predictability.


It would be interesting to look into the long-term stability of predictive price patterns. For this we had to run another series of experiments and modify the training period ( WFOPeriod in the script above) and the 90% IS/OOS split. This takes longer time since we must use more historical data. I have done a few tests and found so far that a year seems to be indeed a good training period. The system deteriorates with periods longer than a few years. Predictive price patterns, at least of EUR/USD, have a limited lifetime.


Where can we go from here? There’s a plethora of possibilities, for instance:


Use inputs from more candles and process them with far bigger networks with thousands of neurons. Use oversampling for expanding the training data. Prediction always improves with more training samples. Compress time series f. i. with spectal analysis and analyze not the candles, but their frequency representation with machine learning methods. Use inputs from many candles – such as, 100 – and pre-process adjacent candles with one-dimensional convolutional network layers. Use recurrent networks. Especially LSTM could be very interesting for analyzing time series – and as to my knowledge, they have been rarely used for financial prediction so far. Use an ensemble of neural networks for prediction, such as Aronson’s “oracles” and “comitees”.


Papers / Articles.


(3) V. Perervenko, Selection of Variables for Machine Learning.


I’ve added the C and R scripts to the 2016 script repository. You need both in Zorro’s Strategy folder. Zorro version 1.474, and R version 3.2.5 (64 bit) was used for the experiment, but it should also work with other versions.


62 thoughts on “Better Strategies 5: A Short-Term Machine Learning System”


I’ve tested your strategy using 30min AAPL data but “sae. dnn. train” returns all NaN in training.


(It works just decreasing neurons to less than (5,10,5)… but accuracy is 49%)


Can you help me to understand why?


شكرا مقدما.


If you have not changed any SAE parameters, look into the. csv data. It is then the only difference to the EUR/USD test. Maybe something is wrong with it.


Another fantastic article, jcl. Zorro is a remarkable environment for these experiments. Thanks for sharing your code and your approach – this really opens up an incredible number of possibilities to anyone willing to invest the time to learn how to use Zorro.


The problem with AAPL 30min data was related to the normalizing method I used (X-mean/SD).


The features range was not between -1:1 and I assume that sae. dnn need it to work…


Anyway performances are not comparable to yours 🙂


I have one question:


why do you use Zorro for creating the features in the csv file and then opening it in R?


why not create the file with all the features in R in a few lines and do the training on the file when you are already in R? instead of getting inside Zorro and then to R.


When you want R to create the features, you must still transmit the price data and the targets from Zorro to R. So you are not gaining much. Creating the features in Zorro results usually in shorter code and faster training. Features in R make only sense when you need some R package for calculating them.


Really helpful and interesting article! I would like to know if there are any English version of the book:


“Das Börsenhackerbuch: Finanziell unabhängig durch algorithmische Handelssysteme”


I am really interested on it,


Not yet, but an English version is planned.


Thanks JCL! Please let me now when the English version is ready, because I am really interested on it.


Works superbly (as always). تشكرات. One small note, if you have the package “dlm” loaded in R, TestOOS will fail with error: “Error in TestOOS() : cannot change value of locked binding for ‘X'”. This is due to there being a function X in the dlm package, so the name is locked when the package is loaded. Easily fixed by either renaming occurrences of the variable X to something else, or temporarily detaching the dlm package with: detach(“package:dlm”, unload=TRUE)


Thanks for the info with the dlm package. I admit that ‘X’ is not a particular good name for a variable, but a function named ‘X’ in a distributed package is even a bit worse.


Results below were generated by revised version of DeepSignals. r – only change was use of LSTM net from the rnn package on CRAN. The authors of the package regard their LSTM implementation as “experimental” and do not feel it is as yet learning properly, so hopefully more improvement to come there. (Spent ages trying to accomplish the LSTM element using the mxnet package but gave up as couldn’t figure out the correct input format when using multiple training features.)


Will post results of full WFO when I have finished LSTM version of DeepLearn. r.


Confusion Matrix and Statistics.


95% CI : (0.5699, 0.5956)


No Information Rate : 0.5002.


P-Value [Acc > NIR] : <2e-16.


Mcnemar's Test P-Value : 0.2438.


Pos Pred Value : 0.5844.


Neg Pred Value : 0.5813.


Detection Rate : 0.2862.


Detection Prevalence : 0.4897.


Balanced Accuracy : 0.5828.


Results of WFO test below. Again, only change to original files was the use of LSTM in R, rather than DNN+SAE.


Walk-Forward Test DeepLearnLSTMV4 EUR/USD.


Simulated account AssetsFix.


Bar period 1 hour (avg 87 min)


Simulation period 15.05.2014-07.06.2016 (12486 bars)


Test period 04.05.2015-07.06.2016 (6649 bars)


Lookback period 100 bars (4 days)


WFO test cycles 11 x 604 bars (5 weeks)


Training cycles 12 x 5439 bars (46 weeks)


Monte Carlo cycles 200.


Assumed slippage 0.0 sec.


Spread 0.0 pips (roll 0.00/0.00)


Contracts per lot 1000.0.


Gross win/loss 3628$ / -3235$ (+5199p)


Average profit 360$/year, 30$/month, 1.38$/day.


Max drawdown -134$ 34% (MAE -134$ 34%)


Total down time 95% (TAE 95%)


Max down time 5 weeks from Aug 2015.


Max open margin 40$


Max open risk 35$


Trade volume 5710964$ (5212652$/year)


Transaction costs 0.00$ spr, 0.00$ slp, 0.00$ rol.


Capital required 262$


Number of trades 6787 (6195/year, 120/week, 25/day)


Percent winning 57.6%


Max win/loss 16$ / -14$


Avg trade profit 0.06$ 0.8p (+12.3p / -14.8p)


Avg trade slippage 0.00$ 0.0p (+0.0p / -0.0p)


Avg trade bars 1 (+1 / -2)


Max trade bars 3 (3 hours)


Time in market 177%


Max open trades 3.


Max loss streak 17 (uncorrelated 11)


Annual return 137%


Profit factor 1.12 (PRR 1.08)


Sharpe ratio 1.79.


Kelly criterion 2.34.


R2 coefficient 0.435.


Ulcer index 13.3%


Prediction error 152%


Confidence level AR DDMax Capital.


Portfolio analysis OptF ProF Win/Loss Wgt% Cycles.


EUR/USD .219 1.12 3907/2880 100.0 XX/\//\X///


EUR/USD:L .302 1.17 1830/1658 65.0 /\/\//\////


EUR/USD:S .145 1.08 2077/1222 35.0 \//\//\\///


مثير للإعجاب! For a still experimental LSTM implementation that result looks not bad.


Sorry for being completely off topic but could you please point me to the best place where i can learn to code trend lines?? I’m a complete beginner, but from trading experience i see them as an important part of what i would like to build…


Robot Wealth has an algorithmic trading course for that – you can find details on his blog robotwealth/.


I think you misunderstand the meaning pretrening. See my articles mql5/ru/articles/1103.


I think there is more fully described this stage.


I don’t think I misunderstood pretraining, at least not more than everyone else, but thanks for the links!


You can paste your LTSM r code please ?


Could you help me answering some questions?


I have few question below:


1.I want to test Commission mode.


If I use interactive broker, I should set Commission = ? in normal case.


2.If I press the “trade” button, I see the log the script will use DeepLearn_EURUSD. ml.


So real trade it will use DeepLearn_EURUSD. ml to get the model to trade?


And use neural. predict function to trade?


3.If I use the slow computer to train the data ,


I should move DeepLearn_EURUSD. ml to the trade computer?


I test the real trade on my interactive brokers and press the result button.


Can I use Commission=0.60 to train the neural and get the real result?


Result button will show the message below:


Trade Trend EUR/USD.


Bar period 2 min (avg 2 min)


Trade period 02.11.2016-02.11.2016.


Spread 0.5 pips (roll -0.02/0.01)


Contracts per lot 1000.0.


Commission should be normally not set up in the script, but entered in the broker specific asset list. Otherwise you had to change the script every time when you want to test it with a different broker or account. IB has different lot sizes and commissions, so you need to add the command.


to the script when you want to test it for an IB account.


Yes, DeepLearn_EURUSD. ml is the model for live trading, and you need to copy it to the trade computer.


Do I write assetList(“AssetsIB. csv”) in the right place?


So below code’s result includes Commission ?


I test the result with Commission that seems pretty good.


Annual +93% +3177p.


BarPeriod = 60; // 1 hour.


WFOPeriod = 252*24; // 1 year.


NumCores = -1; // use all CPU cores but one.


Spread = RollLong = RollShort = Commission = Slippage = 0;


if(Train) Hedge = 2;


I run the DeepLearn. c in the IB paper trade.


The code “LifeTime = 3; // prediction horizon” seems to close the position that you open after 3 bars(3 hours).


But I can’t see it close the position on third bar close.


I see the logs below:


Closing prohibited – check NFA flag!


[EUR/USD::L4202] Can’t close 11.10995 at 09:10:51.


In my IB paper trade, it the default order size is 1k on EUR/USD.


How to change the order size in paper trade?


شكرا جزيلا.


IB is an NFA compliant broker. You can not close trades on NFA accounts. You must set the NFA flag for opening a reverse position instead. And you must enable trading costs, otherwise including the commission has no effect. I don’t think that you get a positive result with trading costs.


Those account issues are not related to machine learning, and are better asked on the Zorro forum. Or even better, read the Zorro manual where all this is explained. Just search for “NFA”.


I do some experiment to change the neural’s parameter with commission.


The code is below:


BarPeriod = 60; // 1 hour.


WFOPeriod = 252*24; // 1 year.


NumCores = -1; // use all CPU cores but one.


Spread = RollLong = RollShort = Slippage = 0;


if(Train) Hedge = 2;


I get the result with commission that Annual Return is about +23%.


But I don’t complete understand the zorro’s setting and zorro’s report.


Walk-Forward Test DeepLearn EUR/USD.


Simulated account AssetsIB. csv.


Bar period 1 hour (avg 86 min)


Simulation period 15.05.2014-09.09.2016 (14075 bars)


Test period 23.04.2015-09.09.2016 (8404 bars)


Lookback period 100 bars (4 days)


WFO test cycles 14 x 600 bars (5 weeks)


Training cycles 15 x 5401 bars (46 weeks)


Monte Carlo cycles 200.


Simulation mode Realistic (slippage 0.0 sec)


Spread 0.0 pips (roll 0.00/0.00)


Contracts per lot 20000.0.


Gross win/loss 24331$ / -22685$ (+914p)


Average profit 1190$/year, 99$/month, 4.58$/day.


Max drawdown -1871$ 114% (MAE -1912$ 116%)


Total down time 92% (TAE 41%)


Max down time 18 weeks from Dec 2015.


Max open margin 2483$


Max open risk 836$


Trade volume 26162350$ (18916130$/year)


Transaction costs 0.00$ spr, 0.00$ slp, 0.00$ rol, -1306$ com.


Capital required 5239$


Number of trades 1306 (945/year, 19/week, 4/day)


Percent winning 52.5%


Max win/loss 375$ / -535$


Avg trade profit 1.26$ 0.7p (+19.7p / -20.3p)


Avg trade slippage 0.00$ 0.0p (+0.0p / -0.0p)


Avg trade bars 2 (+2 / -3)


Max trade bars 3 (3 hours)


Time in market 46%


Max open trades 3.


Max loss streak 19 (uncorrelated 10)


Annual return 23%


Profit factor 1.07 (PRR 0.99)


Sharpe ratio 0.56.


Kelly criterion 1.39.


R2 coefficient 0.000.


Ulcer index 20.8%


Confidence level AR DDMax Capital.


10% 29% 1134$ 4153$


20% 27% 1320$ 4427$


30% 26% 1476$ 4656$


40% 24% 1649$ 4911$


50% 23% 1767$ 5085$


60% 22% 1914$ 5301$


70% 21% 2245$ 5789$


80% 19% 2535$ 6216$


90% 16% 3341$ 7403$


95% 15% 3690$ 7917$


100% 12% 4850$ 9625$


Portfolio analysis OptF ProF Win/Loss Wgt% Cycles.


EUR/USD .256 1.07 685/621 100.0 /X/XXXXXXXXXXX.


The manual is your friend:


Great read…I built this framework to use XGB to analyze live ETF price movements. Let me know what you think:


Hi, deep learning researcher and programmer here. 🙂


Great blog and great article, congratulations! I have some comments:


& # 8211؛ if you use ReLUs as activation functions, pretraining is not necessary.


& # 8211؛ AE is genarraly referred to as networks with same input and output, I would call the proposed network rather a MLP (multi-layer perceptron).


Do you think it is possible to use Python (like TensorFlow) or LUA (like Torch7) based deep learing libraries with Zorro?


I have also heard that ReLUs make a network so fast that you can brute force train it in some cases, with no pretraining. But I have not yet experimented with that. The described network is commonly called ‘SAE’ since it uses autoencoders, with indeed the same number of inputs and outputs, for the pre-training process. & # 8211؛ I am not familiar with Torch7, but you can theoretically use Tensorflow with Zorro with a DLL based interface. The network structure must still be defined in Python, but Zorro can use the network for training and prediction.


Would you do YouTube Tutorials to your work, this series of articles. And where can I subscribe this kinda of algorithmic trading tutorials. Thanks for your contribution.


I would do YouTube tutorials if someone payed me very well for them. Until then, you can subscribe this blog with the link on the right above.


Why not feed economic data from a calendar like forexfactory into the net as well? I suggested that several times before. This data is what makes me a profitable manual trader (rookie though), if there is any intelligence in these neuronal networks it should improve performance greatly. input must be name (non farm payrolls for example or some unique identifier) , time left to release, predicted value (like 3-5 days before) last value and revision. Some human institutional traders claim its possible to trade profitably without a chart from this data alone. Detecting static support and resistance areas (horizontal lines) should be superior to any simple candle patterns. It can be mathematically modeled, as the Support and Resistance indicator from Point Zero Trading proves. Unfortunately i dont have a clue how Arturo the programmer did it. I imagine an artificial intelligence actually “seeing” what the market is focussed on (like speculation on a better than expected NFP report based on other positive Data in the days before, driving the dollar up into the report). “seeing” significant support and resistance levels should allow for trading risk, making reasonable decisions on where to place SL and TP.


We also made the experience that well chosen external data, not derived from the price curve, can improve the prediction. There is even a trading system based on Trump’s twitter outpourings. I can’t comment on support and resistance since I know no successful systems that use them, and am not sure that they exist at all.


thank you very much for everything that you did so far.


I read the book (German here, too) and am working through your blog articles right now.


I already learnt a lot and still am learning more and more about the really important stuff (other than: Your mindset must be perfect and you need to have well-defined goals. I never was a fan of such things and finally I found someone that is on the same opinion and actually teaches people how to correctly do it).


So, thank you very much and thanks in advance for all upcoming articles that I will read and you will post.


As a thank you I was thinking about sending you a corrected version of your book (there are some typos and wrong articles here and there…). Would you be interested in that?


Again thank you for everything and please keep up the good work.


شكر! And I’m certainly interested in a list of all my mistakes.


Thank you for this interesting post. I ran it on my pc and obtained similar results as yours. Then I wanted to see if it could perform as well when commission and rollover and slippage were included during test. I used the same figures as the ones used in the workshops and included in the AssetFix. csv file. The modifications I did in your DeepLearn. c file are as follows:


Spread = RollLong = RollShort = Commission = Slippage = 0;


The results then were not as optimistic as without commission:


Walk-Forward Test DeepLearn_realistic EUR/USD.


Simulated account AssetsFix.


Bar period 1 hour (avg 86 min)


Simulation period 09.05.2014-27.01.2017 (16460 bars)


Test period 22.04.2015-27.01.2017 (10736 bars)


Lookback period 100 bars (4 days)


WFO test cycles 18 x 596 bars (5 weeks)


Training cycles 19 x 5367 bars (46 weeks)


Monte Carlo cycles 200.


Simulation mode Realistic (slippage 5.0 sec)


Spread 0.5 pips (roll -0.02/0.01)


Contracts per lot 1000.0.


Gross win/loss 5608$ / -6161$ (-6347p)


Average profit -312$/year, -26$/month, -1.20$/day.


Max drawdown -635$ -115% (MAE -636$ -115%)


Total down time 99% (TAE 99%)


Max down time 85 weeks from Jun 2015.


Max open margin 40$


Max open risk 41$


Trade volume 10202591$ (5760396$/year)


Transaction costs -462$ spr, 46$ slp, -0.16$ rol, -636$ com.


Capital required 867$


Number of trades 10606 (5989/year, 116/week, 24/day)


Percent winning 54.9%


Max win/loss 18$ / -26$


Avg trade profit -0.05$ -0.6p (+11.1p / -14.8p)


Avg trade slippage 0.00$ 0.0p (+1.5p / -1.7p)


Avg trade bars 1 (+1 / -2)


Max trade bars 3 (3 hours)


Time in market 188%


Max open trades 3.


Max loss streak 19 (uncorrelated 12)


Annual return -36%


Profit factor 0.91 (PRR 0.89)


Sharpe ratio -1.39.


Kelly criterion -5.39.


R2 coefficient 0.737.


Ulcer index 100.0%


Confidence level AR DDMax Capital.


Portfolio analysis OptF ProF Win/Loss Wgt% Cycles.


EUR/USD .000 0.91 5820/4786 100.0 XX/\XX\X\X/X/\\X\\


I am a very beginner with Zorro, maybe I did a mistake ? What do you think ?


No, your results look absolutely ok. The predictive power of 4 candles is very weak. This is just an experiment for finding out if price action has any predictive power at all.


Although it apparently has, I have not yet seen a really profitable system with this method. From the machine learning systems that we’ve programmed so far, all that turned out profitable used data from a longer price history.


Thank you for the great article, it’s exactly what I needed in order to start experimenting with ML in Zorro.


I’ve noticed that the results are slightly different each time despite using the random seed. Here it doesn’t matter thanks to the large number of trades but for example with daily bars the performance metrics fluctuate much more. My question is: do you happen to know from where does the randomness come? Is it still the training process in R despite the seed?


It is indeed so. Deepnet apparently uses also an internal function, not only the R random function, for randomizing some initial value.


any idea about how to use machine learning like in this example with indicators? you could do as better strategy 6.


would be very interesting.


Is it grid search inside the neural. train function allowed? I get error when I try it.


Besides Andy, how did you end up definining the LSTM structure using rnn? Is it not clear for me after reading inside the package.


أين هو رمز كامل؟ (أو أين هو مستودع؟)


You said” Use genetic optimization for determining the most important signals just by the most profitable results from the prediction process. Great for curve fitting” How about after using genetic optimization process for determining the most profitable signals , match and measure the most profitable signals with distance metrics/similarity analysis(mutual information, DTW, frechet distance algorithm etc…) then use the distance metrics/similarity analysis as function for neural network prediction? هل هذا منطقي ؟


Distance to what? To each other?


Yes find similar profitable signal-patterns in history and find distance between patterns/profitable signals then predict the behavior of the profitable signal in the future from past patterns.


Was wondering about this point you made in Step 5:


“Our target is the return of a trade with 3 bars life time.”


But in the code, doesn’t.


mean that we are actually predicting the SIGN of the return, rather than the return itself?


نعم فعلا. Only the binary win/loss result, but not the magnitude of the win or loss is used for the prediction.


“When you used almost 1 year’s data for training a system, it can obviously not deteriorate after a single day. Or if it did, and only produced positive test results with daily retraining, I would strongly suspect that the results are artifacts by some coding mistake.”


There is an additional trap to be aware of related to jcl’s comment above that applies to supervised machine learning techniques (where you train a model against actual outcomes). Assume you are trying to predict the return three bars ahead (as in the example above – LifeTime = 3;). In real time you obviously don’t have access to the outcomes for one, two and three bars ahead with which to retrain your model, but when using historical data you do. With frequently retrained models (especially if using relatively short blocks of training data) it is easy to train a model offline (and get impressive results) with data you will not have available for training in real time. Then reality kicks in. Therefore truncating your offline training set by N bars (where N is the number of bars ahead you are trying to predict) may well be advisable…


Amazing work, could you please share the WFO code as well. I was able to run the code till neural. save but unable to generate the WFO results.


شكرا جزيلا.


The code above does use WFO.


Dear jcl, in the text you mentioned that you could predict the current leg of zig-zag indicator, could you please elaborate on how to do that? what features and responses would you reccomend?


I would never claim that I could predict the current leg of zigzag indicator. But we have indeed coded a few systems that attempted that. For this, simply use not the current price movement, but the current zigzag slope as a training target. Which parameters you use for the features is completely up to you.


عمل جيد. I was wondering if you ever tried using something like a net long-short ratio of the asset (I. e. the FXCM SSI index – real time live data) as a feature to improve prediction?


Not with the FXCM SSI index, since it is not available as historical data as far as I know. But similar data of other markets, such as order book content, COT report or the like, have been used as features to a machine learning system.


I see, thanks, and whats’s the experience on those? do they have any predictive power? if you know any materials on this, I would be very interested to read it. (fyi, the SSI index can be exported from FXCM Trading Station (daily data from 2003 for most currency pairs)


Thanks for the info with the SSI. Yes, additional market data can have predictive power, especially from the order book. But since we gathered this experience with contract work for clients, I’m not at liberty to disclose details. However we plan an own study with ML evaluation of additional data, and that might result in an article on this blog.


Thanks jcl, looking forward to it! there is a way to record SSI ratios in a CSV file from a LUA Strategy script (FXCM’s scripting language) for live evaluation. happy to give you some details if you decide to evaluate this. (drop me an ) MyFxbook also has a similar indicator, but no historical data on that one unfortunately.


Nanalyze.


In previous articles, we’ve defined some of the terms being thrown around lately like “machine learning” و & # 8220؛ الذكاء الاصطناعي & # 8220 ؛. هذه التقنيات التخريبية سوف تغير العالم قريبا كما نعرفه. في حين توقع بعض النقاد أننا كنا سنوات بعيدا عن جهاز كمبيوتر يمكن أن تغلب على خبير بشري في & # 8220؛ الذهاب & # 8221؛، تم الإعلان عن هذا الإنجاز مؤخرا. If a “deep learning” يمكن للبرنامج الآن الفوز على اللعبة التي لديها خطوات أكثر من الذرات في الكون المعروف، ثم ما الذي يمنعنا من إطلاق العنان لها في سوق الأسهم وجعل الملايين؟


إن فكرة استخدام الحواسيب لتجارة الأسهم ليست جديدة. التداول الخوارزمي (المعروف أيضا باسم تجارة ألغو أو التداول في الصندوق الأسود الذي هو مجموعة فرعية من تجارة ألغو) كان موجودا لأكثر من عقد من الزمان وسرعان ما تكتسب شعبية. هنا & # 8217؛ s نظرة على التداول حسابي كنسبة مئوية من حجم السوق:


المصدر: مورتون غلانتز، روبرت كيسيل. نمذجة مخاطر الأصول المتعددة: تقنيات الاقتصاد العالمي في عصر التجارة الإلكترونية والخوارزمية.


إذا استمر هذا الاتجاه، فهذا يعني أن ما يزيد على 90٪ من التداول يجري حاليا من خلال برامج الكمبيوتر. One thing to notice about algorithmic trading is that it has been moving in the direction of shorter and shorter holding times. تجارة عالية التردد (هفت) هي مجموعة فرعية من التداول الخوارزمي الذي يتم شراء الأسهم ثم تباع في كسور من الثانية. هذه الاستراتيجية هي شكل من أشكال المراجحة التي خوارزمية هفت البقع تباين الأسعار ومن ثم يستفيد منه بسرعة. كما تتوقعون، فإن أرباح التداول هفت أصبحت أصغر وأصغر ولكن حجم الصفقات لا تزال تهيمن على السوق بشكل عام:


الآن بعد أن عرفنا عن التداول الحسابي و هفت، فقط كيف يمكن تعلم الآلة أو التعلم العميق في اللعب؟ وللإجابة عن هذا السؤال، فإن المتغير الهام الذي يجب أخذه في الاعتبار هو المدة. في حين أن التداول هفت و ألغو يؤديان الصفقات لفترة قصيرة، يصبح من الصعب جدا على & # 8220؛ التقاط ألفا & # 8221؛ عند البدء في زيادة الإطار الزمني. والحقيقة هي أن بعض من أكبر صناديق التحوط في العالم هي بالفعل في جميع أنحاء هذا الفضاء، وقد تم التقاط ألفا عبر عدة فترات لفترة طويلة الآن باستخدام التعلم الآلي.


في أوائل العام الماضي، بدأت شركة بريدج ووتر أسوسياتس التي لديها 150 مليار دولار في الأصول تحت الإدارة (أوم) وحدة جديدة للذكاء الاصطناعي بقيادة ديفيد فيروتشي الذي قاد تطوير شركة عب & # 8217's واتسون. بعد عمله في شركة آي بي إم لمدة 17 عاما، تم صيده من قبل بريدجووتر في عام 2012.


Another firm called Renaissance Technologies has $65 billion in AUM and is said to have “the best physics and mathematics department in the world”. صندوق الميداليات في عصر النهضة، الذي يديره معظم موظفي الشركة، لديه واحدة من أفضل السجلات في تاريخ الاستثمار بعد أن عاد + 35٪ سنويا على مدى 20 عاما. وقد تم تعيين اثنين من المديرين التنفيذيين معا من عصر النهضة على حد سواء من عب البحوث في عام 1993 حيث كانوا يعملون على برامج التعرف على اللغة.


مع 32 مليار $ تحت الإدارة، ومن المعروف اثنين سيغما الاستثمارات لاستخدام منظمة العفو الدولية والتعلم الآلي كجزء أساسي من استراتيجيتها. أحد مؤسسيه لم دكتوراه في الذكاء الاصطناعي في معهد ماساتشوستس للتكنولوجيا والآخر كان أولمبياد رياضي ميدالية فضية الدولية. Being a finance professional is not a requirement to work at this firm.


في حين أن صناديق التحوط مثل هذه 3 هي رواد استخدام التعلم الآلي لاستراتيجيات تداول الأسهم، وهناك بعض الشركات الناشئة تلعب في هذا الفضاء أيضا. Binatix is a deep learning trading firm that came out of stealth mode in 2014 and claims to be nicely profitable having used their strategy for well over three years. إدييا هو صندوق التحوط مقرها هونغ كونغ أطلقت في عام 2015 أن يتداول في الأسهم الأمريكية ويجعل جميع الأسهم التداول باستخدام الذكاء الاصطناعي دون تدخل البشري المطلوبة. وقد قامت شركة "سنتيانت"، وهي شركة تعليمية عميقة أخرى ناقشناها من قبل، بتطوير تاجر ذكاء اصطناعي كان ناجحا بما فيه الكفاية بحيث ينظرون في تدويره كشركة تجارية دعائية أو شركة لإدارة الأصول.


إذا كانت هناك شركة ناشئة تظهر وعدا في هذا المجال، فيمكنك أن تراهن على أن صناديق التحوط الثلاثة التي ناقشناها تعرف عنها. إذا كان لديك خوارزمية تعلم الآلة التي ولدت ألفا، هل لك أن تخبر العالم عن ذلك؟ على الأرجح لا. But then how would you raise the capital needed to make some serious money off of your strategy? شركات مثل بريدج ووتر يمكن أن تكون ذكيا كما أي بدء التشغيل، وفي الوقت نفسه لديها 150 مليار $ في رأس المال للعب مع. It’s hard to compete if you’re a startup that’s trying to get funded. If you’re looking for investors, you have to disclose what you’re doing. كلمة يسافر بسرعة. ليس من الصعب أن نرى صناديق التحوط مثل بريدجواتر الصيد غير المشروع المواهب من منظمة العفو الدولية الناشئة التي تحاول أن تلعب في هذا الفضاء وبسرعة معرفة ما هم & # 8217؛ إعادة تصل إلى.


بالنسبة للمستثمرين الأفراد للاستفادة من تعلم الآلة لتداول الأسهم، لديك اتجاهين لاتخاذ. بالنسبة للمستثمرين الأفراد ذوي القيمة الصافية العالية جدا، يمكنك استثمار أموالك في أحد صناديق التحوط باستخدام منظمة العفو الدولية مثل بريدج ووتر أو عصر النهضة. بالنسبة لأولئك منا الذين لا تملك مثل هذه كميات كبيرة من رأس المال، ونحن يمكن أن تنتظر لشركات التعلم عميقة مثل سنتيت للذهاب العامة أو الحصول عليها ومن ثم الاستثمار في تلك المركبات. نحن & # 8217؛ ليرة لبنانية أن يراقب عن كثب على هذه المساحة لأنه بصراحة، انها & # 8217؛ s رائعة فقط.


إذا كنت تدفع أكثر من 4.95 $ التجارة، كنت تدفع الكثير. ألي انفست هي واحدة من الوسطاء الأقل رسوما حول ذلك تنفق أقل من المال على رسوم المعاملات وأكثر على الأسهم. With more than 30 trades a quarter it drops even lower to $3.95 a trade . فتح حساب والبدء في التداول اليوم.


بابليشيد: أبريل 14، 2016.


5 ETFs and Funds Using AI for Stock Selection.


Is Stitch Fix an Artificial Intelligence IPO?


A Warning About “Artificial Intelligence Stocks”


قلت: التداول الخوارزمي (المعروف أيضا باسم تجارة ألغو أو تداول الصندوق الأسود)


أردت فقط أن نشير إلى أن ليس كل التداول ألغو هو الصندوق الأسود.


شكرا لك على التوضيح ديفيد! لاحظنا أنه في هذه المادة.


هناك إتف التي تسمح للمستثمرين للوصول إلى هذه التقنيات اليوم! رمز السهم المدرجة في بورصة نيويورك & # 8216؛ باز & # 8217 ؛. معرفة المزيد في بوزينديكسيس.


شكرا لك على التعليق جيمي! كان ذلك مقابلة كبيرة كان لديك على سكوك صندوق إدخال الباز إتف.


شكرا لرؤساء متابعة!


اشترك في الملخص الأسبوعي.


Subscribe to the Nanalyze Weekly Digest.


Subscribe to our Nanalyze Weekly Digest to receive a summary of all articles every week.


نحن لن تستخدم أبدا لأي شيء آخر غير إرسال لك مقالات كبيرة حول الاستثمار في التقنيات التخريبية.

No comments:

Post a Comment