Wednesday 14 March 2018

استراتيجية أزواج التكامل المشترك


دروس.
انظر أيضا الوثائق ومقاطع الفيديو والدردشة.
جينغ هو المطور الكمي في كوانتكونيكت. لديها ماجستير في الرياضيات المالية من جون هوبكنز وعملت سابقا في شمال شرق الأوراق المالية إجراء البحوث الكمية.
المقالات الأخيرة.
أزواج التداول & # 8211؛ كوبولا فس كوينتغراشيون.
في دروس استراتيجية، نشرت في 13 يونيو 2017.
نحن نحقق في اثنين من أساليب التداول أزواج ومقارنة النتائج. ينطوي تداول أزواج في التحقيق في هيكل الاعتماد بين اثنين من الأصول المترابطة للغاية. مع افتراض أن معدل العائد سوف يحدث، يتم إدخال مراكز طويلة أو قصيرة في الاتجاه المعاكس عندما يكون هناك اختلاف السعر. وعادة ما يتم توزيع توزيع سعر الأصول من خلال توزيع غوسي لسلاسل العودة ولكن التوزيع العادي المشترك قد يفشل في التقاط بعض السمات الرئيسية لاعتماد سعر أزواج الأسهم مثل الاعتماد على الذيل. نحن التحقيق في استخدام نظرية كوبولا لتحديد هذه الفرص التجارية.
في هذا البرنامج التعليمي، وسوف نناقش الإطار الأساسي لل كوبولا من منظور رياضي وشرح كيفية تطبيق النهج في التداول أزواج. ويستند تنفيذ الخوارزمية على أساس ورقة استراتيجيات التداول مع كوبولاس [1] الواقف Y، ماريز D، بوتا I. استراتيجيات التداول مع كوبولاس [J]. مجلة العلوم الاقتصادية والمالية، 2018، 6 (1): 83-107. نسخة على الإنترنت من ستاندير Y، ماريز D، بوتا I (2018). نقارن أداء استراتيجية التداول أزواج كوبولا مع طريقة التداول أزواج التكامل على أساس ورقة استراتيجيات التداول التحكيم الإحصائية والتداول عالية التردد من هانسون تا، قاعة J R. (2018) [2] هانسون تا، قاعة J ر. استراتيجيات التداول في المراجحة الإحصائية والتجارة عالية التردد [J]. 2018. وتفترض تقنية التكامل المشترك علاقة التكامل المشترك بين الأسهم المقترنة لتحديد فرص تجارية مربحة. وتشير النتائج التجريبية إلى أن الإستراتيجية القائمة على كوبولا هي أكثر ربحية من تقنيات تداول الأزواج التقليدية.
إطار، بسبب، كوبولا.
1. التعريف.
وبالنظر إلى متجه عشوائي، فإن وظائف التوزيع التراكمي الهامشية (دفس) هي. من خلال تطبيق احتمالية التكامل المتكامل لكل مكون، توزيعات هامشية موحدة (من ويكيبيديا).
ثم يعرف كوبولا كدالة التوزيع التراكمي المشترك، التي يكون التوزيع الهامشي لكل متغير U موحدا.
تحتوي وظيفة كوبولاس على جميع خصائص التبعية للتوزيعات الهامشية، وسوف تصف بشكل أفضل العلاقة الخطية وغير الخطية بين المتغيرات، باستخدام الاحتمال. وهي تسمح بتوزيع التوزيعات الهامشية بشكل مستقل عن بعضها البعض، وليس هناك حاجة إلى افتراض على السلوك المشترك للهامشيات. [3] راد H، لو R K Y، فاف R. ربحية استراتيجيات التداول أزواج: المسافة، والتكامل المشترك وأساليب كوبولا [J]. كوانتيتاتيف فينانس، 2018، 16 (10): 1541-1558.online كوبي.
2. كوبولاس ثنائي المتغير.
منذ يركز هذا البحث على كوبولاس ثنائي المتغير (لتداول أزواج لدينا 2 المتغيرات العشوائية) يتم تحديد بعض الخصائص الاحتمالية.
اسمحوا X و Y يكون اثنين من المتغيرات العشوائية مع وظيفة الاحتمال التراكمي و. والتي يتم توزيعها بشكل موحد. ثم وظيفة كوبولا هو. إن أخذ مشتق جزئي من الدالة كوبولا على U و V يعطي وظيفة التوزيع المشروط كما يلي:
3. أرخميد كوبولاس.
هناك العديد من الوظائف كوبولا التي تمكننا من وصف هياكل الاعتماد بين المتغيرات، بخلاف الافتراض غاوس. هنا سوف نركز ثلاثة من هذه؛ و كلايتون، غومبل وصياغات كوبولا فرانك من الطبقة أرتشيميدان.
أركيميدان كوبولاس [4] محفوظ M، مايكل M. بيفاريت أرشيميدان كوبولاس: تطبيق لمؤشرين سوق الأسهم [J]. بمي بابر، 2018. تستند النسخ الإلكترونية على تحويلات لابلاس φ لوظائف التوزيع أحادي المتغير. [5] لاندغراف N، سشولتوس K، ديريس D R B. تداول أزواج عالية التردد على أساس الأسهم الذهبية للذهب [J]. 2018.
وتكون دالة كثافة الاحتمال هي:
أين هو معكوس المشتقة الثانية من وظيفة المولد.
جينست أند ماكاي (1986) [6] جينست، C. أند ماكاي، J.، 1986، ذي جوي أوف كوبولاس: بييفاريت ديستريبوتيونس ويث ونيفورم هامينز، ذي ستاتيستيكيان أمريكان، 40، 280-283 أثبت أن العلاقة بين وظيفة مولد كوبولا و كندال رتبة تاو الارتباط في حالة ثنائي المتغير يمكن أن تعطى من قبل:
حتى نتمكن من تقدير بسهولة المعلمة في أرخميدان كوبولاس إذا كنا نعرف كندال تاو رتبة الترتيب وظيفة مولد. يرجى الرجوع إلى الخطوة 3 لرؤية الصيغ.
الجزء الأول: طريقة الكوبولا.
صناديق الاستثمار المتداولة لديها العديد من قطاعات الأسهم المختلفة وفئات الأصول التي توفر لنا مجموعة واسعة من أزواج التداول المرشحين. تتكون مجموعة البيانات لدينا من البيانات اليومية لصناديق الاستثمار المتداولة في بورصة ناسداك أو بورصة نيويورك.
نحن نستخدم أول 3 سنوات من البيانات لاختيار أفضل المناسب كوبولا وزوج الأصول ("فترة تكوين التدريب"). بعد ذلك، نستخدم فترة 5 سنوات من 2018 إلى 2017 ("فترة التداول")، لتنفيذ الاستراتيجية. خلال فترة التداول نستخدم نافذة المتداول 12 شهرا من البيانات للحصول على المعلمات كوبولا ("فترة تشكيل المتداول").
الخطوة 1: تحديد الأسهم المقترنة.
وتستند الطريقة العامة لاختيار الزوج على كل من التحليل الأساسي والإحصائي. (7) جين فولغر. أزواج التداول مثال نسخة على الانترنت.
1) تجميع قائمة من الأزواج المحتملة ذات الصلة.
ويمكن ربط أي أزواج عشوائية. ومن المحتمل ألا تكون هذه المتغيرات ذات صلة ببعضها البعض، ولكن بسبب علاقة زائفة إما بسبب المصادفة أو وجود عامل ثالث غير مرئي. وبالتالي، فمن المهم بالنسبة لنا أن نبدأ مع قائمة من الأوراق المالية التي لديها شيء مشترك. لهذا العرض، نختار بعض صناديق الاستثمار المتداولة الأكثر تداولا في بورصة ناسداك أو بورصة نيويورك. ويمكن أن تكون العلاقة بين تلك الأزواج التي يحتمل أن تكون ذات صلة بسبب تداخل في الفهرس أو القطاع أو الأصول. مثلا كوق و زلك هما إتفس التي تتبع مؤشرات السوق الرائدة.
2) تصفية زوج التداول مع الارتباط الإحصائي.
لتحديد أزواج الأسهم لتضمينها في التحليل، يتم تحليل الارتباطات بين أزواج إتف المحددة مسبقا. وفيما يلي ثلاثة أنواع من تدابير الارتباط التي نستخدمها عادة في الإحصاءات:
= عدد من كونكوردانت.
= عدد المتناقض.
= الفرق بين صفوف القيم المقابلة و.
يمكننا الحصول على هذه المعاملات في بيثون باستخدام وظائف من مكتبة احصائيات في سسيبي. وقد تم حساب الارتباطات باستخدام عوائد سعر السهم اليومي خلال فترة تكوين التدريب. وجدنا أن تقنيات الارتباط الثلاث تعطي إتفس المقترنة نفس تصنيف معامل الارتباط. ويفترض الارتباط بيرسون أن كلا المتغيرات يجب أن توزع عادة. وبالتالي هنا نستخدم كندال رتبة كقياس الارتباط واختيار أزواج مع أعلى ترتيب كندال رتبة لتنفيذ التداول أزواج.
نحصل على سعر الإغلاق التاريخي اليومي لزوج صناديق الاستثمار المتداولة لدينا باستخدام وظيفة التاريخ وتحويل الأسعار إلى سلسلة عودة السجل. اسمحوا والدلالة على سلسلة سعر السهم التاريخية للسهم س والأوراق المالية ذ. يعاد السجل إلى زوج إتف بواسطة:
t = 1،2. n حيث n هو عدد بيانات الأسعار.
الخطوة 2: تقدير توزيعات هامشية من لوغ-ريتورن.
من أجل بناء كوبولا، نحن بحاجة إلى تحويل سلسلة لوغ-ريتورن وإلى قيمتين موزعة بشكل موحد u و v. ويمكن القيام بذلك عن طريق تقدير وظائف التوزيع الهامشية وربط قيم الإرجاع بوظيفة التوزيع. وبما أننا لا نقدم أي افتراضات حول توزيع سلسلتي لوغ-ريتورن، فإننا نستخدم هنا وظيفة التوزيع التجريبي للتوصل إلى التوزيع الهامشي. وظيفة بيثون إسدف من مكتبة ستاتسموديل يعطينا سدف التجريبية كدالة الخطوة.
الخطوة 3: تقدير معلمات الكوبولا.
كما نوقش أعلاه، ونحن نقدر المعلمة كوبولا ثيتا من قبل العلاقة بين كوبولا ومقياس الاعتماد تاو كندال، لكل من كوبولاس أرخميدين.
الخطوة 4: اختيار أفضل المناسب كوبولا.
مرة واحدة نحصل على تقدير المعلمة لوظائف كوبولا، نستخدم معايير إيك لتحديد كوبولا الذي يوفر أفضل تناسب في تهيئة الخوارزمية.
حيث هي دالة احتمال الاحتمال و k هي عدد المعلمات، هنا k = 1.
وظائف الكثافة لكل وظيفة كوبولا هي كما يلي:
و كوبولا الذي يوفر أفضل تناسب هو واحد الذي يتوافق مع أدنى قيمة إيك المعيار. الزوج المختار هو "كق" & أمب؛ "XLK".
الخطوة 5: توليد إشارات التداول.
وتشمل وظائف كوبولا جميع المعلومات حول هياكل الاعتماد من اثنين من سلسلة العودة. وفقا ل ستاندير Y، ماريز D، بوتا I (2018) [8] الواقف Y، ماريز D، بوتا I. استراتيجيات التداول مع كوبولاس [J]. مجلة العلوم الاقتصادية والمالية، 2018، 6 (1): 83-107. نسخ على الانترنت، ويستخدم كوبولا المجهزة لاستخلاص نطاقات الثقة لوظيفة التوزيع الهامشي الشرطي من و، وهذا هو مؤشرات التبسيط. عندما تقع ملاحظات السوق خارج نطاق الثقة، فهذا مؤشر على أن فرص تداول الأزواج متاحة. هنا نختار 95٪ كما الفرقة الثقة العليا، 5٪ كما انخفاض الفرقة الثقة كما هو مبين في ورقة. تم اختيار مستوى الثقة بناء على تحليل الاختبار الخلفي في الورقة التي تظهر أن استخدام 95٪ يبدو أنه يؤدي إلى تحديد فرص تجارية مناسبة.
وبالنظر إلى العائدات الحالية للسهم X والسهم Y، فإننا نحدد "مؤشرات التسعير الخاطئ" هي:
للحصول على مزيد من الأدلة الرياضية، يرجى الرجوع إلى شيه W، وو Y (2018) [9] شيه W، وو Y. كوبولا القائم على استراتيجية التداول أزواج [C] // جمعية التمويل الآسيوي (أسفا) 2018 المؤتمر. دوي. 2018، 10.
يمكن اشتقاق صيغ الاحتمالات المشروطة من كوبولاس ثنائي المتغير عن طريق أخذ مشتقات جزئية من وظائف كوبولا المبينة في الجدول 1. النتائج هي كما يلي:
بعد اختيار أزواج التداول وأفضل كوبولاس المجهزة، ونحن نتخذ الخطوات التالية للتداول. يرجى ملاحظة أننا ننفذ الخطوات 1 و 2 و 3 و 4 في اليوم الأول من كل شهر باستخدام البيانات اليومية للأشهر ال 12 الماضية، مما يعني أن وظائف التوزيع التجريبية ومعلمات الكوبولا يتم تحديث تقدير ثيتا مرة واحدة في الشهر. باختصار كل شهر:
خلال فترة التشكيل المتداول لمدة 12 شهرا، يتم استخدام أسعار الإغلاق اليومية لحساب عوائد السجل اليومي لزوج صناديق المؤشرات المتداولة ومن ثم حساب ارتباط رتبة كندال. تقدير وظائف التوزيع الهامشية لعودة سجل X و Y، وهما ecdf_x و ecdf_y بشكل منفصل. المكونات تاو كندال في كوباول المعلمات تقدير المعلمة للحصول على قيمة ثيتا. تشغيل الانحدار الخطي على سلسلة السعر اثنين. يستخدم المعامل لتحديد عدد الأسهم من الأسهم X و Y لشراء وبيع. على سبيل المثال، إذا كان المعامل هو 2، لكل سهم X الذي يتم شراؤه أو بيعه، يتم بيع أو شراء وحدتين من Y.
وأخيرا خلال فترة التداول، كل يوم نقوم بتحويل عوائد اليوم ل u و v باستخدام وظائف التوزيع التجريبية ecdf_x و ecdf_y. بعد ذلك، يتم حساب مؤشرين خاطئين في كل يوم تداول باستخدام الكوبية المقدرة C. تقوم الخوارزمية ببناء مراكز قصيرة في X والمواقف الطويلة في Y في الأيام التي و. أنه يبني موقف قصير في Y والمواقف الطويلة في X في الأيام التي و.
الجزء الثاني: طريقة التكامل المشترك.
بالنسبة لأسلوب تداول أزواج التكامل، نختار نفس زوج إتف "غلد" & أمب؛ "DGL". ليست هناك حاجة لاختيار وظيفة كوبولا لذلك ليس هناك سوى 12 شهرا فترة تشكيل المتداول. فترة التداول 5 سنوات من يناير 2018 إلى مايو 2017.
الخطوة 1: إنشاء سلسلة انتشار.
في بداية كل شهر، نقوم بإنشاء سلسلة الأسعار سجل اثنين من صناديق الاستثمار المتداولة مع الإغلاق اليومي. ثم يتم تقدير سلسلة الانتشار باستخدام تحليل الانحدار استنادا إلى بيانات سلسلة سعر السجل.
للأسهم X و Y، ونحن تشغيل الانحدار الخطي على سلسلة الأسعار سجل والحصول على معامل β.
الخطوة 2: حساب العتبة.
باستخدام الانحراف المعياري للفرق خلال فترة تشكيل المتداول، يتم تعيين عتبة اثنين من الانحرافات المعيارية لاستراتيجية التداول كما هو مبين في الورقة.
الخطوة 3: إعداد إشارات التداول.
في كل يوم تداول، ندخل التجارة كلما تنتشر الفارق أكثر من اثنين من الانحرافات المعيارية بعيدا عن المتوسط. وبعبارة أخرى، نقوم بإنشاء مواقع قصيرة في X والمواقف الطويلة في Y في اليوم الذي ينتشر & غ؛ يعني + 2 * ستد. نقوم بإنشاء مراكز بيع قصيرة في Y و مراكز طويلة في X في اليوم الذي ينتشر و لوت؛ المتوسط ​​-2 * ستد. وتخرج التجارة إذا أعيد انتشارها إلى توازنها (الذي يعرف بأنه أقل من نصف انحراف معياري عن الصفر).
وتحسب قيمة المتوسط ​​والانحراف المعياري من فترة تشكيل المتداول وسيتم تحديثها مرة واحدة في الشهر.
استنتاج.
في نهاية المطاف تعتزم أزواج التداول التقاط الاختلاف السعر بين اثنين من الأصول المترابطة من خلال انعكاس المتوسط. نتائجنا تثبت أن النهج كوبولا لتداول أزواج متفوقة على طريقة التكامل المشترك التقليدية لأنه يقوم على احتمال هيكل الاعتماد، مقابل التكامل المشترك الذي يعتمد على التباين الخطي بسيط الانحدار من التسعير العادي. لقد وجدنا من خلال اختبار أداء طريقة كوبولا أقل حساسية لمعلمات البداية. ولأن أسلوب التكامل المشترك يعتمد على التوزيع المعياري وأن أزواج إتف لديها تقلبات منخفضة، فإن هناك فرصا تجارية قليلة.
وبوجه عام، فإن صناديق الاستثمار المتداولة غير متقلبة جدا، وبالتالي فإن معدلات الانتعاش لم توفر فرصا تجارية كثيرة. هناك فقط 39 الصفقات خلال 5 سنوات لطريقة التكامل المشترك.
ويلاحظ أن استخدام كوبولا في التداول أزواج يوفر المزيد من الفرص التجارية لأنها لا تتطلب أي افتراضات صارمة [10] ليو R Q، وو Y. التداول أزواج: نهج كوبولا [J]. جورنال أوف ديريفاتيفس & أمب؛ صناديق التحوط، 2018، 19 (1): 12-30. .
باكتست طريقة كوبولا.
المساهمين.
المراجع.
`مرحبا جينغ وو. أشكركم على مقال ممتاز. لدي سؤال، ولكن قد يكون ذلك بسبب سوء فهم رمز بيثون (الخلفية في C #). تشير النظرية إلى أن سلسلة عودة السجل تعطى بواسطة لن (P_x، t / P_x، t-1)، ولكن في التعليمات البرمجية يبدو أنك تعود فقط لن (P_x، t)، في السطر التالي من التعليمات البرمجية: نب. log ([فلوت (z) فور z في close_price]). واسمحوا لي أن أعرف ما أنا في عداد المفقودين. شكرا لكم.
هل تتحدث عن التكامل المشترك؟ نظريا لن (بت) يجب أن تستخدم بدلا من ذلك إذا عود السجل.
عذرا، خطأ إملائي في الرد الأخير:
يرجى تجاهل تعليقي / السؤال السابق، وأنا أدرك & # 8220؛ فرق & # 8221؛ وظيفة يعتني هذا & # 8211؛ الرياضيات 101.
مرحبا جينغ وو، لقد باكتستد استراتيجيتك من الفترة 2018-01-01 إلى 2017-09-11. ومع ذلك، من حوالي سبتمبر 2018 فصاعدا، بيتا، صافي حيازات والرافعة المالية ويبدو أن تكون ثابتة. هل هناك أي حدس لذلك؟ أنا لا & # 8217؛ ر أعتقد أن رمز مكسورة، ولكن أنا مجرد فضول لمعرفة ما الحدس سيكون أن يسبب مثل هذه النتيجة.
وقد يكون ذلك بسبب عدم وجود تجارة جديدة في ذلك الوقت. لتداول أزواج يعني أن يتم تشغيل حالة التداول.
شكرا جزيلا لهذا المنصب مثيرة جدا للاهتمام. ومن المفيد جدا أن يكون كل المنطق والصيغة أوضح بشكل واضح وتوليفها.
لدي 2 ملاحظات بشأن ألغو على الرغم من:
+ غومبيل تناسب القيام به على مجموعة المعايرة [2006 - 2009] لا يعمل. هذا لا يمنع الغو على الرغم من أن الأخير يختار كوبولا فرانك في النهاية لكنه يقرر فقط استخدام إيك لفرانك وكلايتون. السبب في أن صالح على غومبل لا يعمل يأتي من 2 الانقسامات بنسبة 0، بسبب قيم u أو الخامس.
+ تشير المشاركة أعلاه إلى الإصدار التجريبي العالي جدا من ألغو، وأوافق على أنه من المستغرب وجود استراتيجية زوج. هذا بيتا عالية هو ستريكينغ بشكل خاص عند مجرد مقارنة نتائج ألغو و S & أمب؛ P. التصورات المحلية للأوراق المالية الأمريكية في الربعين الثالث والثامن من عام 2018 والربع الأول من عام 2018 تظهر على الطبقة القبلية كما لو كان الأخير هو مجرد أسهم طويلة. أخذت الحرية لحساب يوم بعد يوم موقف صافي في كل عنصر من الزوج المختار [أي. زلك و كق]. يبدو أنه من نهاية عام 2018 حتى نهاية الغو هو طويل الأجل إتفس وبالكاد يغير الموقف. قد أكون مخطئا تماما ولكن أعتقد أن هذا يفسر بيتا، والحيازات الصافية وانخفض فجأة حجم الصفقات.
مرحبا جينغ وو، لقد باكتستد الاستراتيجية الخاصة بك ولكن أنا لا & # 8217؛ ر يبدو أن فهم كيف بالضبط يتم اتخاذ المواقف. وفقا ل تبويب التجارة فقط يتم تداول كميات صغيرة من الأصول الأساسية.
المنطقي هو هذا. افترض أن لدي 100000 دولار وهناك إشارة من كوبولاس لشراء A (الأسعار حاليا في 10 $) وقصير B (بسعر حاليا في 20 $). هل يمكنني شراء 10 000 سهم من A و قصيرة 5 000 سهم من B؟
كم من الوقت سأكون في هذا الموقف؟ حتى نهاية اليوم / اليوم التالي أو حتى يحدث إشارة أخرى؟ شكرا لكم.
مرحبا فراتي، نعم هنا أنا تخصيص 40٪ رأس المال في كل سهم. غير أن نسبة المخزون ألف وباء تستند إلى معامل الانحدار للسعر التاريخي لأصولين، وليس فقط السعر في يوم التداول. يتم تغيير الموقف حتى يحدث إشارة أخرى.
مرحبا جينغ، شكرا لك فر كثيرا عن المادة ممتازة وتقديم طريقة تطبيق كوبولا لتداول الزوج 🙂
فيما يتعلق بإشارات التداول، ذكرت أنك & # 8220؛ نقوم بإنشاء مواقع قصيرة في X ومواقع طويلة في Y في اليوم الذي ينتشر & غ؛ يعني + 2 * ستد. نقوم بإنشاء مراكز بيع قصيرة في Y ومراكز طويلة في X في اليوم الذي ينتشر & لوت؛ يعني -2 * ستد & كوت؛
وبما أننا نراجع Y على X، فإذا كان انتشار & كوت؛ تطبيع & كوت؛ انتشار (متوسط ​​الانتشار) / سد، هو أوسع من انحرافين معياريين، فهذا يعني أن Y غير مؤهل X، وبالتالي نريد أن نختصر الانتشار ، وهذا يعني أننا نذهب قصيرة على Y (وهو الأسهم المتفوقة) و لونغ X (وهو الأسهم أدفورفورمينغ).
مرحبا أنا طالب دراسة زوج التداول، وأنا & # 8217؛ م مبتدئ فقط،
أريد تشغيل التعليمات البرمجية وفهم المنطق، ولكن يمكنني & # 8217؛ ر ر.
كل من التعليمات البرمجية الخاصة بك .. إذا كنت العقل يطلب منك أن ترسل لي رمز كامل.
أنا & # 8217؛ م ليست جيدة جدا في اللغة الإنجليزية لأنني & # 8217؛ m الكورية آسف لذلك!
آمل أن ردكم. شكرا.
الرمز في نهاية الصفحة. ما عليك سوى النقر على الرمز & # 8216؛ الشفرة & # 8217؛ علامة التبويب باكتست المرفقة أو استنساخ خوارزمية سترى التعليمات البرمجية.
عمل جيد. في بعض الأحيان قد نكون مهتمين متى ولماذا افتراض يعني انعكاس يحمل. من شأنه أن يكون مغريا لتقديم أفكار جديدة لتأكيد الملكية العائد العائد في أوقات التداول. عملك هو مدهش، ونأمل أنه أفضل.
ملصق ممتاز. أنا لست بيثون مبرمج حتى أنا سحب شعري من تحويل هذا إلى ماتلاب. ولكن، في السطور التالية من التعليمات البرمجية يبدو لي مثل ترتيب حساب عوائد مختلفة:
1. لوجريتورن [self. ticker [j]] = np. diff (np. log ([فلوت (z) فور z في كلوز]))
2. return_x = np. log (فلوت (self. price_list [self. syl [0]] [- 1] /self. price_list [self. syl [0]] [- 2]))
في (1) يختلف سعر السجل ولكن في (2) يتم تسجيل الفرق؟
(1) و (2) هي نفسها لأن لوغ (A / B) = لوغ (A) & # 8211؛ سجل (B)
هل يمكنك أن توضح ما هي الخطوط التالية؟
٪ تحويل العائدين إلى قيم موحدة u و v باستخدام وظائف التوزيع التجريبية.
ويفترض أنها ليست ببساطة: ecdf_x، ecdf_y = إسدف (x)، إسدف (y)؟
لماذا ألغو كوبلا التجارة فقط ق / زلك؟ قمت بإجراء اختبار باكتست من 01/01/2006 و فقط هذا الزوج يتداول.
أخذ المناقشة إلى استخدامات كوبولا في مناطق أخرى (I & # 8217؛ م تاجر الخيارات) & # 8230؛.wikipedia يقول: & # 8220؛ في حين أن تطبيق كوبولاس في الائتمان قد ذهب من خلال شعبية وكذلك سوء الحظ خلال والأزمة المالية العالمية 2008-2009، [29] يمكن القول إن نموذجا معياريا للصناعة لتسعير كدوس. كما تم تطبيق كوبولاس على فئات الأصول الأخرى كأداة مرنة في تحليل المنتجات المشتقة متعددة الأصول. وكان أول تطبيق من هذا القبيل خارج الائتمان هو استخدام كوبولا لبناء سطح سلة تقلب ضمنية، [30] مع الأخذ بعين الاعتبار ابتسامة تقلب مكونات سلة. اكتسبت كوبولاس منذ ذلك الحين شعبية في التسعير وإدارة المخاطر [31] من الخيارات على الأصول المتعددة في وجود تقلب الابتسامة / الانحراف، & # 8221؛ هل هذا يعني بناء ابتسامة تقلب ليقول خيارات سبس باستخدام الابتسامات تقلب مكوناته؟ هذه مشكلة في & # 8217؛ واجهت مرات عديدة كمدير موقف. شكرا لكم.
يمكن لهذا النهج كوبولا إلى أزواج العمل التجاري على إطار زمني أقصر بكثير & # 8230؛ .. يقول 3-5 الرسم البياني دقيقة حيث كنت تبحث عن تردد أعلى بكثير من الصفقات؟

استراتيجية تداول أزواج التكامل
تداول الأزواج هو شكل من أشكال انعكاس المتوسط ​​الذي يتميز بميزة واضحة من التحوط دائما ضد تحركات السوق. وهي عموما استراتيجية ألفا عالية عندما تدعمها بعض الإحصاءات الدقيقة. هذا المفكرة يعمل من خلال المفاهيم التالية.
ويهدف دفتر الملاحظات ليكون مقدمة للمفهوم، وبينما هذا الكمبيوتر المحمول يتميز زوج واحد فقط، وربما كنت تريد خوارزمية الخاص بك للنظر في العديد من أزواج في آن واحد.
تم إنشاء جهاز الكمبيوتر المحمول أصلا لعرض في قسم كس التطبيقية هارفارد ومنذ ذلك الحين استخدمت في ستانفورد، كورنيل، والعديد من الأماكن الأخرى. إذا كنت ترغب في معرفة المزيد عن كيفية استخدام كوانتوبيان كأداة تعليمية في أعلى الجامعات، يرجى الاتصال بي على [إمايل & # 160؛ المحمية]
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
وهنا خوارزمية بسيطة جدا على أساس النهج المقدم في دفتر الملاحظات.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
وهنا خوارزمية أكثر تطورا كتبه إرني تشان. وتحسب هذه الخوارزمية نسبة التحوط بدلا من مجرد الاحتفاظ بكميات متساوية من كل ضمان.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
أشياء مفيدة جدا.
ما الذي يجعلها تفقد بشكل منهجي لما يقرب من 3 أشهر؟ هل فشل التكامل المشترك في تلك الفترة؟
في الأساس نعم، اتضح أن لا تكون مشتركة في هذا الإطار الزمني، ولكن عاد إلى كونونيغراتد على المدى الطويل.
أعتقد أن السحب الذي تشير إليه هو حالة قوية لماذا تريد فعلا العديد من أزواج التداول في نفس الوقت. أزواج يمكن كوينيغراتد على نطاقات زمنية مختلفة، وأي واحد معين لن يكون دائما في حالة تجارية (انتشار كبير، انتشار صغير). من خلال زيادة حجم العينة الخاصة بك، يمكنك جعله أكثر احتمالا أن زوج واحد على الأقل سوف تكون دولة قابلة للتداول بقوة في وقت معين، وسلس من المطبات الغريبة التي تراها هنا.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
شكرا على هذا. مفيدة جدا في الواقع. لاحظت كنت تستخدم المعزز ديكي فولر اختبار لاختبار التكامل المشترك. هل لديك تطبيق مماثل باستخدام اختبار يوهانسن؟ أنا غير قادر على العثور على اختبار جوهانسن مع الثعبان.
ويبدو أنه في حين كانت هناك بعض المحاولات لإضافة اختبار جوهانسن إلى مكتبة ستاتسموديلز، حاليا لا يوجد أي تطبيق مدمج. هنا، على سبيل المثال، هو تنفيذ طرف ثالث. أنا لست متأكدا متى ستحصل على إضافة إلى المكتبات بايثون، هل هناك طريقة يمكنك العمل حولها عدم وجود ذلك؟
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
شكر. لقد رأيت هذا الرابط. معقدة جدا لتنفيذ وكتابة كل شيء في إيد. في الواقع، حاول ساتيا B هنا هتبس: // كوانتوبيان / المشاركات / ترادينغ-باسكيتس-كو-إنتغراتد-ويث-سبي.
جمال اختبار يوهانسن هو أنه يولد إيجنفكتورس، والتي أعتقد أنه يمكنك استخدام طرق أخرى لحساب على الرغم من أنني لا أستذكر في هذه اللحظة، لمدة تصل إلى 12 الأصول والعديد من الأشياء الأخرى، والتي يمكن استخدامها لإنشاء سلة. كنت أبحث في واحدة من استراتيجية أرنب مؤشر إرني ومحاولة تكرار ذلك على منصة Q لتقييم الأداء بعد الرسوم / الخ الخ. لاحظت الرسوم يبدو أن مضغ الكثير من الأداء. ذي أبغ & أمب؛ زوج فسلر أعلاه لديه نسبة شارب 0.75 ولكن انتهت مع شارب نسبة -0.29. وهناك الكثير من الأزواج تبدو مربحة تحولت إلى أن تكون غير مربحة بعد انتشار عرض / طلب، والرسوم، والعمولة وما إلى ذلك وبالتالي، وأنا أنظر في 3 أو أكثر من الأسهم تداول الزوج، وفهرس أرب. سوف جوهانسن اختبار جعل هذا أسهل لتنفيذ.
سأواصل المحاولة.
دفتر الملاحظات هو مقدمة إحصائية ممتازة لتداول أزواج، أوصي أي شخص مهتم في هذا الموضوع ننظر أيضا في بعض البحوث المالية. تشريح أزواج التداول هو بداية جيدة، والمراجع هي مفيدة كذلك. هناك ورقتان عامتان أخريان حول إستراتيجيات المراجحة المخاطر هي خصائص المخاطر و العائد في مخاطر المخاطر و المراجحة المحدودة في أسواق الأسهم. هناك بعض الدروس المكلفة التي تعلمها الناس حول إدارة هذه الأنواع من الاستراتيجيات، ومن المفيد معرفة الدروس مقدما. يتم تحذير مسبق.
أنتوني، جيد أن أراك هنا! لقد كنت تبحث عن تنفيذ جيد للاختبار يوهانسن لفترة من الوقت ولكن لا يمكن العثور على واحد. // ^ جيثب / ستاتسموديلز / ستاتسموديلز / القضايا / 448 و هتبس: // جيثب / جوزيف-يكت / ستاتسموديلز / كوميت / bf79e8ecb12d946f1113213692db6dac5df2b6e9 انها حقا سيئة للغاية كما بالتأكيد في التمويل الكمي هذا هو على نطاق واسع تستخدم على نطاق واسع.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Aaron. شكرا لرؤساء متابعة. نقدر أنها القادمة من الخاص بك. سأقضي بعض الوقت مع تلك الأوراق.
Thomas. شكرا على الرابط. كما قلت، فمن القديم قليلا. أفضل من لا شيء أفترض.
هنا هو تنفيذ الثعبان لنماذج تصحيح الخطأ ناقلات. يمكنك أيضا استخدامه للعثور على الأوزان كوينغراشيون. econ. schreiberlin. de/software/vecmclass. py.
هنا هو نسخة من إرني تشان خوارزمية تعديلها لتداول أزواج متعددة. هذا هو وسيلة جيدة للحصول على العديد من تيارات العائد غير مترابطة والحد من بيتا من الاستراتيجية الشاملة.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Delany، هل هناك طرق متاحة للكشف عن أزواج باستخدام اختبارات إحصائية؟ أم أن تلك عادة ما تكون مكلفة حسابيا؟
ونحن نعمل على طريقة لجعل استنساخ أجهزة الكمبيوتر المحمولة - قادرة على بيئة البحث الخاصة. في هذه الأثناء المهتمين في اللعب مع دفتر الملاحظات من آخر الأصلي يمكن تحميل البرنامج هنا. بعد تحميل تحميله في حساب البحث الخاص بك. إذا لم يكن لديك حساب بحث حتى الآن، أدخل خوارزمية في المسابقة لتلقي الوصول.
good التاجر، فإن الطريقة المقدمة في دفتر الملاحظات شاشة قائمة معينة من الأوراق المالية للتكامل المشترك، والحالة الأساسية اللازمة لتداول أزواج. المشكلة ليست بقدر تعقيد الحسابية كما هو فقدان القوة الإحصائية. لمزيد من المقارنات التي تقوم بها، وأقل وزنك يجب أن تضع على قيم P كبيرة. هذه الظاهرة موصوفة هنا. ولكي تكون صادقا إحصائيا، يجب تطبيق تصحيح بونفيروني على قيم p التي تم الحصول عليها من نص برمجي ثنائي التكافؤ. والسبب في ذلك هو أنه كلما زادت قيم p التي تولدها، كلما زادت احتمالية مواجهة قيم P ذات قيمة زائفة ولا تعكس سلوك التكامل المشترك الفعلي في الأوراق المالية الأساسية. وبما أن عدد المقارنات التي أجريت عند البحث عن التكامل المشترك بين الزوجين في الأوراق المالية ن ينمو بمعدل O (n ^ 2)، فإن النظر إلى 20 ورقة مالية سيجعل معظم الاختبارات الإحصائية غير مجدية. وهناك نهج أفضل هو التوصل إلى مجموعة صغيرة من الأوراق المالية المرشحة باستخدام تحليل الروابط الاقتصادية الأساسية. ويمكن بعد ذلك إجراء عدد قليل من الاختبارات الإحصائية لتحديد أي، إذا وجدت، أزواج هي كوينغراتد. اسمحوا لي أن أعرف إذا كان هذا هو ما تقصده.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
إنني أختلف إلى حد ما عن المشكلة التي تنطوي على مقارنات كثيرة جدا. تصحيح بونفيروني مناسب عندما كنت تبحث عن الحقيقة. على سبيل المثال، إذا كان لديك استبيان يحتوي على 1000 عنصر وكنت تعطيه للأشخاص الذين يعانون من السرطان أو بدونه، سوف تجد في المتوسط ​​50 البنود التي ترتبط مع السرطان عند مستوى 5٪ من الأهمية الإحصائية، حتى لو كان لا شيء على يرتبط الاستبيان بالسرطان. إذا كنت تفكر في مجموعات من عنصرين أو أكثر، يمكنك إنشاء العديد من الارتباطات تريد.
ولكن عند تصميم استراتيجيات التداول الآلي، والعلاقات المصادفة لا تؤذي لك كثيرا. أنها تضيف الضوضاء العشوائية وتكاليف التداول إلى النتائج الخاصة بك. وبما أن نتائج قليلة هي 100٪ لا معنى لها، فإن معظم العلاقات لديها على الأقل بعض درجة من المثابرة، فإنه ليس من الأهمية بمكان لتصفية الاستراتيجية الخاصة بك وصولا الى تلك التي تم التحقق منها بدقة. الأرباح المسألة، وليس الحقيقة. بونفيروني ومقاييس مماثلة يدفعك إلى العلاقات الأكثر موثوقية إحصائيا، والتي ليست عموما الأكثر فائدة اقتصاديا.
إذا كان "تحليل الروابط الاقتصادية الأساسية & كوت؛ يعني البدء مع أزواج الطبيعية مثل اثنين من الشركات المماثلة في نفس الصناعة، لم أجد أن من المفيد. في الأساس الناس يلاحظ الاشياء واضحة. إذا كنت تعنى التفكير في علاقات أقل وضوحا، وخاصة الأشياء التي غير مرئية في البيانات المعتادة الناس استخدام، ثم أوافق. من الناحية المثالية تريد قصة اقتصادية صالحة للعلاقة الزوج، وهو ما يفسر كل من سبب وجوده ولماذا لا يتم محجوب بعيدا. ليس فقط هذا الحراسة ضد استخراج البيانات، ولكن هذا يعني أنه يمكنك قياس ما إذا كان التأثير لا يزال يعمل (دون ذلك، فإن الطريقة الوحيدة التي تعرف استراتيجية لا تعمل عندما تفقد المال).
عمل جيد. أنا لا أقرأ من خلال دفتر الملاحظات الخاص بك سطر بخط، ولكن أستطيع أن أقول أنه سيكون إضافة كبيرة إلى مكتبة مثال كوانتوبيان. ومتابعة مع الطحالب المشتركة - خطوة جيدة.
قد يكون لديك نظرة على دفتر نشرت، هتبس: // كوانتوبيان / بوستس / أناليسيس-أوف-مينوت-بار-ترادينغ-فولوميس-أوف-ذي-إتفس-سبي-أند-ش. لتصور كيف يذهب زوج معين من والخروج من التكامل المشترك، هل يمكن أن تجعل مؤامرة مماثلة. تطبيق الاختبار الإحصائي 390 مرة في كل يوم تداول على مدى سنوات عديدة يتطلب بعض الصبر، على الرغم من.
Aaron هل أنا صحيح في قراءة حجتك عموما كما يلي؟
- في العالم الحقيقي بونفيروني هو تقييدية جدا وعدد من أزواج مربحة تخسر عن طريق تصحيح يفوق اليقين الإحصائي تكسب أنت.
وأعتقد أننا نتفق على النقطة النهائية التي تقوم بها. وأعتقد أن العديد من الناس تحليل الارتباط الاقتصادي تفعل التبسيط وتجاهل العلاقات التي يحتمل أن تكون مثيرة للاهتمام التي هي أكثر عرضة لاحتواء ألفا غير محجوب.
Grant شكرا لك. نحن نخطط بالفعل لتوسيع مكتبة المثال إلى منهج تمويل كمي كامل تدرس مع أجهزة الكمبيوتر المحمولة وخوارزميات رفيق. سنحظى بسلسلة من المحاضرات الصيفية أثناء تطوير المزيد من الموضوعات، لذا كن على اطلاع بذلك. دفتر الملاحظات الخاص بك هو بارد جدا وأنا لا أتساءل كيف مستقرة درجات التكامل المشترك حتى لأزواج كوينيغراتد بقوة. للأسف، لا أعتقد أنه سيكون لدي الوقت للنظر في ذلك في المستقبل القريب ما هو مع إنتاج أجهزة الكمبيوتر المحمولة المناهج الدراسية الأخرى. نحن نبحث عن المساهمين الضيوف، ولكن. إذا كان لديك أي أجهزة الكمبيوتر المحمولة كنت ترغب في أن تكون واردة في المناهج الدراسية لدينا مع الائتمان الكامل للمؤلف (ق)، وإرسالها في طريقي وأنا سوف نرى ما إذا كانت تناسب المحتوى الحالي لدينا.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
في العالم الحقيقي بونفيروني هو تقييدية جدا وعدد من أزواج مربحة تخسر عن طريق تصحيح يفوق اليقين الإحصائي تكسب أنت.
ليس على وجه التحديد. نعم، بونفيروني مقيد جدا بمعنى أنه يعطيك عدد قليل جدا من الأزواج، ولكن بونفيروني يوجهك أيضا إلى أزواج خاطئة.
في مثال استبيان يحتوي على 1000 مادة تعطى لمرضى السرطان والمرضى غير المصابين بالسرطان، فمن المرجح أن معظم العناصر ليس لها تأثير على السرطان، أو على الأقل هذه التأثيرات الضعيفة والمعقدة التي لا يستحق استخدامها للحصول على المشورة الطبية. حتى إذا كنت تريد أهمية 5٪، يمكنك اختبار كل عنصر عند مستوى 0.005٪ (الذي تريد 3.9 الانحرافات القياسية، وليس فقط 1.6). أنت لا تفكر في ذلك، لأن أي تأثير حقيقي قوي بما فيه الكفاية إلى المسألة من المرجح أن تظهر مع أهمية قوية. If you didn't do Bonferroni, you'd end up with 50 recommendations even when none of the items mattered, and a lot of useless advice.
Incidentally, Bonferroni is a very conservative correction, and there are more sophisticated ones that allow more items.
But if you have 1,000 pairs to test, it's likely that many of them have some degree of cointegral predictability. Even if there is no predictability, including the extra pair only adds a little noise to your strategy, which is not terrible. Also you don't believe that any of them have predictability so strong that anyone would have noticed it and arbitraged it away. So it's reasonable to consider all the pairs with 5% significance or less, and filter them out using economic or other criteria unrelated to the data. Selecting only the strongest statistical relations is not wise.
You can set this up in a Bayesian framework if you like consistency and precision; or you can just use ad hoc rules of thumb.
Just for the il-pair-literated who want to learn. must there be a story behind the pair? Should there be a logical explanation? I played around with pairs and found for example that MorganStanley and Expedia work. but why? Or doesn't one want to know why.
must there be a story behind the pair?
This is actually a semantic question rather than a financial one. If you adopted a pure statistical approach with no consideration of the actual pairs, you would end up with hundreds or thousands of pairs, including some overlapping ones. Then we wouldn't call it a pairs-trading strategy but a long-short equity strategy.
The idea of pairs trading is you can get additional insight by considering specific reasons for the dependence between the stocks; and that insight can result in more accurate positioning, and also avoidance of big losses when the relation breaks.
Obvious relations, like two large-cap stocks in the same industry, tend not to be useful. That's confusing sometimes, because some of the famous early pairs trades involved such pairs, and they're still used for examples in most texts. But too many people are watching those spreads too closely to get the high Sharpe ratios you need for undiversified strategies like pairs trading. Leave those marginal Sharpes to the long-short equity people who have a lot more positions.
Also, when we talk about a reason for the pairs relation, we're talking about both a positive--why is it hard to imagine a world in which the values of these companies diverge from their historical proportions--and a negative--why do these stocks respond to different economic news? So for two near-identical companies the first question is easy, but the second is hard. For two seemingly unrelated companies like MS and EXPE it's the reverse. You might say something like, "In a good economy Morgan Stanley gets a lot of business and people travel a lot," but that's basically true of almost any two companies.
The classic pairs reason was two companies that responded to the same basic economic factors, say oil prices or interest rates or US dollar strength, but at different points in the supply chain, say crude oil prices versus gas station revenues. A single link is not good enough, virtually all companies respond to these factors. But you can find pairs that are matched on narrower factors, say fracking activity in the Northeast US or precipitation in central California, or that match direction on a number of broad factors. Or you can find two companies that are actually in similar businesses today, but that for historical reasons are listed in different sectors. Another common situation is two companies involved at different points of the lifecycle of durable assets; homebuilders and furniture stores with similar geography for example.
Anyway, when you have a reason, you have things to monitor to fine-tune your position; and to alert you if a big dislocation is a great trading opportunity or a sign than the historical relation has broken. If you don't have a reason, you'd better have a lot of diversification, meaning you can't afford the specific analysis work for each pair.
Wouldn't you admit though that if a pair has a story then that story is known and therefore unprofitable by the likes of slow to trade retail traders? And if one could mine the data and discover, through the data, stories that were unexpected that one could at least compete in the pairs trading space? I see your point on maintaining a large pool of pairs if the stories that connect the participants are weak or unexplored, but still, if we underlings wish to participate why wouldn't we use such a technique? Or do you maintain that retail traders can capture and profit from anomalous pair spreads of well known couples?
Wouldn't you admit though that if a pair has a story then that story is known and therefore unprofitable by the likes of slow to trade retail traders?
No, I wouldn't agree with that view. Pairs trading tends to be low capacity, especially in lower-cap stocks, and takes a lot of work. It's not attractive for asset managers because the investment amounts and risk characteristics are erratic. It's mostly pursued by individual full-time professional traders, who might follow a dozen pairs in addition to a few dozen other strategies, and semi-pro traders who are willing to take what the market gives them and stay in cash when none of their strategies are attractive. There are more good pairs than there are competent traders chasing them.
In principle, you could find good pairs using a clever automated filter, or by reading and thinking. My general feeling is the first is harder, and if you're going to do it, you'll want to do it to identify large numbers of pretty good pairs rather than two or three great pairs. In that case, I'd say just switch to long-short equity and forget pairs. The good thing about reading and thinking is most good quants are lazy, and would rather let the computer do the work. So you're competing with non-quants, some of whom are pretty good at reading and thinking, but are at a huge disadvantage to someone with a computer who knows a little math.
I don't want to come across as dogmatic, anyone who does what other people tell them is not likely to find great success in any sort of trading. If you think you can design an algorithm to identify good pairs, there's no harm in trying. It just doesn't strike me as the most promising approach.
. takes a lot of work.
بلى. The easy pairs trade money was made long ago. Lucrative stories in lower-cap stocks though exposes a pair to the aberrations of smaller company volatility no? "Whoops, that solar stock just lost its major contract. Or, wow, that driller just got a windfall state contract." And then the story gets rewritten, or thee or four pages get torn out. One might catch such preludes to story changes if one only watches a dozen or so stories. But here, where we're looking to avoid story watching -- going fully automated, we would get nailed by such narrative breakdowns in just a few pair relationships.
When you say switch to long/short equities you would seem to advocate abandoning the statistical search for obscure (perhaps whimsical) stories in lieu of broader mean reversion -- is this true? But, if one has the tools, why not create dozens and dozens of strange storied pair trades. Sure the stories may not actually exist. But then again, maybe you discover 10 or 20 that are unique. And through a process of eliminating the poorly paired partners, you end up with a manageable set that are capable of dancing with the stars? This site is nothing if not a massive experiment in data mining no?
Again, I'm not trying to law down laws here, but the two straightforward approaches are (a) try to find a few pairs you can understand or (b) forget about pairs and just try to build a large portfolio of longs and shorts without worrying about pairing up stocks or doing unautomated research. In other words (a) niche clever research or (b) massive data mining.
Trying to split the difference by finding dozens of pairs but not doing the tailored research necessary to understand each one seems suboptimal.
try to find a few pairs you can understand.
If I'm reading things correctly, by "understand" you mean that there should be some underlying intuitive story behind the relationship, I suppose so that there is less risk that the relationship will suddenly disappear? Are you talking about a kind of narrative, "The reason we think this is happening, but can't really explain with a model, is. ومثل. or an explanatory quantitative model that provides the story behind the relationship? Say I find a pairs trade based on the idea that when consumers buy lots of eggs, bacon sales drop off, and vice versa. I could make up a story that people can only eat so much for breakfast, and leave it at that. I have a warm, fuzzy feeling, and if I'm a professional trader, hopefully my management will feel warm and fuzzy, too. But is the risk really any different without the story? Unless I actually find a relevant study on breakfast eating, or conduct one myself, then I could just be deluded. And if the underlying cause can't be coded into a set of rules, then it is not really automated quantitative trading, right? As a Quantopian user who doesn't do this sort of thing for a living, I need to get an algo in the Quantopian hedge fund, let it run, and collect a check. No time for doing lots of offline analyses.
There are more good pairs than there are competent traders chasing them.
sounds like the land of milk and honey for us inhabitants of Quantopia. This would say that the Quantopian team should think about churning out candidate pairs for their 35,000+ users to examine like a bunch of ants, trying to come up with stories for a subset of them ("I'll take XYZ & PDQ, do some research, and see if I can find a 'story' to support the relationship.").
I'm just trying to sort out if any of this can be reduced to practice for Joe Schmo Quantopian user, or if it is a hopeless endeavor. Is there a path for Quantopian to get hundreds of lucrative, scalable pairs trading algos for their $10B hedge fund (keep in mind that by my estimation, they need several thousand distinct algos in the fund)? Or is this all a bunch of blah, blah, blah?
I've tried the automated searching of pairs/baskets, using the public knowledge techniques, and though I haven't gone through them all with my tick-level back-tester, the few that I did examine personally were largely worthless; the supposed spread mean-reversion that my grid search turned up was just spurious or due to bid-ask bounce.
However, I do know for a fact that people run decently profitable automated pairs trading portfolios. I take that to mean that it is possible, but the way that I approached it was naive. Perhaps the legwork method is the way to go, coming up with theses about drivers and then looking for portfolios that would express the theses, with the actual hedge ratio construction done "rigorously" using Kalman filters or whatever.
My take is that chatting about pairs trading is wonderful, but there should be a focus on reducing it to practice, with some sort of approachable workflow, so that a Quantopian user can sit down in his pajamas with a cup of coffee on a rainy day and actually come up with a halfway decent algo that would have a shot at getting into the crowd-sourced Q fund. For example, we have:
. try to find a few pairs you can understand.
Perhaps the legwork method is the way to go, coming up with theses about drivers.
O. K. So what's the workflow for your typical Q user? Keep in mind, this needs to be scalable. it won't do Q any good if only users with an advanced degree and 20 years of industry experience can be successful. If the answer is, "Well, there is no workflow. you just need to know" then pairs trading won't be approachable on Q. We have Aaron's "reading and thinking" recommendation above, but read what?
Also, I'd seen somewhere that there are techniques for synthesizing trading pairs, from baskets of securities. Does this work? Or does one effectively end up with the long-short equity portfolio referred to by Aaron Brown above?
The kind of warm-and-fuzzy story you mention is worthless for investing, although as you say it can reassure investors and regulators. What you're looking for is covariates to refine your strategy and, most important, warn you when it's not going to work. The quant trap is that when your relation breaks it simply looks more attractive to your model, and you spiral to doom.
The eggs-and-bacon story is actually the reverse of what you want. That says there is a fixed total consumption, so the total amount consumed of both products is fixed, meaning they are negatively cointegrated. If they were positively correlated, say because investors bid up or down all breakfast foods as a group, you would do anti-pairs trading. You're looking for things that have to be in some kind of long-term balance, but move is opposite directions in the short-term. A warm-and-fuzzy story might be residential construction and furniture sales, in the short run if people are saving for down payments they're not buying furniture, and newly house poor families are making due with old furniture and underfurnishing. But in the long run, houses will get furnished. This would never be a pairs trading story because it's relating entire sectors. To exploit this, you'd build a model tracing the full life cycle, and likely involving other factors like interest rates and family demographics and migration patterns, and trade large numbers of stocks.
To keep this practical, here is a Pairs Trading for Dummies recipe (I mean that respectfully, I'm a big fan for For Dummies books).
Run some kind of statistical screen to identify promising pairs trading targets. Don't look for extreme statistical significance, just some moderate level to screen out the noise like 5% or 1%. It can help to limit one member of each pair to companies or regions you know something about.
Clearly this is for someone who has quant skills, but also general research skills and business judgment.
Run some kind of statistical screen to identify promising pairs trading targets. Don't look for extreme statistical significance, just some moderate level to screen out the noise like 5% or 1%. It can help to limit one member of each pair to companies or regions you know something about.
it sounds like it could be productive for Quantopian to open-source some efficient tools for the screening (and maybe up their game in terms of computing resources). Let's say I'm an expert on company XYZ and maybe I could narrow down my field of candidate securities for comparison to NASDAQ-listed stocks, of which there are about 3,000. So, it is an O(N) computing problem, not O(N^2) as Delaney mentions above for the general screening problem. But, I'd like to compute the statistics on a rolling basis, every trading minute over 2 years. I'd have:
(3000 comparisons/minute)(390 minutes/day)(252 days/year)(2 years) = 589,680,000 comparisons.
Is something like this at all feasible on the Quantopian research platform? If not, how would I scale it back to something that would actually run in a reasonable amount of time (a few days at most) but still provide useful results?
I'm playing around with the algorithm by Ernie Chan that you posted.
Surprisingly, it fails entirely when I swap the pair, see the attached backtest (I've only changed the order).
Also, how to treat the negative hedge (beta from OLS). With the current implementation we go long (short) on both positions when the sign of the hedge is the same as the sign of the z-score, which you don't expect from pair trading. What economic reason can lead to such cointegrations?
Not sure exactly why it's failing when you swap the order. Seems like the math may not be robust to an 'upside-down' pair. The hedge ratio comes from the formal definition of cointegration, which is that for some b and u_t = y_t - b * x_t, u_t is stationary (the mean stays the same). Therefore we try to estimate the b parameter in each trade so that we can correctly produce a stationary drift between the two securities. It can be the case that the two are negatively cointegrated, whether there's a strong economic reason for this I'm not sure. You might try putting in place restrictions to not trade when you have double long or double short positions, or employing a better estimation method for b (more data points for example).
All of the issues you bring up are very sophisticated improvements, and making these improvements to the algorithm could result in something very good. I don't have cut and dried solutions for you, as you are now dancing around the edge of what is known about algorithmic trading. A lot of it comes down to rigorously testing different signal processing methods to see which yield the best out of sample performance. Also, like you said it's important to let the economic reasoning drive the creation of your model.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Thank you for your quick reply.
This is actually a very valuable response, as I was afraid I might have missed something obvious.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Here is a temp website which has similarity of movement information, which is about the same idea as pairs. StockA is the stock you are comparing to, row is how this pair ranks to all pairs, (its row count). It only contains information for the top 5000 or so pairs.
The data is pulled from the period of Aug 2018 to Feb 2018 and is an average of each day.
(Change IYR to symbol wanted)
The idea behind the algorithm is not actually for pairs trading, but is for similarity of how a pair moves. I will leave this test site up for a few weeks.
Thanks Delaney. It's a great starting step for pair trading technique.
I am working on the missing piece of this strategy which is how to use Quantopian Research environment to find statistical cointegration stock/ETF pairs from entire universe or from the same sectors. After I construct good pairs, then I can use the Notebook you provided for further analysis and backtest.
Does anyone have any suggestion for me?
I have a question for those trading pairs.
How do you deal with the large processing requirements?
I coded some tests for co-integration and results per combination take roughly 1 second.
I can get this down with parallel processing and by storing data locally but a universe of 2000 stocks will still have 4000000 potential combinations.
Perhaps pointing out the obvious, but .
A pre-screening tool, or pre-screening done for you for a fee .
When I was researching this sort of thing a couple of years ago, the baskets of 3 and 4 of only a few hundred ETFs took months on my MacBook. And they were all mostly garbage, though I never actually went through them all. I probably should.
If I remember correctly, that was 1.6T combinations, or something like that.
The formula is R to the Sterling S, divided by S!
so, for 4000 stocks, it would be.
(4000 x3999)/2! or, about 8 million pairs made from the 4000 typical stocks. for 3 stocks considered together, there would be 4000 x 3999 x 3998 /3!
You can prune the possible tree pretty easily though. I believe most stocks behave as if they really were ETFs (at the market neutral way of looking at it only) and can be represented by a group of other stocks, that move with their same fundamentals. You only have to know what sectors they move with, and then check for pairs against this.
So, for example, with HLF, it moves with consumer, several currencies, emerging markets, and a few others. It is hard to separate out exactly as emerging markets also move with currency, so which is which becomes the question.
For two typical tech stocks that appear to be very similar, it may well be the case that their main difference is which currencies they move with. So, for most of the time, they may appear co-integrated, but then, when there is a difference in currencies that affects one a lot, and not so much the other, they then move apart.
I was working on an algorithm to determine the underlying components, (so to speak) that collectively make each stock behave with the same logic as if it was a multi-sector ETF. (where the underlying stocks are a mystery to be solved) I have most of it done, and I believe I have enough done to prove it does work this way, but I lost my real time quote stream a few months ago, and so stopped working on it.
since my algorithm would need to consider up to 15 underlying components to solve this problem, it would be 4000 x 3999 x3998 . 3985/15! So, I have to trim it. The link I posted a few messages above shows some of the results of this work, where I first determine the possible stocks to consider, for each symbol.
It is my belief that the market is essentially swamped out with pairs trading, and this is why it works so mathematically perfect for each stock to behave as if it is an ETF.
There is certainly a high computational cost to looking at all possible pairs. However, there is a tradeoff to this approach, as you put yourself at a high risk for multiple comparisons bias. Please see earlier in this thread for a fairly complete discussion of this issue. Regardless of which method you use to select pairs, you'll want to do some additional validation using the notebook and then use the algorithms in this thread to try backtesting a strategy.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Indeed, Aaron Brown's advice is gold.
What is "multiple comparisons bias"? I'm lazy and don't feel like sifting through this rather extensive discussion thread.
I find it hard to believe that pairs trading would work as a scalable hedge fund strategy (be able to pour $10's of millions into a single pair). Is there any evidence? In other words, why is Quantopian promoting this?
This is one of the best threads on the site.
It scales; you can trade hundreds of pairs.
Multiple comparisons is a core problem in all of statistics, right up there with overfitting. The general idea is that if you run 100 statistical tests on random data, you should still expect to get 5 below a 5% cutoff and 1 below a 1% cutoff based on random chance. This is true when testing various iterations of a model, or many pairs. Because the number of pairs is O(n^2) you should expect to get a lot of spurious p-values when looking for pairs. A naive strategy of just looping through pairs won't work, you need to be a bit more sophisticated.
And yes you trade many pairs with low exposure to each. That said, I think that long-short equity strategies may be a better first bet to get into the fund at this point, just based on robustness and capacity.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
There is more electricity used in the state of New Jersey doing calculations on the market than there is electricity used in that state for manufacturing. Pairs strategy likely accounts for at least 50% of this usage as even HFT likely often uses some version of deviation from the mean. It is my opinion that the market is so saturated with pairs trading that given the price of any ten tickers that had no big news, one could deduce the price of the rest of the market and be within 0.7% of the actual price, 90% of the time for the top traded 4000 stocks. (and it could probably be done with less than ten tickers. ) So, for a 30 dollar stock, the margin of error would be about a quarter. This is how precisely, compared to each other, I think they move. Until there is news.
It sounds like a corollary to the reciprocal of the law of large numbers; given enough samples you will always find something to fit.
I would reintroduce the concept I proposed in an article in S&C last spring ; the directed acyclic graph or DAG. Using thousands of correlated or cointegrated pairs I built groups from them. Those groups were essentially social graphs of securities. You can search here for DAG, but briefly, you can use the concept of pair trading, that is, fade and favor the divergences, but with a correlated group. And such a group is assembled, dynamically, from a list of pairs that are "friends of friends". It's a pairs strategy, essentially, but with lower risk and less work managing hundreds of separate strategies.
That said, I think that long-short equity strategies may be a better first bet to get into the fund at this point, just based on robustness and capacity.
Have people been coming up with good ones? If so, what proportion are using the new data sets? If not, why not, do you think that is?
I haven't been focusing on them at all, mostly because there's a problem of opportunity cost; if I spend all my time looking for equity long-short algos, not only is there a chance I don't find anything, but if I do, there's still a chance that Quantopian doesn't select it, and since I cannot trade them myself, that time is wasted (unless I pitch it to other funds I suppose). If I look for algos that I personally can trade, and I find some, then I trade them.
I realize there's an unfortunate schism wherein I am using your platform but not contributing to your business model, so if you have any ideas how I can help without wasting my time writing algos that only work high account levels, please let me know. Pairs trading/statistical arbitrage might be one solution, but I've found them very difficult to implement; anything that looks promising in Quantopian fails the backtest when using dividend-adjusted bid-ask tick data, so I might shift my focus back to building my own lower latency infrastructure for a while.
I would reintroduce the concept I proposed in an article in S&C last spring ; the directed acyclic graph or DAG. Using thousands of correlated or cointegrated pairs I built groups from them.
Cool. Yeah, pretty similar. The DAG though was used specifically to find the networked graph. Those trees might embody the same thing, not sure. But I'd guess the idea is approximate.
Why would anyone want to pairs trade when trading a Minimum Spanning Tree or correlated network graph of stocks is so much safer and easier? I've built dozens of pairs strategies and the directionality of the pair always broke the model. And all pairs I ever tested all went directional at some point -- beyond the account's ability to Martingale down.
Have people been coming up with good ones? If so, what proportion are using the new data sets? If not, why not, do you think that is?
I can't release any specific data on this. I can say that there's a lag between when we update product features/try to educate people about algorithm writing techniques (larger universe size, shorting), and when new strategies start appearing. We'd love more large universe strategies right now and I'm trying to figure out ways to make it easier for folks to develop large universe long-short strategies using pipeline.
I haven't been focusing on them at all, mostly because there's a problem of opportunity cost; if I spend all my time looking for equity long-short algos, not only is there a chance I don't find anything, but if I do, there's still a chance that Quantopian doesn't select it, and since I cannot trade them myself, that time is wasted (unless I pitch it to other funds I suppose). If I look for algos that I personally can trade, and I find some, then I trade them.
I realize there's an unfortunate schism wherein I am using your platform but not contributing to your business model, so if you have any ideas how I can help without wasting my time writing algos that only work high account levels, please let me know. Pairs trading/statistical arbitrage might be one solution, but I've found them very difficult to implement; anything that looks promising in Quantopian fails the backtest when using dividend-adjusted bid-ask tick data, so I might shift my focus back to building my own lower latency infrastructure for a while.
Totally reasonable. We don't release our product with the expectation that everybody will use it to develop strategies for the fund, we also want to support your use case of personal trading. We also understand there's a conflict between pushing people to write high capacity market neutral long-short strategies, when those will never work on their own money. What I'm trying to figure out is ways to make the workflow of producing and evaluating factors easier, because once you have a factor-based ranking system, it's pretty easy to slot that into an existing long-short algorithm using pipeline. I'm working on sharing a pipeline algorithm with the community and attaching it to the lectures page in an effort to get more cloning and tweaking going on.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
I share Simon's sentiment. I've continued to participate in the contests, but the idea of spending tens (hundreds?) of hours trying to come up with an uber algo that will compete with the big dogs sounds like a lot of work, with a very uncertain pay-off (it's not even clear that you are still working on the hedge fund. any substantive news?). The pipeline thingy has a bit of a learning curve, so I haven't taken that on yet (the fact that lots of obscure modules need to be imported is a red flag). That said, if there were good working examples that could be tweaked, I might give it a go.
What I'm trying to figure out is ways to make the workflow of producing and evaluating factors easier, because once you have a factor-based ranking system, it's pretty easy to slot that into an existing long-short algorithm using pipeline.
Why don't you get all of the Q eggheads together for 1 week and see if you can come up with a long-short algo that would be Q hedge-fundable, and publish it (and better yet, actually fund it). Not only would this provide an existence proof, but you should also gain some insight into the workflow and the person-hours to accomplish the task.
Here is a pipeline algorithm that I just published as the goto example of a long-short equity strategy. I'm sure it will go through many improvements as the public eye turns to it, but it should at least be a start. It's tricky because we do want to publish algorithms that are 95% of the way done, so that users can take the last 5% and improve the strategies in many different uncorrelated ways. With long-short equity most of the work is in choosing good factors and factor ranking techniques. Unfortunately those are the type of signals that will disappear when shared publicly, but the actual machinery to trade within the algorithm should stay pretty consistent. If you're maybe looking to learn pipeline a bit, I would recommend going through Lectures 17 and 18, then looking at the algorithm.
I can say for certain we are working on the hedge fund. Even if you have strategies that aren't consistently winning the contest, we may be interested in an algorithm that can consistently do ok. Ultimately, my job as the one overseeing the lectures is to keep trying to make it easier so people don't have to spend as much time working on algorithms that may never pay off for them, and so we get more algorithms that do pay off in the long run.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
I start to implement pair trading backtesting in research environment instead of IDE. The main reason is to automatic run multiple pairs performance analysis before I jump into IDE for full backtest. Another reason for this work is to do further analysis for returns from many pairs.
I am wondering where I can find the example of backtesting in research environment to start with. Any comment is very appreciated.
In your research environment there should be a 'Tutorials and Documentation' مجلد. Inside the folder should be a notebook with the title 'Tutorial (Advanced) - Backtesting with Zipline'. Make a copy of that and let me know if that's enough to get you started.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
May 28 algo falls below benchmark if extended to date and -43% PvR with default slippage and commissions, tanking thru 2018.
Hope it can be rescued b/c it shows good potential.
The example strategies cheat and run on the same timeframe over which we did research and found the securities to be cointegrated. In a real strategy you'd want to find pairs that were cointegrated into the future and not just historically cointegrated. The template should stay largely the same, so it's an issue of swapping in new securities that you have statistical evidence will stay cointegrated.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Could you post a tutorial on calibrating an Ornstein Uhlenbeck process for mean reverting series residuals?
We've added a lecture on this to our queue. No idea when we might currently get to it, but it's on there.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Ages ago I posted, perhaps as anonymole, that a "pair" needn't be made of only two securities. In fact, the whole "we only allow low beta strats" mantra is pretty much an argument that all strategies should be a variation of a pairs strat. That is, over all, a market neutral position is best.
Taking this further however, and applying a more formal model to the pairs strategy (that the security set have a "story" attached to it) I wonder if the two halves of the pair would do better as independent baskets of securities. That if one approached a pairs strategy with the mind to match up two behaviorally opposed baskets of securities that instead of trying to search all pair combinations looking for all the super-great-marvelous attributes a pair should have, that instead, one determine the two sides of the pair coin and fill each side with the most appropriately identified securities -- for each side.
A simplistic model might be described thusly:
Equities which cycle up in the spring/summer and down in the fall/winter would be bundled together and set against equities which cycle oppositely (down in the summer, up in the winter).
No doubt there are more interesting or undiscovered cycles that exist. My point is that rather than identify securities that yin and yang, one discover technical, or macro, or fundamental classifications which zig when the other zags. Then find securities which fit each of those baskets of behavior.
This is a very interesting idea and definitely something that professional quants do. At the core we just want two assets on either side of a pair, and a portfolio of assets will do just as well as a single equity. There are probably pros and cons of each method, but the idea of using a basket of things rather than a single thing can greatly reduce your position concentration risk and lead to a better algorithm. I'd say it's worth research. You'd still likely want a few different pairs of baskets as each would smooth out the return curve of the other and produce a lower volatility algorithm.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
I have to run an errand, so I only have five minutes, but hopefully I can be clear in that time.
To demonstrate the chops of an AI system, I created an algorithm that can represent the small changes in stocks price, as the sum of a set of ETFs. For example, with MSFT one might have XLK, XLY, FXE, FXI, and some others.
I can show that the typical price movements during a day can be represented in this way. However, when there is specific news, then it is no longer true, if the news is strong.
What I believe this shows is that instead of things "returning to the mean" they are in fact not moving arbitrarily and so, if they return to the mean, it is because one of the underlying components in fact moved. (Of all the underlying components, usually only one or two have news, and the rest are balancing each other out, once the price has adjusted.)
How might one design a trading platform for this as even if you do know it is the sum of other waveforms that are causing one waveform, one still doesn't know what causes them to move until after the fact.
(the reduction in influence is 1/1.6 when looking at the components, so after a couple of feedback loops, the influence is not measurable. Thanks, and sorry for the hurried note,
Have you read Algorithmic Trading written by Ernie Chan? For sure you read it, I have a question: in fact I am not good in programming and working with Matlab, I am really interested in Currency cross rate part of the book and I want to implement the positions in live trading but I don't know how to do that in fact I can't understand what the numbers as positions mean! If somebody can guide me I'm really appreciated.
Not entirely sure I'm understanding your thesis but it seems that you've created an expression that models the returns of a specific stock from it's sector exposures. This is actually a common risk modeling tactic, check out my notebook here. To build a trading strategy off of this I would take your hypothesis about changing news and use that to alter the coefficients of your model. A cool place to start would be to check out the lectures on factor modeling and then maybe look at some news/sentiment data sets to see if you can find any anomalies.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
That is close. It models the returns to within a few cents usually, at any moment in time, depending on the stock and its volatility as a sum of its sectors. (except when it has specific news.) What I envision behind it is a large set of funds using NLP to invest by sector based on news. Because they are so large, then they tend to swamp out the market during normal times.
I can also show that stock prices changes are directly proportional to the sum of the underlying sectors information, for most time periods. For example, the price changes for three months show this and also for three weeks, which is a bit chaos like, as it would seem they wouldnt be so perfectly in tune. Anyway, with this I can sort stocks by their overall market efficiency (the more efficient you are, the more you sync with the relationship stated above).
I also believe that there are huge funds that are interested in doing nothing more than treading water (as one possible explanation) and they move their money around the world, just trying to stay even, and so the result is that at any given time, the sum of everything stays near zero. (when one thing goes up somewhere, something else somewhere else goes down.)
These relationships also break down during periods of very high volatility such as fall 2018.
There are other things I am able to quantify, but again have no idea how to use. When information about a specific stock or sector hits the market, it is my observation that the more objective the information, the faster the market responds, and the more subjective it is, the slower the market responds.
For example, when Ackman says that HLF is a pyramid scheme, then it can sometimes be hours, and sometimes even days before that news is no longer affecting the price of the stock, but when an analyst upgrades or downgrades a stock, that is more objective and the entire price adjustment is over in fifteen minutes. (If you subtract out market movements then an analysts announcement looks like a log curve, with most of the action in the beginning and a bit of a ringing at the last.)
Again, this all happens too fast to be of use, and it is after the fact that I can say, "That was subjective."
I don't think I am able to alter the coefficients as you suggest. I am using a hard coded take on a system of recursive polynomials for my modeling, so there are billions of coefficients.
Hi, I have a quick and possibly dumb question. Why did you use the ratio instead of the difference between S1 and S2 in the Quantopain pairs trading lecture? In the co-integration lecture, you use the difference instead. In other sources, they use the difference as well.
There's an updated notebook, algorithm, and video available on the lecture series page.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
And as a response to pandasaurus' question, which I unfortunately just saw, we have removed the ratio as it was a typo in the lecture.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Greetings Quantopian Community,
I was at the NYC Event on Pairs Trading, and the current example algorithm is deprecated, such that one cannot deploy it in live trading. With this fix, users can now deploy the algorithm in live trading. The fix is hosted as a pull request on github--thanks.
شكرا جزيلا. Could you please submit your PR to the following repo? It's where we store lectures and examples. Doesn't quite fit in the current form of zipline.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Thanks, Delaney. I submitted the PR to the specified branch.
شكر! Delaney. I am finishing my graduation thesis these days, Your work may help me a lot.
That's great to hear, Dzi. Hope it goes well!
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
I have question in regards to high frequency pairs trading using bid/ask price. One thing that I noticed is during an entry signal if I'm supposed to go long in one and short the other, the Long position that I enter would be using the ask price and this ask price normally is higher than the bid price, so when my exit signals to exit, my bid price that I close my position at will often cause me to loose than make money. What are some of the ways to prevent this from happening or what are some strategies that goes hand in hand with trading high frequently with pairs strategy. Further, how are limit orders used with the bid/ask price.
If you need to make the spread in order for the strategy to be profitable, then you are squarely competing with high-frequency market makers, and it's a whole different ball game. You are unlikely to win. If you have control over the specific order types you send, you could attempt to use mid-point pegs or something, but as soon as you admit any sort of limit orders where execution is not immediate, you now need to be concerned about being exposed unhedged, which is something that you'll need to backtest. (not easy either). What some people do is try and rest or peg an order for the less liquid leg, and attempt to save some of the cost of the wider spread (though again, these days, you'll probably just get adversely selected for no net gain), and then as soon as that fills, you aggressively execute the hedge leg across the narrower spread.
How does one use both bid and ask z score in high frequency trading? For simplicity, I can understand using z score, but when it comes to using both bid and ask price z score, I have trouble picturing how it is used.
Simon's right, mid-frequency strategies generally should be fairly robust to bid-ask spreads. If they're not the edge is probably too small to be consistently profitable. For high frequency trading you do have to consider the bid and ask in many different ways, as your trading will be very sensitive to movements in both. How exactly you use the data would depend on your model.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
You can imagine that the spread is a synthetic asset. For instance, X = 1L -1S so a single unit of X is long one unit of L and short one unit of S. If you need to buy one unit of X immediately, you will buy at the ask of L and sell at the bid of S. If you need to sell one unit of X, you will sell at the bid of L and buy at the ask of S.
You can then easily calculate the bid and ask for X, you have just two "z-scores" to deal with. Then, if you like, you can delay buying until the X_ask_zscore < threshold, and delay selling until the X_bid_zscore > exit_threshold.
أتمنى أن يساعدك هذا.
I had a chance to see this notebook before and I would recommend it to everyone here. Lots of amazing info can be found inside.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان. وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
Hey Simon. thanks for that last post. I've been thinking through the logic behind that, but I do have some questions. Hope you don't mind explaining or expanding on it a little. 1) If I understood you correctly you mean X being the spread between a pair? in other words one unit of X immediately to be traded immediately, I would think that you will buy at the ask of X rather than L to be immediate wouldn't you? One problem that I would encounter by buying one unit of X at the ask price of L would be that the ask price of L may not be the lowest ask price of X and therefore may cause me to still queue to purchase the unit of X or not even fill. Can you say a little more in regards to this?
2) Further, there is one concept that I'm having a hard time to understand. Let's say that my Z score > entry threshold of +2. I would short L by one unit by selling one unit of L at the bid price of L and go long one unit of Y at the ask price of Y. Assuming hedge ratio is 1 and all. When my Z score < exit threshold of say 0.2. I would then exit my short and long position of the pair. The issue that I would encounter assuming no fees and all is that I would loose money during these trades. I'm having a hard time understanding why that would be if my Z score returned to or close to mean. Is the reason behind this due to the fact that the volatility of the bid/ask price may not be high enough to allow the difference in the entry and exit bid/ask spread price at the start and end of the transaction to pull far enough to earn money?
Please take a look at the last part of the page for this link that shows the true correlations, which are arrived at by saying "from the point of view of a pairs trader, how correlated are these tickers."
If you know how to subtract out the part of the market that floats all boats, to be left only with the information pertaining to neutral, there are extreme correlations. XLK is the ticker used in the example, but there are a thousand I could have used. When you know how to subtract out all but the neutral information, the market becomes completely different in how it appears.
Scroll to the very bottom of the article and look at the two tables with correlation information. These numbers are this way because there is so much interest in pairs trading that it tends to swamp things out. It is even more pronounced in Europe.
1) I think you are getting a bit confused; X is not a real thing, it's a synthetic asset formed by the basket of L and S. X has a price to buy and a price to sell which you calculate from the bids and asks of the components. If you cross the spread, generally, you trade immediately in small enough size. You only have uncertainty about fills if you try to earn the spread. That gets much more difficult.
2) Maybe. If your trades are not making money, I mean, that's a big problem. I can't answer why they are not making money. It could be transaction costs like the bid/ask spreads, you should analyze the volatility of your baskets as a function of the bid/ask spreads you have to pay. If you have to cross four 5-cent spreads to try and capture a spread mean-reversion of 2 cents, well yeah you are going to have problems. A bigger problem I found was that mean reversion happens one of two ways; either the asset reverts to the mean, or the mean converges with the asset (assuming you are constantly recomputing the mean, which seems to be common practice). In both cases your z-score goes back to zero, but only in the first case do you make any money.
@daniel I read your article, the correlations at the end, are those of prices, or returns ?
Thanks for clearing that up for me. The idea of using synthetic assets is relatively new to me. I went and researched it a little and noticed that it is often used to capture streams of cash flow. I'm currently trying to perform residual pairs trading with Chinese Future Contracts. As I research it for the use of Futures, I don’t really find much articles or explanations. Is it applicable to Futures?
At the same time, I'm relatively new at this and trying to go through the lectures and stuff to learn. When you say I should analyze the volatility of my baskets as a function of the bid/ask spreads. Do you know where I can find a lecture that discuss this further? Sorry to ask some fundamental questions. One thing I notice in my data is that the bid/ask spread is really small and by small the it is just a spread of one tick of the futures contract; while the Volume for that tick is also small just around 80 or less contracts for either bid or ask.
The correlations are about prices, but just a subset.
(I have edited this down, as compared to what you probably have in email. Please don't copy anything from the email onto the board.)
James - maybe? You need pairs/baskets with enough variance to profitably trade the mean reversion. There tends to be a spectrum; structurally correlated assets (like ETF vs their component baskets) are perfect to trade, so perfect, that everyone does it and therefore the deviations are probably less than the spread. Then there's really shitty pairs which you find doing brute force analysis of the stock market. These have lots of variance, but they probably don't converge, and/or the relationship is totally spurious. Read closely Aaron Brown's posts on this thread. You want something in the middle.
Danial - I am not sure how useful correlations of prices of any kind are ? They are bound to be super high.
By itself I don't believe there is any one thing that is useful for a neutral strategy.
My approach is to look at the market as being represented by several hundred core waveform, and similar to the idea of Fourier Transform, you can use these fundamental waveform to create the 4000 heaviest played stocks. So, basically everything I believe about the market is based on the idea of correlations, as this is what I used as one of the first steps to find those wave forms. (which are not easy to find.)
Consider if you have Tickers AAA and BBB, and they are two similar stocks.
AAA might have as its composite the waves A, B, C, D, E, F, G, H, I, J, and BBB may have D, E, F, G, H, I, J, K, L.
During the times that there is little to no activity in the components A, B, C, K, L then the two tickers would be nearly perfectly correlated. But if suddenly component A had news (for example), then the perfect correlations would no longer hold, since stock BBB does not have an A component waveform..
If you apply the above to the idea of mean reversion, then you can see what I believe the mean reversion strategy is actually about.
In my opinion the best way to play a neutral strategy would be to devise a portfolio that is about the underlying fundamental wave components..
And in the interest of completeness, I will mention that in the above examples, waves A, B, C, etc are also made of composite waves, (and those composites . ) as the market is self referencing. The several hundred are at the bottom of the self referencing, and are something that exists in theory, that I believe I could "easily" find, but have not spent the time and energy to do so as of this date.
I also believe that if I had data for all the major markets of the world and was able to deduce the underlying component waves for those instruments that are heavily played by the collectively speaking, multi-trillion dollar funds, that the sum of these waves would (except for inflation) most of these times sum to be zero.
Some researchers generate the log price series of two equities with the daily close. Then the spread series is estimated using regression analysis based on log price series data. For equities X and Y, they run linear regression over the log price series and get the coefficient β.
Any reason they use log price series instead?
عذرا، هناك خطأ ما. حاول مرة أخرى أو اتصل بنا عن طريق إرسال الملاحظات.
لقد أرسلت بنجاح تذكرة دعم.
سيكون فريق الدعم لدينا على اتصال قريبا.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان.
وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.
يتم توفير المواد على هذا الموقع لأغراض إعلامية فقط ولا تشكل عرضا لبيع أو طلب شراء أو توصية أو تأييد لأي أمن أو استراتيجية، كما أنها لا تشكل عرضا لتقديم الخدمات الاستشارية الاستثمارية من قبل كوانتوبيان.
وبالإضافة إلى ذلك، لا تقدم المادة أي رأي فيما يتعلق بملاءمة أي ضمان أو استثمار محدد. لا ینبغي اعتبار أي معلومات واردة في ھذه الوثیقة بمثابة اقتراح للانخراط في أي مسار عمل یتعلق بالاستثمار أو الامتناع عنھ حیث لا یقوم أي من کوانتوبيان أو أي من الشرکات التابعة لھ بتقدیم المشورة الاستثماریة أو العمل کمستشار لأي خطة أو کیان خاضع ل وقانون تأمين دخل التقاعد للموظفين لعام 1974، بصيغته المعدلة، أو حساب التقاعد الفردي أو المعاش التقاعدي الفردي، أو تقديم المشورة بصفة الأمانة فيما يتعلق بالمواد المعروضة في هذه الوثيقة. إذا كنت مستقلا فرديا أو مستثمرا آخر، فاتصل بمستشارك المالي أو أي جهة مالية أخرى لا علاقة لها بكوانتوبيان حول ما إذا كانت أي فكرة استثمار أو إستراتيجية أو منتج أو خدمة معينة مذكورة هنا قد تكون مناسبة لظروفك. وتشمل جميع الاستثمارات مخاطر، بما في ذلك خسارة أصل الدين. لا تقدم كوانتوبيان أي ضمانات بشأن دقة أو اكتمال الآراء المعرب عنها في الموقع. وتخضع اآلراء للتغيير، وقد تصبح غير موثوقة ألسباب مختلفة، بما في ذلك التغيرات في ظروف السوق أو الظروف االقتصادية.

Cointegration pairs trading strategy


A related paper has been added to:
#12 - Pairs Trading with Stocks.
Title: Cointegration and Relative Value Arbitrage.
Notable quotations from the academic research paper:
"In the pairs trading literature, the most common type of relative value arbitrage, substitutes for individual stocks are identified by minimizing the Euclidean distance in the daily price space over a historical period.5 Matching stocks over the price space instead of the return space is consistent with short-term relative value trading strategies, while removing the need to specify factors. Although the matching method is simple to perform, by design, it guarantees the existence of a counterpart for every stock, which is counterintuitive. More importantly, stocks that exhibit little variation in the price pattern over the formation period (possibly due to lack of news flow) would end up being labelled close substitutes, although they are not fundamentally related.
In this paper, we propose a simple method of identifying close economic substitutes using cointegration. When a pair of stock prices is cointegrated, one series co-moves with a scaled version of the other. We show that close economic substitutes can be represented by a system of cointegrated prices where the scaling factor, or the cointegration coefficient, is close to one.
We find that from 1962 to 2018, NonParity, a positive-valued metric of closeness that measures the distance of the cointegration coefficient from unity, strongly predicts both the probability that relative mispricing will subsequently be corrected as well as the profitability of the arbitrage trade. A one standard deviation increase in the variable reduces the convergence probability by seven percentage points and pairs trade payoffs by 2.78 percentage points. Further, predictability through NonParity also presents profitable trading opportunities. At the portfolio level, the pairs trading of cointegrated stocks is generally unprofitable. However, when trading is confined to pairs of stocks with NonParity close to zero, the strategy is profitable after reasonable estimates of brokerage, slippage, and short selling costs. Specifically, over the sample period, the average after-cost risk-adjusted return to trading a portfolio of cointegrated pairs with NonParity less than 0.5 (0.2) is 0.43% per month, with a t-statistic of 5.29 (0.58% per month, with a t-statistic of 4.77)."

Gekko Quant – Quantitative Trading.
Quantitative Trading, Statistical Arbitrage, Machine Learning and Binary Options.
آخر الملاحة.
Statistical Arbitrage – Trading a cointegrated pair.
In my last post gekkoquant/2018/12/17/statistical-arbitrage-testing-for-cointegration-augmented-dicky-fuller/ I demonstrated cointegration, a mathematical test to identify stationary pairs where the spread by definition must be mean reverting.
In this post I intend to show how to trade a cointegrated pair and will continue analysing Royal Dutch Shell A vs B shares (we know they’re cointegrated from my last post). Trading a cointegrated pair is straight forward, we know the mean and variance of the spread, we know that those values are constant. The entry point for a stat arb is to simply look for a large deviation away from the mean.
A basic strategy is:
If spread(t) >= Mean Spread + 2*Standard Deviation then go Short If spread(t) <= Mean Spread – 2*Standard Deviation then go Long.
If spread(t) >= nDay Moving Average + 2*nDay Rolling Standard deviation then go Short If spread(t) <= nDay Moving Average – 2*nDay Rolling Standard deviation then go long.
If spread(t) <= Mean Spread + 2*Std AND spread(t-1)> Mean Spread + 2*Std If spread(t) >= Mean Spread – 2*Std AND spread(t-1)< Mean Spread – 2*Std Advantage is that we only trade when we see the mean reversion, where as the other models are hoping for mean reversion on a large deviation from the mean (is the spread blowing up?)
This post will look at the moving average and rolling standard deviation model for Royal Dutch Shell A vs B shares, it will use the hedge ratio found in the last post.
Sharpe Ratio Shell A & B Stat Arb Shell A.
Annualized Sharpe Ratio (Rf=0%):
Shell A&B Stat Arb 0.8224211.
Shell A 0.166307.
The stat arb has a Superior Sharpe ratio over simply investing in Shell A. At a first glance the sharpe ratio of 0.8 looks disappointing, however since the strategy spends most of it’s time out of the market it will have a low annualized sharpe ratio. To increase the sharpe ratio one can look at trading higher frequencies or have a portfolio pairs so that more time is spent in the market.
22 thoughts on “ Statistical Arbitrage – Trading a cointegrated pair ”
it also means that when identified the maximum divergence i can take position in derivatives like options?
-selling ATM Call option on first stock.
-buy Call option on the second one.
or with a BacKSpreadCall on the first and a BackSpreadPut on the second so I can set the protections and I can roll them if they go out control…
The short positions should be moneyness ATM or lightly OTM in my opinion.
What do yo think about?
Did you tried using Johansen’s testing approach in order to perform a more rigorous testing of cointegration? What do you think about combining Engle-Granger with Johansen?
The spread in the above does not oscillate around it mean, ideally, a cointegrated pair should trade sideways not in a trending manner as shown above….your write-up was perfect on proper cointegration you demonstrated. but this spread is not a perfect spread.
I 100% agree with you.
However for practical purposes as long as the mean reversion happens faster than the mean changes then you’ll do well.
I guess that’s something I’ve missed, how to quantify the half life/reversion speed.
Please note that in the above demo the look back period is 90days. This is fairly short. Choosing 200 days will result in a mean that is less responsive / changes direction. It will most likely increase the size of the standard deviation bands and result in less trades per year. This usually results in a lower Sharpe ratio.
Very interesting post. Would love to see the implementation on a basket of pairs.
I do some changes in your programme to calculate the bollinger bands and I wanna know why you’re put the Standard deviation to the right? (movingStd = rollapply(spread, lookback, sd, align=”right”, na. pad=TRUE))
OK thank you for answering!
Your blog give me the chance to implement and build more quickly my stat arb strategy.
I am going to test different models for statistical arbitrage. I keep all the visitors in the loop!
In your program, the martingale effect is not here. How can I add this effect?
I am running my iwn backtests with differents programs (Excel, R et ProRealTime (a french platform)) and in order to do some comparison, I need to add the martingale effect.
Thanks for the clarification. By the same argument, rollmean has to have the same: rollmean(spread, lookback, na. pad=TRUE, align=’right’)
With this new modification the Sharpe ratio drops dramatically ..
Great stuff!! I think there are two bugs in your code, though. First one is in calculation of moving average. You forgot to set align parameter to “right” (like you do for standard deviation). Function uses default “center” and your data – spread and moving average are not aligned. You can see this from the plot as well. Moving average ends 45 days before the spread. Second bug is in calculation of trading returns. I think you should take return from the next day as we enter the position at the closing price.
Thanks for your elegant code. I noticed that your line of code:
is meant to apply the function shortPositionFunc to (-1*aboveUpperBand+belowMAvg).
However, the function shortPositionFunc takes two arguments x and y.
Is there any typo in the code?
Thank you for your clarification!
Thanks Gekko for the backtesting code. It is very useful. Couple of comments below:
1) Another reader has already commented about this above. movingAvg needs to be amended by adding align=”right” in order to have the first moving avg number on day 90:
movingAvg = rollmean(spread, lookback, align=”right”, na. pad=TRUE)
2) since we enter trades at end of day, the return on trade date shouldn’t count. we can simply shift every element in the “positions” vector down by using the “shift” function in the taRifx library.
Also, I don’t believe daily return is (aRet – stockPair$hedgeRatio*bRet). Imagine if you had a large hedge ratio, i. e. if stock A is priced at $100 and stock B is priced at $10, then the hedgeRatio would be in the neighborhood of 10. Since aRet and bRet are in % terms, the formula won’t work. Daily return should be aRet – bRet * (ratio between dollar neutral ratio vs hedge ratio).
#Calculate spread daily ret.
dailyRet <- aRet – bRet*hedgeRatioOVERdollarNeutralRatio.
tradingRet <- dailyRet * shift(positions,-1)
I am looking for new strategies in equity pair trading that improve the standard cointegration approach (for instance I started looking into the pair trading with copulas, which still seems an “unstable” alternative to cointegration). Do you have any new paper to suggest me? Thank you very much and congrats for the great blog.
The second half of the book goes through lots of more advanced techniques for hedging a portfolio / finding stationary pairs.
i am a bit confused in this step.
when i plotted the longPositions and ShortPositions along with the spread, bands and moving average lines found then there are consecutive long signals and short signals. According to my understanding.
longPostions <- if spread is below lowerband.
longExit <- if spread is above movAvg while long.
shortPostions <- if spread is above upperband.
shortExit <- if spread is below movAvg while short.
is this same thing your code is doing. Please help me understand this part.
Hi Gekko, I read the books of EP Chan that talks about this topic and I a little bit confused about mean reservion. When two assets ara cointegrated we are supposing that they will come back to their mean, but their moving average or their total mean in a fixed period? I’m giving better results using static parameters than using bollinger bands. I will show you an image with my doubt. prntscr/51jofw Could you write another article of mean reversion! Thanks for all.
Hi Gekko. Great Code. Could you closer explain an idea behind this cappedCumSum function ? I do not understand the moment when you are specifing two input variables, but in Reduce() function is only one parameter, – is it because of 0?
There is a mistake. Your algorithm looks in the future, the problem in rollmean function. Algorithm using moving average from future days to close position.

QuantStart.
الانضمام إلى كوانتكاديمي بوابة العضوية الخاصة التي تلبي احتياجات التجزئة المتزايد بسرعة المجتمع تاجر الكمي. سوف تجد مجموعة من ذوي الخبرة مثل التفكير من التجار الكميون على استعداد للرد على أسئلة التداول الكمي الأكثر إلحاحا.
تحقق من بلدي يبوك على التداول الكمي حيث أنا يعلمك كيفية بناء مربحة استراتيجيات التداول المنهجي مع أدوات بايثون، من الصفر.
نلقي نظرة على بلدي الكتاب الاليكتروني الجديد على استراتيجيات التداول المتقدمة باستخدام تحليل سلسلة زمنية، والتعلم الآلي والإحصاءات بايزي، مع بيثون و R.
By Michael Halls-Moore on June 14th, 2018.
In the previous article on cointegration in R we simulated two non-stationary time series that formed a cointegrated pair under a specific linear combination. We made use of the statistical Augmented Dickey-Fuller, Phillips-Perron and Phillips-Ouliaris tests for the presence of unit roots and cointegration.
A problem with the ADF test is that it does not provide us with the necessary $\beta$ regression parameter - the hedge ratio - for forming the linear combination of the two time series. In this article we are going to consider the Cointegrated Augmented Dickey-Fuller (CADF) procedure, which attempts to solve this problem. We've looked at CADF before using Python, but in this article we are going to implement our CADF function using R.
While CADF will help us identify the $\beta$ regression coefficient for our two series it will not tell us which of the two series is the dependent or independent variable for the regression. That is, the "response" value $Y$ from the "feature" $X$, in statistical machine learning parlance. We will show how to avoid this problem by calculating the test statistic in the ADF test and using it to determine which of the two regressions will correctly produce a stationary series.
Cointegrated Augmented Dickey Fuller Test.
The main motivation for the CADF test is to determine an optimal hedging ratio to use between two pairs in a mean reversion trade, which was a problem that we identified with the analysis in the previous article. In essence it helps us determine how much of each pair to long and short when carrying out a pairs trade.
The CADF is a relatively simple procedure. We take a sample of historical data for two assets and then perform a linear regression between them, which produces $\alpha$ and $\beta$ regression coefficients, representing the intercept and slope, respectively. The slope term helps us identify how much of each pair to relatively trade.
Once the slope coefficient - the hedge ratio - has been obtained we can then perform an ADF test (as in the previous article) on the linear regression residuals in order to determine evidence of stationarity and hence cointegration.
We will use R to carry out the CADF procedure, making use of the tseries and quantmod libraries for the ADF test and historical data acquisition, respectively.
We will begin by constructing a synthetic data set, with known cointegrating properties, to see if the CADF procedure can recover the stationarity and hedging ratio. We will then apply the same analysis to some real historical future data, as a precursor to implementing some mean reversion trading strategies.
CADF on Simulated Data.
We are now going to demonstrate the CADF approach on simulated data. We will use the same simulated time series from the previous article.
Recall that we artificially created two non-stationary time series that formed a stationary residual series under a specific linear combination.
We can use the R linear model lm function to carry out a linear regression between the two series. This will provide us with an estimate for the regression coefficients and thus the optimal hedge ratio between the two series.
We begin by importing the tseries library, necessary for the ADF test:
Since we wish to use the same underlying stochastic trend series as in the previous article we set the seed for the random number generator as before:
In the previous article we created an underlying stochastic random walk time series, $z_t$:
We then created two subsequent series, which I will rename to $p_t$ and $q_t$ so that we do not confuse the original names $y_t$ and $x_t$ with the conventional names for regression reponses and predictors:
At this stage we can make use of the lm function, which calculates a linear regression between two vectors. In this instance we will set $q_t$ to be the independent variable and $p_t$ to be the dependent variable:
If we take a look at the comb linear regression model we can see that the estimate for the $\beta$ regression coefficient is approximately 0.5, which makes sense given that $q_t$ is twice dependent on $z_t$ compared to $p_t$ (0.6 compared to 0.3):
Finally, we apply the ADF test to the residuals of the linear model in order to test for stationarity:
The Dickey-Fuller test statistic is very low, providing us with a low p-value. We can likely reject the null hypothesis of the presence of a unit root and conclude that we have a stationary series and hence a cointegrated pair. This is clearly not surprising given that we simulated the data to have these properties in the first place.
We are now going to apply the CADF procedure to multiple sets of historical financial data.
CADF on Financial Data.
There are many ways of forming a cointegrating set of assets. A common source is to use ETFs that track similar characteristics. A good example is an ETF representing a basket of gold mining firms paired with an ETF that tracks the spot price of gold. Similarly for crude oil or any other commodity.
An alternative is to form tighter cointegrating pairs by considering separate share classes on the same stock, as with the Royal Dutch Shell example below. Another is the famous Berkshire Hathaway holding company, run by Warren Buffet and Charlie Munger, which also has A shares and B shares. However, in this instance we need to be careful because we must ask ourselves whether we would likely be able to form a profitable mean reversion trading strategy on such a pair, given how tight the cointegration is likely to be.
EWA and EWC.
A famous example in the quant community of the CADF test applied to equities data is given by Ernie Chan [1] . He forms a cointegrating pair from two ETFs, with ticker symbols EWA and EWC, representing a set of Australian and Canadian equities baskets, respectively. The logic is that both of these countries are heavily commodities based and so will likely have a similar underlying stochastic trend.
Ernie makes uses of MatLab for his work, but this is an article about R. Hence I thought it would be instructive to utilise the same starting and ending dates for his historical analysis in order to see how the results compare.
The first task is to import the R quant finance library, quantmod, which will be helpful for us in downloading financial data:
We then need to obtain the backward-adjusted closing prices from Yahoo Finance for EWA and EWC across the exact period used in Ernie's work - April 26th 2006 to April 9th 2018:
We now place the adjusted prices into the ewaAdj and ewcAdj variables:
For completeness I will replicate the plots from Ernie's work, in order that you can see the same code in the R environment. Firstly, let's plot the adjusted ETF prices themselves.
To carry this out in R we need to utilise the par(new=T) command to append to a plot, rather than renew it. Notice that I've set the axes on both plot(. ) commands to be equal and have not added axes to the second plot. If we don't do this the plot becomes cluttered and illegible:
Backward-adjusted closing prices of EWA and EWC.
You will notice that it differs slightly from the chart given in Ernie's work as we are plotting the adjusted prices here, rather than the unadjusted closing prices. We can also create a scatter plot of their prices:
Scatter plot of backward-adjusted closing prices for EWA and EWC.
At this stage we need to perform the linear regressions between the two price series. However, we have previously mentioned that it is unclear as to which series is the dependent variable and which is the independent variable for the regression. Thus we will try both and make a choice based on the negativity of the ADF test statistic. We will use the R linear model ( lm ) function for the regression:
This will provide us with the intercept and regression coefficient for these pairs. We can plot the residuals and visually assess the stationarity of the series:
Residuals of the first linear combination of EWA and EWC.
We can also view the regression coefficients starting with EWA as the independent variable:
This provides us with an intercept of $\alpha=3.809$ and a $\beta=1.194$. Similarly for EWC as the independent variable:
This provides us with an intercept $\alpha=-1.638$ and a $\beta=0.771$. The key issue here is that they are not equal to the previous regression coefficients. Hence we must use the ADF test statistic in order to determine the optimal hedge ratio. For EWA as the independent variable:
Our test statistic gives a p-value less than 0.05 providing evidence that we can reject the null hypothesis of a unit root at the 5% level. Similarly for EWC as the independent variable:
Once again we have evidence to reject the null hypothesis of the presence of a unit root, leading to evidence for a stationary series (and cointegrated pair) at the 5% level.
The ADF test statistic for EWC as the independent variable is smaller (more negative) than that for EWA as the independent variable and hence we will choose this as our linear combination for any future trading implementations.
RDS-A and RDS-B.
A common method of obtaining a strong cointegrated relationship is to take two publicly traded share classes of the same underlying equity. One such pair is given by the London-listed Royal Dutch Shell oil major, with its two share classes RDS-A and RDS-B.
We can replicate the above steps for RDS-A and RDS-B as we did for EWA and EWC. The full code to carry this out is given below. The only minor difference is that we need to utilise the get(". ") R function, since quantmod pulls in RDS-A as the variable "RDS-A" . R does not like hyphens in variable names as the minus operator takes precedence. Hence we need to use get as a workaround:
We can plot both share classes on the same chart. Clearly they are tightly cointegrated:
Backward-adjusted closing prices of RDS-A and RDS-B.
We can also plot a scatter graph of the two price series. It is apparent how tight the linear relationship between them is. This is no surprise given that they track the same underlying equity:
Scatter plot of backward-adjusted closing prices for RDS-A and RDS-B.
Once again we utilise the linear model lm function to ascertain the regression coefficients, making sure to swap the dependent and independent variables for the second regression. We can then plot the residuals of the first regression:
Residuals of the first linear combination of RDS-A and RDS-B.
Finally, we can calculate the ADF test-statistic to ascertain the optimal hedge ratio. For the first linear combination:
And for the second:
Since the first linear combination has the smallest Dickey-Fuller statistic, we conclude that this is the optimal linear regression. In any subsequent trading strategy we would utilise these regression coefficients for our relative long-short positioning.
الخطوات التالية.
We have utilised the CADF to obtain the optimal hedge ratio for two cointegrated time series. In subsequent articles we will consider the Johansen test, which will allow us to form cointegrating time series for more than two assets, providing a much larger trading universe from which to pick strategies.
In addition we will consider the fact that the hedge ratio itself is not stationary and as such will utilise techniques to update our hedge ratio as new information arrives. We can utilise the Bayesian approach of the Kalman Filter for this.
Once we have examined these tests we will apply them to a set of trading strategies built in QSTrader and see how they perform with realistic transaction costs.
المراجع.
مجرد بدء مع التداول الكمي؟
3 أسباب الاشتراك في قائمة البريد الإلكتروني كوانتستارت:
1. دروس التداول الكمي.
سوف تحصل على إمكانية الوصول الفوري إلى دورة مجانية 10-البريد الإلكتروني معبأة مع تلميحات ونصائح لمساعدتك على البدء في التداول الكمي!
2. جميع أحدث المحتوى.
كل أسبوع سوف نرسل لك التفاف جميع الأنشطة على كوانتستارت لذلك عليك أن لا يفوتون وظيفة مرة أخرى.
ريال مدريد، وقابلة للتنفيذ نصائح التداول الكمي مع أي هراء.

No comments:

Post a Comment