Thursday 20 July 2017

ปริมาณ ซื้อขาย กลยุทธ์ excel


อ่านความคิดเห็นของผู้อ่านเกี่ยวกับการซื้อขายโดยใช้ Excel VBA และ Factor Model ความคิดเห็นจากผู้อ่านจอห์นเอสจากสหราชอาณาจักรเกี่ยวกับประสบการณ์ของเขาเกี่ยวกับเทคโนโลยีและโมเดลการซื้อขาย: ฉันได้พัฒนาระบบการซื้อขายอัตโนมัติส่วนบุคคลของตนเองโดยใช้ Excel VBA และตามกฎที่ฉันมี พัฒนามาเป็นเวลาหลายปีในฐานะนักลงทุนรายย่อยที่ใช้งานโดยใช้ข้อมูลและการวิเคราะห์ข้อมูลพื้นฐาน หนึ่งในข้อดีที่สำคัญในการใช้วิธีการระบบการซื้อขายอัตโนมัติที่ช่วยฉันคือการหลีกเลี่ยงการล่อลวงสำหรับการแทรกแซงด้วยตนเองและการปรับปรุงความสามารถในการทำกำไรโดยการรักษาความสม่ำเสมอ ฉันได้พบกับความท้าทายในการพัฒนาระบบที่ประสบความสำเร็จอย่างมากจากมุมมองส่วนตัวเนื่องจากฉันตระหนักดีว่ามีหลายอย่างที่พยายามและล้มเหลว อย่างไรก็ตามปัญหาหนึ่งที่ฉันพบคือความปรารถนาอย่างต่อเนื่องของฉันในการปรับเปลี่ยนและปรับปรุงระบบอย่างสม่ำเสมอซึ่งเป็นสิ่งที่ฉันพบได้กลายเป็นสิ่งที่มีประสิทธิผลเนื่องจากมีอันตรายที่แท้จริงที่การพัฒนาระบบจะสิ้นสุดลงในตัวเองฉันไม่สามารถหยุดการปรับแต่งได้ทันทีที่ฉัน มากับความคิดใหม่หรือคุณลักษณะหนึ่งข้อดีของการใช้ Excel VBA ที่ฉันพบคือมีความยืดหยุ่นโดยเนื้อแท้เนื่องจากเอื้อต่อการประมวลผลข้อมูลซึ่งอาจมีความสำคัญโดยเฉพาะอย่างยิ่งเมื่อใช้ข้อมูลพื้นฐานเป็นส่วนหนึ่งของระบบ ในแง่นี้ผมยอมรับว่าผู้ประกอบการค้าทุกคนพยายามที่จะสร้างในขอบที่จะทำให้ระบบมีกำไรมากขึ้น ฉันได้สังเกตเห็นว่าผู้ค้าจำนวนมากดูเหมือนจะมุ่งเน้นเฉพาะราคาโดยพยายามหาขอบโดยดูที่ตัวบ่งชี้พิเศษหรือการรวมกันของตัวบ่งชี้อื่น ๆ รวมการวิเคราะห์ข้อมูลราคาด้วยวิธีแบบจำลองปัจจัยเป็นความท้าทายที่เหมาะอย่างยิ่งสำหรับ Excel VBA ตามที่สามารถทำได้ สามารถใช้ข้อมูลกระบวนการพื้นฐานและข้อมูลเศรษฐกิจมหภาคในรูปแบบที่สามารถรวมเข้ากับการวิเคราะห์ข้อมูลราคาได้อย่างง่ายดาย ฉันรู้จากหนังสือของคุณว่า Matlab มีประสิทธิภาพมากกว่า Excel VBA และอาจเป็นเพียงความยืดหยุ่นในการรวมข้อมูลพื้นฐานและข้อมูลเศรษฐกิจมหภาค แต่ฉันต้องการเพียงแค่ดึงความสนใจของคุณไปยังประโยชน์ที่ฉันได้พบโดยใช้ Excel VBA ซึ่งอาจเหมาะกับผู้ที่ชอบตัวเองมีมากขึ้น สะดวกสบายในการใช้ Excel VBA และไม่เต็มใจที่จะเปลี่ยนแปลง คุณลักษณะอื่น ๆ ที่สามารถใช้ประโยชน์ได้ซึ่งฉันพบว่าเป็นประโยชน์เมื่อการทดสอบกลับทำแผนภูมิราคาโดยอัตโนมัติซึ่งรวมจุดเข้าและออกซึ่งจะให้การรับรองว่าระบบกำลังทำงานตามที่ตั้งใจรวมทั้งสร้างรายงาน Word อัตโนมัติที่บันทึกเอาต์พุตหลักสำหรับการอ้างอิงในอนาคต ฉันขอโทษถ้าฉันเสียงมากเกินไปเช่นการโฆษณาสำหรับ Microsoft 7 ความเห็น: ฉันคิดเหตุผลสำคัญที่อยู่เบื้องหลังความนิยมของ ExcelVBA ในโลกการค้า Quant และ Quant: 1 คนจำนวนมากอยู่แล้วใช้มัน - ดังนั้นทุกคนคิดว่า thats ทางที่จะไป. 2. ความเรียบง่ายของ VBA (ไม่แน่ใจว่าจะมีความสัมพันธ์กับความยืดหยุ่น) หรือไม่ซึ่งจะทำให้ทุกคนสามารถใช้งานได้อย่างมีประสิทธิภาพไม่ว่าจะเป็นผู้ประกอบการรายย่อยหรือนักพัฒนาโต๊ะ 3. VBA และ Excel สามารถขยายได้อย่างง่ายดาย (เพื่อปรับปรุงประสิทธิภาพรวมซอฟต์แวร์ของบุคคลที่ 3 หรือเพื่อวัตถุประสงค์ในการใช้ modularizere) โดยการย้ายตรรกะของโมเดลที่แท้จริงลงใน C, COM หรือสำหรับภายหลัง (วิธีง่ายๆในการรวม Quant analytics เขียนด้วย Excel และ VBA) - หนึ่งอาจมีลักษณะที่โซลูชันของฉัน: excel4net ฉันมั่นเหมาะคิดว่าปัจจัย bandwagon อยู่ที่เล่นเรามักจะชอบแกะและฉันเห็นเหตุผลว่าทำไมกลยุทธ์การลงทุนหรือระบบจะไม่แตกต่างกันใด โชคร้ายนิดหน่อยจะไม่แทรกแซงใน forex อย่างไรก็ตามปัญหาหนึ่งที่ฉันได้พบคือความปรารถนาอย่างต่อเนื่องของฉันในการปรับเปลี่ยนและปรับปรุงระบบอย่างสม่ำเสมอซึ่งเป็นสิ่งที่ฉันพบได้กลายเป็นสิ่งที่มีประสิทธิผลเนื่องจากมีอันตรายที่แท้จริงที่การพัฒนาระบบจะสิ้นสุดลงในตัวของมันเอง จุดที่น่าสนใจ ฉันคิดว่าวิธีที่ดีที่สุดในการจัดการกับสิ่งนี้คือการยอมรับ (หรือปฏิเสธ) ชนิดของอัตราส่วนของ WinLoss ที่คุณใช้ในการซื้อขาย สิ่งที่ฉันหมายถึงคือถ้าคุณค้าแนวโน้มเคาน์เตอร์และจิตใจคุณจะรู้สึกสบายกับระดับสูงของการค้าที่ชนะคุณจะมีเวลาที่ยากลำบากในการรับมือกับระบบที่สร้างชัยชนะหรือการสูญเสียมากที่สุด ในสถานการณ์เช่นนี้อาจคุณ (และระบบ) จะดีขึ้นโดยการตั้งเกณฑ์ที่เข้มงวดมากขึ้นและเสียสละการตั้งค่าบางอย่าง - แต่ไม่มากเกินไป - เพื่อให้บรรลุระดับการค้าที่สูงขึ้น (แม้ว่าในกระบวนการนี้คุณยัง อาจลดอัตราการสูญเสียเฉลี่ยรายได้เฉลี่ยของคุณ) แต่ฉันเห็นด้วย: ปัญหาที่ยุ่งยากที่ทำให้เกิดเหตุการณ์ที่ผู้ค้าเก๋าที่สุด อย่างไรก็ตามปัญหาหนึ่งที่ฉันได้พบคือความปรารถนาอย่างต่อเนื่องของฉันที่จะปรับเปลี่ยนและปรับปรุงระบบอย่างสม่ำเสมอซึ่งฉันได้พบว่าสามารถสร้างผลตอบแทนได้ไม่ดีเนื่องจากมีอันตรายที่แท้จริงที่การพัฒนาระบบจะกลายเป็นจุดจบในตัวเองฉันรู้สึกประหลาดใจมากในโพสต์ของคุณ ในโลกของนักวิเคราะห์เชิงปริมาณ (การออกแบบรูปแบบอนุพันธ์และการใช้งานอื่น ๆ สำหรับธนาคารเพื่อการลงทุนชั้นสูงสุดฉันใช้เวลา 6 ปีในการดำเนินการนี้) Excel VBA เชื่อว่าเป็นภาษาการเขียนโปรแกรมที่มีความยืดหยุ่นน้อยที่สุดและยั่งยืนเราต้องจัดการกับระบบที่เขียนขึ้นโดยใช้ ภาษากำลังจะเกษียณ ฉันเข้าใจว่าบัดนี้คุณยังพอใจกับมัน แต่คิดว่าคุณอาจต้องการศึกษาทางเลือก ในราคาเริ่มต้นที่ค่อนข้างเจียมเนื้อเจียมตัวคุณจะได้รับประสิทธิภาพและความยั่งยืนที่จะทำให้คุณประหลาดใจ ประเด็นปัญหา VBA ที่ต้องคำนึงถึงคือประสิทธิภาพที่ไม่ดีการจัดการหน่วยความจำที่ไม่ดี (ซึ่งอาจทำให้ประสิทธิภาพการทำงานยิ่งแย่ลง) คุณไม่สามารถใช้ระบบควบคุมเวอร์ชันที่จะช่วยให้คุณสามารถติดตามการเปลี่ยนแปลง (ใคร - อะไร - เมื่อ - เมื่อไร) และจะช่วยให้การทำงานร่วมกันเป็นไปได้ (โปรดดูที่ svnbook. red-beannightlyensvn. intro. whatis. htmlsvn. intro. righttool และ tortoisesvn. tigris. org ควรมีเครื่องมือควบคุมเวอร์ชันของ Microsoft) ขึ้นอยู่กับประสบการณ์ของฉันเริ่มต้นจากรหัส VBA ปริมาณบางกลายเป็นไม่สามารถจัดการได้หนึ่งในเหตุผลนี้เป็นที่คุณไม่สามารถใช้การควบคุมเวอร์ชัน ความยืดหยุ่นต่ำ (เมื่อเทียบกับทางเลือกที่ฉันจะขาดเรียน (โครงสร้างชั้นเรียนวิธีการที่สามารถเข้าถึงและแก้ไขเนื้อหาของโครงสร้าง) การขาดเสมือนจริงของกลไกลบ (Variant มากผิดพลาดได้ง่าย) คุณอาจจำเป็นต้องใช้ถ้าคุณต้องการ (การกระทำเดียวกันวัตถุที่แตกต่างกัน) ทางเลือกที่ง่ายต่อการใช้ภาษาโปรแกรมจะ Matlab และ Python ทั้งสองภาษา SVN เป็นมิตร (ดูกระสุนที่สาม), Excel เป็นมิตร แต่ มีประสิทธิภาพต่ำ Matlab เป็นค่าใช้จ่ายค่อนข้างสูง (1K - 10K ขึ้นอยู่กับสิ่งที่แพคเกจที่คุณต้องการและในตำแหน่งของคุณ) มาก nicer และมิตรกับผู้ใช้ทีมสนับสนุนอยู่ที่พร้อม Matlab ประสิทธิภาพปลาย: vectorize รหัสของคุณ (ทำงานกับ vectors และเมทริกซ์มากกว่าองค์ประกอบขององค์ประกอบตามองค์ประกอบเช่นเวกเตอร์ที่องค์ประกอบ i จะเป็นราคาหุ้น X ในวันที่สังเกตวันที่ i วันหรือเมทริกซ์ที่องค์ประกอบ ij จะเป็นผลผลิตของสกุลเงิน Y ในวันที่ i สำหรับวุฒิภาวะ j) อีกวิธีหนึ่งในการ peed ขึ้น Matlab คือการซื้อแพคเกจที่สามารถแปลงโค้ด Matlab ลงในรหัส C ที่สามารถรวบรวมไว้ใน DLL ที่คุณสามารถใช้ใน Excel DLL ดังกล่าวจะทำงานได้เร็วขึ้นมาก (อาจจะเร็วขึ้นกว่า 100 เท่าขึ้นอยู่กับงานของคุณ) งูหลามเป็นโปรแกรมฟรีแวร์ค่อนข้างเข้มงวดใช้เวลาสักเล็กน้อยในการเข้าใช้งาน แต่จะคุ้มค่า มันมีความยืดหยุ่นมากขึ้นของการเขียนโปรแกรมภาษาที่เหมาะสม ภาษาอื่น ๆ ที่คุณอาจต้องการพิจารณา ได้แก่ C, VB และ VB แบบสแตนด์อะโลน (ทั้งหมดนี้เป็นของ Microsoft ราคาสมเหตุสมผล) ฉันจะวางพวกเขาในระหว่าง C (ดูด้านล่าง) และ Excel VBA C จะเป็นหนึ่งที่มีประสิทธิภาพมากที่สุด, VB จะง่ายสำหรับคุณที่จะใช้ - เกือบจะเหมือนกับ VBA อีกครั้งมีการค้าระหว่าง performanceflexibility และ forwardnesssimilarity ตรงไปยัง Excel VBA รหัส C เขียนด้วยมือเป็นสิ่งที่ดีที่สุดจากจุดประสิทธิภาพของมุมมองซึ่งเป็นภาษาอเนกประสงค์ แต่ใช้เวลาเรียนรู้มากขึ้น หวังว่าคุณจะพบว่ามันน่าสนใจ Hi Dr Ernie Chan ฉันได้อ่านหนังสือของคุณเกี่ยวกับการซื้อขายเชิงปริมาณ ว่ากันว่า MATLAB เป็นเครื่องมือที่ดีในการพัฒนากลยุทธ์ที่ซับซ้อน แต่ไม่มี API ที่ได้รับการยอมรับเป็นอย่างดีสำหรับสิ่งนั้น มี MATLAB2IB ที่เพิ่งค้นพบ แต่มันมีการทดสอบที่ดีพอและดีมีการกล่าวในหนังสือของคุณว่า ExcelVBA ช้าเมื่อเทียบกับ C. ฉันสนใจในการพัฒนาระบบการซื้อขายอัตโนมัติ ฉันจะใช้ MATLAB2IB ใหม่นี้และยังคงพัฒนากลยุทธ์ใน Matlab ฉันดีใน Matlab และฉันได้ใช้มันอย่างกว้างขวางในช่วง Ph. D ของฉันและงานอื่น ๆ ฉันไม่ได้ใช้ C มากและฉันพบว่ามันยากขึ้นเมื่อเทียบกับ MATLAB ได้รับเลือกฉันมักจะเขียนโค้ดใน MATLAB แต่จำเป็นต้องพัฒนากลยุทธ์ใน C ถ้าฉันต้องการพัฒนาระบบการซื้อขายอัตโนมัติ Hi Vinay ฉันใช้ matlab2ibapi เป็นเวลาหลายเดือนและพบว่ามีประโยชน์และเชื่อถือได้สำหรับการใช้กลยุทธ์ของฉันโดยอัตโนมัติ ในความเป็นจริงฉันจะเผยแพร่บทความที่อธิบายถึงวิธีการใช้งาน กลยุทธ์การซื้อขายเชิงปริมาณของ ErnieMany เป็นที่นิยมในขณะนี้ ตอนนี้ถ้าคุณต้องการใช้กลยุทธ์แบบนี้ด้วยเงินจริงคุณต้องตรวจสอบให้แน่ใจว่ากลยุทธ์ของคุณทำงานได้ดี สำหรับกลยุทธ์ง่ายๆ MS Excel เหมาะสำหรับงานนี้ แต่เนื่องจากเราต้องการใช้การเพิ่มประสิทธิภาพและการแสดงเฉพาะภายหลังเราใช้ Theta Suite และ Matlab นอกจากนี้ยังช่วยให้สามารถวิเคราะห์กลยุทธ์ที่ซับซ้อนมากขึ้นได้หากต้องการ การกำหนดกลยุทธ์การซื้อขายเชิงปริมาณ: สัญญาณ MACD 8211 ตัวบ่งชี้ทางเทคนิคที่เป็นที่นิยมมากที่สุดคือ Moving Average ConvergenceDivergence (MACD) ซึ่งเป็นส่วนต่างระหว่างค่าเฉลี่ยเคลื่อนที่ 2 ค่า วรรณกรรมกล่าวว่าการข้ามศูนย์ของเส้น MACD จะเป็นตัวบ่งชี้ที่ดีสำหรับการซื้อหุ้นที่ขายได้ บางครั้งพวกเขาเพิ่มสัญญาณกระตุ้นและการอ้างสิทธิ์บางอย่างซึ่งจะดียิ่งขึ้น Let8217s ดูว่านี่เป็นจริงหรือไม่ การค้าที่แม่นยำยิ่งขึ้น MACD มักถูกกำหนดเป็น resp. ในช่วงเวลาผ่านไปซึ่งดูเหมือนว่า EMA12 และ EMA26 มีค่าเฉลี่ยเลขคณิตที่มีการแจกแจงที่แตกต่างกันสองค่าโดยมีค่าคงที่คือ 8220constl128221 และ 82208221constl268221 EMA หมายถึง: ระบบการซื้อขายที่เหมาะสมกับช่วงเวลาของสัญญาณ 8220constl 98221 ดูเหมือนว่าการทดสอบกลยุทธ์กับข้อมูลที่เป็นจริงในอดีตส่วนนี้มีความสำคัญมาก ฉันไม่สามารถเน้นความจริงนี้มากเกินไป: ในโพสต์ภายหลังเราจะพูดถึงการทดสอบกลับมากขึ้น การกำหนดข้อมูลนี้ให้กับกระบวนการ ThetaML ช่วยให้สามารถประมาณประสิทธิภาพของกลยุทธ์การซื้อขาย MACD ได้ นี่คือกราฟของราคาหุ้นของ IBM ตั้งแต่ 2000-01-01 ถึง 2011-12-31: แผนผัง Matlab ของราคาหุ้นของ IBM การทำ backtesting กลยุทธ์การซื้อขาย MACD เราสามารถเรียกใช้โมเดล ThetaML ข้างต้นโดยใช้ Theta Suite Orchestrator และเชื่อมต่อกับประวัติ ข้อมูล IBM ใน Matlab ใน Configurator จากนั้นใน Explorer ผลลัพธ์เราได้รับประสิทธิภาพของกลยุทธ์การซื้อขาย MACD สัญญาณที่สอดคล้องกันโดยไม่ต้องขายสั้นกลยุทธ์การดำเนินงานของกลยุทธ์การซื้อขาย MACD และมีการขายสั้นดูเหมือนว่าประสิทธิภาพของกลยุทธ์การซื้อขาย MACD กับการขายสั้นทราบว่าในช่วงหลายปี กลยุทธ์ MACD-signal ไม่ได้ผลดีกว่าหุ้นอ้างอิง คำนึงถึงค่าใช้จ่ายในการทำธุรกรรมซึ่งจะยิ่งแย่ลง ที่น่าสนใจในปี 2000 ส่งผลการดำเนินงานที่ดีของกลยุทธ์ MACD แต่ทุกปีต่อมาไม่ได้ดำเนินการที่ดี ข้อสรุปง่ายที่จะตรวจสอบว่ากลยุทธ์จะใช้ข้อมูลทางประวัติศาสตร์ได้ดีหรือไม่ ThetaML และ Matlab เป็นเครื่องมือที่ยอดเยี่ยมสำหรับงานนี้ กลยุทธ์การซื้อขายของ MACD ซึ่งเราวิเคราะห์ไม่ได้ดีไปกว่าการถือครองหลักทรัพย์อ้างอิง พารามิเตอร์อื่น ๆ ของกลยุทธ์การซื้อขายอาจนำไปสู่ผลลัพธ์ที่ดีขึ้นเพื่อให้เราสามารถเพิ่มประสิทธิภาพได้ เราจะเห็นว่าสัปดาห์หน้า 30 พฤศจิกายน 2016, 12:34 น. ไม่กี่เดือนที่ผ่านมาผู้อ่านชี้ให้ฉันเห็นวิธีการใหม่ในการเชื่อมต่อ R และ Excel ฉัน don8217t รู้นานเท่าไหร่นี้ได้รับรอบ แต่ฉันไม่เคยเจอมันและ I8217ve ไม่เคยเห็นโพสต์บล็อกหรือบทความเกี่ยวกับเรื่องใด ๆ ดังนั้นฉันจึงตัดสินใจที่จะเขียนโพสต์เป็นเครื่องมือที่มีค่าจริงๆและก่อนใครถาม I8217m ไม่เกี่ยวข้องกับ บริษัท ในทางใดทางหนึ่ง BERT ย่อมาจาก Basic Excel R Toolkit It8217s ฟรี (มีใบอนุญาตภายใต้ GPL v2) และได้รับการพัฒนาโดย Structured Data LLC ในขณะที่เขียนเวอร์ชันปัจจุบันของ BERT เท่ากับ 1.07 ข้อมูลเพิ่มเติมสามารถดูได้ที่นี่. จากมุมมองด้านเทคนิคเพิ่มเติม BERT ได้รับการออกแบบมาเพื่อสนับสนุนการทำงานของ R จากเซลล์กระดาษคำนวณของ Excel ในข้อกำหนดของ Excel, it8217s สำหรับการเขียน User-Defined Functions (UDF) ใน R. ใน I8217m โพสต์นี้จะไม่แสดงให้คุณเห็นว่า R และ Excel มีปฏิสัมพันธ์ผ่านทาง BERT มีบทเรียนดีๆอยู่ที่นี่ ที่นี่และที่นี่ แต่ฉันต้องการแสดงให้คุณเห็นว่าฉันใช้ BERT เพื่อสร้าง 8220control tower8221 เพื่อการซื้อขายของฉันอย่างไร สัญญาณการค้าของฉันถูกสร้างโดยใช้รายการยาวของไฟล์ R แต่ฉันต้องการความยืดหยุ่นของ Excel เพื่อแสดงผลลัพธ์อย่างรวดเร็วและมีประสิทธิภาพ ดังที่แสดงไว้ข้างต้น BERT สามารถทำเช่นนี้ได้สำหรับฉัน แต่ฉันต้องการปรับแต่งแอพพลิเคชันตามความต้องการของฉันด้วย โดยการรวมพลังของ XML, VBA, R และ BERT ฉันสามารถสร้างแอปพลิเคชันที่ดูดี แต่ทรงพลังในรูปแบบไฟล์ Excel ที่มีรหัส VBA ต่ำสุด สุดท้ายฉันมีไฟล์ Excel เดียวรวบรวมงานทั้งหมดที่จำเป็นในการจัดการพอร์ตโฟลิโอของฉัน: การอัพเดตฐานข้อมูลการสร้างสัญญาณการส่งใบสั่งซื้อเป็นต้น 8230 วิธีการของฉันอาจถูกแบ่งออกเป็น 3 ขั้นตอนด้านล่างนี้: ใช้ XML เพื่อสร้างเมนูและปุ่มที่ผู้ใช้กำหนดเองใน Excel ไฟล์. เมนูและปุ่มข้างต้นเป็นหลักเรียกฟังก์ชัน VBA ฟังก์ชั่น VBA ดังกล่าวจะถูกตัดรอบฟังก์ชัน R ที่กำหนดโดยใช้ BERT ด้วยวิธีนี้ฉันสามารถเก็บความแตกต่างระหว่างหลักของรหัสของฉันเก็บไว้ใน R, SQL และ Python และทุกอย่างใช้ในการแสดงและจัดรูปแบบผลเก็บไว้ใน Excel, VBA amp XML ในส่วนถัดไปฉันจะนำเสนอสิ่งที่จำเป็นสำหรับการพัฒนาแนวทางดังกล่าวและคำแนะนำทีละขั้นตอนที่อธิบายว่า BERT สามารถใช้สำหรับการส่งผ่านข้อมูลจาก R ไปยัง Excel ด้วยรหัส VBA ที่น้อยที่สุดได้อย่างไร 1 8211 ดาวน์โหลดและติดตั้ง BERT จากลิงค์นี้ เมื่อการติดตั้งเสร็จสิ้นคุณควรจะมีเมนู Add-Ins ใหม่ใน Excel ด้วยปุ่มดังแสดงด้านล่าง นี่เป็นวิธีที่ BERT มีอยู่ใน Excel 2 8211 ดาวน์โหลดและติดตั้ง Custom UI editor ตัวแก้ไข UI ที่กำหนดเองช่วยในการสร้างเมนูและปุ่มที่กำหนดโดยผู้ใช้ใน Excel ribbon มีขั้นตอนการทำตามขั้นตอนที่นี่ คำแนะนำทีละขั้นตอน 1 8211 R รหัส: ฟังก์ชัน R ด้านล่างเป็นโค้ดที่ใช้งานง่ายสำหรับการอธิบายเท่านั้น จะคำนวณและคืนส่วนที่เหลือจากการถดถอยเชิงเส้น นี่คือสิ่งที่เราต้องการดึงข้อมูลใน Excel บันทึกไฟล์นี้ไว้ในไฟล์ myRCode. R (ชื่อใด ๆ ก็ได้ดี) ในไดเร็กทอรีที่คุณเลือก 2 8211 functions. R ใน BERT จาก Excel เลือก Add-Ins - gt Home Directory และเปิดไฟล์ที่ชื่อว่า functions. R ในไฟล์นี้วางรหัสต่อไปนี้ ตรวจสอบว่าคุณได้ใส่เส้นทางที่ถูกต้อง นี่เป็นเพียงการจัดหาไฟล์ BERT ที่ R ที่คุณสร้างไว้ข้างต้น จากนั้นให้บันทึกและปิดฟังก์ชั่นไฟล์ R หากคุณต้องการทำการเปลี่ยนแปลงใด ๆ ในไฟล์ R ที่สร้างขึ้นในขั้นตอนที่ 1 คุณจะต้องโหลดใหม่โดยใช้ปุ่ม BERT 8220Reload Startup File8221 จากเมนู Add-Ins ใน Excel 3 8211 ใน Excel: สร้างและบันทึกไฟล์ที่ชื่อ myFile. xslm (ชื่ออื่นใดก็ได้) นี่คือไฟล์ที่เปิดใช้งานมาโครที่คุณบันทึกไว้ในไดเร็กทอรีที่คุณเลือก เมื่อแฟ้มถูกบันทึกไว้ปิดมัน 4 8211 เปิดไฟล์ที่สร้างขึ้นข้างต้นในโปรแกรมแก้ไข UI แบบกำหนดเอง: เมื่อเปิดไฟล์แล้ววางโค้ดด้านล่าง คุณควรมีบางอย่างเช่นนี้ในตัวแก้ไข XML: โค้ด XML นี้จะสร้างเมนูเพิ่มเติม (RTrader) กลุ่มใหม่ (กลุ่มของฉัน) และปุ่มกำหนดเอง (New Button) ใน ribbon Excel เมื่อ you8217re เสร็จแล้วให้เปิด myFile. xslm ใน Excel และปิด Custom UI Editor คุณควรเห็นบางอย่างเช่นนี้ 5 8211 เปิดตัวแก้ไข VBA ใน myFile. xlsm แทรกโมดูลใหม่ วางโค้ดด้านล่างลงในโมดูลที่สร้างขึ้นใหม่ การดำเนินการนี้จะลบผลการค้นหาก่อนหน้าในแผ่นงานก่อนที่จะดำเนินการใหม่ 6 8211 คลิกปุ่ม New ตอนนี้กลับไปที่สเปรดชีตและในเมนู RTrader คลิกปุ่ม 8220New Button8221 คุณจะเห็นสิ่งที่ปรากฏด้านล่าง คู่มือข้างต้นเป็นรุ่นพื้นฐานของสิ่งที่สามารถทำได้โดยใช้ BERT แต่จะแสดงวิธีการรวมพลังของเครื่องมือที่เฉพาะเจาะจงหลายตัวเพื่อสร้างแอ็พพลิเคชันที่กำหนดเองของคุณเอง จากมุมมองของฉันความสนใจของวิธีดังกล่าวคือความสามารถในการกาวด้วยกัน R และ Excel ชัด แต่รวมถึง XML (และชุด) ชิ้นส่วนของโค้ดจาก Python, SQL และอื่น ๆ นี่คือสิ่งที่ฉันต้องการ สุดท้ายฉันอยากรู้ว่าใครมีประสบการณ์กับ BERT 19 สิงหาคม 2016, 9:26 น. เมื่อทดสอบกลยุทธ์การซื้อขายวิธีการทั่วไปคือการแบ่งข้อมูลเริ่มแรกที่ตั้งไว้ในตัวอย่างข้อมูล: ส่วนหนึ่งของข้อมูลที่ออกแบบมาเพื่อปรับเทียบ โมเดลและข้อมูลตัวอย่าง: ส่วนหนึ่งของข้อมูลที่ใช้ในการตรวจสอบการสอบเทียบและตรวจสอบว่าประสิทธิภาพที่สร้างขึ้นในตัวอย่างจะสะท้อนให้เห็นในโลกแห่งความจริง ตามกฎของหัวแม่มือประมาณ 70 ของข้อมูลเริ่มต้นสามารถใช้สำหรับการสอบเทียบ (เช่นในตัวอย่าง) และ 30 สำหรับการตรวจสอบ (เช่นออกจากตัวอย่าง) จากนั้นการเปรียบเทียบข้อมูลในและนอกของตัวอย่างช่วยในการตัดสินใจว่ารูปแบบนั้นมีประสิทธิภาพเพียงพอหรือไม่ โพสต์นี้มุ่งไปที่ขั้นตอนต่อไปและเป็นวิธีการทางสถิติในการตัดสินใจว่าข้อมูลตัวอย่างจะไม่ตรงกับสิ่งที่สร้างขึ้นในตัวอย่าง ในแผนภูมิด้านล่างพื้นที่สีน้ำเงินหมายถึงประสิทธิภาพตัวอย่างสำหรับกลยุทธ์ของฉัน การตรวจสอบภาพที่เรียบง่ายแสดงให้เห็นถึงความพอดีที่ดีระหว่างการเข้าและออกจากการทดสอบตัวอย่าง แต่ฉันมีความมั่นใจในระดับใดในขั้นตอนนี้ไม่มากนักและนี่เป็นปัญหา สิ่งที่จำเป็นอย่างแท้จริงคือการวัดความคล้ายคลึงกันระหว่างชุดข้อมูลตัวอย่างในและนอก ในแง่ทางสถิติอาจแปลได้ว่าเป็นไปได้ว่าตัวเลขการเข้าชมและออกจากตัวเลขประสิทธิภาพตัวอย่างมาจากการกระจายเดียวกัน มีการทดสอบสถิติที่ไม่ใช่พารามิเตอร์ที่ไม่ตรงนี้: การทดสอบ Kruskall-Wallis ความหมายที่ดีของการทดสอบนี้สามารถพบได้ในกลุ่มตัวอย่างของ R-Tutor 8220A ที่เก็บตัวอย่างข้อมูลได้โดยอิสระหากมาจากประชากรที่ไม่เกี่ยวกันและตัวอย่างเหล่านี้ไม่มีผลต่อกันและกัน ใช้การทดสอบ Kruskal-Wallis เราสามารถตัดสินใจได้ว่าการกระจายของประชากรจะเหมือนกันหรือไม่โดยสมมติว่าพวกเขาไม่ปฏิบัติตามการแจกแจงแบบปกติ 8221 ผลประโยชน์เพิ่มเติมของการทดสอบนี้ไม่ได้เป็นการสมมติว่ามีการแจกแจงแบบปกติ มีการทดสอบอื่นที่มีลักษณะเดียวกับที่สามารถใส่ลงในกรอบดังกล่าวได้ การทดสอบ Mann-Whitney-Wilcoxon หรือการทดสอบ Kolmogorov-Smirnov จะเหมาะกับกรอบการทำงานนี้อย่างสมบูรณ์ แต่นี่ไม่ใช่ข้อ จำกัด ของบทความนี้เพื่อหารือเกี่ยวกับข้อดีข้อเสียของการทดสอบแต่ละข้อ คำอธิบายที่ดีพร้อมกับตัวอย่าง R สามารถดูได้ที่นี่ Here8217s รหัสที่ใช้ในการสร้างแผนภูมิด้านบนและการวิเคราะห์: ในตัวอย่างข้างต้นในช่วงตัวอย่างมีค่าเกินกว่าระยะเวลาตัวอย่างดังนั้นฉันจึงสุ่มสร้าง 1000 ส่วนย่อยของข้อมูลตัวอย่างซึ่งแต่ละตัวมีความยาวเท่ากันหมด ของข้อมูลตัวอย่าง จากนั้นผมได้ทดสอบแต่ละชุดย่อยตัวอย่างเทียบกับข้อมูลตัวอย่างและบันทึกค่า p - กระบวนการนี้สร้างค่า p เดียวสำหรับการทดสอบ Kruskall-Wallis แต่เป็นการกระจายที่ทำให้การวิเคราะห์มีประสิทธิภาพมากขึ้น ในตัวอย่างนี้ค่าเฉลี่ย p - ค่าดีกว่าศูนย์ (0.478) แสดงให้เห็นว่าสมมติฐานที่เป็นโมฆะควรได้รับการยอมรับ: มีหลักฐานที่ชัดเจนว่าข้อมูลเข้าและออกจากตัวอย่างมาจากการกระจายเดียวกัน ตามปกติแล้วสิ่งที่นำเสนอในโพสต์นี้เป็นตัวอย่างของเล่นที่ทำหน้าที่ขูดขีดพื้นผิวของปัญหาเท่านั้นและควรปรับให้ตรงตามความต้องการของแต่ละบุคคล อย่างไรก็ตามผมคิดว่าข้อเสนอแนะนี้เป็นกรอบทางสถิติที่น่าสนใจและมีเหตุผลเพื่อประเมินผลลัพธ์จากผลการทดสอบตัวอย่าง โพสต์นี้ได้รับแรงบันดาลใจจากเอกสารสองฉบับต่อไปนี้: Vigier Alexandre, Chmil Swann (2007), ผลกระทบของฟังก์ชันการเพิ่มประสิทธิภาพต่างๆที่มีต่อประสิทธิภาพการทำงานของตัวอย่างของกลยุทธ์การซื้อขายพันธุกรรมที่พัฒนาขึ้น, การคาดการณ์การประชุมตลาดการเงิน Vigier Alexandre, Chmil Swann (2010), กระบวนการเพิ่มประสิทธิภาพเพื่อปรับปรุงความสอดคล้องตัวอย่าง, กรณี Stock Market, การประชุมเชิงปริมาณ JP Morgan Cazenove Equity, London October 2010 13 ธันวาคม 2015, 2:03 pm การทำวิจัยเชิงปริมาณหมายถึงการกระทืบข้อมูลจำนวนมากและต้องการข้อมูลที่สะอาดและเชื่อถือได้ บรรลุเป้าหมายนี้ สิ่งที่จำเป็นจริงๆคือข้อมูลสะอาดที่สามารถเข้าถึงได้ง่าย (แม้จะไม่มีการเชื่อมต่ออินเทอร์เน็ต) วิธีที่มีประสิทธิภาพมากที่สุดในการทำเช่นนี้สำหรับฉันคือการรักษาชุดของไฟล์ CSV แน่นอนกระบวนการนี้สามารถจัดการได้หลายวิธี แต่ฉันพบว่ามีประสิทธิภาพมากและง่ายทำงานล่วงเวลาเพื่อรักษาไดเรกทอรีที่ฉันเก็บและ update ไฟล์ csv ฉันมีไฟล์ csv หนึ่งไฟล์ต่อหนึ่งตราสารและไฟล์แต่ละไฟล์จะมีชื่อตามอุปกรณ์ที่มีอยู่ เหตุผลที่ฉันทำเช่นนั้นเป็นสองเท่า: ประการแรกฉัน don8217t ต้องการดาวน์โหลดข้อมูลราคา (ราคา) จาก Yahoo, Google itd8230 ทุกครั้งที่ฉันต้องการทดสอบแนวคิดใหม่ ๆ แต่ที่สำคัญกว่าเมื่อฉันระบุและแก้ไขปัญหาแล้วฉัน don8217t ต้องการจะต้อง ทำอีกครั้งในครั้งต่อไปที่ฉันต้องการเครื่องดนตรีเดียวกัน เรียบง่ายและมีประสิทธิภาพมาก กระบวนการดังกล่าวสรุปได้จากตารางด้านล่าง ในทุกอย่างที่ตามมาผมถือว่าข้อมูลมาจาก Yahoo รหัสจะต้องได้รับการแก้ไขสำหรับข้อมูลจาก Google, Quandl ฯลฯ8230นอกจากนี้ฉันยังเสนอขั้นตอนการอัปเดตข้อมูลราคารายวัน การตั้งค่าจะแตกต่างกันสำหรับข้อมูลความถี่สูงและชุดข้อมูลประเภทอื่น ๆ (เช่นแตกต่างจากราคา) 1 8211 การดาวน์โหลดข้อมูลเบื้องต้น (listOfInstruments. R amp historicalData. R) ไฟล์ listOfInstruments. R คือไฟล์ที่มีเฉพาะรายการเครื่องมือทั้งหมด หากเครื่องไม่ได้เป็นส่วนหนึ่งของรายการของฉัน (เช่นไม่มีไฟล์ csv ในโฟลเดอร์ข้อมูล) หรือถ้าคุณทำเช่นนั้นเป็นครั้งแรกคุณต้องดาวน์โหลดชุดข้อมูลทางประวัติศาสตร์ในตอนแรก ตัวอย่างด้านล่างดาวน์โหลดชุดราคา ETFs ประจำวันจาก Yahoo Finance ตั้งแต่เดือนมกราคม 2000 และเก็บข้อมูลไว้ในไฟล์ CSV 2 8211 อัพเดตข้อมูลที่มีอยู่ (updateData. R) โค้ดด้านล่างนี้เริ่มจากไฟล์ที่มีอยู่ในโฟลเดอร์เฉพาะและอัปเดตข้อมูลทั้งหมดที่มีอยู่หลังจากที่อื่น ฉันมักจะเรียกใช้กระบวนการนี้ทุกวันยกเว้นเมื่อ I8217m ในวันหยุด หากต้องการเพิ่มเครื่องมือใหม่ให้ใช้ขั้นตอนที่ 1 ด้านบนสำหรับเครื่องนี้เพียงอย่างเดียว 3 8211 สร้างไฟล์แบทช์ (updateDailyPrices. bat) ส่วนที่สำคัญอีกอย่างหนึ่งของงานคือการสร้างไฟล์แบทช์ที่ทำให้กระบวนการอัปเดตทำงานโดยอัตโนมัติ (I8217m เป็นผู้ใช้ Windows) วิธีนี้จะหลีกเลี่ยงการเปิด RRStudio และเรียกใช้โค้ดจากที่นั่น รหัสด้านล่างจะอยู่ในไฟล์. bat (เส้นทางจะต้องมีการแก้ไขด้วยการตั้งค่า reader8217s) โปรดทราบว่าฉันได้เพิ่มไฟล์ที่ส่งออก (updateLog. txt) เพื่อติดตามการดำเนินการ ขั้นตอนข้างต้นเป็นเรื่องง่ายมากเพราะจะอธิบายเฉพาะวิธีการอัปเดตข้อมูลราคารายวันเท่านั้น I8217 ใช้เวลานี้มาเรื่อย ๆ และทำงานได้อย่างราบรื่นสำหรับฉันจนถึงตอนนี้ สำหรับข้อมูลขั้นสูงและความถี่ที่สูงขึ้นสิ่งต่างๆจะมีความซับซ้อนมากขึ้น ตามปกติความคิดเห็นใด ๆ ต้อนรับ 23 มีนาคม 2015, 8:55 น. เมื่อพูดถึงการจัดการพอร์ตการลงทุนของหุ้นเทียบกับเกณฑ์มาตรฐานปัญหาจะแตกต่างจากการกำหนดกลยุทธ์การคืนผลแน่นอน ในอดีตต้องถือหุ้นมากขึ้นกว่าในภายหลังซึ่งไม่มีหุ้นที่สามารถถือได้หากมีโอกาสไม่ดีพอ เหตุผลคือข้อผิดพลาดในการติดตาม นี่คือส่วนเบี่ยงเบนมาตรฐานของผลตอบแทนของพอร์ตการลงทุนโดยหักผลตอบแทนจากการลงทุน มีการจัดเก็บหุ้นที่น้อยลงเทียบกับเกณฑ์มาตรฐานมากขึ้นจะทำให้เกิดข้อผิดพลาดในการติดตามได้มากขึ้น (เช่นความเสี่ยงที่สูงขึ้น) การวิเคราะห์ต่อไปนี้ได้รับแรงบันดาลใจมาจากหนังสือ 8220Active Portfolio Management8221 โดย Grinold amp Kahn นี่คือพระคัมภีร์สำหรับทุกคนที่สนใจในการทำผลงานกับมาตรฐาน ผมขอแนะนำให้ทุกคนที่มีความสนใจในหัวข้อนี้ในการอ่านหนังสือตั้งแต่ต้นจนจบ It8217s เขียนเป็นอย่างดีและวางรากฐานของการจัดการพอร์ตโฟลิโอที่ใช้งานอย่างเป็นระบบ (ฉันไม่มีความร่วมมือใด ๆ กับบรรณาธิการหรือผู้เขียน) 1 8211 Factor Analysis นี่เรากำลังพยายามจัดอันดับหุ้นในจักรวาลการลงทุนให้ได้มากที่สุดเท่าที่จะเป็นไปได้ หลายคนคิดค้นเครื่องมือและเครื่องมือมากมายที่พัฒนาขึ้นเพื่อให้บรรลุเป้าหมายนี้ ในบทความนี้ฉันมุ่งเน้นไปที่สองเมตริกที่ง่ายและใช้กันอย่างแพร่หลาย: ค่าสัมประสิทธิ์ข้อมูล (IC) และ Quantiles Return (QR) 1.1 8211 ค่าสัมประสิทธิ์ข้อมูลเส้นขอบฟ้าสำหรับผลตอบแทนที่ได้รับจะต้องถูกกำหนดโดยนักวิเคราะห์และ it8217s ซึ่งเป็นส่วนหนึ่งของการหมุนเวียนของกลยุทธ์8217และการสลายตัวของอัลฟา (ซึ่งเป็นหัวข้อที่ครอบคลุมการวิจัย) เห็นได้ชัดว่าไอซีจะต้องสูงที่สุดเท่าที่จะเป็นไปได้ในรูปแบบสัมบูรณ์ สำหรับผู้อ่านที่กระตือรือร้นในหนังสือโดย Grinold amp Kahn สูตรการเชื่อมโยง Information Ratio (IR) และ IC จะได้รับ: ด้วยความกว้างคือจำนวนของการเดิมพันที่เป็นอิสระ (ธุรกิจการค้า) สูตรนี้เรียกว่ากฎพื้นฐานของการจัดการที่ใช้งานอยู่ ปัญหาคือบ่อยครั้งที่การกำหนดความกว้างได้อย่างถูกต้องไม่ใช่เรื่องง่ายเหมือนกับเสียง 1.2 8211 Quantiles Return เพื่อให้มีการคาดการณ์ที่ถูกต้องยิ่งขึ้นเกี่ยวกับปัจจัยที่ทำให้พลังงานที่คาดการณ์ได้ it8217s จำเป็นที่จะต้องก้าวไปอีกขั้นหนึ่งและจัดกลุ่มหุ้นตามปริมาณของค่าปัจจัยจากนั้นวิเคราะห์ค่าเฉลี่ยของผลตอบแทน (หรือตัวชี้วัดค่าเฉลี่ยของศูนย์กลางอื่น ๆ ) ของแต่ละกลุ่ม quantiles ประโยชน์ของเครื่องมือนี้ตรงไปตรงมา ปัจจัยหนึ่งสามารถมี IC ที่ดี แต่พลังการคาดการณ์อาจ จำกัด อยู่ที่จำนวนหุ้นที่น้อย ไม่ดีเท่าผู้จัดการด้านการลงทุนจะต้องเลือกหุ้นภายในจักรวาลทั้งหมดเพื่อให้สอดคล้องกับข้อ จำกัด ในการติดตามข้อผิดพลาด กลับ quantiles ดีมีลักษณะความสัมพันธ์ที่น่าเบื่อระหว่างแต่ละ quantiles และส่งกลับ. หุ้นทั้งหมดในดัชนี SampP500 (ในขณะที่เขียน) เห็นได้ชัดว่ามีอคติในการอยู่รอดของเรือ: รายการดัชนีหุ้นในดัชนีมีการเปลี่ยนแปลงอย่างมีนัยสำคัญระหว่างช่วงเริ่มต้นและช่วงสิ้นสุดของช่วงเวลาตัวอย่าง แต่ก็มีความสามารถเพียงพอสำหรับวัตถุประสงค์ในการแสดงเท่านั้น รหัสด้านล่างดาวน์โหลดราคาหุ้นแต่ละแบบใน SampP500 ระหว่างเดือน ม. ค. 2548 ถึงวันนี้ (ต้องใช้เวลาสักครู่) และจะเปลี่ยนราคาวัตถุดิบให้เป็นผลตอบแทนในช่วง 12 เดือนที่ผ่านมาและเดือนที่ผ่านมา อดีตเป็นปัจจัยของเราหลังจะใช้เป็นมาตรการส่งกลับ ด้านล่างนี้เป็นรหัสในการคำนวณค่าสัมประสิทธิ์ข้อมูลและปริมาณการส่งกลับ โปรดทราบว่าฉันใช้ quintiles ในตัวอย่างนี้ แต่สามารถใช้วิธีจัดกลุ่มอื่น ๆ (terciles, deciles etc8230) จริงๆมันขึ้นอยู่กับขนาดตัวอย่างสิ่งที่คุณต้องการจับภาพและสภาพอากาศที่คุณต้องการมีภาพรวมกว้างหรือมุ่งเน้นกระจายหาง สำหรับการประเมินผลตอบแทนภายในแต่ละกลุ่มค่ามัธยฐานถูกใช้เป็นตัวประมาณแนวโน้มกลาง มาตรการนี้มีความไวต่อค่าผิดปกติน้อยกว่าค่าเฉลี่ยเลขคณิต และสุดท้ายโค้ดเพื่อสร้างแผนภูมิ Quantiles Return 3 8211 วิธีการใช้ประโยชน์จากข้อมูลข้างต้นในแผนภูมิด้านบน Q1 จะกลับมาต่ำสุดในรอบ 12 เดือนและ Q5 สูงสุด มีการเพิ่มผลตอบแทนเชิงปริมาณในช่วง Q1 และ Q5 ที่เพิ่มขึ้นอย่างเห็นได้ชัดเกือบทุกอย่างซึ่งแสดงให้เห็นว่าหุ้นที่ลดลงใน Q5 ดีกว่าไตรมาสที่ 1 ประมาณ 1 ต่อเดือน นี่เป็นสิ่งที่มีความสำคัญและมีประสิทธิภาพสำหรับปัจจัยง่ายๆเช่น (ไม่แปลกใจเลยครับ) ดังนั้นเราจึงมีโอกาสที่จะเอาชนะดัชนีได้มากขึ้นโดยการถ่วงน้ำหนักหุ้นที่ลดลงในไตรมาสที่ 5 และทำให้น้ำหนักลดลงเมื่อเทียบกับเกณฑ์มาตรฐาน IC ของ 0.0206 อาจไม่ได้หมายถึงการจัดการที่ดีในตัวเอง แต่ it8217s อย่างมีนัยสำคัญที่แตกต่างจาก 0 และบ่งบอกถึงพลังการคาดการณ์ที่ดีของที่ผ่านมา 12 เดือนกลับโดยรวม การทดสอบความสำคัญอย่างเป็นทางการสามารถประเมินได้ แต่สิ่งนี้อยู่นอกเหนือขอบเขตของบทความนี้ 4 8211 ข้อ จำกัด ในทางปฏิบัติกรอบการทำงานข้างต้นเป็นสิ่งที่ยอดเยี่ยมสำหรับการประเมินคุณภาพของปัจจัยการลงทุน 8272s อย่างไรก็ตามมีข้อ จำกัด ในทางปฏิบัติที่ต้องใช้ในการดำเนินการในชีวิตจริงคือการปรับสมดุล ในคำอธิบายด้านบน it8217s สันนิษฐานว่า ณ สิ้นเดือนของพอร์ตโฟลิโอจะปรับสมดุลได้อย่างเต็มที่ ซึ่งหมายความว่าหุ้นทั้งหมดที่ร่วงลงใน Q1 มีน้ำหนักน้อยและหุ้นทั้งหมดที่ตกอยู่ในไตรมาสที่ 5 มีน้ำหนักเกินเมื่อเทียบกับเกณฑ์มาตรฐาน นี่เป็นไปไม่ได้ที่จะเป็นไปได้ในทางปฏิบัติ: บางหุ้นอาจถูกแยกออกจากจักรวาลการลงทุนมีข้อจํากัดเกี่ยวกับอุตสาหกรรมหรือภาคน้ำหนักมีข้อจํากัดในการหมุนเวียนอื่น ๆ 822 ค่าใช้จ่ายในการทำธุรกรรม สิ่งนี้ไม่ได้ถูกนำมาพิจารณาในการวิเคราะห์ข้างต้นและเป็นข้อบกพร่องร้ายแรงในการใช้ชีวิตจริง การพิจารณาการหมุนเวียนมักใช้ในชีวิตจริงในรูปของการลงโทษต่อคุณภาพของปัจจัย สัมประสิทธิ์การถ่ายเท นี่คือการขยายกฎหมายพื้นฐานของการจัดการที่ใช้งานอยู่และเป็นการผ่อนคลายสมมติฐานของแบบจำลอง Grinold8217s ที่ผู้บริหารไม่ต้องเผชิญกับข้อ จำกัด ที่ทำให้พวกเขาไม่สามารถแปลข้อมูลเชิงลึกด้านการลงทุนของตนโดยตรงไปยังการเดิมพันที่เป็นผลงานได้ และสุดท้าย I8217m ประหลาดใจด้วยสิ่งที่สามารถทำได้ในน้อยกว่า 80 บรรทัดของรหัสกับ R8230 ตามปกติความคิดเห็นใด ๆ ต้อนรับ 14 มีนาคม 2014, 01:07 คำถามหนึ่งควรถาม himherself เมื่อใช้ตัวชี้วัดทางเทคนิคคือสิ่งที่จะเป็นวัตถุประสงค์ เกณฑ์การเลือกพารามิเตอร์ตัวบ่งชี้ (เช่นทำไมต้องใช้ RSI 14 วันมากกว่า 15 หรือ 20 วัน) อัลกอริทึมทางพันธุกรรม (GA) เป็นเครื่องมือที่เหมาะสำหรับตอบคำถามนี้ ในบทความนี้ I8217 จะแสดงวิธีการตั้งค่าปัญหาใน R. ก่อนดำเนินการเตือนตามปกติ: สิ่งที่ฉันนำเสนอในโพสต์นี้เป็นเพียงตัวอย่างของเล่นเท่านั้นไม่ใช่คำเชิญในการลงทุน ไม่ใช่กลยุทธ์ที่สมบูรณ์แบบ แต่เป็นแนวคิดการวิจัยที่ต้องมีการวิจัยพัฒนาและปรับแต่งตามความต้องการของแต่ละบุคคล ขั้นตอนวิธีเชิงพันธุกรรมคืออะไรคำอธิบายที่ดีที่สุดของ GA ที่ฉันมาจาก Cybernatic Trading เป็นหนังสือของ Murray A. Ruggiero 8220Genetic Algorithms ถูกคิดค้นโดย John Holland ในช่วงกลางปี ​​1970 เพื่อแก้ปัญหาการเพิ่มประสิทธิภาพอย่างหนัก วิธีนี้ใช้การคัดเลือกโดยธรรมชาติการอยู่รอดของ fittest8221 กระบวนการทั่วไปทำตามขั้นตอนด้านล่าง: เข้ารหัสปัญหาเป็นโครโมโซมใช้การเข้ารหัสการพัฒนาฟังก์ชั่นสมรรถภาพสำหรับใช้ในการประเมินแต่ละค่าโครโมโซม 8017 ในการแก้ปัญหาที่กำหนดเริ่มต้นประชากรโครโมโซมประเมินแต่ละโครโมโซมในประชากรสร้างโครโมโซมใหม่โดยการผสมพันธุ์สอง โครโมโซม (พ่อแม่จะถูกเลือกแบบสุ่ม แต่ลำเอียงโดยการออกกำลังกายของพวกเขา) ประเมินโครโมโซมใหม่ลบสมาชิกของประชากรที่ไม่พอดีกับโครโมโซมใหม่และใส่โครโมโซมใหม่ในประชากร . ถ้าเกณฑ์หยุดถึง (จำนวนสูงสุดของรุ่นเกณฑ์การออกกำลังกายดีพอ 823) แล้วกลับโครโมโซมที่ดีที่สุดหรือไปที่ขั้นตอนที่ 4 จากมุมมองการซื้อขาย GA มีประโยชน์มากเพราะดีในการจัดการกับปัญหาไม่เชิงเส้นสูง อย่างไรก็ตามคุณลักษณะเหล่านี้แสดงถึงคุณลักษณะที่น่ารังเกียจซึ่งน่าจะเป็นที่กล่าวถึง: เหมาะกว่า: นี่เป็นปัญหาหลักและทำให้นักวิเคราะห์วิเคราะห์ปัญหาในลักษณะที่ลดความเสี่ยงนี้ลง เวลาในการคำนวณ ถ้าปัญหา isn8217t ถูกกำหนดอย่างถูกต้องอาจใช้เวลานานมากในการเข้าถึงโซลูชันที่ดีและความซับซ้อนเพิ่มขึ้นอย่างมากตามจำนวนตัวแปร ดังนั้นความจำเป็นในการเลือกพารามิเตอร์อย่างรอบคอบ มีหลายแพคเกจ R เกี่ยวกับ GA ฉันเลือกที่จะใช้กันมากที่สุด: rgenoud ราคาปิดรายวันสำหรับ ETFs สภาพคล่องส่วนใหญ่จากการเงินของ Yahoo จะย้อนกลับไปในเดือนมกราคม 2000 ในช่วงตัวอย่างมาจากมกราคม 2000 ถึงธันวาคม 2010 Out of ระยะเวลาตัวอย่างจะเริ่มในเดือนมกราคม 2554 ตรรกะดังต่อไปนี้ฟังก์ชั่นการออกกำลังกายจะได้รับการปรับให้เหมาะกับช่วงเวลาตัวอย่างเพื่อให้ได้พารามิเตอร์ที่ดีที่สุดสำหรับตัวชี้วัดทางเทคนิคที่เลือก ผลการปฏิบัติงานของตัวชี้วัดเหล่านี้จะได้รับการประเมินในช่วงเวลาที่ตัวอย่าง แต่ก่อนที่จะทำเช่นนั้นตัวชี้วัดทางเทคนิคจะต้องได้รับการคัดเลือก ตลาดตราสารทุนมีลักษณะสำคัญสองอย่างที่คุ้นเคยกับทุกคนที่มีประสบการณ์ในการซื้อขาย โมเมนตัมระยะยาวและการกลับรายการระยะสั้น คุณลักษณะเหล่านี้สามารถแปลเป็นตัวชี้วัดทางเทคนิคได้จาก: moving averages cross over และ RSI ค่านี้แสดงถึงชุดของพารามิเตอร์ 4 ตัวคือช่วงเวลามองย้อนกลับสำหรับค่าเฉลี่ยเคลื่อนที่แบบระยะสั้นและระยะยาวช่วงเวลามองย้อนกลับของเกณฑ์ RSI และ RSI ชุดของพารามิเตอร์คือโครโมโซม องค์ประกอบสำคัญอื่น ๆ คือการออกกำลังกาย เราอาจต้องการใช้สิ่งที่ต้องการเช่นอัตราผลตอบแทนสูงสุดหรืออัตราส่วน Sharpe หรือค่าเฉลี่ยถ่วงน้ำหนักขั้นต่ำ ในสิ่งต่อไปนี้ฉันเลือกที่จะเพิ่มอัตราส่วน Sharpe การใช้ R คือชุดของ 3 ฟังก์ชัน: fitnessFunction กำหนดฟังก์ชันการออกกำลังกาย (เช่นอัตราส่วนชาร์ปสูงสุด) ที่จะใช้ภายในสถิติการซื้อขายเครื่องมือของ GA สรุปสถิติการซื้อขายสำหรับทั้งในและนอกช่วงเวลาตัวอย่างเพื่อวัตถุประสงค์ในการเปรียบเทียบ โปรแกรม GA จากแพคเกจ rgenoud ฟังก์ชั่น genoud ค่อนข้างซับซ้อน แต่ I8217m จะไม่อธิบายว่าพารามิเตอร์แต่ละข้อมีความหมายอย่างไรเนื่องจากฉันต้องการเก็บบทความนี้สั้น ๆ (และเอกสารเป็นสิ่งที่ดีมาก) ในตารางด้านล่างผมจะนำเสนอพารามิเตอร์ที่เหมาะสมที่สุด (RSI look-back period, RSI threshold, Movement Average เฉลี่ยระยะยาวและ Average Moving Average) พร้อมกับสถิติการเข้าและออกตัวอย่าง ก่อนที่จะแสดงความคิดเห็นข้างต้นฉันต้องการอธิบายประเด็นสำคัญบางประการ เพื่อให้ตรงกับตรรกะที่กำหนดข้างต้นฉันได้กำหนดพารามิเตอร์ไว้เพื่อให้แน่ใจว่าระยะเวลาย้อนกลับของค่าเฉลี่ยเคลื่อนที่ในระยะยาวนั้นยาวกว่าค่าเฉลี่ยเคลื่อนที่ที่สั้นกว่า ฉันยัง จำกัด การเพิ่มประสิทธิภาพให้เลือกเฉพาะโซลูชันที่มีมากกว่า 50 ธุรกิจการค้าในช่วงเวลาตัวอย่าง (เช่นความสำคัญทางสถิติ) โดยรวมผลลัพธ์จากตัวอย่างไม่ได้น่าประทับใจ ผลตอบแทนต่ำแม้ว่าจำนวนธุรกิจการค้าจะมีขนาดเล็กเพื่อให้ผลลัพธ์มีความสำคัญมาก อย่างไรก็ตามการสูญเสียประสิทธิภาพอย่างมีนัยสำคัญระหว่างการเข้าและออกจากกลุ่มตัวอย่างสำหรับประเทศญี่ปุ่น (EWJ) ซึ่งน่าจะหมายถึงการปรับตัวให้เหมาะสม โพสต์นี้มีวัตถุประสงค์เพื่อมอบเครื่องมือให้ผู้อ่านใช้ GA อย่างถูกต้องในกรอบการทำธุรกรรมเชิงปริมาณ อีกครั้ง It8217s เป็นตัวอย่างที่ต้องได้รับการขัดเกลาเพิ่มเติม การปรับปรุงศักยภาพในการสำรวจคือการออกกำลังกาย การเพิ่มอัตราส่วน Sharpe เป็นเรื่องง่ายมาก ฟังก์ชัน 8220smarter8221 จะช่วยปรับปรุงรูปแบบสถิติการซื้อขายตัวอย่างตัวอย่าง we try to capture a very straightforward pattern. A more in depth pattern research is definitely needed. optimisation . there are many ways to improve the way the optimisation is conducted. This would improve both the computation speed and the rationality of the results. The code used in this post is available on a Gist repository . As usual any comments welcome February 28, 2014, 3:52 pm There is an enormous body of literature both academic and empirical about market forecasting. Most of the time it mixes two market features: Magnitude and Direction. In this article I want to focus on identifying the market direction only. The goal I set myself, is to identify market conditions when the odds are significantly biased toward an up or a down market. This post gives an example of how CART (Classification And Regression Trees) can be used in this context. Before I proceed the usual reminder: What I present in this post is just a toy example and not an invitation to invest. Its not a finished strategy either but a research idea that needs to be further researched, developed and tailored to individual needs. 1 8211 What is CART and why using it From statistics, CART are a set of techniques for classification and prediction. The technique is aimed at producing rules that predict the value of an outcome (target) variable from known values of predictor (explanatory) variables. There are many different implementations but they are all sharing a general characteristic and thats what Im interested in. From Wikipedia, Algorithms for constructing decision trees usually work top-down, by choosing a variable at each step that best splits the set of items. Different algorithms use different metrics for measuring 8220best8221. These generally measure the homogeneity of the target variable within the subsets. These metrics are applied to each candidate subset, and the resulting values are combined (e. g. averaged) to provide a measure of the quality of the split. CART methodology exhibits some characteristics that are very well suited for market analysis: Non parametric . CART can handle any type of statistical distributions Non linear . CART can handle a large spectrum of dependency between variables (e. g. not limited to linear relationships) Robust to outliers There are various R packages dealing with Recursive Partitioning, I use here rpart for trees estimation and rpart. plot for trees drawing. 2 8211 Data amp Experiment Design Daily OHLC prices for most liquid ETFs from January 2000 to December 2013 extracted from Google finance. The in sample period goes from January 2000 to December 2010 the rest of the dataset is the out of sample period. Before running any type of analysis the dataset has to be prepared for the task. The target variable is the ETF weekly forward return defined as a two states of the world outcome (UP or DOWN). If weekly forward return gt 0 then the market in the UP state, DOWN state otherwise The explanatory variables are a set of technical indicators derived from the initial daily OHLC dataset. Each indicator represents a well-documented market behavior. In order to reduce the noise in the data and to try to identify robust relationships, each independent variable is considered to have a binary outcome. Volatility (VAR1) . High volatility is usually associated with a down market and low volatility with an up market. Volatility is defined as the 20 days raw ATR (Average True Range) spread to its moving average (MA). If raw ATR gt MA then VAR1 1, else VAR1 -1. Short term momentum (VAR2) . The equity market exhibits short term momentum behavior captured here by a 5 days simple moving averages (SMA). If Price gt SMA then VAR2 1 else VAR2 -1 Long term momentum (VAR3) . The equity market exhibits long term momentum behavior captured here by a 50 days simple moving averages (LMA). If Price gt LMA then VAR3 1 else VAR3 -1 Short term reversal (VAR4) . This is captured by the CRTDR which stands for Close Relative To Daily Range and calculated as following: . If CRTDR gt 0.5, then VAR4 1 else VAR4 -1 Autocorrelation regime (VAR5) . The equity market tends to go through periods of negative and positive autocorrelation regimes. If returns autocorrelation over the last 5 days gt 0 then VAR5 1 else VAR5 -1 I put below a tree example with some explanations In the tree above, the path to reach node 4 is: VAR3 gt0 (Long Term Momentum gt 0) and VAR4 gt 0 (CRTDR gt 0). The red rectangle indicates this is a DOWN leaf (e. g. terminal node) with a probability of 58 (1 8211 0.42). In market terms this means that if Long Term Momentum is Up and CRTDR is gt 0.5 then the probability of a positive return next week is 42 based on the in sample sample data. 18 indicates the proportion of the data set that falls into that terminal node (e. g. leaf). There are many ways to use the above approach, I chose to estimate and combine all possible trees. From the in sample data, I collect all leaves from all possible trees and I gather them into a matrix. This is the 8220rules matrix8221 giving the probability of next week beeing UP or DOWN. I apply the rules in the above matrix to the out of sample data (Jan 2011 8211 Dec 2013) and I compare the results to the real outcome. The problem with this approach is that a single point (week) can fall into several rules and even belong to UP and DOWN rules simultaneously. Therefore I apply a voting scheme . For a given week I sum up all the rules that apply to that week giving a 1 for an UP rule and -1 for a DOWN rule. If the sum is greater than 0 the week is classified as UP, if the sum is negative it8217s a DOWN week and if the sum is equal to 0 there will be no position taken that week (return 0) The above methodology is applied to a set of very liquid ETFs. I plot below the out of sample equity curves along with the buy and hold strategy over the same period. Initial results seem encouraging even if the quality of the outcome varies greatly by instrument. However there is a huge room for improvement. I put below some directions for further analysis Path optimality . The algorithm used here for defining the trees is optimal at each split but it doesn8217t guarantee the optimality of the path. Adding a metric to measure the optimality of the path would certainly improve the above results. Other variables . I chose the explanatory variables solely based on experience. It8217s very likely that this choice is neither good nor optimal. Backtest methodology . I used a simple In and Out of sample methodology. In a more formal backtest I would rather use a rolling or expanding window of in and out sample sub-periods (e. g. walk forward analysis) As usual, any comments welcomeCategory Archives: Trading Strategies Looks can be deceiving, a wise person once said. The phrase holds true for Algorithmic Trading Strategies. The term Algorithmic trading strategies might sound very fancy or too complicated. However, the concept is very simple to understand, once the basics are clear. In this article, I will be telling you about algorithmic trading strategies with some interesting examples. If you look at it from the outside, an algorithm is just a set of instructions or rules. These set of rules are then used on a stock exchange to automate the execution of orders without human intervention. This concept is called Algorithmic Trading. Let me start with a very simple trading strategy. Those who are already into trading would know about S. M.A and for those who dont S. M.A is Simple Moving Average. S. M.A can be calculated using any predefined and fixed number of days. An algorithmic trading strategy based on S. M.A can be simplified in these four simple steps: Calculate 5 day SMA Calculate 20 day SMA Take a long position when the 5 day SMA is larger than or equal to 20 day SMA Take a short position when the 5 day SMA is smaller than 20 day SMA We refer to this algorithmic trading strategy as Moving Average Crossover Strategy . This was just a simple example. Now don8217t get down to thinking that it is all going to be a bed of roses. Even if it were, then be prepared for the thorns. In everyday trading, far more complex trading algorithms are used to generate algorithmic trading strategies. Algorithmic Trading Strategies All the algorithmic trading strategies that are being used today can be classified broadly into the following categories: MomentumTrend Following Arbitrage Statistical Arbitrage Market Making Let me go into some detail. Momentum based Strategies Assuming that there is a particular trend in the market. As an algo trader, you are following that trend. Further to our assumption, the markets fall within the week. Now, you can use stats to determine if this trend is going to continue. Or if it will change in the coming weeks. Accordingly, you will make your next move. You have based your algorithmic trading strategy on the market trends which you determined by using statistics. This method of following trends is called Momentum Based Strategy. There are numerous ways to implement this algorithmic trading strategy and I have discussed this in detail in one of our previous articles called Methodology of Quantifying News for Automated Trading If we assume that a pharma-corp is to be bought by another company, then the stock price of our corp could go up. This is triggered by the acquisition which is a corporate event. If you are planning to invest based on the pricing inefficiencies that may happen during a corporate event (before or after), then you are using an event-driven strategy. Bankruptcy, acquisition, merger, spin-offs etc could be the event that drives such kind of an investment strategy. These strategies can be market neutral and used by hedge fund and proprietary traders widely. Statistical Arbitrage When an arbitrage opportunity arises because of misquoting in prices, it can be very advantageous to algo trading strategy. Although such opportunities exist for a very short duration as the prices in the market get adjusted quickly. And thats why this is the best use of algorithmic trading strategies, as an automated machine can track such changes instantly. For instance, if Apple8217s price falls under 1 then Microsoft will fall by 0.5 but Microsoft has not fallen, so you will go and sell Microsoft to make a profit. You can read about the common misconceptions people have about Statistical Arbitrage here . Market Making To understand Market making, let me first talk about Market Makers. According to Wikipedia: A market maker or liquidity provider is a company, or an individual, that quotes both a buy and a sell price in a financial instrument or commodity held in inventory, hoping to make a profit on the bid-offer spread, or turn. Market making provides liquidity to securities which are not frequently traded on the stock exchange. The market maker can enhance the demand-supply equation of securities. Let me give you an example: Lets assume you have Martin, a market maker, who buys for Rs. 500 from the market and sell it at 505. He will give you a bid-ask quote of Rs. 505-500. The profit of Rs. 5 cannot be sold or exchanged for cash without substantial loss in value. When Martin takes a higher risk then the profit is also higher. I found Michael Lewis book Flash Boys in Indian Bull Market pretty interesting and it talks about liquidity, market making and HFT in great detail. Check it out after you finish reading this article. Since you will need to be analytical amp quantitative while getting into or upgrading to algorithmic trading it is imperative to learn programming (some if not all) and build foolproof systems and execute right algorithmic trading strategy . Reading this article on Automated Trading with Interactive Brokers using Python will be very beneficial for you. You can read the article here . Paradigms amp Modeling Ideas Now that I have introduced you to algorithmic trading strategies, I will be throwing some light on the strategy paradigms and modeling ideas pertaining to each strategy. Market Making Statistical Arbitrage Momentum Machine Learning Based Market Making As I had mentioned earlier, the primary objective of Market making is to infuse liquidity in securities that are not traded on stock exchanges. In order to measure the liquidity, we take the bid-ask spread and trading volumes into consideration. The trading algorithms tend to profit from the bid-ask spread. I will be referring to our buddy, Martin, again in this section. Martin being a market maker is a liquidity provider who can quote on both buy and sell side in a financial instrument hoping to profit from the bid-offer spread. Martin will accept the risk of holding the securities for which he has quoted the price for and once the order is received, he will often immediately sell from his own inventory. He might seek an offsetting offer in seconds and vice versa. When it comes to illiquid securities, the spreads are usually higher and so are the profits. Martin will take a higher risk in this case. Several segments in the market lack investor interest due to lack of liquidity as they are unable to gain exit from several small - and mid-cap stocks at any given point in time. Market Makers like Martin are helpful as they are always ready to buy and sell at the price quoted by them. In fact, much of high frequency trading (HFT) is passive market making. The strategies are present on both sides of the market (often simultaneously) competing with each other to provide liquidity to those who need. So, when is this strategy most profitable This strategy is profitable as long as the model accurately predicts the future price variations. Modeling ideas based on this Paradigm The bid-ask spread and trade volume can be modeled together to get the liquidity cost curve which is the fee paid by the liquidity taker. If the liquidity taker only executes orders at the best bid and ask, the fee will be equal to the bid ask spread times the volume. When the traders go beyond best bid and ask taking more volume, the fee becomes a function of the volume as well. Trade volume is difficult to model as it depends on the liquidity takers execution strategy. The objective should be to find a model for trade volumes that is consistent with price dynamics. Market making models are usually based on one of the two: The first focuses on inventory risk. The model is based on preferred inventory position and prices based on the risk appetite. The second is based on adverse selection which distinguishes between informed and noise trades. Noise trades do not possess any view on the market whereas informed trades do. When the view of the liquidity taker is short term, its aim is to make short term profit utilizing the statistical edge. In the case of long term view, the objective is to minimize the transaction cost. The long-term strategies and liquidity constraints can be modeled as noise around the short-term execution strategies. To know more about Market Makers, you can check out this interesting article on QuantInstis blog. Statistical Arbitrage If Market making is the strategy that makes use of the bid-ask spread, Statistical Arbitrage seeks to profit from statistical mispricing of one or more assets based on the expected value of these assets. A more academic way to explain statistical arbitrage is to spread the risk among thousand to million trades in a very short holding time to, expecting to gain profit from the law of large numbers. Statistical Arbitrage Algorithms are based on mean reversion hypothesis, mostly as a pair. Pairs trading is one of the several strategies collectively referred to as Statistical Arbitrage Strategies. In pairs trade strategy, stocks that exhibit historical co-movement in prices are paired using fundamental or market-based similarities. The strategy builds upon the notion that the relative prices in a market are in equilibrium, and that deviations from this equilibrium eventually will be corrected. When one stock outperforms the other, the outperformer is sold short and the other stock is bought long with the expectation that the short term diversion will end in convergence. This often hedges market risk from adverse market movements i. e. makes the strategy beta neutral. However, the total market risk of a position depends on the amount of capital invested in each stock and the sensitivity of stocks to such risk. Momentum Strategies seek to profit from the continuance of existing trend by taking advantage of market swings. In simple words, buy high and sell higher and vice versa. And how do we achieve this In this particular algo-trading strategy we will take short-term positions in stocks that are going up or down until they show signs of reversal. It is counter-intuitive to almost all other well-known strategies. Value investing is generally based on long-term reversion to mean whereas momentum investing is based on the gap in time before mean reversion occurs. Momentum is chasing performance, but in a systematic way taking advantage of other performance chasers who are making emotional decisions. There are usually two explanations given for any strategy that has been proven to work historically, either the strategy is compensated for the extra risk that it takes or there are behavioral factors due to which premium exists. There is a long list of behavioral biases and emotional mistakes that investors exhibit due to which momentum works. However, this is easier said than done as trends dont last forever and can exhibit swift reversals when they peak and come to an end. Momentum trading carries a higher degree of volatility than most other strategies and tries to capitalize on the market volatility. It is important to time the buys and sells correctly to avoid losses by using proper risk management techniques and stop losses. Momentum investing requires proper monitoring and appropriate diversification to safeguard against such severe crashes. Firstly, you should know how to detect Price momentum or the trends. As you are already into trading, you know that trends can be detected by following stocks and ETFs that have been continuously going up for days, weeks or even several months in a row. For instance, identify the stocks trading within 10 of their 52 weeks high or look at the percentage price change over the last 12 or 24 weeks. Similarly to spot a shorter trend, include a shorter term price change. If you remember, back in 2008, the oil and energy sector was continuously ranked as one of the top sectors even while it was collapsing. We can also look at earnings to understand the movements in stock prices. Strategies based on either past returns (price momentum strategies) or on earnings surprise (known as earnings momentum strategies) exploit market under-reaction to different pieces of information. An earnings momentum strategy may profit from the under-reaction to information related to short-term earnings. Similarly, a price momentum strategy may profit from markets slow response to a broader set of information including longer-term profitability. Machine Learning based In Machine Learning based trading, algorithms are used to predict the range for very short term price movements at a certain confidence interval. The advantage of using Artificial Intelligence (AI) is that humans develop the initial software and the AI itself develops the model and improves it over time. A large number of funds rely on computer models built by data scientists and quants but theyre usually static, i. e. they dont change with the market. ML based models on the other hand can analyze large amounts of data at high speed and improve themselves through such analysis. A form of machine leaning called Bayesian networks can be used to predict market trends while utilizing a couple of machines. An AI which includes techniques such as evolutionary computation (which is inspired by genetics) and deep learning might run across hundreds or even thousands of machines. It can create a large and random collection of digital stock traders and test their performance on historical data. It then picks the best performers and uses their stylepatterns to create a new of evolved traders. This process repeats multiple times and a digital trader that can fully operate on its own is created. This process repeats multiple times and a digital trader that can fully operate on its own is created. This process repeats multiple times and a digital trader that can fully operate on its own is created. These were some important strategy paradigms and modelling ideas. Next, we will go through the step by step procedure to build a trading strategy. You can learn these Paradigms in great detail in QuantInstis Executive Programme in Algorithmic Trading (EPAT) . one of the most extensive algorithmic trading courses available online with lecture recordings and lifetime access and support. Building an algorithmic trading strategy From algo trading strategies to paradigms and modeling ideas, I come to that section of the article where I will tell you how to build a basic algorithmic trading strategy. How do you start with the implementation of algo trading strategies That is the first question that must have come to your mind, I presume. The point is that you have already started by knowing the basics and paradigms of algorithmic trading strategies while reading this article. Now, that our bandwagon has its engine turned on, it is time to press on the accelerator. And how exactly is this done I will explain how an algorithmic trading strategy is built, step by step. The concise description will give you an idea about the entire process. The first step is to decide the strategy paradigm. It can be Market Making, Arbitrage based, Alpha generating, Hedging or Execution based strategy. For this particular instance, I will choose pair trading which is a statistical arbitrage strategy that is market neutral (Beta neutral) and generates alpha, i. e.makes money irrespective of market movement. You can decide on the actual securities you want to trade based on market view or through visual correlation (in the case of pair trading strategy). Establish if the strategy is statistically significant for the selected securities. For instance, in the case of pair trading, check for co-integration of the selected pairs. Now, code the logic based on which you want to generate buysell signals in your strategy. For pair trading check for mean reversion calculate the z-score for the spread of the pair and generate buysell signals when you expect it to revert to mean. Decide on the Stop Loss and Profit Taking conditions. Stop Loss 8211 A stop-loss order limits an investors loss on a position in a security. It fires an order to square off the existing long or short position to avoid further losses and helps to take emotion out of trading decisions. Take Profit 8211 take-profit orders are used to automatically close out existing positions in order to lock in profits when there is a move in a favorable direction. Quoting or Hitting strategy It is very important to decide if the strategy will be quoting or hitting. Execution strategy to a great extent decides how aggressive or passive your strategy is going to be. Quoting 8211 In pair trading you quote for one security and depending on if that position gets filled or not you send out the order for the other. In this case, the probability of getting a fill is lesser but you save bid-ask on one side. Hitting - In this case, you send out simultaneous market orders for both securities. The probability of getting a fill is higher but at the same time slippage is more and you pay bid-ask on both sides. The choice between the probability of fill and Optimized execution in terms of slippage and timed executive is what this is if I have to put it that way. If you choose to quote, then you need to decide what are quoting for, this is how pair trading works. If you decide to quote for the less liquid security, slippage will be less but the trading volumes will come down liquid securities on the other hand increase the risk of slippage but trading volumes will be high. Using stats to check causality is another way of arriving at a decision, i. e. change in which security causes change in the other and which one leads. The causality test will determine the lead-lag pair quote for the leading and cover the lagging security. How do you decide if the strategy you chose was good or bad How do you judge your hypothesis This is where back-testing the strategy comes as an essential tool for estimation of the performance of the designed hypothesis based on historical data. A strategy can be considered to be good if the backtest results and performance statistics back the hypothesis. Hence, it is important to choose historical data with a sufficient number of data points. This is to create a sufficient number of sample trades (at least 100 trades) covering various market scenarios (bullish, bearish etc.). Ensure that you make provision for brokerage and slippage costs as well. This will get you more realistic results but you might still have to make some approximations while backtesting. For instance, while backtesting quoting strategies it is difficult to figure out when you get a fill. So, the common practice is to assume that the positions get filled with the last traded price. What kind of tools should you go for, while backtesting Since backtesting for algorithmic trading strategies involves a huge amount of data, especially if you are going to use tick by tick data. So, you should go for tools which can handle such mammoth load of data. R or MATLAB R is excellent for dealing with huge amounts of data and has a high computation power as well. Thus, making it one of the better tools for backtesting. Also, R is open source and free of cost. We can use MATLAB as well but it comes with a licensing cost. With great strategy, comes greater scrutiny, A Great Thinker once quoted. Fine, I just ripped off Ben Parkers famous quotation from the Spiderman movie (not the Amazing one). But trust me, it is 100 true. No matter how confident you seem with your strategy or how successful it might turn out previously, you must go down and evaluate each and everything in detail. There are several parameters that you would need to monitor when analyzing a strategys performance and risk. Some important metricsratios are mentioned below: Total Returns (CAGR)- Compound Annual Growth Rate (CAGR). It is the mean annual growth rate of an investment over a specified period of time longer than one year. Hit Ratio - Order to trade ratio. Average Profit per Trade - Total profit divided by the total number of trades Average Loss per trade - Total loss divided by the total number of trades Maximum Drawdown 8211 Maximum loss in any trade Volatility of Returns - Standard deviation of the returns Sharpe Ratio - Risk adjusted returns, i. e. excess returns (over risk free rate) per unit volatility or total risk. The entire process of Algorithmic trading strategies does not end here. What I have provided in this article is just the foot of an endless Everest. In order to conquer this, you must be equipped with the right knowledge and mentored by the right guide . Thats where QuantInsti comes in, to guide you through this journey. QuantInsti will help you conquer the Everest at the end. If you want to know more about algorithmic trading strategies then you can click here . This article is the final project submitted by the author as a part of his coursework in Executive Programme in Algorithmic Trading (EPAT) at QuantInsti. Do check our Projects page and have a look at what our students are building. Marco has spent his career as a trader and portfolio manager, with a particular focus in equity and derivatives markets. He specializes in quantitative finance and algorithmic trading and currently serves as head of the Quantitative Trading Desk and Vice-president of Argentina Valores S. A. Marco is also Co-Founder and CEO of Quanticko Trading SA, a firm devoted to the development of high frequency trading strategies and trading software. Marco holds a BS in Economics and an MSc in Finance from the University of San Andrs. Introduction One of my favorite classes during EPAT was the one on statistical arbitrage. so the pair trading strategy seemed a nice idea for me. My strategy triggers new orders when the pair ratio of the prices of the stocks diverge from the mean. But in order to work, we first have to test for the pair to be cointegrated. If the pair ratio is cointegrated, the ratio is mean-reverting and the greater the dispersion from its mean, the higher the probability of a reversal, which makes the trade more attractive. I chose the following pair of stocks: The idea is the following: If we find two stocks that are correlated (they correspond to the same sector), and the pair ratio diverges from a certain threshold, we short the stock that is expensive and buy the one that is cheap. Once they converge to the mean, we close the positions and profit from the reversal. In this post we see how to compute historical volatility in python, and the different measures of risk-adjusted return based on it. We have also provided the python codes for these measures which might be of help to the readers. Introduction Volatility measures the dispersion of returns for a given security. Volatility can be measured by the standard deviation of returns for a security over a chosen period of time. Historic volatility is derived from time series of past price data, whereas, an implied volatility is derived using the market price of a traded derivative instrument like an options contract. Sentiment Analysis. also known as opinion mining, is the process of computationally identifying and categorizing opinions expressed in a piece of text, especially in order to determine whether the writers attitude towards a particular topic, product, etc. is positive, negative, or neutral. The analysis finds significant prominence in social media, stock markets, law, policy making, sociology and even customer service. Machines are faster at responding to events than humans and can process much vaster amount of information without any fatigue. In more volatile markets, people tend to react less strongly to positive news and react more strongly to negative news. Of course, there are situations where sentiment analysis, or sometimes also called News Analytics, works well for a position, while in other cases it fails. The following slide show is a summary of favourable and profitable outcomes of sentiment analysis in trading. Next Steps: Now that you have understood a little about how sentiment analysis works, you would also want to know the pitfalls. For this and other such questions, we have an upcoming webinar on 8220Quantitative Strategies using Sentiment Analysis8221 by Rajib Ranjan Borah. The webinar will give a brief overview of how sentiment analysis works and some historical perspective along with suggestions on how to develop trading strategies. Register for the webinar on this link. Python has emerged as one of the most popular language to code in Algorithmic Trading, owing to its ease of installation, free usage, easy structure, and availability of variety of modules. Globally, Algo Traders and researchers in Quant are extensively using Python for prototyping, backtesting, building their proprietary risk and order management system as well as in optimisation of testing modules. This blog post highlights some of the key steps involved in Algorithmic Trading using Python as the programming language. The screenshots are taken from the webinar of Dr. Yves Hilpisch. in collaboration with QuantInsti. Dr. Hilpisch is world-renowned authority in the world of Python and is the founder of Python Quants GmbH, with several books on the subject under his belt. He also serves as a faculty at QuantInsti, one of Asias pioneer education training firm in Algorithmic Trading. All examples shown are based on the platform and API of oanda. Background information about Python and the libraries used can be found in the OReilly book Hilpisch, Yves (2014): Python for Finance Analyze Big Financial Data. The post is divided in two parts. The current post highlights the basics of connecting with the Oanda platform using python and backtesting the trading strategies. The next post will cover working with streaming data as well as automated trading in real-time. High Frequency Trading (HFT) involves the concept of 8220Order Types8221, which signals a trader to enter or exit a position. According to Reuters, Order types can reach an estimated 2,000 variations as a fully electronic market and more than 50 trading venues have multiplied the possibilities of how, when and with whom to trade. Clearly, the rules of the game are redefined by the Order Types and their correct implementation in the marketplace. Amidst a long list, we touch upon some of the popular ones, frequently used by HFT practitioners. The following Infographic shows 4 HFT Order Types, and examples when a buy or sell order is placed. Introduction Traders in the derivative market often exercise one of the following: Call option or Put Option . Call option is a financial contract between a buyer and seller, whereby the buyer has the right, but not the obligation, to buy an agreed quantity of a financial instrument from the seller of the option at a certain time for a certain price (the strike price). The Put Option serves the opposite. In a Covered Call , the seller of the call options owns the corresponding amount of the underlying instrument. A Covered Call is an income generating option strategy which involves two legs: Buying a stock Selling an Out of the money (OTM) call option If the call is sold simultaneously along with the stock purchase, the strategy is referred to as a buy-write strategy. In a Covered Call, the trader holds a neutral to a bullish outlook. Covered Call is a net debit transaction because you pay for the stock and receive a small premium for the call option sold. The idea of this blog post is to elaborate on the covered call strategy by an example and to plot its payoff using Python. The post also highlights 8220Calendar Call8221 as it is a modification of the Covered Call strategy. To measure the performance of a trading strategy, annualized returns are often a common metric. However comparing two strategies based on annualised returns may not always be a logical way due to several reasons. Some strategies might be directional, some market neutral and some might be leveraged which makes annualized return alone a futile measure of performance measurement. Also, even if two strategies have comparable annual returns, the risk is still an important aspect that needs to be measured. A strategy with high annual returns is not necessarily very attractive if it has a high-risk component we generally prefer better risk-adjusted returns over just better returns. Sharpe Ratio takes care of risk assessment and the problem related to the comparison of strategies. Sharpe ratio is a measure for calculating the risk-adjusted return. It is the ratio of the excess expected return of an investment (over risk-free rate) per unit of volatility or standard deviation. (morehellip)

No comments:

Post a Comment