Skip to content

Commit

Permalink
version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Lee Yung Rowe authored and gaborcsardi committed Feb 4, 2013
1 parent 05da435 commit e5d4a9c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 47 deletions.
20 changes: 10 additions & 10 deletions DESCRIPTION
Expand Up @@ -2,23 +2,23 @@ Package: fractalrock
Type: Package
Title: Generate fractal time series with non-normal returns
distribution
Version: 1.0.3
Date: 2011-09-17
Version: 1.1.0
Date: 2013-02-04
Author: Brian Lee Yung Rowe
Maintainer: Brian Lee Yung Rowe <r@nurometic.com>
Depends: R (>= 2.8.0), futile.any, futile.logger, timeDate, zoo, xts,
Maintainer: Brian Lee Yung Rowe <r@zatonovo.com>
Depends: futile.any (>= 1.3.0), futile.logger (>= 1.3.0), timeDate,
quantmod
Description: The basic principle driving fractal generation of time
series is that data is generated iteratively based on
increasing levels of resolution. The initial series is defined
increasing levels of resolution. The initial series is defined
by a so-called initiator pattern and then generators are used
to replace each segment of the initial pattern. Regular,
repeatable patterns can be produced by using the same seed and
generators. By using a set of generators, non-repeatable time
series can be produced. This technique is the basis of the
generators. By using a set of generators, non-repeatable time
series can be produced. This technique is the basis of the
fractal time series process in this package.
License: GPL-2
License: GPL-3
LazyLoad: yes
Packaged: 2011-09-18 00:25:43 UTC; brian
Packaged: 2013-02-04 20:03:17 UTC; brian
Repository: CRAN
Date/Publication: 2011-09-18 06:20:28
Date/Publication: 2013-02-05 05:41:05
6 changes: 3 additions & 3 deletions MD5
@@ -1,11 +1,11 @@
1e57bd49a6293bed4edcd945e0da5f96 *DESCRIPTION
e0fc949700bc88c2b5824fa3205f229f *DESCRIPTION
012592abf4b40a8d741b299df2ded05a *NAMESPACE
ea4ac2f22787072c4cb4aee9cad0bbe6 *R/framework.R
df30a045f407a039f4605ed661bc732a *R/framework.R
3b3476adf9529b8f6d9fc99613305dc1 *R/ornstein-uhlenbeck.R
38fbd8cf0f1e7db9bb2566241417dc17 *TODO
b2410ca2d2b2c0eb512c78509eebd7a4 *data/generators.RData
ea0cf86e4987c239b36da4b82eca0275 *man/fractal.Rd
e314583e5df76ce659213b09b06c51c5 *man/fractalrock-package.Rd
b69158509da819155e070eaa96d3461e *man/fractalrock-package.Rd
53f4f0c1f25fafbebe3e1d71f4c114bd *man/getPortfolioPrices.Rd
b5f254c3ad7237e3aa939b32ee42995a *man/plotReturns.Rd
ae6f1445f729976a5acac073e1f4ce95 *man/process.Rd
Expand Down
53 changes: 23 additions & 30 deletions R/framework.R
Expand Up @@ -6,8 +6,6 @@
# getTradingDates('2009-02-24',obs=10)
getTradingDates <- function(end, start=NULL, obs=NULL, calendar=holidayNYSE)
{
require(futile.any)
require(timeDate, quietly=TRUE)
if (is.null(obs) & is.null(start)) stop("Either obs or start must be set")

end <- as.Date(end)
Expand Down Expand Up @@ -46,7 +44,6 @@ getTradingDates <- function(end, start=NULL, obs=NULL, calendar=holidayNYSE)
getPortfolioPrices <- function(symbols, obs=NULL, end=Sys.Date(), start=NULL,
calendar=holidayNYSE, seeds=NULL, patterns=NULL, ..., type='uniform')
{
require(futile.any)
# Get dates
dates <- getTradingDates(end, start, obs, calendar)
if (is.null(seeds))
Expand Down Expand Up @@ -90,10 +87,6 @@ getPortfolioPrices <- function(symbols, obs=NULL, end=Sys.Date(), start=NULL,
# ps <- fractal(seed, pats, epochs=3)
fractal <- function(seeds, patterns, count=NULL, epochs=NULL, ..., type='uniform')
{
require(futile.logger)
logger <<- getLogger('fractalrock')

require(xts, quietly=TRUE)
if ('list' %in% class(seeds)) seed <- sample(seeds, 1)[[1]]
else seed <- seeds

Expand Down Expand Up @@ -130,7 +123,7 @@ fractal.uniform <- function(seed, patterns, count=NULL, epochs=NULL,
pattern.legs <- nrow(patterns[[1]])-1
epochs <- floor(log(count / seed.legs, base=pattern.legs)) + 1
#cat("seed.legs:",seed.legs,"; pattern.legs:",pattern.legs,"\n")
logger(DEBUG, sprintf("Set epochs to %s",epochs))
flog.debug("Set epochs to %s",epochs)
}
if (is.na(epochs) | is.null(epochs)) stop("Unable to calculate epochs")

Expand Down Expand Up @@ -164,8 +157,8 @@ next.seeds <- function(old.seed, new.seed, pattern, idx, epoch)
scale <- c(x.delta, y.delta)
start <- c(old.seed[idx-1,1], old.seed[idx-1,2])

logger(DEBUG, sprintf("[%s.%s] scale: %s",epoch,idx, scale))
logger(DEBUG, sprintf("[%s.%s] epoch: %s",epoch,idx, start))
flog.debug("[%s.%s] scale: %s",epoch,idx, scale)
flog.debug("[%s.%s] epoch: %s",epoch,idx, start)

segment <- pattern *
matrix(rep(scale, nrow(pattern)), ncol=2, byrow=TRUE) +
Expand All @@ -176,7 +169,7 @@ next.seeds <- function(old.seed, new.seed, pattern, idx, epoch)
old.seed <- rbind(old.seed[! (old.seed[,1] %in% segment[,1]), ],
segment[(segment[,1] %in% old.seed[,1]), ])
old.seed <- old.seed[order(old.seed[,1]),]
logger(DEBUG, sprintf("[%s.%s] segment: %s",epoch,idx,segment))
flog.debug("[%s.%s] segment: %s",epoch,idx,segment)

return(list(this.seed=old.seed, next.seed=new.seed))
}
Expand All @@ -199,7 +192,7 @@ fractal.random <- function(seed, patterns, count=NULL, epochs=NULL,
pattern.legs <- nrow(patterns[[1]])-1
epochs <- floor(log(count / seed.legs, base=pattern.legs)) + 1
#cat("seed.legs:",seed.legs,"; pattern.legs:",pattern.legs,"\n")
logger(DEBUG, sprintf("Set epochs to %s",epochs))
flog.debug("Set epochs to %s",epochs)
}
if (is.na(epochs) | is.null(epochs)) stop("Unable to calculate epochs")

Expand Down Expand Up @@ -240,7 +233,6 @@ fractal.random <- function(seed, patterns, count=NULL, epochs=NULL,

plotReturns <- function(series, ...)
{
require(quantmod, quietly=TRUE)
o.par <- par(mfrow=c(2,1), mar=c(3.1, 2.1, 2.1, 1.1))
plot(series, type='l', main='Prices',...)
plot(Delt(series), main='Returns')
Expand Down Expand Up @@ -296,21 +288,22 @@ plotReturns <- function(series, ...)
#)
#ps <- getPortfolioPrices('IBM',10, seeds=microInitiators, patterns=microGenerators, date.fun=as.POSIXct)

.fracret <- function(assets=10, epochs=3)
{
fn <- function(x)
{
series <- fractal(seed, pats, epochs=epochs)
series <- Delt(series)
series <- series[! is.na(series) & ! is.infinite(series)]
series <- series - mean(series)
}
rets <- do.call(cbind, lapply(1:assets, fn))
names(rets) <- 1:assets
rets
}
# Unused
#.fracret <- function(assets=10, epochs=3)
#{
# fn <- function(x)
# {
# series <- fractal(seed, pats, epochs=epochs)
# series <- Delt(series)
# series <- series[! is.na(series) & ! is.infinite(series)]
# series <- series - mean(series)
# }
# rets <- do.call(cbind, lapply(1:assets, fn))
# names(rets) <- 1:assets
# rets
#}

.interpolate.mat <- function(x, by.col)
{

}
#.interpolate.mat <- function(x, by.col)
#{
#
#}
8 changes: 4 additions & 4 deletions man/fractalrock-package.Rd
Expand Up @@ -27,9 +27,9 @@
\tabular{ll}{
Package: \tab fractalrock\cr
Type: \tab Package\cr
Version: \tab 1.0.3\cr
Date: \tab 2011-09-17\cr
License: \tab GPL-2\cr
Version: \tab 1.1.0\cr
Date: \tab 2013-02-04\cr
License: \tab GPL-3\cr
}
To generate a set of asset prices, the function \code{\link{getPortfolioPrices}}is the most direct way to accomplish this. An xts object will be returned with
one time series per 'asset' provided. In addition, the dates will be coerced
Expand All @@ -40,7 +40,7 @@ underlying \code{\link{fractal}} function. This function produces raw values
useful for analysis of the fractal generation process.
}
\author{
Brian Lee Yung Rowe <r@nurometic.com>
Brian Lee Yung Rowe <r@zatonovo.com>
}
\references{
M. Frame, B. Mandelbrot, N. Neger. Fractal Geometry. 2009.
Expand Down

0 comments on commit e5d4a9c

Please sign in to comment.