What are the advantages of switching platforms/languages between strategy development and implementation?
-
I am interested in coding a medium frequency (trading over minutes to hours, holding for days to weeks) quantitative trading strategy and trading it with Interactive Brokers. I have seen many people here mention that they use Matlab (or R, SAS, etc.) for strategy development/backtesting, but that they would prefer to program the execution code for live trading in C++/C#/Java. What are the advantages of re-coding the strategy into a lower-level language and/or the disadvantages of maintaining the same platform for strategy development and implementation? My thinking is that keeping the same platform allows one to easily incorporate updates and improvements to the strategy over time, whereas the IBrokers package and various commercial Matlab tie-ins to IB's API make it feasible to communicate directly with IB from the development platform. Is there something I am missing here? Have others tried this?
-
Answer:
This is an evergreen. I've been discussing this with many people - without any clear-cut conclusion. The answer and the preferred solution depend on your trading style (e.g. frequency), your skills, the size of the team, and many other factors. For simplicity, I call "Research" the Matlab/R/etc. environments, whereas "Live" refers to the re-programmed C++/Java/C# environments. The proponents of reprogramming usually claim that the two environments are very different in nature, namely: Robustness: Research is ad-hoc-ish by nature, your main concern is not speed, programming robustness and style. Production needs to be more robust and faster, and you want to reuse components such as e.g. a price stream. Data Research is usually done on a closed data-set: you have a set of in-sample data and wherever possible, you're running backtests with matrix functions (e.g. in Matlab or R). In live trading, you are working on incremental data, new information is popping in irregular spacing. Thus, live trading is much more event-driven (at least for higher frequencies). Assumptions In a backtest, you need to make assumptions on the fill ratio and price, and very often you calculate positions asymptotically (i.e. as a percentage of your portfolio, regardless of the minimum size you can hold of a position). In live trading, you can't do that. You need to generate an order in terms of size of futures/shares/etc. Also, you will need to feed back in your actual position (which depends on the fills you got), which is something you don't have to worry about in research. People usually try to overcome these differences with different strategies, such as: The Python way take the middle route by building everything in a high-level language that possibly fits both requirements. The opponents of this strategy claim that this way you won't end up with best-of-breed solutions, neither in research nor in live trading. The Matlab/R way Research-centric shops try to build everything around Matlab. In my experience, this works well to a certain size, but with larger teams things can get very difficult to maintain. Re-usability of components among the team can become very difficult. The Reprogramming This requires either very good skills or a dedicated re-programming team. This is usually expensive and difficult, and the risk is to add errors. Integration There are some platforms that allow you to deploy strategies in multiple languages (e.g. compiled matlab code, R automation, etc.). If done well, this may be the best solution. For yourself, if you're the only one working on the strategy, and with the frequency you mention, the The Matlab/R way sounds like the way to go.
Tal Fishman at Quantitative Finance Visit the source
Other answers
The only benefits I can imagine from re-coding in C++ would be speed. But speed doesn't seem to be a concern for your time horizon (especially if you write efficient Matlab code). Some may argue that C++ is more stable, but Matlab is plenty stable for live trading. However, the downsides of using two languages are even more significant than just ease of updating and improving the strategy. Not only do you have to code new updates twice, but C++ and Matlab aren't that similar, so you'll have to write different code. This will dramatically increase your chance of making errors, which will more than likely lose you money. Ultimately, unless you're at the point where speed is critical, having two different code bases for development and implementation is a nightmare.
Frank Fingerman
You could combine both languages into one platform. I use Octave a lot ( the open source equivalent of MATLAB ) and where speed is an issue I have re-written .oct functions in C++ that are called from Octave. This has the advantage of using just Octave code for functional day to day use but with the speed of C++ where necessary.
babelproofreader
There is no advantage. You will introduce new bugs. It's a basic fact of software writing. Just by wishing they weren't there you don't make bugs go away. A few years ago, I had a job (at medium to high frequency) where all code morphed from research / development to production, often with a translation. It was a huge issue, even at that rather advanced firm. My next job was higher/highest frequency where things happened in C++ only. So to do more higher-level analysis in R, I needed to bring R and C++ closer together. http://dirk.eddelbuettel.com/code/rcpp.html makes that possible. Now, language choice is both personal (style, what you may have learned first, ...) and institutional (whatever the shop has settled on) so this pairing can't and won't work for everyone. But it did for me, and largely because it alleviated the split between research software and trading software. These were the same C++ routines, simply deployed in different contexts.
Dirk Eddelbuettel
I am still researching this topic more fully, but so far I have found the following advantages to re-coding the strategy in a lower level language (for better or worse, my language of choice in this case is Java): Access to the latest API. R's IBrokers doesn't implement all of the IB API's latest features, and there is no guarantee that the package will be kept up-to-date. I do not like relying on a commercial vendor for a Matlab interface to IB, and most of the developers of these interfaces would lead you to believe that setting it up is no trivial matter. Personalized trading front-end/GUI. Both R and Matlab's GUI capabilities leave much to be desired. Java's Swing is a joy to use. Multi-threading. Although parallel processing has been built into R, and Matlab somewhat if you are willing to pay for it, both were designed as fundamentally single-threaded languages. Ability to call R/Matlab code from Java. I am as yet unsure as to how well this would work, but it at least seems possible to directly use much of the strategy code I've already built by calling an instance of Matlab from Java. Help or further advice on this topic would still be greatly appreciated.
Tal Fishman
Related Q & A:
- What are the advantages and disadvantages of fossil fuels?Best solution by Yahoo! Answers
- What are the advantages and disadvantages of digital voltmeters over the analogue voltmeters?Best solution by Yahoo! Answers
- What are the advantages and disadvantages of animal testing?Best solution by ehow.com
- What are the advantages and the disadvantages of using fossil fuels?Best solution by Yahoo! Answers
- What are the advantages of the amniotic egg?Best solution by ask.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.