نظام التداول غولانغ


نظام التداول في غولانغ
غوتريد هو فيكس بروتوكول التداول الإلكتروني ونظام إدارة النظام المكتوب في غولانغ، منظم للاستخدام نموذجي متعددة الأصول المؤسسية.
هذا المشروع هو حاليا أكثر من دليل على المفهوم. ليس هناك مكان بالقرب من اكتمال المنتج التجاري. هذا الريبو العام يخدم في الغالب لغرض تجريب وتبادل الأفكار.
ابدء.
[x] التجارة في الوقت الحقيقي عبر فيكس من خلال أبي محايد الوسيط. [x] تصحيح سلوك تدفق النظام فيكس عبر إصدارات فيكس متعددة وفئات الأصول. [x] بيور غو. [x] محايد منصة: الكتابة مرة واحدة، وبناء لأي أنظمة التشغيل والقوس (لينكس / ويندوز / أوسك الخ). [x] أداء التعليمات البرمجية الأصلية. [x] سهولة النشر. [x] الافتقار إلى الشرف أوب، يعمل لفرق صغيرة وكبيرة. [x] بروتوبوف. [x] شكل ترميز ثنائي، فعال بعد موسع. [x] سهولة التشغيل البيني للغة (C ++، بيثون، جافا، C #، جافاسكريبت، الخ). [x] توافق البروتوكول إلى الخلف.
أمثلة.
الذهاب 1.4 أو أعلى الذهاب الحصول جيثب / إريكستمارتين / الذهاب-تستدب الذهاب الحصول جيثب / ناتس-إو / غناتسد.
أفضل طريقة لرؤية غوتريد في العمل هي إلقاء نظرة على الاختبارات (انظر المقياس المرجعي أدناه):
سوف أوردروتر و ماركيتكونكتور حالات الاختبار وهمية تستدب والحافلات الرسائل لنهاية إلى نهاية، رسالة إلى اختبار الرسالة.
الجهاز: إنتل كور i5 بو @ 2.80GHz` + `أوبونتو 14.04 سطح المكتب x86_64.
العميل إرسال النظام بروتوبوف إلى أوردرروتر (أور) أور ⇒ ماك:
أوردروتر أمر العملية والإرسال استمر كيان النظام لاستهداف ماركيتكونكتور ماك ⇒ فيكس:
يترجم ماركيتكونكتور إلى رسالة نيووردرسينغل فيكس استنادا إلى الجلسة مع الطرف المقابل فيكس ⇒ ماك:
تلقى ماركيتكونكتور رسالة فيكس على ترتيبها، هنا محاكاة إرسال ملء ملء إيكس ⇒ كل:
ماركيتكونكتور نشر معالجتها واستمر التنفيذ على حافلة الرسائل، وهنا عملائنا سوف الاستماع إلى.
من أجل إلى فيكس إلى ملء كامل تنفيذ رسالة إلى تنفيذ بروتوبوف نشرت مرة أخرى سيريالزينغ / ديزيريالزينغ وهمية النظام في بروتوبوف رسائل طلب / نشر والاستجابة / الاشتراك عبر ناقل الرسائل NATS. io الوقت الذي يقضيه في لينكس تكب / إب المكدس فك رسائل فيكس والرد بواسطة وسيط محاكاة.
وقت المعاملة قاعدة البيانات (من الصعب السلكية إلى مضمنة سائق دب وهمية)
النتيجة: 0.176ms لكل المرجع، 5670 ترتيب + ملء أزواج في الثانية.

جيسي سبولدينغ.
كيف جعلت 500K $ مع تعلم الآلة و هفت (تجارة عالية التردد)
هذه الوظيفة سوف تفاصيل ما فعلت لجعل تقريبا. 500k من تجارة عالية التردد من عام 2009 إلى عام 2018. منذ كنت التداول بشكل مستقل تماما وأنا لم يعد تشغيل برنامج أنا & [رسقوو]؛ م سعيد أن أقول كل شيء. كان تداولي في معظمه في عقود راسل 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 - لقد نشرت سؤالا متابعا للمتابعة يجيب عن بعض الأسئلة الشائعة التي تلقيتها من التجار حول هذه المشاركة.
ديليديفيانت معجب بهذا.
مرحبا، أنا جيسي، مؤسس ثينكلاب. أعيش واللعب في سان فرانسيسكو. لقد وجدت بيتي على شبكة الإنترنت .. أهلا وسهلا بك!

نظام التداول في غولانغ
سحب طلبات 0.
تاريخ جيثب اليوم.
جيثب هي موطن لأكثر من 20 مليون مطورين يعملون معا لاستضافة ومراجعة التعليمات البرمجية، وإدارة المشاريع، وبناء البرمجيات معا.
استنساخ مع هتبس.
استخدام جيت أو الخروج مع سفن باستخدام ورل على شبكة الإنترنت.
نظام تداول الأسهم الظاهري يستخدم النظام التسعير في الوقت الحقيقي عبر ياهو المالية أبي وسوف تدعم الدولار الأمريكي فقط. النظام لديه اثنين من الميزات:
شراء الأسهم طلب "ستوكسمبولاندبرسنتاد": سترينغ (إغ "غوغ: 50٪، يهو: 50٪") "بودجيت": float32 ريسبونز "تريديد": نومبر "ستوكس": سترينغ (إغ "غوغ 💯 $ 500.25"، "يهو: 200 : 31.40 ")" ونفستدامونت ": float32.
التحقق من محفظتك (خسارة / ربح) طلب "تريديد": رقم.
ريسبونز "ستوكس": سترينغ (على سبيل المثال "غوغ 💯 + $ 520.25"، "يهو: 200: - 30.40") "كيرنتماركيتفالو": float32 "ونفستدامونت": float32.
يحتوي النظام على مكونين: العميل والخادم. الخادم: سيكون لمحرك التداول واجهة جسون-ريك للميزات المذكورة أعلاه. العميل: العميل جسون-ريك سوف تأخذ إدخال سطر الأوامر وإرسال الطلبات الملقم.
&نسخ؛ 2017 جيثب، Inc. شروط الخصوصية تعليمات حالة الأمان.
لا يمكنك تنفيذ هذا الإجراء في الوقت الحالي.
لقد سجلت الدخول باستخدام علامة تبويب أو نافذة أخرى. أعد التحميل لتحديث الجلسة. لقد سجلت الخروج في علامة تبويب أو نافذة أخرى. أعد التحميل لتحديث الجلسة.

نظام التداول في غولانغ
سحب طلبات 0.
تاريخ جيثب اليوم.
جيثب هي موطن لأكثر من 20 مليون مطورين يعملون معا لاستضافة ومراجعة التعليمات البرمجية، وإدارة المشاريع، وبناء البرمجيات معا.
استنساخ مع هتبس.
استخدام جيت أو الخروج مع سفن باستخدام ورل على شبكة الإنترنت.
هذا هو نظام تداول الأسهم الظاهري لمن يريد أن يتعلم كيفية الاستثمار في الأسهم.
يستخدم النظام التسعير في الوقت الحقيقي عبر ياهو المالية أبي ويدعم العملة الدولار فقط. النظام لديه اثنين من الميزات:
شراء الأسهم طلب "ستوكسمبولاندبرسنتاد": سترينغ (إغ "غوغ: 55٪، يهو: 45٪") "بودجيت": float64 ريسبونز "تريديد": نومبر "ستوكس": سترينغ (إغ "غوغ: 51: $ 500.25"، "يهو : 252: 31.40 ")" ونفستدامونت ": float64.
الأمر: اذهب تشغيل العميل. شراء "غوغ: 55٪، يهو: 45٪" 50000.
التحقق من محفظتك (الخسارة / الربح) طلب "تريديد": نومبر ريسبونز "ستوكس": سترينغ (على سبيل المثال "غوغ: 51: + 52025.25"، "يهو: 252: - 30.40") // + - - الربح أو الخسارة "كيرنتيماركيتفالو": float32 "ونفستدامونت": float32.
الأمر: اذهب تشغيل العميل. تحقق.
يحتوي النظام على مكونين: العميل والخادم. الخادم: سيكون لمحرك التداول واجهة جسون-ريك للميزات المذكورة أعلاه. العميل: العميل جسون-ريك سوف تأخذ إدخال سطر الأوامر وإرسال الطلبات الملقم.
&نسخ؛ 2017 جيثب، Inc. شروط الخصوصية تعليمات حالة الأمان.
لا يمكنك تنفيذ هذا الإجراء في الوقت الحالي.
لقد سجلت الدخول باستخدام علامة تبويب أو نافذة أخرى. أعد التحميل لتحديث الجلسة. لقد سجلت الخروج في علامة تبويب أو نافذة أخرى. أعد التحميل لتحديث الجلسة.

QuantStart.
الانضمام إلى كوانتكاديمي بوابة العضوية الخاصة التي تلبي احتياجات التجزئة المتزايد بسرعة المجتمع تاجر الكمي. سوف تجد مجموعة من ذوي الخبرة مثل التفكير من التجار الكميون على استعداد للرد على أسئلة التداول الكمي الأكثر إلحاحا.
تحقق من بلدي يبوك على التداول الكمي حيث أنا يعلمك كيفية بناء مربحة استراتيجيات التداول المنهجي مع أدوات بايثون، من الصفر.
نلقي نظرة على بلدي الكتاب الاليكتروني الجديد على استراتيجيات التداول المتقدمة باستخدام تحليل سلسلة زمنية، والتعلم الآلي والإحصاءات بايزي، مع بيثون و R.
من قبل مايكل هالز مور في 26 يوليو، 2018.
واحدة من الأسئلة الأكثر تواترا التي تلقيتها في كيس البريد قس هو "ما هي أفضل لغة البرمجة للتجارة الخوارزمية؟". الجواب القصير هو أنه لا توجد لغة "أفضل". يجب النظر في معايير الاستراتيجية، والأداء، نمطية، والتنمية، والمرونة والتكلفة. سوف توضح هذه المقالة المكونات الضرورية لهيكل نظام التداول الخوارزمي وكيف تؤثر القرارات المتعلقة بالتنفيذ على اختيار اللغة.
أولا، سيتم النظر في المكونات الرئيسية لنظام التداول الخوارزمي، مثل أدوات البحث، ومحفظة المحفظة، ومدير المخاطر ومحرك التنفيذ. وفي وقت لاحق، سيتم دراسة استراتيجيات التداول المختلفة وكيفية تأثيرها على تصميم النظام. على وجه الخصوص وتيرة التداول وحجم التداول المحتمل على حد سواء سيتم مناقشتها.
مرة واحدة وقد تم اختيار استراتيجية التداول، فمن الضروري لمهندس النظام بأكمله. وهذا يشمل اختيار الأجهزة، ونظام التشغيل (ق) ومرونة النظام ضد الأحداث النادرة، التي يحتمل أن تكون كارثية. وبينما يجري النظر في العمارة، يجب إيلاء الاعتبار الواجب للأداء - سواء لأدوات البحث أو لبيئة التنفيذ المباشر.
ما هو نظام التداول في محاولة للقيام به؟
قبل اتخاذ قرار بشأن "أفضل" اللغة التي لكتابة نظام التداول الآلي من الضروري تحديد المتطلبات. هل سيكون النظام قائما على التنفيذ فقط؟ هل يتطلب النظام إدارة مخاطر أو وحدة بناء محفظة؟ سوف يتطلب النظام باكتستر عالية الأداء؟ بالنسبة لمعظم الاستراتيجيات نظام التداول يمكن تقسيمها إلى فئتين: البحوث وتوليد إشارة.
وتتعلق البحوث بتقييم أداء الاستراتيجية على البيانات التاريخية. إن عملية تقييم إستراتيجية التداول على بيانات السوق السابقة تعرف باختصار. وسيكون حجم البيانات والتعقيد الخوارزمي لها تأثير كبير على كثافة الحسابية من باكتستر. سرعة وحدة المعالجة المركزية والتزامن غالبا ما تكون العوامل المحددة في تحسين سرعة تنفيذ البحث.
ويتعلق توليد الإشارة بتوليد مجموعة من إشارات التداول من خوارزمية وإرسال هذه الأوامر إلى السوق، وعادة عن طريق الوساطة. بالنسبة لبعض الإستراتیجیات، یلزم وجود مستوى عال من الأداء. قضايا الإدخال / الإخراج مثل عرض النطاق الترددي للشبكة والكمون غالبا ما تكون العامل المحدد في تحسين أنظمة التنفيذ. وبالتالي فإن اختيار اللغات لكل مكون من مكونات النظام بأكمله قد يكون مختلفا تماما.
نوع، وتيرة وحجم الاستراتيجية.
وسيكون لنوع الاستراتيجية الخوارزمية المستخدمة أثر كبير على تصميم النظام. وسوف يكون من الضروري النظر في الأسواق التي يجري تداولها، والاتصال ببائعي البيانات الخارجية، وتواتر وحجم الاستراتيجية، والمفاضلة بين سهولة التنمية وتحسين الأداء، فضلا عن أي أجهزة مخصصة، بما في ذلك العرف المشترك والخوادم، وحدات معالجة الرسومات أو فبغا التي قد تكون ضرورية.
خيارات التكنولوجيا لاستراتيجية منخفضة الأسهم الأسهم الولايات المتحدة سوف تختلف اختلافا كبيرا عن تلك التي من استراتيجية عالية التردد التحكيم الإحصائية التداول في سوق العقود الآجلة. قبل اختيار اللغة يجب تقييم العديد من بائعي البيانات التي تتعلق باستراتيجية في متناول اليد.
سيكون من الضروري النظر في الاتصال بالمورد، وهيكل أي واجهات برمجة تطبيقات، وتوقيت البيانات، ومتطلبات التخزين والمرونة في مواجهة البائع الذي يعمل دون اتصال. ومن الحكمة أيضا أن تمتلك إمكانية الوصول السريع إلى العديد من البائعين! ولجميع الأدوات المختلفة مخزونات تخزين خاصة بها، ومن الأمثلة على ذلك رموز شريط متعددة للأسهم وتاريخ انتهاء الصلاحية للعقود الآجلة (ناهيك عن أي بيانات أوتك محددة). ويتعين مراعاة ذلك في تصميم المنصة.
ومن المرجح أن يكون تكرار الاستراتيجية واحدا من أكبر العوامل الدافعة لكيفية تحديد كومة التكنولوجيا. الاستراتيجيات التي تستخدم بيانات أكثر تواترا من الحانات بدقة أو الثانية تتطلب اهتماما كبيرا فيما يتعلق بالأداء.
وتؤدي الاستراتيجية التي تتجاوز الحدود الثانية (أي بيانات القراد) إلى تصميم مدعوم بالأداء باعتباره الشرط الأساسي. وبالنسبة للاستراتيجيات ذات التردد العالي، سيلزم تخزين كمية كبيرة من بيانات السوق وتقييمها. برامج مثل HDF5 أو كدب + تستخدم عادة لهذه الأدوار.
من أجل معالجة كميات واسعة من البيانات اللازمة لتطبيقات هفت، يجب أن تستخدم على نطاق واسع باكتستر ونظام التنفيذ. C / C ++ (ربما مع بعض المجمع) من المرجح أن أقوى مرشح اللغة. وسوف تتطلب استراتيجيات فائقة التردد تقريبا تقريبا الأجهزة المخصصة مثل فبغاس، وتبادل المشاركة في الموقع وضبط شبكة النواة / شبكة.
نظم البحوث.
نظم البحوث عادة ما تنطوي على مزيج من التنمية التفاعلية والنصوص الآلي. وغالبا ما يحدث الأول داخل إيد مثل فيسوال ستوديو، ماتلاب أو R ستوديو. ويشمل هذا الأخير حسابات عددية واسعة النطاق على العديد من المعلمات ونقاط البيانات. وهذا يؤدي إلى اختيار اللغة توفير بيئة مباشرة لاختبار التعليمات البرمجية، ولكن أيضا يوفر أداء كافيا لتقييم الاستراتيجيات على أبعاد متعددة المعلمة.
تتضمن إيد النموذجية في هذه المساحة ميكروسوفت فيسوال C ++ / C #، الذي يحتوي على أدوات مساعدة التصحيح واسعة، قدرات اكتمال التعليمات البرمجية (عبر "إنتليسنز") ومحات عامة مباشرة من كومة المشروع بأكمله (عبر قاعدة البيانات أورم، لينق)؛ ماتلاب، الذي صمم لالجبر العددي واسعة النطاق وعمليات فيكتوريسد، ولكن بطريقة وحدة التحكم التفاعلية؛ R ستوديو، الذي يلتف وحدة تحكم اللغة الإحصائية R في إيد كاملة؛ إكليبس إيد لينوكس جافا و C ++؛ و إيدس شبه الملكية مثل إينوهت الستارة لبيثون، والتي تشمل مكتبات تحليل البيانات مثل نومبي، سسيبي، سكيكيت التعلم والباندا في بيئة تفاعلية واحدة (وحدة التحكم).
ل باكتستينغ العددية، جميع اللغات المذكورة أعلاه هي مناسبة، على الرغم من أنه ليس من الضروري استخدام واجهة المستخدم الرسومية / إيد كما سيتم تنفيذ التعليمات البرمجية "في الخلفية". الاعتبار الرئيسي في هذه المرحلة هو سرعة التنفيذ. غالبا ما تكون اللغة المترجمة (مثل C ++) مفيدة إذا كانت أبعاد معلمة باكتستينغ كبيرة. تذكر أنه من الضروري أن نكون حذرين من هذه الأنظمة إذا كان هذا هو الحال!
وغالبا ما تستفيد اللغات المفترضة مثل بيثون من المكتبات عالية الأداء مثل نومبي / بانداس لخطوة الاختبار المسبق، من أجل الحفاظ على درجة معقولة من القدرة التنافسية مع معادلات مجمعة. في نهاية المطاف سيتم تحديد اللغة المختارة لل باكتستينغ من قبل الاحتياجات الخوارزمية محددة وكذلك مجموعة من المكتبات المتاحة في اللغة (أكثر على ذلك أدناه). ومع ذلك، فإن اللغة المستخدمة لباكتستر والبيئات البحثية يمكن أن تكون مستقلة تماما عن تلك المستخدمة في بناء محفظة، وإدارة المخاطر ومكونات التنفيذ، كما سيتبين.
إدارة المحفظة وإدارة المخاطر.
وغالبا ما يتم تجاهل مكونات بناء المحفظة وإدارة المخاطر من قبل تجار التجزئة الخوارزمية. هذا هو دائما تقريبا خطأ. وتوفر هذه الأدوات الآلية التي سيتم من خلالها الحفاظ على رأس المال. فهي لا تحاول فقط التخفيف من عدد الرهانات "المحفوفة بالمخاطر"، بل إنها تقلل أيضا من تقلبات الصفقات نفسها، مما يقلل من تكاليف المعاملات.
يمكن أن يكون للإصدارات المتطورة من هذه المكونات تأثير كبير على جودة وانسجام الربحية. فمن السهل إنشاء استراتيجيات مستقرة حيث يمكن بسهولة تعديل آلية بناء المحفظة ومدير المخاطر للتعامل مع أنظمة متعددة. ومن ثم ينبغي اعتبارها عناصر أساسية في بداية تصميم نظام تجاري حسابي.
وظيفة نظام بناء محفظة هو اتخاذ مجموعة من الصفقات المطلوبة وإنتاج مجموعة من الصفقات الفعلية التي تقلل من زبد، والحفاظ على التعرض لعوامل مختلفة (مثل القطاعات وفئات الأصول والتقلب وغيرها) وتحسين تخصيص رأس المال لمختلف استراتيجيات في محفظة.
غالبا ما يقلل بناء الحافظة من مشكلة الجبر الخطي (مثل معامل المصفوفة)، وبالتالي يعتمد الأداء بشكل كبير على فعالية تنفيذ الجبر الخطي العددي المتوفر. وتشمل المكتبات الشائعة أوبلاس، لاباك و ناغ ل C ++. ماتلاب تمتلك أيضا عمليات مصفوفة الأمثل على نطاق واسع. يستخدم بيثون نومبي / سسيبي لمثل هذه الحسابات. وستتطلب المحفظة التي تمت إعادة توازنها بشكل متكرر مكتبة مصفوفة مجمعة (ومثبتة بشكل جيد!) لتنفيذ هذه الخطوة، حتى لا تعيق نظام التداول.
إدارة المخاطر جزء آخر مهم للغاية من نظام التداول الخوارزمي. يمكن أن تأتي المخاطر بأشكال عديدة: زيادة التقلب (على الرغم من أن هذا قد يكون مرغوبا فيه لاستراتيجيات معينة!)، وزيادة الارتباطات بين فئات الأصول، والتخلف عن الطرف المقابل، وانقطاعات الخادم، وأحداث "البجعة السوداء" والأخطاء غير المكتشفة في رمز التداول، على سبيل المثال لا الحصر.
وتسعى مكونات إدارة المخاطر إلى التنبؤ بآثار التقلبات المفرطة والروابط بين فئات األصول وتأثيرها الالحق على رأس المال المتداول. في كثير من الأحيان هذا يقلل إلى مجموعة من الحسابات الإحصائية مثل مونت كارلو "اختبارات الإجهاد". وهذا يشبه إلى حد كبير الاحتياجات الحسابية لمحرك تسعير المشتقات وعلى هذا النحو سوف تكون مرتبطة بو. هذه المحاكاة هي موازية للغاية (انظر أدناه)، وإلى حد ما، فمن الممكن "رمي الأجهزة في المشكلة".
أنظمة التنفيذ.
وتتمثل مهمة نظام التنفيذ في تلقي إشارات تجارية مصفاة من مكونات بناء المحفظة وإدارة المخاطر وإرسالها إلى وساطة أو أي وسيلة أخرى للوصول إلى الأسواق. بالنسبة لمعظم استراتيجيات التداول خوارزمية التجزئة وهذا ينطوي على اتصال أبي أو فيكس إلى الوساطة مثل وسطاء التفاعلية. الاعتبارات الأساسية عند اتخاذ قرار بشأن لغة تشمل جودة أبي، توفر اللغة المجمع ل أبي، وتيرة التنفيذ والانزلاق المتوقع.
The "quality" of the API refers to how well documented it is, what sort of performance it provides, whether it needs standalone software to be accessed or whether a gateway can be established in a headless fashion (i. e. no GUI). In the case of Interactive Brokers, the Trader WorkStation tool needs to be running in a GUI environment in order to access their API. I once had to install a Desktop Ubuntu edition onto an Amazon cloud server to access Interactive Brokers remotely, purely for this reason!
Most APIs will provide a C++ and/or Java interface. It is usually up to the community to develop language-specific wrappers for C#, Python, R, Excel and MatLab. Note that with every additional plugin utilised (especially API wrappers) there is scope for bugs to creep into the system. Always test plugins of this sort and ensure they are actively maintained. A worthwhile gauge is to see how many new updates to a codebase have been made in recent months.
Execution frequency is of the utmost importance in the execution algorithm. Note that hundreds of orders may be sent every minute and as such performance is critical. Slippage will be incurred through a badly-performing execution system and this will have a dramatic impact on profitability.
Statically-typed languages (see below) such as C++/Java are generally optimal for execution but there is a trade-off in development time, testing and ease of maintenance. Dynamically-typed languages, such as Python and Perl are now generally "fast enough". Always make sure the components are designed in a modular fashion (see below) so that they can be "swapped out" out as the system scales.
Architectural Planning and Development Process.
The components of a trading system, its frequency and volume requirements have been discussed above, but system infrastructure has yet to be covered. Those acting as a retail trader or working in a small fund will likely be "wearing many hats". It will be necessary to be covering the alpha model, risk management and execution parameters, and also the final implementation of the system. Before delving into specific languages the design of an optimal system architecture will be discussed.
Separation of Concerns.
One of the most important decisions that must be made at the outset is how to "separate the concerns" of a trading system. In software development, this essentially means how to break up the different aspects of the trading system into separate modular components.
By exposing interfaces at each of the components it is easy to swap out parts of the system for other versions that aid performance, reliability or maintenance, without modifying any external dependency code. This is the "best practice" for such systems. For strategies at lower frequencies such practices are advised. For ultra high frequency trading the rulebook might have to be ignored at the expense of tweaking the system for even more performance. A more tightly coupled system may be desirable.
Creating a component map of an algorithmic trading system is worth an article in itself. However, an optimal approach is to make sure there are separate components for the historical and real-time market data inputs, data storage, data access API, backtester, strategy parameters, portfolio construction, risk management and automated execution systems.
For instance, if the data store being used is currently underperforming, even at significant levels of optimisation, it can be swapped out with minimal rewrites to the data ingestion or data access API. As far the as the backtester and subsequent components are concerned, there is no difference.
Another benefit of separated components is that it allows a variety of programming languages to be used in the overall system. There is no need to be restricted to a single language if the communication method of the components is language independent. This will be the case if they are communicating via TCP/IP, ZeroMQ or some other language-independent protocol.
As a concrete example, consider the case of a backtesting system being written in C++ for "number crunching" performance, while the portfolio manager and execution systems are written in Python using SciPy and IBPy.
Performance Considerations.
Performance is a significant consideration for most trading strategies. For higher frequency strategies it is the most important factor. "Performance" covers a wide range of issues, such as algorithmic execution speed, network latency, bandwidth, data I/O, concurrency/parallelism and scaling. Each of these areas are individually covered by large textbooks, so this article will only scratch the surface of each topic. Architecture and language choice will now be discussed in terms of their effects on performance.
The prevailing wisdom as stated by Donald Knuth, one of the fathers of Computer Science, is that "premature optimisation is the root of all evil". This is almost always the case - except when building a high frequency trading algorithm! For those who are interested in lower frequency strategies, a common approach is to build a system in the simplest way possible and only optimise as bottlenecks begin to appear.
Profiling tools are used to determine where bottlenecks arise. Profiles can be made for all of the factors listed above, either in a MS Windows or Linux environment. There are many operating system and language tools available to do so, as well as third party utilities. Language choice will now be discussed in the context of performance.
C++, Java, Python, R and MatLab all contain high-performance libraries (either as part of their standard or externally) for basic data structure and algorithmic work. C++ ships with the Standard Template Library, while Python contains NumPy/SciPy. Common mathematical tasks are to be found in these libraries and it is rarely beneficial to write a new implementation.
One exception is if highly customised hardware architecture is required and an algorithm is making extensive use of proprietary extensions (such as custom caches). However, often "reinvention of the wheel" wastes time that could be better spent developing and optimising other parts of the trading infrastructure. Development time is extremely precious especially in the context of sole developers.
Latency is often an issue of the execution system as the research tools are usually situated on the same machine. For the former, latency can occur at multiple points along the execution path. Databases must be consulted (disk/network latency), signals must be generated (operating syste, kernal messaging latency), trade signals sent (NIC latency) and orders processed (exchange systems internal latency).
For higher frequency operations it is necessary to become intimately familiar with kernal optimisation as well as optimisation of network transmission. This is a deep area and is significantly beyond the scope of the article but if an UHFT algorithm is desired then be aware of the depth of knowledge required!
Caching is very useful in the toolkit of a quantitative trading developer. Caching refers to the concept of storing frequently accessed data in a manner which allows higher-performance access, at the expense of potential staleness of the data. A common use case occurs in web development when taking data from a disk-backed relational database and putting it into memory. Any subsequent requests for the data do not have to "hit the database" and so performance gains can be significant.
For trading situations caching can be extremely beneficial. For instance, the current state of a strategy portfolio can be stored in a cache until it is rebalanced, such that the list doesn't need to be regenerated upon each loop of the trading algorithm. Such regeneration is likely to be a high CPU or disk I/O operation.
However, caching is not without its own issues. Regeneration of cache data all at once, due to the volatilie nature of cache storage, can place significant demand on infrastructure. Another issue is dog-piling , where multiple generations of a new cache copy are carried out under extremely high load, which leads to cascade failure.
Dynamic memory allocation is an expensive operation in software execution. Thus it is imperative for higher performance trading applications to be well-aware how memory is being allocated and deallocated during program flow. Newer language standards such as Java, C# and Python all perform automatic garbage collection , which refers to deallocation of dynamically allocated memory when objects go out of scope .
Garbage collection is extremely useful during development as it reduces errors and aids readability. However, it is often sub-optimal for certain high frequency trading strategies. Custom garbage collection is often desired for these cases. In Java, for instance, by tuning the garbage collector and heap configuration, it is possible to obtain high performance for HFT strategies.
C++ doesn't provide a native garbage collector and so it is necessary to handle all memory allocation/deallocation as part of an object's implementation. While potentially error prone (potentially leading to dangling pointers) it is extremely useful to have fine-grained control of how objects appear on the heap for certain applications. When choosing a language make sure to study how the garbage collector works and whether it can be modified to optimise for a particular use case.
Many operations in algorithmic trading systems are amenable to parallelisation . This refers to the concept of carrying out multiple programmatic operations at the same time, i. e in "parallel". So-called "embarassingly parallel" algorithms include steps that can be computed fully independently of other steps. Certain statistical operations, such as Monte Carlo simulations, are a good example of embarassingly parallel algorithms as each random draw and subsequent path operation can be computed without knowledge of other paths.
Other algorithms are only partially parallelisable. Fluid dynamics simulations are such an example, where the domain of computation can be subdivided, but ultimately these domains must communicate with each other and thus the operations are partially sequential. Parallelisable algorithms are subject to Amdahl's Law, which provides a theoretical upper limit to the performance increase of a parallelised algorithm when subject to $N$ separate processes (e. g. on a CPU core or thread ).
Parallelisation has become increasingly important as a means of optimisation since processor clock-speeds have stagnated, as newer processors contain many cores with which to perform parallel calculations. The rise of consumer graphics hardware (predominently for video games) has lead to the development of Graphical Processing Units (GPUs), which contain hundreds of "cores" for highly concurrent operations. Such GPUs are now very affordable. High-level frameworks, such as Nvidia's CUDA have lead to widespread adoption in academia and finance.
Such GPU hardware is generally only suitable for the research aspect of quantitative finance, whereas other more specialised hardware (including Field-Programmable Gate Arrays - FPGAs) are used for (U)HFT. Nowadays, most modern langauges support a degree of concurrency/multithreading. Thus it is straightforward to optimise a backtester, since all calculations are generally independent of the others.
Scaling in software engineering and operations refers to the ability of the system to handle consistently increasing loads in the form of greater requests, higher processor usage and more memory allocation. In algorithmic trading a strategy is able to scale if it can accept larger quantities of capital and still produce consistent returns. The trading technology stack scales if it can endure larger trade volumes and increased latency, without bottlenecking .
While systems must be designed to scale, it is often hard to predict beforehand where a bottleneck will occur. Rigourous logging, testing, profiling and monitoring will aid greatly in allowing a system to scale. Languages themselves are often described as "unscalable". This is usually the result of misinformation, rather than hard fact. It is the total technology stack that should be ascertained for scalability, not the language. Clearly certain languages have greater performance than others in particular use cases, but one language is never "better" than another in every sense.
One means of managing scale is to separate concerns, as stated above. In order to further introduce the ability to handle "spikes" in the system (i. e. sudden volatility which triggers a raft of trades), it is useful to create a "message queuing architecture". This simply means placing a message queue system between components so that orders are "stacked up" if a certain component is unable to process many requests.
Rather than requests being lost they are simply kept in a stack until the message is handled. This is particularly useful for sending trades to an execution engine. If the engine is suffering under heavy latency then it will back up trades. A queue between the trade signal generator and the execution API will alleviate this issue at the expense of potential trade slippage. A well-respected open source message queue broker is RabbitMQ.
Hardware and Operating Systems.
The hardware running your strategy can have a significant impact on the profitability of your algorithm. This is not an issue restricted to high frequency traders either. A poor choice in hardware and operating system can lead to a machine crash or reboot at the most inopportune moment. Thus it is necessary to consider where your application will reside. The choice is generally between a personal desktop machine, a remote server, a "cloud" provider or an exchange co-located server.
Desktop machines are simple to install and administer, especially with newer user friendly operating systems such as Windows 7/8, Mac OSX and Ubuntu. Desktop systems do possess some significant drawbacks, however. The foremost is that the versions of operating systems designed for desktop machines are likely to require reboots/patching (and often at the worst of times!). They also use up more computational resources by the virtue of requiring a graphical user interface (GUI).
Utilising hardware in a home (or local office) environment can lead to internet connectivity and power uptime problems. The main benefit of a desktop system is that significant computational horsepower can be purchased for the fraction of the cost of a remote dedicated server (or cloud based system) of comparable speed.
A dedicated server or cloud-based machine, while often more expensive than a desktop option, allows for more significant redundancy infrastructure, such as automated data backups, the ability to more straightforwardly ensure uptime and remote monitoring. They are harder to administer since they require the ability to use remote login capabilities of the operating system.
In Windows this is generally via the GUI Remote Desktop Protocol (RDP). In Unix-based systems the command-line Secure SHell (SSH) is used. Unix-based server infrastructure is almost always command-line based which immediately renders GUI-based programming tools (such as MatLab or Excel) to be unusable.
A co-located server, as the phrase is used in the capital markets, is simply a dedicated server that resides within an exchange in order to reduce latency of the trading algorithm. This is absolutely necessary for certain high frequency trading strategies, which rely on low latency in order to generate alpha.
The final aspect to hardware choice and the choice of programming language is platform-independence. Is there a need for the code to run across multiple different operating systems? Is the code designed to be run on a particular type of processor architecture, such as the Intel x86/x64 or will it be possible to execute on RISC processors such as those manufactured by ARM? These issues will be highly dependent upon the frequency and type of strategy being implemented.
Resilience and Testing.
One of the best ways to lose a lot of money on algorithmic trading is to create a system with no resiliency . This refers to the durability of the sytem when subject to rare events, such as brokerage bankruptcies, sudden excess volatility, region-wide downtime for a cloud server provider or the accidental deletion of an entire trading database. Years of profits can be eliminated within seconds with a poorly-designed architecture. It is absolutely essential to consider issues such as debuggng, testing, logging, backups, high-availability and monitoring as core components of your system.
It is likely that in any reasonably complicated custom quantitative trading application at least 50% of development time will be spent on debugging, testing and maintenance.
Nearly all programming languages either ship with an associated debugger or possess well-respected third-party alternatives. In essence, a debugger allows execution of a program with insertion of arbitrary break points in the code path, which temporarily halt execution in order to investigate the state of the system. The main benefit of debugging is that it is possible to investigate the behaviour of code prior to a known crash point .
Debugging is an essential component in the toolbox for analysing programming errors. However, they are more widely used in compiled languages such as C++ or Java, as interpreted languages such as Python are often easier to debug due to fewer LOC and less verbose statements. Despite this tendency Python does ship with the pdb, which is a sophisticated debugging tool. The Microsoft Visual C++ IDE possesses extensive GUI debugging utilities, while for the command line Linux C++ programmer, the gdb debugger exists.
Testing in software development refers to the process of applying known parameters and results to specific functions, methods and objects within a codebase, in order to simulate behaviour and evaluate multiple code-paths, helping to ensure that a system behaves as it should. A more recent paradigm is known as Test Driven Development (TDD), where test code is developed against a specified interface with no implementation. Prior to the completion of the actual codebase all tests will fail. As code is written to "fill in the blanks", the tests will eventually all pass, at which point development should cease.
TDD requires extensive upfront specification design as well as a healthy degree of discipline in order to carry out successfully. In C++, Boost provides a unit testing framework. In Java, the JUnit library exists to fulfill the same purpose. Python also has the unittest module as part of the standard library. Many other languages possess unit testing frameworks and often there are multiple options.
In a production environment, sophisticated logging is absolutely essential. Logging refers to the process of outputting messages, with various degrees of severity, regarding execution behaviour of a system to a flat file or database. Logs are a "first line of attack" when hunting for unexpected program runtime behaviour. Unfortunately the shortcomings of a logging system tend only to be discovered after the fact! As with backups discussed below, a logging system should be given due consideration BEFORE a system is designed.
Both Microsoft Windows and Linux come with extensive system logging capability and programming languages tend to ship with standard logging libraries that cover most use cases. It is often wise to centralise logging information in order to analyse it at a later date, since it can often lead to ideas about improving performance or error reduction, which will almost certainly have a positive impact on your trading returns.
While logging of a system will provide information about what has transpired in the past, monitoring of an application will provide insight into what is happening right now . All aspects of the system should be considered for monitoring. System level metrics such as disk usage, available memory, network bandwidth and CPU usage provide basic load information.
Trading metrics such as abnormal prices/volume, sudden rapid drawdowns and account exposure for different sectors/markets should also be continuously monitored. Further, a threshold system should be instigated that provides notification when certain metrics are breached, elevating the notification method (email, SMS, automated phone call) depending upon the severity of the metric.
System monitoring is often the domain of the system administrator or operations manager. However, as a sole trading developer, these metrics must be established as part of the larger design. Many solutions for monitoring exist: proprietary, hosted and open source, which allow extensive customisation of metrics for a particular use case.
Backups and high availability should be prime concerns of a trading system. Consider the following two questions: 1) If an entire production database of market data and trading history was deleted (without backups) how would the research and execution algorithm be affected? 2) If the trading system suffers an outage for an extended period (with open positions) how would account equity and ongoing profitability be affected? The answers to both of these questions are often sobering!
It is imperative to put in place a system for backing up data and also for testing the restoration of such data. Many individuals do not test a restore strategy. If recovery from a crash has not been tested in a safe environment, what guarantees exist that restoration will be available at the worst possible moment?
Similarly, high availability needs to be "baked in from the start". Redundant infrastructure (even at additional expense) must always be considered, as the cost of downtime is likely to far outweigh the ongoing maintenance cost of such systems. I won't delve too deeply into this topic as it is a large area, but make sure it is one of the first considerations given to your trading system.
Choosing a Language.
Considerable detail has now been provided on the various factors that arise when developing a custom high-performance algorithmic trading system. The next stage is to discuss how programming languages are generally categorised.
Type Systems.
When choosing a language for a trading stack it is necessary to consider the type system . The languages which are of interest for algorithmic trading are either statically - or dynamically-typed . A statically-typed language performs checks of the types (e. g. integers, floats, custom classes etc) during the compilation process. Such languages include C++ and Java. A dynamically-typed language performs the majority of its type-checking at runtime. Such languages include Python, Perl and JavaScript.
For a highly numerical system such as an algorithmic trading engine, type-checking at compile time can be extremely beneficial, as it can eliminate many bugs that would otherwise lead to numerical errors. However, type-checking doesn't catch everything, and this is where exception handling comes in due to the necessity of having to handle unexpected operations. 'Dynamic' languages (i. e. those that are dynamically-typed) can often lead to run-time errors that would otherwise be caught with a compilation-time type-check. For this reason, the concept of TDD (see above) and unit testing arose which, when carried out correctly, often provides more safety than compile-time checking alone.
Another benefit of statically-typed languages is that the compiler is able to make many optimisations that are otherwise unavailable to the dynamically - typed language, simply because the type (and thus memory requirements) are known at compile-time. In fact, part of the inefficiency of many dynamically-typed languages stems from the fact that certain objects must be type-inspected at run-time and this carries a performance hit. Libraries for dynamic languages, such as NumPy/SciPy alleviate this issue due to enforcing a type within arrays.
Open Source or Proprietary?
One of the biggest choices available to an algorithmic trading developer is whether to use proprietary (commercial) or open source technologies. There are advantages and disadvantages to both approaches. It is necessary to consider how well a language is supported, the activity of the community surrounding a language, ease of installation and maintenance, quality of the documentation and any licensing/maintenance costs.
The Microsoft stack (including Visual C++, Visual C#) and MathWorks' MatLab are two of the larger proprietary choices for developing custom algorithmic trading software. Both tools have had significant "battle testing" in the financial space, with the former making up the predominant software stack for investment banking trading infrastructure and the latter being heavily used for quantitative trading research within investment funds.
Microsoft and MathWorks both provide extensive high quality documentation for their products. Further, the communities surrounding each tool are very large with active web forums for both. The software allows cohesive integration with multiple languages such as C++, C# and VB, as well as easy linkage to other Microsoft products such as the SQL Server database via LINQ. MatLab also has many plugins/libraries (some free, some commercial) for nearly any quantitative research domain.
There are also drawbacks. With either piece of software the costs are not insignificant for a lone trader (although Microsoft does provide entry-level version of Visual Studio for free). Microsoft tools "play well" with each other, but integrate less well with external code. Visual Studio must also be executed on Microsoft Windows, which is arguably far less performant than an equivalent Linux server which is optimally tuned.
MatLab also lacks a few key plugins such as a good wrapper around the Interactive Brokers API, one of the few brokers amenable to high-performance algorithmic trading. The main issue with proprietary products is the lack of availability of the source code. This means that if ultra performance is truly required, both of these tools will be far less attractive.
Open source tools have been industry grade for sometime. Much of the alternative asset space makes extensive use of open-source Linux, MySQL/PostgreSQL, Python, R, C++ and Java in high-performance production roles. However, they are far from restricted to this domain. Python and R, in particular, contain a wealth of extensive numerical libraries for performing nearly any type of data analysis imaginable, often at execution speeds comparable to compiled languages, with certain caveats.
The main benefit of using interpreted languages is the speed of development time. Python and R require far fewer lines of code (LOC) to achieve similar functionality, principally due to the extensive libraries. وعلاوة على ذلك، فإنها غالبا ما تسمح تطوير وحدة التحكم التفاعلية القائمة، والحد بسرعة من عملية التنمية التكرارية.
Given that time as a developer is extremely valuable, and execution speed often less so (unless in the HFT space), it is worth giving extensive consideration to an open source technology stack. Python and R possess significant development communities and are extremely well supported, due to their popularity. Documentation is excellent and bugs (at least for core libraries) remain scarce.
Open source tools often suffer from a lack of a dedicated commercial support contract and run optimally on systems with less-forgiving user interfaces. A typical Linux server (such as Ubuntu) will often be fully command-line oriented. In addition, Python and R can be slow for certain execution tasks. There are mechanisms for integrating with C++ in order to improve execution speeds, but it requires some experience in multi-language programming.
While proprietary software is not immune from dependency/versioning issues it is far less common to have to deal with incorrect library versions in such environments. أنظمة التشغيل مفتوحة المصدر مثل لينكس يمكن أن تكون أكثر صعوبة لإدارة.
I will venture my personal opinion here and state that I build all of my trading tools with open source technologies. In particular I use: Ubuntu, MySQL, Python, C++ and R. The maturity, community size, ability to "dig deep" if problems occur and lower total cost ownership (TCO) far outweigh the simplicity of proprietary GUIs and easier installations. Having said that, Microsoft Visual Studio (especially for C++) is a fantastic Integrated Development Environment (IDE) which I would also highly recommend.
Batteries Included?
The header of this section refers to the "out of the box" capabilities of the language - what libraries does it contain and how good are they? This is where mature languages have an advantage over newer variants. C++, Java and Python all now possess extensive libraries for network programming, HTTP, operating system interaction, GUIs, regular expressions (regex), iteration and basic algorithms.
C++ is famed for its Standard Template Library (STL) which contains a wealth of high performance data structures and algorithms "for free". Python is known for being able to communicate with nearly any other type of system/protocol (especially the web), mostly through its own standard library. R has a wealth of statistical and econometric tools built in, while MatLab is extremely optimised for any numerical linear algebra code (which can be found in portfolio optimisation and derivatives pricing, for instance).
Outside of the standard libraries, C++ makes use of the Boost library, which fills in the "missing parts" of the standard library. In fact, many parts of Boost made it into the TR1 standard and subsequently are available in the C++11 spec, including native support for lambda expressions and concurrency.
Python has the high performance NumPy/SciPy/Pandas data analysis library combination, which has gained widespread acceptance for algorithmic trading research. Further, high-performance plugins exist for access to the main relational databases, such as MySQL++ (MySQL/C++), JDBC (Java/MatLab), MySQLdb (MySQL/Python) and psychopg2 (PostgreSQL/Python). Python can even communicate with R via the RPy plugin!
An often overlooked aspect of a trading system while in the initial research and design stage is the connectivity to a broker API. Most APIs natively support C++ and Java, but some also support C# and Python, either directly or with community-provided wrapper code to the C++ APIs. In particular, Interactive Brokers can be connected to via the IBPy plugin. If high-performance is required, brokerages will support the FIX protocol.
استنتاج.
As is now evident, the choice of programming language(s) for an algorithmic trading system is not straightforward and requires deep thought. The main considerations are performance, ease of development, resiliency and testing, separation of concerns, familiarity, maintenance, source code availability, licensing costs and maturity of libraries.
فائدة الهندسة المعمارية المنفصلة هي أنه يسمح لللغات بأن تكون "موصولة" لمختلف جوانب كومة التداول، وعندما تتغير المتطلبات. A trading system is an evolving tool and it is likely that any language choices will evolve along with it.
مجرد بدء مع التداول الكمي؟
3 أسباب الاشتراك في قائمة البريد الإلكتروني كوانتستارت:
1. دروس التداول الكمي.
سوف تحصل على إمكانية الوصول الفوري إلى دورة مجانية 10-البريد الإلكتروني معبأة مع تلميحات ونصائح لمساعدتك على البدء في التداول الكمي!
2. جميع أحدث المحتوى.
كل أسبوع سوف نرسل لك التفاف جميع الأنشطة على كوانتستارت لذلك عليك أن لا يفوتون وظيفة مرة أخرى.
ريال مدريد، وقابلة للتنفيذ نصائح التداول الكمي مع أي هراء.

Comments

Popular posts from this blog

معظم استراتيجيات التداول اللحظي الأكثر نجاحا

سيغنال فوريكس 2017

نظام التداول العالمي البوكيمون أوميغا روبي