inst/tests/test_prep_maturity.R

context("VIX")

test_that("test.prep_maturity", {
  load(system.file("data", "vix_spx.RData", package = "ifrogs"))
  load(system.file("data", "vix_nifty.RData", package = "ifrogs"))

                                        # load the test output data
  load(system.file("tests", "data_prep_maturity.RData", package = "ifrogs"))

  test_spx_near <- prep_maturity(maturity=vix_spx$opt_near$maturity[[1]],
                                 riskfree=vix_spx$opt_near$riskfree[[1]],
                                 carry=vix_spx$opt_near$riskfree[[1]],
                                 type=vix_spx$opt_near$type,
                                 strike=vix_spx$opt_near$strike,
                                 underlying=vix_spx$opt_near$underlying,
                                 schemes="vega",
                                 bid=vix_spx$opt_near$bid,
                                 ask=vix_spx$opt_near$ask,
                                 tv_filter=FALSE)

  cat("\ntest.prep_maturity: spx_near ")
  expect_that(test_spx_near, equals(spx_near))

  ##
  test_nifty_near <- prep_maturity(maturity=vix_nifty$opt_near$maturity[[1]],
                                   riskfree=vix_nifty$opt_near$riskfree[[1]],
                                   carry=vix_nifty$opt_near$riskfree[[1]],
                                   type=vix_nifty$opt_near$type,
                                   strike=vix_nifty$opt_near$strike,
                                   underlying=vix_nifty$opt_near$underlying,
                                   schemes=c("spread", "elasticity", "vega"),
                                   bid=vix_nifty$opt_near$bid,
                                   ask=vix_nifty$opt_near$ask,
                                   traded_vol=vix_nifty$opt_near$traded_vol,
                                   tv_filter=TRUE)

  cat("\ntest.prep_maturity: nifty_near ")
  expect_that(test_nifty_near, equals(nifty_near))
})

Try the ifrogs package in your browser

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

ifrogs documentation built on May 31, 2017, 2:27 a.m.