Kategorien
Hobbies

Skydiving – Beginner guide

Skydiving has always been on my bucket list and in July 2017 I fulfilled my dream. I did my first solo jump in Alvor, a small village in the south of Portugal. It was an incredible experience and I would like to share it here with you and give you some tips on how you can start skydiving. Today I have over 220 skydives there will be much more to come!

I just finished my bachelor in Banking and Finance at the University of Zurich and I spontaneously decided to do my skydiving license. After some research on the internet, I discovered the dropzone in Alvor. It is one of the largest and most professional dropzones in Europe and in January 2017 I contacted the dropzone and booked 4 weeks of holiday in Alvor and the Expert Package for 2’861 Euros (cf. here). In total, the package includes 25 jumps and finally, you will receive the American skydiving licence (USPA).

To receive your skydiving licence you start with the Accelerated freefall (AFF) course. This course is subdivided into 8 levels you need to pass one by one. Each level focuses on single movements in the air with the main goal that you can stabilise yourself in the air, move forward & backwards and be confident in freefall.

Step 1: Accelerated freefall (AFF) – all 8 Levels explained

  • Level 1: Your first skydive!
    This will be the scariest one since it will be the first time you jump out of the plane by yourself – however, it will also be the most exciting one. During the jump, two instructors will hold onto you and you need to perform 3 practice pulls. In other words, you just need to touch the bridle 3 times. This might sound very easy but under extreme conditions, this can be hard as we are not used to jumping out of planes and fall 200 km/h to the ground.
  • Level 2: Refine your body position
    The body position is key for a stable exit and freefall. You will have been practising arching on the ground for hours and put it into practice in the air. Strong legs, relaxed arms and a tensed butt will result in a smooth arching position. Again this sounds easy but during the exit students often forget what do to. I had the feeling that during the first 3 seconds of the skydive my brain shut down and didn’t remember that I must arch to get into a stable position. 
  • Level 3: Instructors release you
    This will be the first time you will be flying totally by yourself! It is a great feeling but you will realise very fast that you are less stable when the instructors release you.
  • Level 4: Practice 90 degrees turns
    On this skydive, you will be accompanied by just 1 instructor. You will practice 90 degree turns in both directions.
  • Level 5: Practice 360-degree turns
    Similar in content to level 4, only this time you will practice turning a full 360 degrees in both directions. You will gain the basic skills required to turn around in free fall.
  • Level 6: Gain confidence in your own stability
    You will perform a „front loop“ – a little like a summersault in mid air and then regain your stability. You will also practice „tracking“ – rapid forward moving designed to create distance between you and other skydivers.
  • Level 7: Putting it all together
    You are soon done with your AFF! In this jump you will perform everything you have learned during the first jumps: You will exit the aircraft, perform a front loop, turn 360 degrees to your left and to your right and then track away from the instructor at the end of the skydive.
  • Level 8: Hop ’n‘ Pop
    This is the least technical jump. You will be jumping from 5000ft (compared to the 14500ft jumped in Level 1-7) and open your parachute a few seconds after the exit.

Finally, you’re done with your AFF! When the weather is good and you are a talented skydiver you will pass all the levels in the first go and within a week! I passed all levels in the first go and about 5 days to finish my AFF. 

Step 2: Pack your parachute

For the USPA licence, you are required to be able to pack your own parachute. You will be spending a whole day learning how to pack it and you will realise that it is a pain to pack it properly and each packjob will take you around 40 minutes at the beginning!

Step 3: 12 Consoljumps

Now comes the fun part! You just need to jump 10 times out of a plane by yourself. At this stage, you will get a better feeling for the time in the air. During the AFF I thought that the 60 seconds of freefall seems really short and there is no time to do anything else than what I am supposed to do. However, time is relative and you will realise that time passes slower when you are confident in the air and you will for the first time enjoy the view.

Step 4: Group jumps

Now it gets serious again. To receive the USPA license you need to be able to jump with other skydiver and perform docks. After you did 4 group jumps with maximum 4 other jumpers you will realise that jumping in groups is much more fun compared to jumping solo.

Step 5: Some theory

As with every license you need to do a theory test and some small practical tests (e.g. spotting the airfield, understanding the winds, …) that can be done within a day.

After this, you are a fully fledged skydiver! Congratulations.

Kategorien
Finance Research

Option valuation using Black-Scholes

Financial options have an intrinsic and a time value. The intrinsic value for a call option is simply the spot (S) minus the strike price (X). The time value of the call option can be derived using the Black-Scholes formula. The resulting price of the option minus the intrinsic value of the option results in the time value of the option.

The following graph illustrates the intrinsic value (red line), the price of the option (grey line) and the time value of the option (dark grey area).

Using the following code you can replicate the figure:

spot <- seq(1,100,by=1)
strike <- 50
riskfree <- 0
time <- 1
standarddev <- 0.2

d1 <- (log(spot/strike)+(0+standarddev^2/2)*1)/(standarddev*time)
d2 <- d1-standarddev*time^(1/2)

value.call <- pnorm(d1,0,1)*spot-pnorm(d2,0,1)*strike*exp(-riskfree*time)

inner.value <- spot-strike
inner.value <- pmax(inner.value,0)

require(ggplot2)

ggplot()+
geom_line(aes(spot,value.call))+
geom_line(aes(spot,inner.value),colour="red")+ geom_ribbon(aes(spot,ymin=value.call,ymax=inner.value),fill="darkgrey")

Kategorien
Finance Research

Efficient frontier in Finance

In every finance class, one of the first topics students are confronted with is the efficient frontier. Even though the intuition behind the efficient frontier might be easy to grasp, I show you that it can also be very easy to derive the efficient frontier – even using multiple assets.

Using the following code you can replicate the image:


stocks <- c("TSLA","AAPL", "FB")

require(PerformanceAnalytics)
require(quantmod)

getSymbols(stocks)

x<- dailyReturn(TSLA)
y <- dailyReturn(AAPL)
z <- dailyReturn(FB)


g <- as.data.frame(cbind(x,y,z))
a <-as.data.frame(cov(g[2000:2620,]))


library(data.table)
library(scales)
library(ggplot2)

link <- "https://raw.githubusercontent.com/DavZim/Efficient_Frontier/master/data/fin_data.csv"
dt <- data.table(read.csv(link))
dt[, date := as.Date(date)]

# create indexed values
dt[, idx_price := price/price[1], by = ticker]

# plot the indexed values
ggplot(dt, aes(x = date, y = idx_price, color = ticker)) +
geom_line() +
# Miscellaneous Formatting
theme_bw() + ggtitle("Price Developments") +
xlab("Date") + ylab("Pricen(Indexed 2000 = 1)") +
scale_color_discrete(name = "Company")


# calculate the arithmetic returns
dt[, ret := price / shift(price, 1) - 1, by = ticker]

# summary table
# take only non-na values
tab <- dt[!is.na(ret), .(ticker, ret)]

# calculate the expected returns (historical mean of returns) and volatility (standard deviation of returns)
tab <- tab[, .(er = round(mean(ret), 4),
sd = round(sd(ret), 4)),
by = "ticker"]


ggplot(tab, aes(x = sd, y = er, color = ticker)) +
geom_point(size = 5) +
# Miscellaneous Formatting
theme_bw() + ggtitle("Risk-Return Tradeoff") +
xlab("Volatility") + ylab("Expected Returns") +
scale_y_continuous(label = percent, limits = c(0, 0.03)) +
scale_x_continuous(label = percent, limits = c(0, 0.1))

link <- "https://raw.githubusercontent.com/DavZim/Efficient_Frontier/master/data/mult_assets.csv"
df <- data.table(read.csv(link))

# calculate the necessary values:
# I) expected returns for the two assets
er_x <- mean(df$x)
er_y <- mean(df$y)

# II) risk (standard deviation) as a risk measure
sd_x <- sd(df$x)
sd_y <- sd(df$y)

# III) covariance
cov_xy <- cov(df$x, df$y)

# create 1000 portfolio weights (omegas)
x_weights <- seq(from = 0, to = 1, length.out = 1000)

# create a data.table that contains the weights for the two assets
two_assets <- data.table(wx = x_weights,
wy = 1 - x_weights)

# calculate the expected returns and standard deviations for the 1000 possible portfolios
two_assets[, ':=' (er_p = wx * er_x + wy * er_y,
sd_p = sqrt(wx^2 * sd_x^2 +
wy^2 * sd_y^2 +
2 * wx * (1 - wx) * cov_xy))]

# lastly plot the values
ggplot() +
geom_point(data = two_assets, aes(x = sd_p, y = er_p, color = wx)) +
geom_point(data = data.table(sd = c(sd_x, sd_y), mean = c(er_x, er_y)),
aes(x = sd, y = mean), color = "red", size = 3, shape = 18) +
# Miscellaneous Formatting
theme_bw() + ggtitle("Possible Portfolios with Two Risky Assets") +
xlab("Volatility") + ylab("Expected Returns") +
scale_y_continuous(label = percent, limits = c(0, max(two_assets$er_p) * 1.2)) +
scale_x_continuous(label = percent, limits = c(0, max(two_assets$sd_p) * 1.2)) +
scale_color_continuous(name = expression(omega[x]), labels = percent)

##### Three assets ###################

# load the data
link <- "https://raw.githubusercontent.com/DavZim/Efficient_Frontier/master/data/mult_assets.csv"
df <- data.table(read.csv(link))

# calculate the necessary values:
# I) expected returns for the two assets
er_x <- mean(df$x)
er_y <- mean(df$y)
er_z <- mean(df$z)

# II) risk (standard deviation) as a risk measure
sd_x <- sd(df$x)
sd_y <- sd(df$y)
sd_z <- sd(df$z)

# III) covariance
cov_xy <- cov(df$x, df$y)
cov_xz <- cov(df$x, df$z)
cov_yz <- cov(df$y, df$z)

# create portfolio weights (omegas)
x_weights <- seq(from = 0, to = 1, length.out = 1000)

# create a data.table that contains the weights for the three assets
three_assets <- data.table(wx = rep(x_weights, each = length(x_weights)),
wy = rep(x_weights, length(x_weights)))

three_assets[, wz := 1 - wx - wy]


# calculate the expected returns and standard deviations for the 1000 possible portfolios
three_assets[, ':=' (er_p = wx * er_x + wy * er_y + wz * er_z,
sd_p = sqrt(wx^2 * sd_x^2 +
wy^2 * sd_y^2 +
wz^2 * sd_z^2 +
2 * wx * wy * cov_xy +
2 * wx * wz * cov_xz +
2 * wy * wz * cov_yz))]

# take out cases where we have negative weights (shortselling)
three_assets <- three_assets[wx >= 0 & wy >= 0 & wz >= 0]
three_assets

# lastly plot the values
ggplot() +
geom_point(data = three_assets, aes(x = sd_p, y = er_p, color = wx - wz)) +
geom_point(data = data.table(sd = c(sd_x, sd_y, sd_z), mean = c(er_x, er_y, er_z)),
aes(x = sd, y = mean), color = "red", size = 3, shape = 18) +
# Miscellaneous Formatting
theme_bw() + ggtitle("Possible Portfolios with Three Risky Assets") +
xlab("Volatility") + ylab("Expected Returns") +
scale_y_continuous(label = percent, limits = c(0, max(three_assets$er_p) * 1.2)) +
scale_x_continuous(label = percent, limits = c(0, max(three_assets$sd_p) * 1.2)) +
scale_color_gradientn(colors = c("red", "blue", "yellow"),
name = expression(omega[x] - omega[z]), labels = percent)

Kategorien
Finance Research

Create your own badman logo in R

This was a fun project to replicate the badman logo using a mathematical function (badman function).

Using the following code you can replicate the image:

require(ggplot2)
require(dplyr)

f1 <- function(x) {
y1 <- 3*sqrt(1-(x/7)^2)
y2 <- -3*sqrt(1-(x/7)^2)
y <- c(y1,y2)
d <- data.frame(x=x,y=y)
d <- d[d$y > -3*sqrt(33)/7,]
return(d)
}

x1 <- c(seq(3, 7, 0.001), seq(-7, -3, 0.001))
d1 <- f1(x1)
p1 <- ggplot(d1,aes(x,y)) + geom_point(color="green")

x2 <- seq(-4,4, 0.001)
y2 <- abs(x2/2)-(3*sqrt(33)-7)*x2^2/112-3 + sqrt(1-(abs(abs(x2)-2)-1)^2)

#only work with ggplot2 <= 0.8.9
#p2 <- p1 + geom_point(aes(x=x2,y=y2), color="yellow")

# in ggplot2 0.9.0, should be:
d2 <- data.frame(x2=x2, y2=y2)
p2 <- p1 + geom_point(data=d2, aes(x=x2,y=y2), color="green")


x3 <- c(seq(0.75,1,0.001), seq(-1,-0.75,0.001))
y3 <- 9-8*abs(x3)
#p3 <- p2+geom_point(aes(x=x3,y=y3), color="green")
d3 <- data.frame(x3=x3, y3=y3)
p3 <- p2+geom_point(data=d3, aes(x=x3,y=y3), color="green")


x4 <- c(seq(0.5,0.75,0.001), seq(-0.75,-0.5,0.001))
y4 <- 3*abs(x4)+0.75
#p4 <- p3+geom_point(aes(x=x4,y=y4), color="steelblue")
d4 <- data.frame(x4=x4,y4=y4)
p4 <- p3+geom_line(data=d4, aes(x=x4,y=y4), color="green")


x5 <- seq(-0.5,0.5,0.001)
y5 <- rep(2.25,length(x5))
#p5 <- p4+geom_point(aes(x=x5,y=y5))
d5 <- data.frame(x5=x5,y5=y5)
p5 <- p4+geom_line(data=d5, aes(x=x5,y=y5),color="green")

x6 <- c(seq(-3,-1,0.001), seq(1,3,0.001))
y6 <- 6 * sqrt(10)/7 +
(1.5 - 0.5 * abs(x6)) * sqrt(abs(abs(x6)-1)/(abs(x6)-1)) -
6 * sqrt(10) * sqrt(4-(abs(x6)-1)^2)/14
#p6 <- p5+geom_point(aes(x=x6,y=y6), colour="blue")
d6 <- data.frame(x6=x6,y6=y6)
p6 <- p5+geom_line(data=d6,aes(x=x6,y=y6), colour="green")

p <- p6

theme_black<- function (base_size = 16, base_family = ""){
theme_minimal() %+replace%
theme( line = element_line(colour = "black", size = 0.5, linetype = 1,
lineend = "butt"),
rect = element_rect(fill = "black",
colour = "black", size = 0.5, linetype = 1),
plot.background = element_rect(colour = 'black', fill = 'black'),
plot.title = element_text(size = rel(1.2)),
panel.border = element_rect(fill = NA, colour = "black"),axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
panel.grid.major = element_blank(), panel.grid.minor = element_blank()
)
}


p+theme_black()