Introduction to Julia – Part III

QuantInsti

Contributor:
QuantInsti
Visit: QuantInsti

See Part I of this series to get started with Julia programming and Part II for instructions on how to install Julia.

How to run Julia in a Jupyter notebook?

To run Julia in a Jupyter notebook, you’ll have to add a package “IJulia” that provides this feature. In your Julia terminal, type:

  1. using Pkg
  2. Pkg.add(“IJulia”)

Run Julia in Jupyter Notebook

Julia is now added to your Jupyter Notebook.

  1. Open your Jupyter notebook by typing “jupyter-notebook” on your anaconda terminal.
  2. On the top right corner, click on “New”.
  3. Select “Julia 1.6.3” from the drop-down menu.
  4. You’re now ready to code in Julia using Jupyter Notebook!

Code Julia using Jupyter Notebook

How to install packages in Julia?

One of the first steps in getting started with any programming language is installing various packages for different purposes.

To add any packages in Julia, follow these steps:

  1. using Pkg
  2. Pkg.add(“package-name”)
  3. using “package-name”

If you’re familiar with Python, the “using” keyword in Julia is equivalent to “import” in Python and “pip install package-name” in Python is equivalent to “Pkg.add(“package-name”)”. “Pkg” is the package manager in Julia.

For example – The screenshot below is an example of adding the package “CSV.jl”, which is used to read “.csv” files in Julia.

Adding Package in Julia

Basic packages in Julia

As I mentioned earlier, there are 6000+ registered packages in Julia.

Here are some packages that will help you get started with the most common operations:

  1. CSV.jl is used to read .csv files,
  2. XLSX.jl can be used for reading excel sheets,
  3. JLD.jl for saving and loading Julia variables,
  4. DataFrames.jl is used to manage dataframes.
  5. Plots.jl is used for generating plots.
  6. Images.jl for image processing,
  7. RCall.jl and PyCall.jl for using R and Python code in Julia.

For more specific applications, these packages are used:

  • Mocha.jl for training neural networks,
  • Tensorflow.jl and ScikitLearn.jl for ML models,
  • DifferentialEquations.jl for solving differential equations.

These packages will be a good starting point on your Julia journey. There are many more useful packages that we will talk about later.


Julia packages for algorithmic trading

Algorithmic trading is an example of a field that requires intensive computing capabilities in some cases. In such a field, processing data faster using an easy-to-write programming language can add a lot of value for traders and investors.

It could also open up the space for non-expert programmers who want to get started and be more actively involved.

Julia has various registered packages available for quantitative finance, such as:

  1. MarketTechnicals.jl – For financial time series technical analysis.
  2. FinancialDerivatives.jl – For financial derivatives modelling and pricing
  3. QuantLib.jl – Aims to provide a Julia version of QuantLib written in C++.
  4. QuantEcon.jl – For quantitative economics
  5. Jib.jl – Julia implementation of Interactive Brokers API
  6. BusinessDays.jl – Highly optimised business days calculator written in Julia
  7. Quandl.jl – For data from Quandl
  8. YStockData.jl – For data from Yahoo Finance
  9. TradingLogic.jl – For backtesting and live trading

Some of these packages are not very stable since Julia is still an emerging language. They should give us an idea of the possibilities and the enthusiasm for this language in quantitative finance.

Bibliography

  1. https://julialang.org/
  2. https://julialang.org/downloads/
  3. https://juliacomputing.com/

Visit QuantInsti for additional insight on this topic: https://blog.quantinsti.com/julia-programming/.

Disclosure: Interactive Brokers

Information posted on IBKR Traders’ Insight that is provided by third-parties and not by Interactive Brokers does NOT constitute a recommendation by Interactive Brokers that you should contract for the services of that third party. Third-party participants who contribute to IBKR Traders’ Insight 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 permission from QuantInsti. The views expressed in this material are solely those of the author and/or QuantInsti and IBKR 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 sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation to buy, sell or hold such security. 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.

In accordance with EU regulation: The statements in this document shall not be considered as an objective or independent explanation of the matters. Please note that this document (a) has not been prepared in accordance with legal requirements designed to promote the independence of investment research, and (b) is not subject to any prohibition on dealing ahead of the dissemination or publication of investment research.

Any trading symbols displayed are for illustrative purposes only and are not intended to portray recommendations.

Disclosure: API Examples Discussed

Throughout the lesson, please keep in mind that the examples discussed are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.