- using R Under development (unstable) (2024-12-17 r87446 ucrt)
- using platform: x86_64-w64-mingw32
- R was compiled by
gcc.exe (GCC) 13.3.0
GNU Fortran (GCC) 13.3.0
- running under: Windows Server 2022 x64 (build 20348)
- using session charset: UTF-8
- checking for file 'tidyquant/DESCRIPTION' ... OK
- checking extension type ... Package
- this is package 'tidyquant' version '1.0.9'
- package encoding: UTF-8
- checking package namespace information ... OK
- checking package dependencies ... OK
- checking if this is a source package ... OK
- checking if there is a namespace ... OK
- checking for hidden files and directories ... OK
- checking for portable file names ... OK
- checking whether package 'tidyquant' can be installed ... OK
See the install log for details.
- checking installed package size ... INFO
installed size is 6.5Mb
sub-directories of 1Mb or more:
doc 5.6Mb
- checking package directory ... OK
- checking 'build' directory ... OK
- checking DESCRIPTION meta-information ... OK
- checking top-level files ... OK
- checking for left-over files ... OK
- checking index information ... OK
- checking package subdirectories ... OK
- checking code files for non-ASCII characters ... OK
- checking R files for syntax errors ... OK
- checking whether the package can be loaded ... [2s] OK
- checking whether the package can be loaded with stated dependencies ... [2s] OK
- checking whether the package can be unloaded cleanly ... [1s] OK
- checking whether the namespace can be loaded with stated dependencies ... [1s] OK
- checking whether the namespace can be unloaded cleanly ... [2s] OK
- checking loading without being on the library search path ... [2s] OK
- checking whether startup messages can be suppressed ... [2s] OK
- checking use of S3 registration ... OK
- checking dependencies in R code ... OK
- checking S3 generic/method consistency ... OK
- checking replacement functions ... OK
- checking foreign function calls ... OK
- checking R code for possible problems ... [8s] OK
- checking Rd files ... [1s] OK
- checking Rd metadata ... OK
- checking Rd cross-references ... OK
- checking for missing documentation entries ... OK
- checking for code/documentation mismatches ... OK
- checking Rd \usage sections ... OK
- checking Rd contents ... OK
- checking for unstated dependencies in examples ... OK
- checking contents of 'data' directory ... OK
- checking data for non-ASCII characters ... [1s] OK
- checking LazyData ... OK
- checking data for ASCII and uncompressed saves ... OK
- checking R/sysdata.rda ... OK
- checking installed files from 'inst/doc' ... OK
- checking files in 'vignettes' ... OK
- checking examples ... [18s] ERROR
Running examples in 'tidyquant-Ex.R' failed
The error most likely occurred in:
> ### Name: tq_performance
> ### Title: Computes a wide variety of summary performance metrics from
> ### stock or portfolio returns
> ### Aliases: tq_performance tq_performance_ tq_performance_fun_options
>
> ### ** Examples
>
> # Load libraries
> library(dplyr)
######################### Warning from 'xts' package ##########################
# #
# The dplyr lag() function breaks how base R's lag() function is supposed to #
# work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
# source() into this session won't work correctly. #
# #
# Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
# conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
# dplyr from breaking base R's lag() function. #
# #
# Code in packages is not affected. It's protected by R's namespace mechanism #
# Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
# #
###############################################################################
Attaching package: 'dplyr'
The following objects are masked from 'package:xts':
first, last
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
>
> # Use FANG data set
>
> # Get returns for individual stock components grouped by symbol
> Ra <- FANG %>%
+ group_by(symbol) %>%
+ tq_transmute(adjusted, periodReturn, period = "monthly", col_rename = "Ra")
>
> # Get returns for SP500 as baseline
> Rb <- "^GSPC" %>%
+ tq_get(get = "stock.prices",
+ from = "2010-01-01",
+ to = "2015-12-31") %>%
+ tq_transmute(adjusted, periodReturn, period = "monthly", col_rename = "Rb")
>
> # Merge stock returns with baseline
> RaRb <- left_join(Ra, Rb, by = c("date" = "date"))
>
> ##### Performance Metrics #####
>
> # View options
> tq_performance_fun_options()
$table.funs
[1] "table.AnnualizedReturns" "table.Arbitrary"
[3] "table.Autocorrelation" "table.CAPM"
[5] "table.CaptureRatios" "table.Correlation"
[7] "table.Distributions" "table.DownsideRisk"
[9] "table.DownsideRiskRatio" "table.DrawdownsRatio"
[11] "table.HigherMoments" "table.InformationRatio"
[13] "table.RollingPeriods" "table.SFM"
[15] "table.SpecificRisk" "table.Stats"
[17] "table.TrailingPeriods" "table.UpDownRatios"
[19] "table.Variability"
$CAPM.funs
[1] "CAPM.alpha" "CAPM.beta" "CAPM.beta.bear" "CAPM.beta.bull"
[5] "CAPM.CML" "CAPM.CML.slope" "CAPM.dynamic" "CAPM.epsilon"
[9] "CAPM.jensenAlpha" "CAPM.RiskPremium" "CAPM.SML.slope" "TimingRatio"
[13] "MarketTiming"
$SFM.funs
[1] "SFM.alpha" "SFM.beta" "SFM.CML" "SFM.CML.slope"
[5] "SFM.dynamic" "SFM.epsilon" "SFM.jensenAlpha"
$descriptive.funs
[1] "mean" "sd" "min" "max"
[5] "cor" "mean.geometric" "mean.stderr" "mean.LCL"
[9] "mean.UCL"
$annualized.funs
[1] "Return.annualized" "Return.annualized.excess"
[3] "sd.annualized" "SharpeRatio.annualized"
$VaR.funs
[1] "VaR" "ES" "ETL" "CDD" "CVaR"
$moment.funs
[1] "var" "cov" "skewness" "kurtosis"
[5] "CoVariance" "CoSkewness" "CoSkewnessMatrix" "CoKurtosis"
[9] "CoKurtosisMatrix" "M3.MM" "M4.MM" "BetaCoVariance"
[13] "BetaCoSkewness" "BetaCoKurtosis"
$drawdown.funs
[1] "AverageDrawdown" "AverageLength" "AverageRecovery"
[4] "DrawdownDeviation" "DrawdownPeak" "maxDrawdown"
$Bacon.risk.funs
[1] "MeanAbsoluteDeviation" "Frequency" "SharpeRatio"
[4] "MSquared" "MSquaredExcess" "HurstIndex"
$Bacon.regression.funs
[1] "CAPM.alpha" "CAPM.beta" "CAPM.epsilon" "CAPM.jensenAlpha"
[5] "SystematicRisk" "SpecificRisk" "TotalRisk" "TreynorRatio"
[9] "AppraisalRatio" "FamaBeta" "Selectivity" "NetSelectivity"
$Bacon.relative.risk.funs
[1] "ActivePremium" "ActiveReturn" "TrackingError" "InformationRatio"
$Bacon.drawdown.funs
[1] "PainIndex" "PainRatio" "CalmarRatio" "SterlingRatio"
[5] "BurkeRatio" "MartinRatio" "UlcerIndex"
$Bacon.downside.risk.funs
[1] "DownsideDeviation" "DownsidePotential" "DownsideFrequency"
[4] "SemiDeviation" "SemiVariance" "UpsideRisk"
[7] "UpsidePotentialRatio" "UpsideFrequency" "BernardoLedoitRatio"
[10] "DRatio" "Omega" "OmegaSharpeRatio"
[13] "OmegaExcessReturn" "SortinoRatio" "M2Sortino"
[16] "Kappa" "VolatilitySkewness" "AdjustedSharpeRatio"
[19] "SkewnessKurtosisRatio" "ProspectRatio"
$misc.funs
[1] "KellyRatio" "Modigliani" "UpDownRatios"
>
> # Get performance metrics
> RaRb %>%
+ tq_performance(Ra = Ra, performance_fun = SharpeRatio, p = 0.95)
# A tibble: 4 × 5
# Groups: symbol [4]
symbol `ESSharpe(Rf=0%,p=95%)` SemiSDSharpe(Rf=0%,p=9…¹ StdDevSharpe(Rf=0%,p…²
<chr> <dbl> <dbl> <dbl>
1 META 0.193 0.424 0.345
2 AMZN 0.215 0.339 0.314
3 NFLX 0.199 0.438 0.355
4 GOOG 0.213 0.354 0.296
# ℹ abbreviated names: ¹`SemiSDSharpe(Rf=0%,p=95%)`,
# ²`StdDevSharpe(Rf=0%,p=95%)`
# ℹ 1 more variable: `VaRSharpe(Rf=0%,p=95%)` <dbl>
>
> RaRb %>%
+ tq_performance(Ra = Ra, Rb = Rb, performance_fun = table.CAPM)
Error in `dplyr::mutate()`:
ℹ In argument: `nested.col = purrr::map(...)`.
ℹ In group 1: `symbol = "AMZN"`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `.coefficients()`:
! "package:RobStatTM" %in% search() || requireNamespace("RobStatTM", .... is not TRUE
Backtrace:
▆
1. ├─RaRb %>% tq_performance(Ra = Ra, Rb = Rb, performance_fun = table.CAPM)
2. ├─tidyquant::tq_performance(., Ra = Ra, Rb = Rb, performance_fun = table.CAPM)
3. │ ├─tidyquant::tq_performance_(...)
4. │ └─tidyquant:::tq_performance_.grouped_df(...)
5. │ └─... %>% dplyr::group_by_at(.vars = group_names)
6. ├─dplyr::group_by_at(., .vars = group_names)
7. │ └─dplyr:::manip_at(...)
8. │ └─dplyr:::tbl_at_syms(...)
9. │ └─dplyr:::tbl_at_vars(...)
10. │ └─dplyr::tbl_vars(tbl)
11. │ ├─dplyr:::new_sel_vars(tbl_vars_dispatch(x), group_vars(x))
12. │ │ └─base::structure(...)
13. │ └─dplyr:::tbl_vars_dispatch(x)
14. ├─tidyr::unnest(., cols = nested.col)
15. ├─dplyr::select(., -"data")
16. ├─dplyr::mutate(...)
17. ├─dplyr:::mutate.data.frame(...)
18. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
19. │ ├─base::withCallingHandlers(...)
20. │ └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
21. │ └─mask$eval_all_mutate(quo)
22. │ └─dplyr (local) eval()
23. ├─purrr::map(...)
24. │ └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
25. │ ├─purrr:::with_indexed_errors(...)
26. │ │ └─base::withCallingHandlers(...)
27. │ ├─purrr:::call_with_cleanup(...)
28. │ └─tidyquant (local) .f(.x[[i]], ...)
29. │ └─base::tryCatch(...)
30. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
31. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
32. │ └─value[[3L]](cond)
33. │ └─base::warning(e)
34. │ └─base::withRestarts(...)
35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
36. │ └─base (local) doWithOneRestart(return(expr), restart)
37. └─purrr (local) `<fn>`(`<smplErrr>`)
38. └─cli::cli_abort(...)
39. └─rlang::abort(...)
Execution halted
- checking for unstated dependencies in 'tests' ... OK
- checking tests ... [10s] ERROR
Running 'testthat.R' [10s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
> # This file is part of the standard setup for testthat.
> # It is recommended that you do not modify it.
> #
> # Where should you do additional test configuration?
> # Learn more about the roles of various files in:
> # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
> # * https://testthat.r-lib.org/articles/special-files.html
>
> library(testthat)
> library(tidyquant)
── Attaching core tidyquant packages ──────────────────────── tidyquant 1.0.9 ──
✔ PerformanceAnalytics 2.0.8 ✔ quantmod 0.4.26
✔ TTR 0.24.4 ✔ xts 0.14.1
── Conflicts ────────────────────────────────────────── tidyquant_conflicts() ──
✖ zoo::as.Date() masks base::as.Date()
✖ zoo::as.Date.numeric() masks base::as.Date.numeric()
✖ PerformanceAnalytics::legend() masks graphics::legend()
✖ quantmod::summary() masks base::summary()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
>
> test_check("tidyquant")
[ FAIL 1 | WARN 0 | SKIP 5 | PASS 60 ]
══ Skipped tests (5) ═══════════════════════════════════════════════════════════
• On CRAN (4): 'test-index-tq_index.R:16:5', 'test-index_tq_exchange.R:18:5',
'test-tq_portfolio.R:4:1', 'test-tq_transmute.R:2:1'
• On Windows (1): 'test-index_tq_exchange.R:32:5'
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-tq_performance.R:27:1'): (code run outside of `test_that()`) ───
<dplyr:::mutate_error/rlang_error/error/condition>
Error in `dplyr::mutate(., nested.col = purrr::map(.x = data, .f = tq_performance_.tbl_df,
Ra = Ra, Rb = Rb, performance_fun = performance_fun, ...))`: ℹ In argument: `nested.col = purrr::map(...)`.
ℹ In group 1: `symbol = "AAPL"`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `.coefficients()`:
! "package:RobStatTM" %in% search() || requireNamespace("RobStatTM", .... is not TRUE
[ FAIL 1 | WARN 0 | SKIP 5 | PASS 60 ]
Error: Test failures
Execution halted
- checking for unstated dependencies in vignettes ... OK
- checking package vignettes ... OK
- checking re-building of vignette outputs ... [78s] ERROR
Error(s) in re-building vignettes:
--- re-building 'TQ00-introduction-to-tidyquant.Rmd' using rmarkdown
--- finished re-building 'TQ00-introduction-to-tidyquant.Rmd'
--- re-building 'TQ01-core-functions-in-tidyquant.Rmd' using rmarkdown
--- finished re-building 'TQ01-core-functions-in-tidyquant.Rmd'
--- re-building 'TQ02-quant-integrations-in-tidyquant.Rmd' using rmarkdown
--- finished re-building 'TQ02-quant-integrations-in-tidyquant.Rmd'
--- re-building 'TQ03-scaling-and-modeling-with-tidyquant.Rmd' using rmarkdown
--- finished re-building 'TQ03-scaling-and-modeling-with-tidyquant.Rmd'
--- re-building 'TQ04-charting-with-tidyquant.Rmd' using rmarkdown
--- finished re-building 'TQ04-charting-with-tidyquant.Rmd'
--- re-building 'TQ05-performance-analysis-with-tidyquant.Rmd' using rmarkdown
Quitting from lines 112-117 [unnamed-chunk-6] (TQ05-performance-analysis-with-tidyquant.Rmd)
Error: processing vignette 'TQ05-performance-analysis-with-tidyquant.Rmd' failed with diagnostics:
ℹ In argument: `nested.col = purrr::map(...)`.
ℹ In group 1: `symbol = "AAPL"`.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `.coefficients()`:
! "package:RobStatTM" %in% search() || requireNamespace("RobStatTM", .... is not TRUE
--- failed re-building 'TQ05-performance-analysis-with-tidyquant.Rmd'
--- re-building 'TQ06-excel-in-r.Rmd' using rmarkdown
--- finished re-building 'TQ06-excel-in-r.Rmd'
SUMMARY: processing the following file failed:
'TQ05-performance-analysis-with-tidyquant.Rmd'
Error: Vignette re-building failed.
Execution halted
- checking PDF version of manual ... [30s] OK
- checking HTML version of manual ... [6s] OK
- DONE
Status: 3 ERRORs