knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.width = 8, fig.height = 4.5, fig.align = 'center', out.width='95%', dpi = 200) library(tidyquant) # devtools::load_all() # Travis CI fails on load_all()
Our short introduction to
Check out our entire Software Intro Series on YouTube!
tidyversetools in R for Data Science
ggplot2functionality for beautiful and meaningful financial visualizations
Minimizing the number of functions reduces the learning curve. What we've done is group the core functions into four categories:
Get a Stock Index,
tq_index(), or a Stock Exchange,
tq_exchange(): Returns the stock symbols and various attributes for every stock in an index or exchange. Eighteen indexes and three exchanges are available.
Get Quantitative Data,
tq_get(): A one-stop shop to get data from various web-sources.
tq_transmute(), and Mutate,
tq_mutate(), Quantitative Data: Perform and scale financial calculations completely within the
tidyverse. These workhorse functions integrate the
tq_performance(), and portfolio aggregation,
PerformanceAnalytics integration enables analyzing performance of assets and portfolios. Refer to Performance Analysis with tidyquant.
For more information, refer to the first topic-specific vignette, Core Functions in tidyquant.
There's a wide range of useful quantitative analysis functions (QAF) that work with time-series objects. The problem is that many of these wonderful functions don't work with data frames or the
tidyverse workflow. That is until now. The
tidyquant package integrates the most useful functions from the
PerformanceAnalytics packages, enabling seamless usage within the
Refer below for information on the performance analysis and portfolio attribution with the
For more information, refer to the second topic-specific vignette, R Quantitative Analysis Package Integrations in tidyquant.
The greatest benefit to
tidyquant is the ability to easily model and scale your financial analysis. Scaling is the process of creating an analysis for one security and then extending it to multiple groups. This idea of scaling is incredibly useful to financial analysts because typically one wants to compare many securities to make informed decisions. Fortunately, the
tidyquant package integrates with the
tidyverse making scaling super simple!
tidyquant functions return data in the
tibble (tidy data frame) format, which allows for interaction within the
tidyverse. This means we can:
%>%) for chaining operations
purrr: mapping functions with
For more information, refer to the third topic-specific vignette, Scaling and Modeling with tidyquant.
tidyquant package includes charting tools to assist users in developing quick visualizations in
ggplot2 using the grammar of graphics format and workflow.
library(tidyverse) library(tidyquant) data("FANG") end <- as_date("2017-01-01") start <- end - weeks(24) FANG %>% filter(date >= start - days(2 * 20)) %>% ggplot(aes(x = date, y = close, open = open, high = high, low = low, close = close, group = symbol)) + geom_barchart() + geom_bbands(ma_fun = SMA, sd = 2, n = 20, linetype = 5) + labs(title = "FANG Bar Chart", subtitle = "BBands with SMA Applied, Multiple Stocks", y = "Closing Price", x = "") + coord_x_date(xlim = c(start, end)) + facet_wrap(~ symbol, ncol = 2, scales = "free_y") + theme_tq()
For more information, refer to the fourth topic-specific vignette, Charting with tidyquant.
Asset and portfolio performance analysis is a deep field with a wide range of theories and methods for analyzing risk versus reward. The
PerformanceAnalytics package consolidates many of the most widely used performance metrics as functions that can be applied to stock or portfolio returns.
tidquant implements the functionality with two primary functions:
tq_performanceimplements the performance analysis functions in a tidy way, enabling scaling analysis using the split, apply, combine framework.
tq_portfolioprovides a useful toolset for aggregating a group of individual asset returns into one or many portfolios.
Performance is based on the statistical properties of returns, and as a result both functions use returns as opposed to stock prices.
For more information, refer to the fifth topic-specific vignette, Performance Analysis with tidyquant.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.