The Problem The reason you are not able to add any more stocks without adding any more months (years) appears to be related to the problem of minimizing the mean-variance. From Cochrane "Asset Pricing" page 81-83 : Theorem: So long as the variance-covariance matrix of returns is non-singular, there is...

r,quantmod,portfolio,trading,algorithmic-trading

I'm not exactly sure what you want the output to be, but see if this is close m <- merge(close.prices, BBands(close.prices, n=20, maType="SMA")) m$sig[with(m, IBM > up) & index(m) %in% index(m)[startpoints(m, on="weeks")]] <- 1 m$sig[with(m, IBM < dn) & index(m) %in% index(m)[startpoints(m, on="weeks")]] <- 0 m$sig[1] <- 0 na.locf(m) ...

apply returns a matrix which needs to be converted to a zoo object. To insure that the dates in the new zoo series match the dates returned by the TTR function, you could first define a function with the TTR function and any parameters used by it and then use...

The main idea here is to work in terms of dollars instead of ratios. If you keep track of the number of shares and the relative dollar values of the ibm and ford shares, then you can express the criterion for rebalancing as mask = (df['ratio'] >= 1+tol) | (df['ratio']...

flex,pdf-generation,flash-builder,portfolio,alivepdf

AlivePDF still works for me. You can use it with FileReference like this: var bytes:ByteArray = pdf.save(Method.LOCAL); saveData(bytes, fileName); public static function saveData(data:*, filename: String, parent: Sprite): Alert { function closeHandler(event: CloseEvent): void { if (event.detail == Alert.YES) { // due to security restrictions FileReference.save() // can only be invoked...

r,quantmod,stock,portfolio,algorithmic-trading

How I would have coded your example: require(quantmod) tickers <- c("ABI.BR","AI.PA","AIR.PA","ALV.DE","ASML.AS") myEnv <- new.env() getSymbols(tickers, from="2012-01-01", to="2013-12-01", env=myEnv) close.prices <- do.call(merge, eapply(myEnv, Cl)) close.prices <- close.prices[,pmatch(tickers,colnames(close.prices))] colnames(close.prices) <- c("Anheuser-Busch InBev", "L'Air Liquide","AIRBUS GROUP","Allianz","ASML HLDG") assets.ret <- ROC(close.prices,type="discrete")[-1] rsi.fct <- function(x) RSI(x, n=20, maType =...

r,for-loop,vectorization,portfolio

This uses the function cummax to identify a series of qualifying points by then testing against the original data: > data <- data[order(data$Stdev),] > data[ which(data$AvgReturn == cummax(data$AvgReturn)) , ] Stdev AvgReturn 24 0.81 0.21 19 0.88 0.22 13 0.96 0.24 9 1.05 0.27 5 1.16 0.30 3 1.39 0.31...

wordpress,url,hyperlink,href,portfolio

Use "Search and Replace Script" as advised by the WordPress Codex. Use to replace 1 with 2: domain.com/ftpfolder/page domain2.com/page Oh, did I tell you to do a backup first?...

html,css,wordpress,floating,portfolio

In style.css you have this rule (which seems to be a reset): html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{ font-size:100%; font:inherit; padding:0;...

r,mathematical-optimization,portfolio,quadratic

There were two issues with the code you posted: The posted Dmat is not actually symmetric; you had accidentally included value 212.31581 instead of 12.31581 The meq=2 option means your first two constraints are held at equality, meaning your weights sum to 1 and your return is exactly 5.2%. The...