Random Portfolio using R to create investment strategy for Hedge Fund

25
Lujiazui Hedge Fund Inc. Ryota Arafuka Kuang-Po Lee Krunal Naik Jiaqi Wang Jianhua Yen

Transcript of Random Portfolio using R to create investment strategy for Hedge Fund

Page 1: Random Portfolio using R to create investment strategy for Hedge Fund

Lujiazui Hedge Fund Inc.

Ryota Arafuka

Kuang-Po Lee

Krunal Naik

Jiaqi Wang

Jianhua Yen

Page 2: Random Portfolio using R to create investment strategy for Hedge Fund

Investment Portfolio Diversification

• Asset allocation diversification Horizontal diversification Vertical diversification

• Geographic diversification

Page 3: Random Portfolio using R to create investment strategy for Hedge Fund

Hedge Fund Investment Portfolio

Source: “Global Survey Hedge Fund and Investor Survey 2012” by Ernst & Young

Page 4: Random Portfolio using R to create investment strategy for Hedge Fund

Our Investment Style

• Relative value Fixed income arbitrage Convertible arbitrage Equity market neutral Event driven

• Directional Equity long/short Macro CTA

Page 5: Random Portfolio using R to create investment strategy for Hedge Fund

Our Objectives Equal Contribution to

•Weight - Gives the portfolio diversification

•Variance- Allocates portfolio variance equally across the portfolio components

•Risk- Directly diversify downside risk among components by using ETL contribution

Page 6: Random Portfolio using R to create investment strategy for Hedge Fund

Random Portfolio

• Random permutations of weights• Selected criteria• High frequency long/short• Multi-strategy• Model should be self sustained with decisions confined

by set of constraints• Assign probabilities to strategies corresponding to

calculated risks in given scenario

Page 7: Random Portfolio using R to create investment strategy for Hedge Fund

R Language for Random Portfolio

Page 8: Random Portfolio using R to create investment strategy for Hedge Fund

Application Example

• Total value : $10m• No. of selected assets for RP=50• Constraints

Long-only 50 to 60 names No asset may have more than 4% weight Industry spread : 10 S&P 500, random portfolio, and previous portfolio will be

benchmark Duration considered 12 months Frequency 10

(Relatively low for us, but this is for testing model)

Page 9: Random Portfolio using R to create investment strategy for Hedge Fund

Cumulative Trading

Page 10: Random Portfolio using R to create investment strategy for Hedge Fund

Comparison of Value with S&P 500

Page 11: Random Portfolio using R to create investment strategy for Hedge Fund

Industries Port wtConsumer

Discretionary 29.56Consumer Staples 11.26

Energy 7.01Financials 4.43

Health Care 11.61Industrials 9.63

Information Technology 10.57Materials 11.42

Telecommunications Services 0Utilities 4.51

Total 100

Weight Distribution

Page 12: Random Portfolio using R to create investment strategy for Hedge Fund

Industries Port ret Bench retConsumer

Discretionary 7.33 1.36Consumer Staples -1.13 4.98

Energy 31.2 30.52Financials 8.41 7.96

Health Care 27.33 7.8Industrials 17.3 22.47

Information Technology 14.26 19.65Materials 84.71 48.53

Telecommunications Services 0 0Utilities 3.92 5.96

Total 20.79 13.64

Cumulative Returns

Page 13: Random Portfolio using R to create investment strategy for Hedge Fund

Portfolio optimization Using R

Page 14: Random Portfolio using R to create investment strategy for Hedge Fund

Efficient Frontier

Page 15: Random Portfolio using R to create investment strategy for Hedge Fund

Efficient Frontier with Short-selling

Page 16: Random Portfolio using R to create investment strategy for Hedge Fund

Measure of Portfolio Performance:

•Annualized return•Annualized standard deviation•VAR and ES (Expected shortfall)•Sharp ratio, Omega Ratio, Sortino Ratio

Implementation of R – Using package PerformanceAnalytics

Page 17: Random Portfolio using R to create investment strategy for Hedge Fund

Code to Create Artificial Stocks

• # create the antithetic pair of stocks and publish it into the environment• # generate sequence of dates• times <- seq(as.POSIXct(strptime('2011-01-1 16:00:00', '%Y-%m-%d %H:%M:%S')),•                       as.POSIXct(strptime('2011-12-1 16:00:00', '%Y-%m-%d %H:%M:%S')),•                       by="1 months")•  • # generate and store dummy price series = 200,100,200,100,200 ...• prices.xts <- xts(rep(c(200,100),length(times)/2), order.by=as.POSIXct(times))• stk <- 'STK1'• colnames(prices.xts) <- paste(stk,'.Adjusted',sep="")• assign(x=stk, value=prices.xts, envir=global.env )•  • # generate and store dummy price series = 100,200,100,200,100 ...• prices.xts <- xts(rep(c(100,200),length(times)/2), order.by=as.POSIXct(times))• stk <- 'STK2'• colnames(prices.xts) <- paste(stk,'.Adjusted',sep="")• assign(x=stk, value=prices.xts, envir=global.env )•  • # run the strategy and create a plot• strategy(portfolio= c("STK1","STK2"),threshold=.9,doplot=TRUE,title="Artificial Portfolio Example")

Page 18: Random Portfolio using R to create investment strategy for Hedge Fund

Download Option Data from Yahoo Finance

• # Goal: download adjusted price data for selected security, convert to returns, and write to output file•  • library(tseries)•  • # Load security data from Yahoo! Finance• prices1 <- get.hist.quote("SPY", quote="Adj", start="2005-12-25", retclass="zoo")•  • prices1 <- na.locf(prices1)               # Copy last traded price when NA•  • # To make week end prices:• nextfri.Date <- function(x) 7 * ceiling(as.numeric(x - 1)/7) + as.Date(1)• weekly.prices <- aggregate(prices, nextfri.Date,tail,1)•  • # To convert month end prices:• monthly.prices <- aggregate(prices1, as.yearmon, tail, 1)•  • # Convert weekly prices into weekly returns• r.weekly <- diff(log(weekly.prices)) # convert prices to log returns• r1.weekly <- exp(r.weekly)-1          # back to simple returns•  • # Convert monthly prices into monthly returns• r.monthly <- diff(log(monthly.prices))  # convert prices to log returns• r1.monthly <- exp(r.monthly)-1          # back to simple returns•  • # Write output data to csv file• write.zoo(r1.weekly, file="weekly.csv",sep=",",col.names=c("Dates","Percent Return"))• write.zoo(r1.monthly, file="monthly.csv",sep=",",col.names=c("Dates","Percent Return"))

Page 19: Random Portfolio using R to create investment strategy for Hedge Fund

Code to Generate Random Portfolio

require(PortfolioProbe)

rp100w05 <- random.portfolio(1e4, prices=sp5.close[1,],

gross=1e6, long.only=TRUE, port.size=100,

max.weight=.05)

Then the returns are computed:

sret.rp100w05 <- valuation(rp100w05, prices=sp5.close[c language="(1,1511),"][/c], returns="simple") lret.rp100w05 <- valuation(rp100w05, prices=sp5.close[c language="(1,1511),"][/c], returns="log")

Page 20: Random Portfolio using R to create investment strategy for Hedge Fund

R code for Adjusting Weight

> pp.bootsim

function (retmat, weight, times=252)

{ dlar <- retmat[sample(nrow(retmat), times,

replace=TRUE),]

pp.porteval(dlar, weight) }

Page 21: Random Portfolio using R to create investment strategy for Hedge Fund

R Code for Portfolio Optimization

Page 22: Random Portfolio using R to create investment strategy for Hedge Fund

R Code for Portfolio Evaluation

> pp.porteval

function (dlar, weight)

{

(exp(colSums(dlar[, names(weight)])) - 1) %*%

weight

}

Page 23: Random Portfolio using R to create investment strategy for Hedge Fund
Page 24: Random Portfolio using R to create investment strategy for Hedge Fund

Optimization with Truncated Straddle using R

Page 25: Random Portfolio using R to create investment strategy for Hedge Fund

Simulation Result for Portfolio 100