This article introduces the Julia programming language, which is specifically designed for scientific computing, that solves the “two-language problem”, i.e. it provides the performance at par with C and the dynamic nature of Python and R.
This series of articles will take you through the journey of getting started with Julia programming to backtesting and implementing live trading strategies in it.
This is the first article in the series and has the following sections –
- What is Julia?
- Why do we need another programming language?
- Is Julia faster than Python or R?
- How to install Julia?
- How to run Julia in a Jupyter notebook?
- How to install packages in Julia?
- Basic packages in Julia
- Julia packages for Algorithmic Trading
What is Julia?
Julia is a high-performance programming language specifically designed for efficient numerical computing. It aims to provide high computational speed combined with an easy-to-write programming language.
Julia project was started in 2009 and was released as an open-source language (under MIT license) through a blog post in 2012. Julia 1.0 was released in 2018. The Julia user base has grown widely as the scientific community realised its potential. As of July 2021, Julia has 203,400+ GitHub stars, provides 6000+ registered packages and has over 29 million downloads.
Why do we need another programming language?
The scientific community has always faced a trade-off between the high-performance vs dynamic nature of programming. Programming languages like Matlab, R or Python are widely used in the scientific community.
However, when it comes to solving challenges that require enormously high computation power, the code has to be re-written in languages like C or Fortran to achieve this goal. This is called the “two-language problem”.
Julia claims to solve this challenge by combining the best of both worlds, i.e., speed and easy-to-write language.
Is Julia faster than Python or R?
Let’s look at some benchmarks.
The following figure shows the computation time for various languages on different operations (mentioned in the legend). The vertical axis shows each benchmark time normalised against the C implementation.
As we can see, Julia is closest to C for most of the operations, lagging behind LuaJIT and Rust in some cases. It’s much faster than Python or R. More details on this benchmark test can be found here.
Multiple operations on large datasets
The below chart compares the task of the
groupby function across various packages. “Query 1” in the figure below is one of the tests performed, and DF.jl (a Julia package) turned out to be the fastest. There are many other queries performed here.
For query 1: “sum v1 by Id1”: 100 groups of ~10,000,000 rows, Python (pandas package) and R (dplyr package) resulted in an internal error and out of memory error, respectively while Julia took 2.4 seconds the first time and 1.8 seconds the second time.
Stay tuned for the next installment in which Anshul Tayal will demonstrate how to install Julia.
Visit QuantInsti for additional insight on this topic: https://blog.quantinsti.com/julia-programming/.
Disclosure: Interactive Brokers
Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from QuantInsti and is being posted with its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.