ebook img

Algorithmic Trading Software PDF

289 Pages·2017·4.32 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Algorithmic Trading Software

Reference Guide AlgoTrader Version 4.5 by Andy Flury, Oleg Kalnichevski, Ricardo Ribeiro, Robert Kolar, Marek Zganiacz, Jakub Chodorowicz, Rubén Fanjul, and Roger Langen CONFIDENTIAL Table of Contents Preface ............................................................................................................................................... xii 1. Document Conventions ........................................................................................................... xii 1.1. Typographic Conventions .............................................................................................. xii 1.2. Pull-quote Conventions ................................................................................................ xiii 1.3. Notes and Warnings .................................................................................................... xiv 1. Introduction .................................................................................................................................... 1 2. Installation and Deployment ........................................................................................................... 2 2.1. Development Environment Installation .................................................................................... 2 2.1.1. Prerequisites ............................................................................................................... 2 2.1.2. AlgoTrader Eclipse IDE Installation .............................................................................. 8 2.1.3. AlgoTrader Server Code Installation ............................................................................. 9 2.1.4. Next Steps ............................................................................................................... 12 2.2. Server Environment Installation ............................................................................................ 12 2.2.1. Docker based Installation .......................................................................................... 12 2.2.2. Docker Containers .................................................................................................... 13 2.2.3. Docker Compose ...................................................................................................... 19 2.2.4. Docker Management ................................................................................................. 22 2.3. VM Arguments ..................................................................................................................... 23 3. Starting AlgoTrader ...................................................................................................................... 24 3.1. Simulation Mode .................................................................................................................. 26 3.2. Live Trading Mode ............................................................................................................... 27 3.2.1. Embedded Mode ....................................................................................................... 27 3.2.2. Distributed Mode ....................................................................................................... 28 3.3. Server Environment ............................................................................................................. 29 3.3.1. Embedded Mode ....................................................................................................... 29 3.3.2. Distributed Mode ....................................................................................................... 31 4. Strategy Development .................................................................................................................. 33 4.1. Creating a Trading Strategy ................................................................................................. 33 4.1.1. AlgoTrader Strategy Wizard ....................................................................................... 33 4.1.2. AlgoTrader Maven Archetype ..................................................................................... 35 4.1.3. Generated Artifacts Java Archetype ........................................................................... 36 4.1.4. Generated Artifacts Esper Archetype .......................................................................... 38 4.2. Building a Trading Strategy .................................................................................................. 44 4.3. Hints for Strategy Development ............................................................................................ 44 4.3.1. Java based Strategies ............................................................................................... 45 4.3.2. Esper based Strategies ............................................................................................. 53 4.4. Strategy life-cycle events ..................................................................................................... 61 4.5. Strategy Groups .................................................................................................................. 62 5. Strategy Backtesting .................................................................................................................... 65 5.1. Exchange Simulator ............................................................................................................. 65 5.2. Simulation Process .............................................................................................................. 67 5.3. Single Run Simulation .......................................................................................................... 68 ii CONFIDENTIAL 5.4. Automated Parameter Optimization ....................................................................................... 68 5.5. Performance Statistics ......................................................................................................... 70 5.6. In-Process Exchange Simulator ............................................................................................ 73 5.7. Multi Security Simulations .................................................................................................... 73 6. Architecture .................................................................................................................................. 75 7. Domain Model ............................................................................................................................... 77 7.1. Entities ................................................................................................................................ 77 7.1.1. Strategy .................................................................................................................... 79 7.1.2. Security .................................................................................................................... 81 7.1.3. Market Data Events .................................................................................................. 84 7.1.4. Order ........................................................................................................................ 85 7.1.5. Account .................................................................................................................... 87 7.1.6. Transaction ............................................................................................................... 88 7.1.7. Position .................................................................................................................... 89 7.1.8. Cash Balance ........................................................................................................... 89 7.1.9. Subscription .............................................................................................................. 90 7.1.10. Exchange ............................................................................................................... 90 7.1.11. Property .................................................................................................................. 91 7.1.12. Order Preference .................................................................................................... 92 7.2. Services .............................................................................................................................. 92 7.2.1. Main Services ........................................................................................................... 93 7.2.2. Client Services .......................................................................................................... 94 7.2.3. Account Service ........................................................................................................ 94 7.2.4. Calendar Service ...................................................................................................... 94 7.2.5. Combination Service ................................................................................................. 95 7.2.6. Future Service .......................................................................................................... 95 7.2.7. Historical Data Service .............................................................................................. 95 7.2.8. Market Data Service ................................................................................................. 95 7.2.9. Measurement Service ................................................................................................ 95 7.2.10. Option Service ........................................................................................................ 96 7.2.11. Order Service ......................................................................................................... 96 7.2.12. Portfolio Service ...................................................................................................... 96 7.2.13. Position Service ...................................................................................................... 97 7.2.14. Property Service ..................................................................................................... 97 7.2.15. Reference Data Service ........................................................................................... 98 7.2.16. Market Data Cache Service ..................................................................................... 98 7.2.17. Lookup Service ....................................................................................................... 98 7.2.18. Strategy Service & Config Aware Strategy Service .................................................... 99 7.2.19. Subscription Service ................................................................................................ 99 7.2.20. Reconciliation Services .......................................................................................... 100 7.2.21. Reset Service ....................................................................................................... 100 7.3. Value Object ...................................................................................................................... 101 7.4. Enumerations ..................................................................................................................... 101 8. Esper Engine .............................................................................................................................. 102 iii CONFIDENTIAL 8.1. Esper Introduction .............................................................................................................. 102 8.1.1. Introduction to event streams and complex events using Esper .................................. 102 8.1.2. Event representations .............................................................................................. 103 8.1.3. Event Stream Analysis ............................................................................................ 103 8.1.4. Combining Pattern Matching with Event Stream Analysis ........................................... 104 8.1.5. Named windows ...................................................................................................... 105 8.1.6. Variables ................................................................................................................ 105 8.2. Esper Quick Start Guide .................................................................................................... 105 8.2.1. Event Types ........................................................................................................... 105 8.2.2. Creating a Statement .............................................................................................. 106 8.2.3. Adding a Subscriber ................................................................................................ 106 8.2.4. Adding a Listener .................................................................................................... 107 8.2.5. Sending events ....................................................................................................... 108 8.2.6. Configuration ........................................................................................................... 108 8.3. Esper Documentation ......................................................................................................... 108 8.4. AlgoTrader specific Esper Artifacts ..................................................................................... 109 8.4.1. Engine & EngineManager ........................................................................................ 109 8.4.2. Modules .................................................................................................................. 110 8.4.3. Tags ....................................................................................................................... 111 8.4.4. Subscribers ............................................................................................................. 111 8.4.5. Listeners ................................................................................................................. 112 8.4.6. Service method invocation in Esper scripts ............................................................... 112 8.4.7. Aggregation Functions ............................................................................................. 113 8.4.8. Callbacks ................................................................................................................ 115 8.5. Esper Threading ................................................................................................................ 118 9. Database ..................................................................................................................................... 119 9.1. Data Source ...................................................................................................................... 119 10. Client ......................................................................................................................................... 120 10.1. HTML5 ............................................................................................................................ 120 10.1.1. Header .................................................................................................................. 120 10.1.2. Order Table .......................................................................................................... 123 10.1.3. Transaction Table .................................................................................................. 124 10.1.4. Positions Table ..................................................................................................... 125 10.1.5. Market Data Table ................................................................................................. 126 10.1.6. Column Selection and Grouping ............................................................................. 127 10.1.7. CSV Export ........................................................................................................... 129 10.1.8. Chart Widget ......................................................................................................... 129 10.1.9. Technologies ......................................................................................................... 131 10.1.10. HTML5 Custom Widgets ...................................................................................... 132 10.2. AlgoTrader Eclipse IDE .................................................................................................... 135 10.2.1. AlgoTrader Perspective .......................................................................................... 135 10.2.2. Strategy Wizard ..................................................................................................... 136 10.2.3. AlgoTrader Configuration Editor ............................................................................. 137 10.2.4. Esper Colorer ........................................................................................................ 144 iv CONFIDENTIAL 11. Performance Measurement ....................................................................................................... 145 11.1. Portfolio Value Logging .................................................................................................... 145 11.2. Portfolio Value Restoration Feature ................................................................................... 145 12. Risk Management ..................................................................................................................... 147 13. Forex Handling ......................................................................................................................... 148 13.1. Currency Handling ........................................................................................................... 148 13.1.1. Futures ................................................................................................................. 149 13.1.2. Forex .................................................................................................................... 149 13.1.3. Currency Attribution ............................................................................................... 149 13.2. Forex-Hedging ................................................................................................................. 150 13.2.1. Virtual FX Positions (IB only) ................................................................................. 150 13.2.2. FX Future ............................................................................................................. 150 14. Options & Futures .................................................................................................................... 151 14.1. Expiration ........................................................................................................................ 151 14.2. Leverage & Exposure ....................................................................................................... 151 14.3. Symbol, ISIN & RIC ......................................................................................................... 152 14.4. Delta Hedging .................................................................................................................. 152 14.5. Option & Future Chain Download ...................................................................................... 153 14.6. Option Greeks ................................................................................................................. 153 14.7. Option Pricing Engine ....................................................................................................... 153 14.7.1. SABR Calibration .................................................................................................. 153 14.7.2. Option Pricing ....................................................................................................... 154 14.7.3. References ........................................................................................................... 154 14.8. OTC Options ................................................................................................................... 154 15. Reconciliation ........................................................................................................................... 155 15.1. Partner Systems .............................................................................................................. 155 15.2. Email Handling ................................................................................................................. 155 15.3. FTP Handling ................................................................................................................... 156 16. Broker/Exchange Interfaces ...................................................................................................... 157 17. Order Management ................................................................................................................... 159 17.1. Place Order ..................................................................................................................... 159 17.1.1. Order Preferences ................................................................................................. 160 17.1.2. Trade Suggestions ................................................................................................ 161 17.1.3. Order Properties .................................................................................................... 161 17.2. Receive Fills .................................................................................................................... 162 17.3. Handling of Fees and Commissions .................................................................................. 163 17.4. Internal Order Id Format ................................................................................................... 163 17.5. Symbology ....................................................................................................................... 164 18. Market Data ............................................................................................................................... 165 18.1. Creation of Bars based on Ticks ....................................................................................... 166 18.2. Numeric Precision ............................................................................................................ 167 18.3. Price normalization ........................................................................................................... 168 18.4. Market Data Gap Checking .............................................................................................. 168 18.5. Generic Events ................................................................................................................ 168 v CONFIDENTIAL 18.6. Generic Tick Events ......................................................................................................... 169 19. Historical Data .......................................................................................................................... 171 19.1. InfluxDB ........................................................................................................................... 172 19.2. Live Data Recording ......................................................................................................... 176 19.3. Historical Data Download ................................................................................................. 176 19.4. Interactive Brokers Historical Data Download ..................................................................... 177 19.5. Quandl Historical Data Download ...................................................................................... 178 19.6. Google Finance Historical Data Download ......................................................................... 178 19.7. Market Data File Format ................................................................................................... 178 19.7.1. Tick Data Files ...................................................................................................... 179 19.7.2. Bar Data Files ....................................................................................................... 180 20. Reference Data ......................................................................................................................... 181 21. Account Data ............................................................................................................................ 183 22. Adapters .................................................................................................................................... 185 22.1. Fix Interface ..................................................................................................................... 185 22.1.1. FIX configuration ................................................................................................... 187 22.1.2. FIX logging ........................................................................................................... 188 22.1.3. FIX message persistence ....................................................................................... 188 22.1.4. FIX Drop-copy support ........................................................................................... 188 22.2. Session life-cycle events .................................................................................................. 189 22.3. Crypto Exchange interfaces .............................................................................................. 189 22.3.1. Crypto Exchange vs. Margin Trading ...................................................................... 189 22.3.2. Custom currency mapping ..................................................................................... 190 22.4. Bloomberg ....................................................................................................................... 190 22.5. Currenex .......................................................................................................................... 190 22.6. DukasCopy ...................................................................................................................... 191 22.7. EzeSoft / Real Tick .......................................................................................................... 191 22.8. Fortex .............................................................................................................................. 192 22.9. FXCM .............................................................................................................................. 192 22.10. IB Native Interface ......................................................................................................... 192 22.10.1. IB Market Data Subscriptions ............................................................................... 195 22.11. IB Fix Interface .............................................................................................................. 199 22.12. JP Morgan ..................................................................................................................... 200 22.13. LMAX ............................................................................................................................ 200 22.14. Nexus Prime .................................................................................................................. 200 22.15. PrimeXM ........................................................................................................................ 201 22.16. Quandl ........................................................................................................................... 201 22.17. QuantHouse ................................................................................................................... 202 22.18. SocGen ......................................................................................................................... 203 22.19. Trading Technologies (TT) .............................................................................................. 203 22.20. UBS .............................................................................................................................. 203 22.21. Crypto-Adapter Order Constraints ................................................................................... 203 22.21.1. Order Type Validation .......................................................................................... 207 22.22. Binance ......................................................................................................................... 208 vi CONFIDENTIAL 22.23. Bitfinex .......................................................................................................................... 209 22.24. Bitflyer ........................................................................................................................... 209 22.25. BitMEX .......................................................................................................................... 211 22.26. Bitstamp ........................................................................................................................ 212 22.27. CoinAPI ......................................................................................................................... 213 22.28. Coinigy .......................................................................................................................... 214 22.28.1. Setup Instructions ................................................................................................ 214 22.29. CoinMarketCap .............................................................................................................. 215 23. Execution Algos ........................................................................................................................ 216 23.1. Existing Execution Algos .................................................................................................. 216 24. Synthetic Securities and Derivative Spreads ............................................................................ 224 24.1. Combination Example ...................................................................................................... 225 24.2. Combination Service ........................................................................................................ 225 24.2.1. Create Combination ............................................................................................... 225 24.2.2. Update Component Quantity .................................................................................. 225 24.2.3. Remove a Component ........................................................................................... 226 25. Spring Services ......................................................................................................................... 227 25.1. Starter Classes ................................................................................................................ 227 25.2. Spring Profiles ................................................................................................................. 228 26. Configuration and Preferences API .......................................................................................... 231 26.1. Configuration Files ........................................................................................................... 231 26.2. Esper Variables ............................................................................................................... 232 27. Processes and Networking ....................................................................................................... 233 27.1. SSL security .................................................................................................................... 233 27.1.1. Importing Certificate into Chrome Browser .............................................................. 234 28. Metrics ...................................................................................................................................... 235 28.1. Configuration ................................................................................................................... 235 28.2. Metrics Reporting ............................................................................................................. 235 29. Logging ..................................................................................................................................... 236 29.1. log4j2.xml ........................................................................................................................ 236 29.2. Production log4j2.xml ....................................................................................................... 236 30. Reporting .................................................................................................................................. 238 A. Example Strategy "BreakOut" ....................................................................................................... 239 A.1. Trading Idea ...................................................................................................................... 239 A.2. Example ............................................................................................................................ 239 A.3. Implementation .................................................................................................................. 240 A.4. Installation & Startup ......................................................................................................... 241 B. Example Strategy "Box" ................................................................................................................ 243 B.1. Trading Idea ...................................................................................................................... 243 B.2. Implementation .................................................................................................................. 246 B.3. Strategy Monitoring ............................................................................................................ 247 B.4. Installation & Startup ......................................................................................................... 247 C. Example Strategy "Pairs Trading" ................................................................................................. 250 C.1. Trading Idea ..................................................................................................................... 250 vii CONFIDENTIAL C.1.1. What Is Pairs Trading? ........................................................................................... 250 C.1.2. Pair Trading Lab ..................................................................................................... 250 C.1.3. AlgoTrader - Pair Trading Lab Integration ................................................................ 250 C.2. Implementation .................................................................................................................. 251 C.3. Installation & Startup ......................................................................................................... 252 C.4. Strategy Monitoring ........................................................................................................... 254 D. Example Strategy "IPO" ............................................................................................................... 257 D.1. Trading Idea ..................................................................................................................... 257 D.2. Strategy Monitoring ........................................................................................................... 257 D.3. Implementation .................................................................................................................. 259 D.4. Installation & Startup ......................................................................................................... 260 E. Example Strategy "EMA" .............................................................................................................. 262 E.1. Trading Idea ...................................................................................................................... 262 E.2. Implementation .................................................................................................................. 262 E.3. Installation & Startup ......................................................................................................... 263 F. Example Strategy "Random" ......................................................................................................... 265 F.1. Trading Idea ...................................................................................................................... 265 F.2. Implementation .................................................................................................................. 265 F.3. Installation & Startup .......................................................................................................... 266 viii CONFIDENTIAL List of Figures 2.1. Eclipse default JRE ..................................................................................................................... 11 3.1. Eclipse Run Configurations .......................................................................................................... 24 3.2. Eclipse Run Configurations .......................................................................................................... 25 3.3. Eclipse Run Configurations .......................................................................................................... 26 4.1. Strategy Development Process ..................................................................................................... 33 4.2. Wizard Selection .......................................................................................................................... 34 4.3. Wizard Location and Working Set ................................................................................................. 34 4.4. Wizard Maven Properties ............................................................................................................. 34 4.5. Wizard Maven Properties ............................................................................................................. 35 5.1. Back Test Report ......................................................................................................................... 71 6.1. Architecture ................................................................................................................................. 75 7.1. Entities Overview ......................................................................................................................... 77 7.2. Strategy ...................................................................................................................................... 79 7.3. Securities .................................................................................................................................... 81 7.4. Securities .................................................................................................................................... 83 7.5. Market Data Event ....................................................................................................................... 84 7.6. Orders ......................................................................................................................................... 85 7.7. Account ....................................................................................................................................... 87 7.8. Transaction ................................................................................................................................. 88 7.9. Position ....................................................................................................................................... 89 7.10. Subscription ............................................................................................................................... 90 7.11. Exchange .................................................................................................................................. 90 7.12. Properties and PropertyHolders .................................................................................................. 91 7.13. Order Preference ....................................................................................................................... 92 10.1. AlgoTrader HTML5 Client Header ............................................................................................. 120 10.2. AlgoTrader HTML5 Client Header Settings ................................................................................ 121 10.3. AlgoTrader HTML5 Client Management ..................................................................................... 122 10.4. AlgoTrader HTML5 Client Management Form ............................................................................ 122 10.5. AlgoTrader HTML5 Client Notification ........................................................................................ 122 10.6. AlgoTrader HTML5 Client Alert ................................................................................................. 123 10.7. AlgoTrader HTML5 Client Alert List ........................................................................................... 123 10.8. AlgoTrader HTML5 Client Order Table ...................................................................................... 123 10.9. AlgoTrader HTML5 Client Manual Order Entry ........................................................................... 123 10.10. AlgoTrader HTML5 Client Manual Order Detail ........................................................................ 124 10.11. AlgoTrader HTML5 Client Manual Order Modification ............................................................... 124 10.12. AlgoTrader HTML5 Client Transaction Table ............................................................................ 125 10.13. AlgoTrader HTML5 Client Transaction Entry ............................................................................ 125 10.14. AlgoTrader HTML5 Client Position Table ................................................................................. 126 10.15. AlgoTrader HTML5 Client Market Data Table ........................................................................... 126 10.16. AlgoTrader HTML5 Client Market Data Subscribe .................................................................... 127 10.17. AlgoTrader HTML5 Client Market Data Unsubscribe ................................................................. 127 10.18. AlgoTrader HTML5 Client Transaction Column Selection .......................................................... 128 ix CONFIDENTIAL 10.19. AlgoTrader HTML5 Client Column Filter .................................................................................. 128 10.20. AlgoTrader HTML5 Client Chart Widget ................................................................................... 129 10.21. AlgoTrader HTML5 Client Chart Widget settings ...................................................................... 130 10.22. AlgoTrader HTML5 Client Chart Widget - selecting security ...................................................... 131 10.23. HTML5 Custom Widget Example ............................................................................................ 132 10.24. AlgoTrader Configuration Editor .............................................................................................. 137 10.25. Strategy Data ......................................................................................................................... 138 10.26. Configuration file without strategy groups ................................................................................ 139 10.27. Titles and Separators in a property file .................................................................................... 141 10.28. Syntax Highlighter .................................................................................................................. 144 14.1. Leverage & Exposure ............................................................................................................... 152 18.1. Market Data Event Types ......................................................................................................... 166 22.1. Market Data Subscriptions 1 ..................................................................................................... 196 22.2. Market Data Subscriptions 2 ..................................................................................................... 196 22.3. Market Data Subscriptions 3 ..................................................................................................... 197 22.4. Market Data Subscriptions 4 ..................................................................................................... 198 22.5. Paper Trading Account 1 .......................................................................................................... 199 22.6. Paper Trading Account 2 .......................................................................................................... 199 24.1. Combinations and Components ................................................................................................ 224 24.2. Combination Example .............................................................................................................. 225 A.1. BreakOut Strategy Example ....................................................................................................... 240 B.1. Box Trading Ranges .................................................................................................................. 243 B.2. Box Strategy ............................................................................................................................. 244 B.3. Box States ................................................................................................................................ 245 B.4. Box Strategy Performance ......................................................................................................... 245 B.5. Box HTML5 Custom Widget Example ......................................................................................... 247 C.1. Pair Trading Portfolio ID ............................................................................................................ 253 C.2. Pairs Trading HTML5 Custom Widget Example ........................................................................... 255 D.1. IPO HTML5 Custom Widget Example ......................................................................................... 258 E.1. EMA Strategy Example .............................................................................................................. 262 x

Description:
AlgoTrader Reference Documentation. Algorithmic Trading Software. Version 4.0 by Andy Flury, Oleg Kalnichevski, Ricardo Ribeiro, and Robert Kolar
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.