R Under development (unstable) (2024-08-23 r87049 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ################################################################################ > ## > ## $Id: portfolio.mvLong.test.R 410 2007-04-22 00:13:06Z enos $ > ## > ## Tests for method "mvLong". > ## > ################################################################################ > > library(portfolio) Loading required package: grid Loading required package: lattice > > price <- rnorm(20, mean = 80, sd = 30) > > data.0 <- data.frame(id = 1:20, symbol.var = letters[1:20], + in.var = price, + ret.var = rnorm(20, mean = 0, sd = 0.1), + price.var = price, round.lot = 1) > > ## corner case of 0 positions > > p <- new("portfolio", id.var = "id", symbol.var = "symbol.var", + in.var = "in.var", ret.var = "ret.var", type = "equal", + size = "quintile", equity = 100000, sides = "long", + price.var = "price.var", data = data.0) > > p@shares <- p@shares[0,] > > stopifnot(portfolio:::mvLong(p) == 0) > > proc.time() user system elapsed 0.34 0.09 0.43