0% found this document useful (0 votes)
30 views6 pages

CQF January 2016 M1S1 Explorations

Uploaded by

trashworkmainak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views6 pages

CQF January 2016 M1S1 Explorations

Uploaded by

trashworkmainak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Random Behaviour of Assets

CQF Lecture One Explorations

CQF Lecture One exercises are explorations intended for you to do some experimentation
with (1) returns estimation, (2) histogram and (3) Q-Q plots. The purpose is seeing how
robust (or not) the estimates and rules are. By estimating returns over √ different timescales
you re-discover the scaling of volatility σ with the square root of time δt.

1. Multi-period projection with log-returns vs. linear returns for the asset price St

St+1 St+1
Rts = −1 vs. Rtc = ln
St St
Rts = exp Rtc − 1

For log-returns (compounded returns),


A τ -period log return is simply the sum of the single-period log returns over τ /n periods,
because it is additive in the exponent.

Rt+τ = Rt + Rt+1 + Rt+2 + · · · + Rt+n−1

R1Y = R1M + R2M + · · · + R12M

where R1M is monthly return for [0, 1M], R2M is monthly return for [1M, 2M] and so on
to R12M as monthly return for [11M, 12M] (strictly following notation, we would have
written Rt as R11M ). The multi-period returns are simple to obtain.

For linear returns (simple returns),


Projecting with linear returns from single periods over a longer time period (converting
timescales) involves multiplication.

1 + Rt+τ = (1 + Rt ) × (1 + Rt+1 ) × · · · × (1 + Rt+n−1 )

1 + R1Y = (1 + R1M ) × (1 + R2M ) × · · · × (1 + R12M )

1 + r1Y = (1 + r1M ) × (1 + f2M ) × · · · × (1 + f12M )

This is also a relationship between the long term simple rate and a set of forward rates.
The notation is fitting because r1M applies over [0, 1M] and f12M is a forward rate
known at the start of [11M, 12M] period.

The exercises have been edited by CQF Faculty, Richard Diamond, [email protected]

1
There are several rules about the use of returns that create common pitfals in
estimation and portfolio management.

While returns are free from a scale in dollars, they are not unitless – their unit is time.
Returns are always estimated over some ‘timescale’, most common is daily timescale
where for Rt+τ − Rt the τ = 1/252.

The square-root rule for volatility σ δt applies under the assumption that the com-
pounded returns are invariants – they behave identically and independently across time.

The familiar variance minimisation (MVP, Markowitz) objective function is defined for
linear returns.
argmin {w0 µτ − λw0 Στ w}
w

where subscript in µτ and Στ means their estimation from market data of respective
frequency,e.g., τ = 1/252 daily.

The linear returns (not log-returns) aggregate across assets. Return calculation for a
portfolio of N assets is done as a weighted average of their individual returns.

Rt,Π = w1 Rt,1 + w2 Rt,2 + w3 Rt,3 + · · · + wN Rt,N

2
2. Histogram is a graphic representation of probability density function f (x), a pdf. It is
also a discrete representation. To built a histogram one actually engages in estimation
of density as follows:

1
f (x) = nj
Nh
where nj is the varying number of observations in a bucket, h is our bandwidth –
bucket/window size on the scale of real numbers R, and N is the sample size.

nj /N gives frequency, while nj /N h is ‘a chunk’ of density also called probability mass.


If we set the window size so small that it includes only one observation, then for each
chunk the pdf is f (x) = 1/N h, where 1/h is a normalising parameter.

With the proper ‘kernel smoothing’ methods small bandwidth setting h will produce
a histogram that repeats the plotted data (low smoothness), while sufficiently high
bandwidth will smooth the representation into a symmetric histogram as if the returns
are Normally distributed.

Figure 1: Histogram of SPX log-returns, built in R environment (code below).

1000 breakpoints were used. It is recommended that you experiment by setting the
number of breakpoints higher (gives low smoothness) and lower but not too low.

3
3. Building a Q-Q plot in explicit steps is more straightforward in Excel because you can
follow the transformations and organise the data in matching columns.

Implementing the steps, you will obtain a result alike the following table. ‘Historic’
stands for the actual S&P 500 return, followed by ‘Scaled’ return (Z-score), indexes and
the Standard Normal Percentile which corresponds to the cumulative probability given
by i/N . Notice one past negative return that was in excess of 21 standard deviations!

Historic Scaled i i/N Standard PDF 1/N CDF i/N


-0.22900 -21.20462 1 0.00009 -3.74534 0.00009 0.00009
-0.09470 -8.78146 2 0.00018 -3.56758 0.00009 0.00018
-0.09354 -8.67429 3 0.00027 -3.45987 0.00009 0.00027
-0.09219 -8.54970 4 0.00036 -3.38162 0.00009 0.00036
-0.08642 -8.01584 5 0.00045 -3.31983 0.00009 0.00045
-0.07922 -7.35036 6 0.00054 -3.26858 0.00009 0.00054
... ... ... ... ... ... ...

Table 1: Left: Inputs for a Q-Q plot. Right: Empirical PDF and CDF

3.1 Q-Q Plot step-by-step


(a) Scale empirical log-returns rt to be the Normal variables Zt = rtσ−µ . For a market
index the average daily return µ ≈ 0, that is increasingly valid for a large sample.
(b) Sort the scaled returns in the ascending order and create an index column i = 1..N .
(c) For each observation, the individual probability density (probability mass) is 1/N
and the cumulative density is i/N . This allows to obtain percentiles.
(d) The standardised percentile is obtained with the inverse cumulative density Φ−1 (i/N ).

Plot the scaled returns (Z-scores) from step (a) against the theoretical percentiles from
step (d). For the perfectly Normal log-returns the Q-Q plot would be a straight line.

Figure 2: Q-Q Plot built step by step.

4
3.2 Q-Q Plot with R libraries Time series experiments are best conducted in the
suitable environment. Most of the student and analytical tools (Eviews, Stata, SPSS,
SAS) package the modelling into standardised statistical tests and procedures. They
allow you to modify parameters but rarely the procedure itself.

We have selected R environment for its convenience in manipulating the time series and
intuitive facilities of programming language. It is also noticeable that statistical tests
were implemented by specialists – the output is organised to present what is important.
A quant job requires the active knowledge of the chosen libraries, e.g., ‘zoo’ objects for
time series analysis, ‘quantlib’ main library of the functions for a financial quant, and
‘urca’ library for working with non-stationary time series (cointegration testing).

Figure 3: Q-Q Plot for SPX log-returns.

R Code: The code below reads from SPX.xls file distributed with Lecture One (saved
as .csv ). It selects certain sub-sample and plots a histogram and Q-Q plot.

######################################################################
# 2015. Richard Diamond. Quieries to [email protected] #
# CQF Lecture One #
######################################################################

prices.zoo = read.zoo("SPX.csv", header=TRUE, sep=",", format = "%d/%m/%y")


prices.this = window(prices.zoo, start=as.Date("1950-01-03"), end=as.Date("2013-01-03"))
plot(prices.this$Close, main = "SPX Closing Prices", ylab = "Price (USD)", xlab = "Date")

5
# P1 Invariants. IID Check (histogram)
returns.this = diff(log(prices.this$Close))
hist(returns.this, breaks=1000, main = "Histogram of SPX Log-Returns", xlab="%")

# P2 Estimation. Normality Check (Q-Q plot)


qqnorm(returns.this, ylab = "SPX Log-Returns")
qqline(returns.this)

The following section of the R code replicates the steps that you might like to do in
Excel in the first instance. It provides an example of matrix manipulation in R. Code
comments abridged.

######################################################################
# 2015. Richard Diamond. Quieries to [email protected] #
# CQF Lecture One. Q-Q Plot Step-by-step #
######################################################################

# P2.1 Empirical density


sreturns.this = (returns.this - mean(returns.this))/ sd(returns.this) #the long way
sreturns.this = scale(returns.this, center=TRUE, scale=TRUE) # each value is a Z-score

plot(sreturns.this, main = "SPX Standardised Returns (Z-scores)",


ylab = "Standard Deviation", xlab = "Date")

# P2.2 Building a data matrix (table for presentation)


sreturns.N = length(sreturns.this)
sreturns.data = matrix(rep(NA, sreturns.N), sreturns.N, 3) #an empty structure
# dim(sreturns.data)

for(i in 1:sreturns.N)
{
sreturns.data[i,1]=i # This can be using seq(1:sreturns.N)
sreturns.data[i,2]=i/sreturns.N
sreturns.data[i,3]= qnorm(i/sreturns.N) # Can this be more efficient computationally?
}
sreturns.data = cbind(sort(as.vector(sreturns.this)), sreturns.data)
# This is a tricky line: sorting a vector of scaled returns and appending it the data matrix

# P2.3 Q-Q Plot


plot(sreturns.data[,4],sreturns.data[,1], main = "Q-Q Plot for Standardised Returns (Z-scores)"
ylab = "Historic Standardised", xlab = "Standard Normal")

You might also like