search for: nasset

Displaying 6 results from an estimated 6 matches for "nasset".

Did you mean: asset
2009 Sep 29
3
How do I access class slots from C?
Hi I'm trying to implement something similar to the following R snippet using C. I seem to have hit the wall on accessing class slots using C. library(fPortfolio) lppData <- 100 * LPP2005.RET[, 1:6] ewSpec <- portfolioSpec() nAssets <- ncol(lppData) setWeights(ewSpec) <- rep(1/nAssets, times = nAssets) ewPortfolio <- feasiblePortfolio( data = lppData, spec = ewSpec, constraints = "LongOnly") ewSpec is an object of type Portfolio Spec which has the following slots: model slot type = "MV&...
2009 Jul 10
3
strange strsplit gsub problem 0 is this a bug or a string length limitation?
...101+A102+A103+A104+A105+A106+A107+A108+A109+A110+A111+A112+A113 benchmarkName = as.character(backtestFormula)[2] print(as.character(backtestFormula)[3]) print(benchmarkName) assetsNames <- strsplit(gsub(" ", "", as.character(backtestFormula)[3]), "\\+")[[1]] nAssets = length(assetsNames) print(nAssets) list(assetsNames) ===============output: > backtestFormula<-SPX~A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15+A16+A17+A18+A19+A20+A21+A22+A23+A24+A25+A26+A27+A28+A29+A30+A31+A32+A33+A34+A35+A36+A37+A38+A39+A40+A41+A42+A43+A44+A45+A46+A47+A48+A49+A...
2012 Sep 04
0
Calculate a minimum-variance portfolio with fPortfolio
...ll, I don't know. The constraints seem good since I would be able to construct an equal-weighted portfolio that satisfies all of them (e.g. with 5% in each asset). 4. Reproducible example: library(fPortfolio) # Data data <- SMALLCAP[, 1:20] # Constraints box.1 <- paste0("minW[1:nAssets] = ", 0) box.2 <- paste0("maxW[1:nAssets] = ", 0.10) box.3 <- "maxsumW[1:nAssets] = 1" box.4 <- "minsumW[1:nAssets] = 1" boxConstraints <- c(box.1, box.2, box.3, box.4) # Portfolio Specs Spec <- portfolioSpec() # Calculate MinVar Portfolio minvar...
2010 Mar 17
1
accessing info in object slots from listed objects using loops
...list. I figure this is because R somehow interpret "$" and "@" in get() differently than $ and @ as "list separators". Does anyone know how to extract information in slots of listed objects using a loop and on the run generated variable/object names? JT sample code nAssets = length(modelStack) for(i in 1:nAssets){ name = paste("modelStack[",i,"]@name$series$h",sep="") a = get(name) t = length(a) } # end for loop -- View this message in context: http://n4.nabble.com/accessing-info-in-object-slot...
2008 Aug 12
1
fPortfolio constraints, maxsumW
...my code file and the resulting error message are pasted below. Suggestions about how to correct my coding would be most welcome. *************Code beings here************************ Data = as.timeSeries(Jdata) Spec = portfolioSpec() setNFrontierPoints(Spec) = 150 Spec Constraint = c("minW[1:nAssets]=0", "maxsumW[1:2Assets]=13.63") frontier = portfolioFrontier(Data, Spec, Constraint) **************Error message begins here*************** Error in parse(text = constraints[i]) : unexpected symbol in "maxsumW[1:2Assets" **************Error message ends here***********...
2008 Sep 03
1
portfolio.optim and assets with weigth equals to zero...
Hello. I don't understand a particular output of portfolio.optim (tseries). I have 4 assets and the portfolio.optim returns an asset with weight equals to zero. If I do a portfolio.optim with 3 assets, without the asset with weight equals to zero, it returns a completely different result. That's I would expected the same weights as the run with 4 assets. Below the code. Thanks in