Skip to content

Commit

Permalink
move date functions to SIT.date
Browse files Browse the repository at this point in the history
Signed-off-by: systematicinvestor <[email protected]>
  • Loading branch information
systematicinvestor committed Nov 16, 2015
1 parent 1ab3800 commit eb29cc4
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 1,339 deletions.
35 changes: 35 additions & 0 deletions R/strategy.r
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,41 @@ dev.off()
}


max.div.portfolio.test <- function()
{

#*****************************************************************
# Load historical data
#******************************************************************
load.packages('quantmod')

tickers = spl('SPY,QQQ,EEM,IWM,EFA,TLT,IYR,GLD')

data = env()
getSymbols.extra(tickers, src = 'yahoo', from = '1980-01-01', env = data, set.symbolnames = T, auto.assign = T)
for(i in data$symbolnames) data[[i]] = adjustOHLC(data[[i]], use.Adjusted=T)
bt.prep(data, align='keep.all', fill.gaps = T)


#*****************************************************************
# Setup
#*****************************************************************
prices = data$prices

period.ends = date.ends(prices, 'month')

hist.returns = prices[period.ends] / mlag(prices[period.ends]) - 1

# Create historical input assumptions
ia = create.historical.ia(hist.returns, 12)

constraints = create.basic.constraints(ia$n, 0, 1, 1)

load.packages('quantmod,quadprog')

max.div.portfolio(ia, constraints)
}

#*****************************************************************
# Max Sharpe portfolio using non-linear solver, based on
# http://stackoverflow.com/questions/10526243/quadprog-optimization
Expand Down
Loading

0 comments on commit eb29cc4

Please sign in to comment.