www.kkb.io

Kyle Balkissoon

KKB Research and Development

2016-10-26

At the end of this presentation you will know how to the following

- Get Data
- Process Data
- Create Portfolio objectives
- Optimize Portfolios
- Analyse Portfolios
- Case Study: Stance Equity

Before we can do anything we need data, some good R libraries for getting data are:

```
library(Quandl) # see Quandl.com for more info
library(quantmod) #Has preconfigured api with yahoo info
```

```
##Quandl - Note requires assignment, type xts is xtensible time series
SPTSXComp=Quandl("YAHOO/INDEX_GSPTSE",type='xts')
##quantmod - assigns to object named GSPTSE - automatically in xts/zoo
getSymbols("^GSPTSE")
```

```
symbol_list = c('XLF','XLE','XLU','XLK','XLB','XLP','XLY','XLI','XLV')
getSymbols(symbol_list, from = '1990-01-01')
getSymbols("SPY",from='1990-01-01')
```

```
library(PerformanceAnalytics)
```

```
securities_matrix = NULL
for( sym in symbol_list){
securities_matrix = merge.xts(securities_matrix,
Return.calculate(Ad(get(paste(sym))),
method='discrete'))}
securities_matrix=securities_matrix[complete.cases(securities_matrix)]
SPYReturn=Return.calculate(Ad(SPY),method='discrete')
```

- Library to compute many functions in return space
- Used by hedge funds, proprietary trading firms, mutual funds, SMA's and banks
- Robust tools for measuring portfolio and security performance with all the standard risk metrics.

```
chart.CumReturns(securities_matrix)
```