R vs Python vs matlab: the quant language war - Matlab, R project and Python | futures io social day trading
futures io futures trading


R vs Python vs matlab: the quant language war
Updated: Views / Replies:21,132 / 26
Created: by treydog999 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

View Poll Results: Which Quantitative Development Language?
R 36 39.56%
Python 43 47.25%
Matlab 12 13.19%
Voters: 91. You may not vote on this poll

Reply
 1  
 
Thread Tools Search this Thread
 

R vs Python vs matlab: the quant language war

  #21 (permalink)
Elite Member
Houston, TX
 
Futures Experience: Intermediate
Platform: Sierra Chart, Bookmap
Favorite Futures: emini ES
 
dominikos's Avatar
 
Posts: 20 since Jan 2014
Thanks: 4 given, 6 received

End to end platform

I'm currently trying to decide which platform to use for both strategy testing and execution. Ilya does excellent job evangelizing usage of R for research but I cannot find any information about usage of R for strategy execution.
Looks like Python is used for both. Since I have to learn anyway I could go either way but I would rather not learn both.
I would appreciate any thoughts or pointers.
Btw, at this point I'm thinking about swing trading with EOD data across a large trade population (Russell 3000) so speed is not as critical as for tick driven trading.
I'm a Linux guy and don't want to get into a vendor tool such as Amibroker

Reply With Quote
 
  #22 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,573 given, 3,982 received


dominikos View Post
I'm currently trying to decide which platform to use for both strategy testing and execution. Ilya does excellent job evangelizing usage of R for research but I cannot find any information about usage of R for strategy execution.
Looks like Python is used for both. Since I have to learn anyway I could go either way but I would rather not learn both.
I would appreciate any thoughts or pointers.
Btw, at this point I'm thinking about swing trading with EOD data across a large trade population (Russell 3000) so speed is not as critical as for tick driven trading.
I'm a Linux guy and don't want to get into a vendor tool such as Amibroker

IMHO Python is easier to learn, and if speed is a problem you can easily prototype in Python and code the piece of code which needs to be as fast as possible in C or C++.
I found R harder to learn and use, but everyone is different and I'm biased by my long years coding in C and its cousins.

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following 2 users say Thank You to sam028 for this post:
 
  #23 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received



dominikos View Post
I'm currently trying to decide which platform to use for both strategy testing and execution. Ilya does excellent job evangelizing usage of R for research but I cannot find any information about usage of R for strategy execution.
Looks like Python is used for both. Since I have to learn anyway I could go either way but I would rather not learn both.
I would appreciate any thoughts or pointers.
Btw, at this point I'm thinking about swing trading with EOD data across a large trade population (Russell 3000) so speed is not as critical as for tick driven trading.
I'm a Linux guy and don't want to get into a vendor tool such as Amibroker

R has librarys to attach to Interactive Brokers as well as send FIX messages. This will allow you to execute automatically. Making it end to end. Also you can use RCpp and basically connect to any broker or exchange API.

Python has the similar capabilities as well. However the financial and econometric ecosystem is very immature compared to R. But if you want to home roll your own its no problem. As well as base execution speed is faster, however R becomes faster with the use of RCpp, even vs Python Pypy. See my previous post link.

Its really up to you since they are very comparable. I feel that R is more geared to people who think more mathematically, and like to do more complex statistical data analysis with less LOC. As the syntax is very close to how you would right actual expressions and equations by hand. But for people who are more programmers by back ground may find this syntax confusing. However using R for more generalized programming methods will be cumbersome.

You do not need to learn both just pick what is more important to you. Data analysis, back testing, financial and econometric analysis then use R. If faster base processing, traditional program syntax friendly, and better generalized programming usage then use Python.

Reply With Quote
The following 2 users say Thank You to treydog999 for this post:
 
  #24 (permalink)
Elite Member
Manchester, NH
 
Futures Experience: Beginner
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: Stocks
 
Posts: 902 since Jul 2012
Thanks: 603 given, 1,785 received


dominikos View Post
I'm currently trying to decide which platform to use for both strategy testing and execution. Ilya does excellent job evangelizing usage of R for research but I cannot find any information about usage of R for strategy execution.
Looks like Python is used for both. Since I have to learn anyway I could go either way but I would rather not learn both.
I would appreciate any thoughts or pointers.
Btw, at this point I'm thinking about swing trading with EOD data across a large trade population (Russell 3000) so speed is not as critical as for tick driven trading.
I'm a Linux guy and don't want to get into a vendor tool such as Amibroker

If writing very optimized programs is not a priority for you and you're a one-man shop, then I would strongly recommend working with an expressive language such as OCaml and not work with all that baggage in R/Python/MATLAB.

Pretty much the entirety of the OCaml language in Backus-Naur form:
 
Code
    exp ::= value                       (* numbers, strings, bools etc. *)
        | id                            (* variables, e.g. x, foo etc. *)
        | exp1 op exp2                  (* expressions, e.g. x+3, "path/"^file *)
        | id exp1 exp2 ... expn         (* function call, e.g. foo 8 99 *)
        | let id = exp1 in exp2         (* local variable declaration *)
        | if exp1 then exp2 else exp3   (* conditionals *)
Most people prefer MATLAB or R for their read-eval-print-loop environments. OCaml has utop for REPL but nevertheless comes with compilers and production quality tools, e.g. ocamldep (dependency generator), ocamlopt (optimizing native code compiler), ocamldebug (debugger).

Reply With Quote
The following 3 users say Thank You to artemiso for this post:
 
  #25 (permalink)
Elite Member
Norwich, UK
 
Futures Experience: Beginner
Platform: Multiple:research&executi
Broker/Data: Started with Stage5/OEC ... multiple
Favorite Futures: Anything found profitable goes ...
 
andby's Avatar
 
Posts: 141 since Jul 2012
Thanks: 82 given, 56 received

backtesting - WFA ?


treydog999 View Post
You do not need to learn both just pick what is more important to you. Data analysis, back testing, financial and econometric analysis then use R. If faster base processing, traditional program syntax friendly, and better generalized programming usage then use Python.

Very good summary!
How about supported types of backtesting and flexibility to extend these:
- which one supports walk-foward testing? I've been told QuantStrat has a somewhat limitted WFA capabilities.
- how flexible is it to build on top of an existing R / Python module?

The problem with Python's zipline engine is - it has been built for a web interface, and it barely does a backtest iteration. Make it do simple optimizations on multiple parameters, and you'll grow old waiting for the <zip> finish line. And I fully agree with Python being best for <faster base processing, traditional program syntax friendly, and better generalized programming>.
However, should we also vote which goals / problems we try to fix are more important?
For me, FAST idea research, optimization and results analysis are more important than flexible interactive graphs, integration with the 1 thousand language flavors are out there in the wild and IDE Perfection (through Visual Studio) - which is always good to have but would be the second priority.
So, the pool is great but relative to what? Looking at the pros/cons listed on the two main competitors, it might show two kinds of dominant voters:

- the ones that voted having as a priority - the (trading related) problems we're trying to solve
- the ones that voted out of their passion for one or another without that much consideration on the problems to be solved

Reply With Quote
 
  #26 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


andby View Post
Very good summary!
How about supported types of backtesting and flexibility to extend these:
- which one supports walk-foward testing? I've been told QuantStrat has a somewhat limitted WFA capabilities.
- how flexible is it to build on top of an existing R / Python module?

The problem with Python's zipline engine is - it has been built for a web interface, and it barely does a backtest iteration. Make it do simple optimizations on multiple parameters, and you'll grow old waiting for the <zip> finish line. And I fully agree with Python being best for <faster base processing, traditional program syntax friendly, and better generalized programming>.
However, should we also vote which goals / problems we try to fix are more important?
For me, FAST idea research, optimization and results analysis are more important than flexible interactive graphs, integration with the 1 thousand language flavors are out there in the wild and IDE Perfection (through Visual Studio) - which is always good to have but would be the second priority.
So, the pool is great but relative to what? Looking at the pros/cons listed on the two main competitors, it might show two kinds of dominant voters:

- the ones that voted having as a priority - the (trading related) problems we're trying to solve
- the ones that voted out of their passion for one or another without that much consideration on the problems to be solved


I think quantstrats WFA is fine. Its not great but workable. I have used it myself on several occasions and it does support multi core processing which is definitely a nice feature given R is usually single threaded.

I looked at zipline one time and saw immediately it did not fit my needs. It is equity focused so if you require anything that has a multiplier (futures, options, swaps or basically any derivative your screwed). So I never even tried it.

If you do not feel like building your own backtesting infrastructure I would say that quantstrat would be the way to go. It is the closest thing to a professional framework you can get in either language. It can handle cash and derivative products, it can do WFA and optimization out of the box. Also the structure makes sense by breaking things down into indicator, signal, rule, etc.

But I found limitations with quantstrat, mostly when you are designing portfolios of strategies. Or using advanced capital aware position sizing or volatility adjustment for your portfolio. This was a wall I could not find my way around. But most people probably will not focus on this area much, until they have several profitable strategies. Also quantstrat is meant to be used for tick data. so there are a few artifacts if you only have OHLC data. This means that some calculations on trailing stops and other orders may come out different than expected.

Overall I ended up designing my own framework in python. Why did i choose python after being such a staunch R supporter? Well 2 reasons first of all its easier to find developers for python than R, as I may need to hire people in the future. Second, translating from R to C++ is a pain in the ass. Seriously takes massive amounts of time for the IT team to translate the logic, debug and simulate to make sure we get identical results. This time savings is immense but also now the IT teams and the quant strategists now can interface and "speak" the same programming language. So coding logic, ideas and paradigms can all be easily shared cross department. Even if the end result will be python, c++ or a mix of the 2. The basic logic and structure and ideas can all be blocked out using python code and see it work at that level, then go into C++ if it requires API access or optimization on speed. Or just refactor the python and job done.

For us right now having that added latency is not that big of a deal as our time horizon for trades is fairly long. The additional slippage or latency is not that important. Also since we can interface c++ much easier into python than into R although both languages do support it. Our execution API is C++, which is why i mention it.

it does point again to python as a developer will be more familiar with the syntax of python vs R. But for me personally i like R syntax better because I think more like a mathematician than a coder. But I am not the only person who is working on this project. So in the end it was better to switch.

Reply With Quote
The following 7 users say Thank You to treydog999 for this post:
 
  #27 (permalink)
Elite Member
Norwich, UK
 
Futures Experience: Beginner
Platform: Multiple:research&executi
Broker/Data: Started with Stage5/OEC ... multiple
Favorite Futures: Anything found profitable goes ...
 
andby's Avatar
 
Posts: 141 since Jul 2012
Thanks: 82 given, 56 received

sample of R backtest performance

Just for the sake of exemplification ... dual moving average sysyem, less than 450 loops on one symbol alone:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


~3.5 minutes??? (on mac os x, 8 cores i7 4th gen)


Last edited by andby; November 29th, 2016 at 05:26 AM.
Reply With Quote
The following user says Thank You to andby for this post:

Reply



futures io > > > > R vs Python vs matlab: the quant language war

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
IB with Python jamesico Matlab, R project and Python 2 September 9th, 2014 08:19 AM
Tradier with R and or Python Keith Leesus Matlab, R project and Python 2 September 5th, 2014 01:23 AM
Python Help Wanted $ wlblount Hire a Consultant or Programmer 0 December 25th, 2013 10:14 AM
quant.stackexchange.com shodson Platforms and Indicators 3 February 11th, 2011 04:18 PM
[Other]       Open Quant / Quant Developer niterate Platforms and Indicators 2 December 5th, 2010 10:10 PM


All times are GMT -4. The time now is 11:51 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-15 in 0.18 seconds with 21 queries on phoenix via your IP 54.163.210.170