ssrrkk
Registered: Jun 2005
Posts: 431 |
03-10-12 10:46 AM
Quote from bs2167:
Thanks for taking the time with your reply. Not to put words in your mouth, but interestingly it seems as if Python may have become the most indispensable of the three languages for your work.
On the other side of things, have you considered using Python to run the strategies live instead of Java? I've read that it might be slow for such an application, but to be honest I don't have enough programming experience to understand why.
(Apologies for the mulitple questions and the partial thread hijacking, but I've read so many good things about the language that I also want to try and understand its limitations.)
I would say Python is my main back test engine, but because I am so used to plotting things and doing quick stats in R, I do use it a lot for just playing with an idea on a few days or a few months of data at a time. For example, I use R the very first time I want to check a new idea. So R is great because I can check things with a few interactive lines of code. But it is slower and the historical data handling is a little bit more cumbersome -- again this is my fault as I haven't fully developed a good SQL interface for it. (Often I write a 5 line python script using my database classes to output a text file of the data I need, then I read that into R using read.table and then analyze my idea).
By the way, I might have given the impression that I have solved every development problem I have which is far from the truth. I still struggle with it every day and sometimes I feel like I am spinning my wheels just to get a simple thing going.
Regarding replacing java for live-trading, I don't see any need for that, as I am NOT constantly redeveloping my live trading platform. The live trading platform is a different thing to me with very different considerations. It has to do with communicating with TWS, order handling, real-time data handling, building bars from ticks, account querying and cash management, logging, etc. All of this does not change every time I have a new strategy. Of course, the core loop / signaling class overlaps with the back tested strategy and that part of the code is where I change if I have a new idea to try.
The main reason I use Java is because the TWS API comes in Java or C++ only. In addition, TWS itself is written in Java. So I decided to use the native interface. There is something called IBPy that wraps all the API calls into python but it looks like it is half finished and the authors seem to have abandoned this project some years ago. As far as performance considerations, there is no question python will be slower, and I am not sure how well it will deal with the multi-threaded nature of TWS API apps -- for example, all API apps must implement callbacks that are initiated by TWS after requests are sent to it. Sometimes, I might make 30 or 50 data requests to TWS. So I will be receiving a huge amount of call backs (hundreds or thousands of times per second) each time tick data comes in for any of those 50 instruments. I would imagine that is a big load for python to handle and in addition I am not sure how well python can handle thread synchronization. Java has absolutely no problems with this and is rock solid.
|