Automated Trading with R: Quantitative Research and Platform Development - Original PDF

دانلود کتاب Automated Trading with R: Quantitative Research and Platform Development - Original PDF

Author: Chris Conlan (auth.)

0 (0)

توضیحات کتاب :

This book explains the broad topic of automated trading, starting with its mathematics and moving to its computation and execution. Readers will gain a unique insight into the mechanics and computational considerations taken in building a backtester, strategy optimizer, and fully functional trading platform. Automated Trading with R provides automated traders with all the tools they need to trade algorithmically with their existing brokerage, from data management, to strategy optimization, to order execution, using free and publically available data. If your brokerage’s API is supported, the source code is plug-and-play. The platform built in this book can serve as a complete replacement for commercially available platforms used by retail traders and small funds. Software components are strictly decoupled and easily scalable, providing opportunity to substitute any data source, trading algorithm, or brokerage. The book’s three objectives are: To provide a flexible alternative to common strategy automation frameworks, like Tradestation, Metatrader, and CQG, to small funds and retail traders. To offer an understanding the internal mechanisms of an automated trading system. To standardize discussion and notation of real-world strategy optimization problems. What you’ll learn Programming an automated strategy in R gives the trader access to R and its package library for optimizing strategies, generating real-time trading decisions, and minimizing computation time. How to best simulate strategy performance in their specific use case to derive accurate performance estimates. Important machine-learning criteria for statistical validity in the context of time-series. An understanding of critical real-world variables pertaining to portfolio management and performance assessment, including latency, drawdowns, varying trade size, portfolio growth, and penalization of unused capital. Who This Book Is For This book is for traders/practitioners at the retail or small fund level with at least an undergraduate background in finance or computer science. Graduate level finance or data science students.

سرچ در وردکت | سرچ در گودریدز | سرچ در اب بوکز | سرچ در آمازون | سرچ در گوگل بوک

685 بازدید 0 خرید

ضمانت بازگشت

ضمانت بازگشت

فایل های تست شده

فایل های تست شده

پرداخت آنلاین

پرداخت آنلاین

تضمین کیفیت

تضمین کیفیت

دانلود فوری

دانلود فوری

xxi Introduction This book will cover the broad topic of automated trading, starting with mathematics and moving to computation and execution. You will gain unique insight into the mechanics and computational considerations taken in building a backtester, strategy optimizer, and fully functional trading platform. The code examples in this text are derived from deliverables of real consulting and software development contracts. At the end of the book, we will bring the concepts together and build an automated trading platform from scratch. This book will give a prospective algorithm trader everything he needs except a trading account, including full source code. Definitions Trading strategies are predetermined sets of rules a trader uses to make trading decisions. Trading strategies use the following tools and techniques: • Manual execution involves the trader placing his trades manually. This can be • Calling the brokerage • Placing an order through E*Trade, Tradestation, or other brokerage platforms • Pit trading • Computer automation involves the trader authorizing a computer to place trades on his behalf. Many retail brokerage platforms and trading software have incorporated this functionality into their platforms, but they are typically very limited. Most brokerages have an API for more customized implementation through the trader’s programming language of choice. • Tradestation Easy Language, Metatrader • Charles Schwab API • Black-box algorithms • Indicators are functions of relevant data that inform the trader by interacting with rule sets. • MSI • Moving averages • Custom indicators

چکیده فارسی

 

xxi مقدمه این کتاب موضوع گسترده ای از تجارت خودکار را پوشش می دهد، که از ریاضیات شروع می شود و به محاسبات و اجرا می رود. شما بینش منحصر به فردی در مورد مکانیک و ملاحظات محاسباتی در ساختن یک بک تستر، بهینه ساز استراتژی و پلت فرم معاملاتی کاملاً کاربردی به دست خواهید آورد. نمونه‌های کد موجود در این متن از نتایج قراردادهای مشاوره واقعی و توسعه نرم‌افزار مشتق شده‌اند. در پایان کتاب، مفاهیم را کنار هم می‌آوریم و یک پلتفرم معاملاتی خودکار را از ابتدا می‌سازیم. این کتاب به معامله گر الگوریتم آینده نگر همه چیزهایی را که به جز یک حساب تجاری، از جمله کد منبع کامل نیاز دارد، می دهد. تعاریف استراتژی های معاملاتی مجموعه ای از قوانین از پیش تعیین شده هستند که یک معامله گر برای تصمیم گیری در مورد معاملات استفاده می کند. استراتژی‌های معاملاتی از ابزارها و تکنیک‌های زیر استفاده می‌کنند: • اجرای دستی شامل معامله‌گر است که معاملات خود را به صورت دستی انجام می‌دهد. این می تواند • تماس با کارگزاری • ثبت سفارش از طریق E*Trade، Tradestation، یا سایر پلتفرم های دلالی • تجارت گودال • اتوماسیون کامپیوتری شامل اجازه معامله گر به کامپیوتر برای انجام معاملات از طرف او می شود. بسیاری از پلتفرم‌های کارگزاری خرده‌فروشی و نرم‌افزارهای معاملاتی این قابلیت را در پلتفرم‌های خود گنجانده‌اند، اما معمولاً بسیار محدود هستند. اکثر کارگزاری ها یک API برای پیاده سازی سفارشی تر از طریق زبان برنامه نویسی انتخابی معامله گر دارند. • Tradestation Easy Language، Metatrader • Charles Schwab API • الگوریتم های جعبه سیاه • شاخص ها توابعی از داده های مرتبط هستند که با تعامل با مجموعه قوانین، معامله گر را آگاه می کنند. • MSI • میانگین های متحرک • شاخص های سفارشی

 

ادامه ...

Author(s): Chris Conlan (auth.)

Publisher: Apress, Year: 2016

ISBN: 978-1-4842-2177-8,978-1-4842-2178-5

ادامه ...

vii Contents About the Author .....................................................................................................xv About the Technical Reviewers .............................................................................xvii Acknowledgments ..................................................................................................xix Introduction ............................................................................................................xxi ■Part 1: Problem Scope ........................................................................ 1 ■Chapter 1: Fundamentals of Automated Trading ................................................... 3 Equity Curve and Return Series ....................................................................................... 3 Characteristics of the Equity Curve ........................................................................................................ 5 Characteristics of the Return Series ....................................................................................................... 5 Risk-Return Metrics ......................................................................................................... 6 Characteristics of Risk-Return Metrics ............................................................................ 8 Sharpe Ratio ......................................................................................................................................... 10 Maximum Drawdown Ratios................................................................................................................. 12 Partial Moment Ratios .......................................................................................................................... 14 Regression-Based Performance Metrics .............................................................................................. 16 Optimizing Performance Metrics .................................................................................... 20 ■Part 2: Building the Platform ............................................................ 21 ■Chapter 2: Networking Part I ............................................................................... 23 Yahoo! Finance API ......................................................................................................... 24 Setting Up Directories........................................................................................................................... 25 URL Query Building ............................................................................................................................... 25 Data Acquisition .................................................................................................................................... 26 ■ CONTENTS viii Loading Data into Memory ................................................................................................................... 27 Updating Data ....................................................................................................................................... 28 YQL Web Service ............................................................................................................ 29 URL and Query Building ........................................................................................................................ 30 Note on Quantmod ......................................................................................................... 33 Background .......................................................................................................................................... 33 Comparison .................................................................................................................... 33 Organizing as Date-Uniform zoo Object ......................................................................... 34 Note on zoo Objects .............................................................................................................................. 35 ■Chapter 3: Data Preparation ................................................................................ 37 Handling NA Values ........................................................................................................ 37 Note: NA vs. NaN in R ........................................................................................................................... 37 IPOs and Additions to S&P 500 ............................................................................................................. 37 Merging to the Uniform Date Template ................................................................................................. 39 Forward Replacement .......................................................................................................................... 40 Linearly Smoothed Replacement .......................................................................................................... 41 Volume-Weighted Smoothed Replacement .......................................................................................... 42 Discussion of Replacement Methods ............................................................................. 43 Real Time vs. Simulation ...................................................................................................................... 43 Infl uence on Volatility Metrics .............................................................................................................. 43 Infl uence on Trading Decisions ............................................................................................................. 44 Conclusion ............................................................................................................................................ 44 Closing Price and Adjusted Close ................................................................................... 44 Adjusting for Stock Splits ..................................................................................................................... 45 Adjusting for Cash Dividends................................................................................................................ 45 Effi cient Updating and Adjusted Close .................................................................................................. 46 Implementing Adjustments ................................................................................................................... 47 Test for and Correct Inactive Symbols............................................................................ 47 Computing the Return Matrix ......................................................................................... 48 ■ CONTENTS ix ■Chapter 4: Indicators ........................................................................................... 51 Indicator Types ............................................................................................................... 51 Overlays ................................................................................................................................................ 51 Oscillators ............................................................................................................................................. 51 Accumulators........................................................................................................................................ 52 Pattern/Binary/Ternary ......................................................................................................................... 52 Machine Learning/Nonvisual/Black Box ............................................................................................... 52 Example Indicators ......................................................................................................... 52 Simple Moving Average ........................................................................................................................ 52 Moving Average Convergence Divergence Oscillator (MACD)............................................................... 53 Bollinger Bands .................................................................................................................................... 54 Custom Indicator Using Correlation and Slope ..................................................................................... 55 Indicators Utilizing Multiple Data Sets .................................................................................................. 56 Conclusion ...................................................................................................................... 57 ■Chapter 5: Rule Sets ............................................................................................ 59 Our Process Flow as Nested Functions .......................................................................... 59 Terminology .................................................................................................................... 59 Example Rule Sets ......................................................................................................... 61 Overlays ................................................................................................................................................ 61 Oscillators ............................................................................................................................................. 61 Accumulators........................................................................................................................................ 61 Filters, Triggers, and Quantifi cations of Favor ................................................................ 62 ■Chapter 6: High-Performance Computing ............................................................ 65 Hardware Overview ........................................................................................................ 65 Processing ............................................................................................................................................ 65 Multicore Processing ............................................................................................................................ 65 Hyperthreading ..................................................................................................................................... 66 Memory ................................................................................................................................................ 67 The Disk ................................................................................................................................................ 68 Random Access Memory (RAM) ........................................................................................................... 68 ■ CONTENTS x Processor Cache ................................................................................................................................... 68 Swap Space .......................................................................................................................................... 68 Software Overview ............................................................................................................................... 69 Compiled vs. Interpreted ...................................................................................................................... 69 Scripting Languages ............................................................................................................................. 70 Speed vs. Safety ................................................................................................................................... 70 Takeaways ............................................................................................................................................ 71 for Loops vs. apply Functions ............................................................................................................... 71 for Loops and Memory Allocation ......................................................................................................... 72 apply-Style Functions ........................................................................................................................... 73 Use Binaries Creatively ......................................................................................................................... 73 Note on Measuring Compute Time ....................................................................................................... 74 Multicore Computing in R ............................................................................................... 74 Embarrassingly Parallel Processes....................................................................................................... 75 doMC and doParallel............................................................................................................................. 75 The foreach Package ............................................................................................................................ 76 The foreach Package in Practice .................................................................................... 77 Integer Mapping ................................................................................................................................... 77 Computing the Return Matrix with foreach .......................................................................................... 78 Computing Indicators with foreach ...................................................................................................... 79 ■Chapter 7: Simulation and Backtesting ............................................................... 83 Example Strategies ........................................................................................................ 83 Our Simulation Workfl ow ................................................................................................ 85 Listing 7-1: Pseudocode ....................................................................................................................... 85 Listing 7-1: Explanation of Inputs and User Guide ................................................................................ 86 Discussion ............................................................................................................................................ 92 Implementing Example Strategies ................................................................................. 93 Summary Statistics and Performance Metrics............................................................... 97 Conclusion ...................................................................................................................... 99 ■ CONTENTS xi ■Chapter 8: Optimization ..................................................................................... 101 Cross Validation in Time Series .................................................................................... 101 Numerical vs. Analytical Optimization .......................................................................... 102 Numerical Optimization Overview ................................................................................ 103 Parameter Transform for Unbounded Search Algorithms ................................................................... 104 Declaring an Evaluator ................................................................................................. 105 Listing 8-1: Pseudocode ..................................................................................................................... 105 Listing 8-1: Explanation of Inputs and User Guide .............................................................................. 106 Exhaustive Search Optimization ................................................................................... 110 Pattern Search Optimization ........................................................................................ 114 Generalized Pattern Search Optimization ........................................................................................... 114 Nelder-Mead Optimization............................................................................................ 120 Nelder-Mead with Random Initialization ............................................................................................ 120 Projecting Trading Performance ................................................................................... 127 Conclusion .................................................................................................................... 130 ■Chapter 9: Networking Part II ............................................................................ 131 Market Overview: Brokerage APIs ................................................................................ 131 Secure Connections ..................................................................................................... 133 Establishing SSL Connections ............................................................................................................ 133 Proprietary SSL Connections .............................................................................................................. 134 HTTP/HTTPS........................................................................................................................................ 135 OAuth .................................................................................................................................................. 135 Feasibility Analysis for Trading APIs ............................................................................. 135 Feasibility of Custom R Packages ...................................................................................................... 135 HTTPS + OAuth Through Existing R Packages .................................................................................... 136 FIX Engines ......................................................................................................................................... 136 Exporting Directions to a Supported Language .................................................................................. 136 Planning and Executing Trades .................................................................................... 136 The PLAN Job ..................................................................................................................................... 137 The TRADE Job ................................................................................................................................... 139 ■ CONTENTS xii Common Data Formats................................................................................................. 140 Manipulating XML ............................................................................................................................... 140 Generating XML Documents ............................................................................................................... 146 Manipulating JSON Data..................................................................................................................... 147 The Financial Information eXchange Protocol .................................................................................... 148 The FIX eXtensible Markup Language ................................................................................................ 149 OAuth in R ........................................................................................................................................... 150 Conclusion .................................................................................................................... 152 ■Part 3: Production Trading.............................................................. 153 ■Chapter 10: Organizing and Automating Scripts ............................................... 155 Organizing Scripts into Jobs ........................................................................................ 155 Calling Jobs with the Source Function ......................................................................... 155 Calling Jobs via Sourcing ............................................................................................. 156 Task Scheduling in Windows ........................................................................................ 156 Running R from the Command Line in Windows ................................................................................ 156 Setting Up and Managing the Task Scheduler .................................................................................... 158 Task Scheduling in UNIX............................................................................................... 159 Conclusion .................................................................................................................... 160 ■Chapter 11: Looking Forward ............................................................................ 161 Language Considerations ............................................................................................. 161 Python................................................................................................................................................. 161 C/C++ ................................................................................................................................................. 161 Hardware Description Languages ...................................................................................................... 162 Retail Brokerages and Right to Refuse......................................................................... 162 Right to Refuse in the Swiss Currency Crisis ..................................................................................... 163 Connection Latency ...................................................................................................... 163 Ethernet vs. WiFi ................................................................................................................................. 163 Proximity to Exchanges ...................................................................................................................... 164 ■ CONTENTS xiii Prime Brokerages ......................................................................................................... 164 Digesting News and Fundamentals.............................................................................. 165 Conclusion .................................................................................................................... 165 ■Appendix A: Source Code .................................................................................. 167 Platform/confi g.R ......................................................................................................... 167 Platform/load................................................................................................................ 168 Platform/load.R................................................................................................................................... 168 Platform/update.R............................................................................................................................... 169 Platform/functions/yahoo.R ................................................................................................................ 170 Platform/load/initial.R......................................................................................................................... 170 Platform/load/loadToMemory.R .......................................................................................................... 171 Platform/load/updateStocks.R............................................................................................................ 172 Platform/load/dateUnif.R .................................................................................................................... 176 Platform/load/spClean.R ..................................................................................................................... 177 Platform/load/adjustClose.R ............................................................................................................... 177 Platform/load/return.R ........................................................................................................................ 177 Platform/load/fi llInactive.R ................................................................................................................. 178 Platform/compute ........................................................................................................ 178 Platform/compute/MCinit.R ................................................................................................................ 178 Platform/compute/functions.R ........................................................................................................... 178 Platform/plan................................................................................................................ 184 Platform/plan.R................................................................................................................................... 184 Platform/plan/decisionGen.R .............................................................................................................. 185 Platform/trade .............................................................................................................. 189 Platform/trade.R ................................................................................................................................. 189 Platform/model............................................................................................................. 189 Platform/model.R................................................................................................................................ 189 Platform/model/optimize.R ................................................................................................................. 190 Platform/model/evaluateFunc.R ......................................................................................................... 190 Platform/model/optimizeFunc.R ......................................................................................................... 192 ■ CONTENTS xiv ■Appendix B: Scoping in Multicore R .................................................................. 195 Scoping Rules in R ....................................................................................................... 195 Using Lexical Scoping......................................................................................................................... 195 Takeaways .......................................................................................................................................... 196 The UNIX fork System Call............................................................................................ 197 The fork Call and Memory Management ............................................................................................ 197 Scoping Implications for R.................................................................................................................. 197 Instance Replication in Windows.................................................................................. 199 Instance Replication and Memory Management ................................................................................ 199 Scoping Implications for R.................................................................................................................. 200 Index ..................................................................................................................... 203

ادامه ...
برای ارسال نظر لطفا وارد شوید یا ثبت نام کنید
ادامه ...
پشتیبانی محصول

۱- در صورت داشتن هرگونه مشکلی در پرداخت، لطفا با پشتیبانی تلگرام در ارتباط باشید.

۲- برای خرید محصولات لطفا به شماره محصول و عنوان دقت کنید.

۳- شما می توانید فایلها را روی نرم افزارهای مختلف اجرا کنید(هیچگونه کد یا قفلی روی فایلها وجود ندارد).

۴- بعد از خرید، محصول مورد نظر از صفحه محصول قابل دانلود خواهد بود همچنین به ایمیل شما ارسال می شود.

۵- در صورت وجود هر مشکلی در فرایند خرید با تماس بگیرید.