Quantitative Finance with R

Audience level:
Novice

Description

An introduction to various concepts in mathematical finance, and related mathematics and statistics. The tutorial will brief you about how R helps finance people and will give an insight into their work. Attendees will learn the basics of Finance, Portfolio Optimization, CAPM and more. We will play with real Financial data. This tutorial requires the participants to have a Mathematics background.

Abstract

The finance industry is increasingly starting to use tools like R and Python for the purpose of understanding and analyzing the dynamics of trading and for the quantitative analysis. This talk is mostly aimed for people interested in beginning their journey towards the financial markets through the basics of finance and programming. For this tutorial, we will be using R as it comes with some of the most intuitive packages to analyse time series and finance.

The tutorial is divided into various modules, with the first modules lucidly explaining the mathematics and intuition behind the tools used in finance (ex. Random Walks, Geometric Brownian motion) along with the terminology which is common in financial institutions and needed for understanding the upcoming modules. The later modules are related to various concepts and techniques used in the domain of finance like Efficient Frontiers, Asset Pricing Models etc.

Requirements

This tutorial has some requirements from the participant's end:

• The participants should have taken at least one course in Probability and Statistics.
• R should be installed with your favourite IDE (we recommend R Studio)
• Familiarity with R is not required but will be helpful.
• You need to install the following packages:
• tseries
• xts
• zoo

• You can use the following code in the command prompt or R-console to install the packages: `install.packages(c("tseries", "xts", “zoo”))`

A detailed description of the module

Introduction to R and Finance (10 Minutes)

A brief introduction to R would be given with introduction to vectors, directions to plot graphs of various distributions, downloading data from Yahoo! Finance [1] with the tseries library. The basic concepts of finance would also be told in this section like the log returns in finance, the meaning of opening and closing prices and the concept of volatility.

The Random Walk Hypothesis and Geometric Brownian motion (20 minutes)

It has widely been observed that market often evolves according to a concept known as the random walk. A random walk is not a predictable event and hence is associated with the efficient market hypothesis. This section will introduce the audience to the concept of random walk and would further model the random walk to try to predict the prices of the stock in the foreseeable future. It would also be helpful in further parts of the course to introduce the autoregressive models and stationary processes.

The concept of Geometric Brownian motion says that the evolution of the stock prices from beginning to time t can be treated as a probabilistic model to calculate the log return prices. We will use Brownian motion-based modelling to predict European Stocks based prices (Specifically the "FTSE" index).

Efficient Frontier theory (25 Minutes)

Now that the audience have understood what do the basic terms mean and have got some experience in the domain of predicting stocks through random walks, we dive into the optimization of the portfolio of various stocks we have. It is at this stage that the concept of Efficient Frontier comes. The Efficient Frontier theory assigns a weight to each asset in the portfolio with the sum of all weights equalling 1 for the sake of normalization and tries to optimize the portfolio through manipulation of these weights while also stating the risk associated with the weights. We will use the same European stock market datasets and try varying weights to see how we can achieve the optimal portfolio of stocks.

Capital Asset Pricing Model (25 Minutes)

The Capital Asset Pricing Model is a model which demonstrates the relationship between the expected return of the stock and the systematic risk associated with it. We will use this model on the portfolio of four big companies to find out the expected return with respect to the market return. We will take the risk-free return as the US Treasury 1 Year Yield. This would help us experiment our portfolio with various weights to find out the optimal return for a period of time.

Exploring Intraday data (BONUS, If time permits)

Intraday data or the tick data is where the magic happens. We will briefly introduce the participant to market microstructure. Then we will explore four days the spot as well as future tick data of 12 NIFTY stocks. The participants will learn how to manipulate the time series and analyse the data.

[1]: We will `use get.hist.quote()` function to retrieve financial data.

We attended Mathematical Finance Summer School at Chennai Mathematical Institute (CMI) this summer and would like to transfer our knowledge to a broader crowd.