tests/testit/test-parse_transforms.1.R

rm(list=ls())

assert('parse_transforms_1', {
  Prices(series) %as% 
  {
    series@asset.class <- 'equity'
    series@periodicity <- 'daily'
    series
  }

  returns(x) %when% {
    x@asset.class == "equity"
    x@periodicity == "daily"
  } %as% {
    x[2:length(x)] / x[1:(length(x) - 1)] - 1
  }

  ps <- Prices(rnorm(50))
  (attr(ps,'asset.class') == 'equity')
  (attr(ps,'periodicity') == 'daily')

  rs <- returns(ps)
  (length(rs) == length(ps) - 1)
})

Try the lambda.r package in your browser

Any scripts or data that you put into this service are public.

lambda.r documentation built on Sept. 18, 2019, 5:02 p.m.