tidyquant

repository·master·Indexed 21 days ago

https://github.com/business-science/tidyquant

An R package that integrates financial and business analysis into the tidyverse. It provides tools for retrieving web-based financial data via tq_get() and integrates quantitative packages such as zoo, xts, quantmod, TTR, and PerformanceAnalytics through functions like tq_mutate(), tq_transmute(), tq_performance(), and tq_portfolio().

Tokens
949
Snippets
1
Records
7
Agent score
25%

What's inside tidyquant

  1. How tidyquant integrates with quantitative analysis packages

    master

    The mission of tidyquant is to bring financial and business analysis to the tidyverse in R. It achieves this by integrating the quantitative analysis functionality of several specialized R packages with the tidy data infrastructure.

    Key integrations include:

    • zoo and xts: For time-series data handling.
    • quantmod: For quantitative financial modeling.
    • TTR: For technical trading rules.
    • PerformanceAnalytics: For advanced performance and portfolio analysis.

    This integration allows users to perform scalable financial modeling and visualization using ggplot2 and other tidyverse tools while maintaining the performance of the xts system.

  2. Install tidyquant

    master

    You can install the stable version of tidyquant from CRAN or the development version with the latest features from GitHub.

    To install the CRAN version:

    install.packages("tidyquant")

    To install the development version using devtools:

    # install.packages("devtools")
    devtools::install_github("business-science/tidyquant")
  3. Explore tidyquant vignettes and learning resources

    master

    For in-depth learning, tidyquant provides several specialized vignettes:

    • TQ00 - Introduction to tidyquant
    • TQ01 - Core Functions in tidyquant
    • TQ02 - R Quantitative Analysis Package Integrations in tidyquant
    • TQ03 - Scaling and Modeling with tidyquant
    • TQ04 - Charting with tidyquant
    • TQ05 - Performance Analysis with tidyquant

    Additionally, there are advanced learning labs available through Business Science covering topics like Portfolio Optimization with ROI, building APIs with plumber, and using Excel-like functionality (Pivot Tables, VLOOKUPs) within R.

  4. Manipulate financial data with tq_mutate() and tq_transmute()

    master

    tidyquant integrates quantitative analysis functions from xts, zoo, quantmod, TTR, and PerformanceAnalytics into the tidyverse workflow using two primary functions:

    • tq_mutate(): Used to add a new column (such as a technical indicator) to an existing data frame.
    • tq_transmute(): Used to return a new data frame, which is necessary when performing operations that involve changes in periodicity.
  5. Get financial data with tq_get()

    master

    The tq_get() function is a central tool for retrieving web-based financial data in a "tidy" data frame format. It supports various data types including:

    • Daily stock prices: Historical data.
    • Key statistics: Real-time data.
    • Key ratios: Historical data.
    • Financial statements
    • Dividends and splits
    • Economic data: From the FRED (Federal Reserve Economic Data).
    • FOREX rates: From Oanda.
  6. Analyze performance and portfolios with tq_performance() and tq_portfolio()

    master

    These functions integrate PerformanceAnalytics capabilities into the tidyverse:

    • tq_performance(): Converts investment returns into various performance metrics.
    • tq_portfolio(): Aggregates a group (or multiple groups) of asset returns into one or more portfolios.
  7. Core functions of tidyquant

    master

    The tidyquant package provides several core functions designed to work within the tidyverse workflow for financial analysis:

    • tq_get(): A central function for retrieving web-based financial data in a tidy data frame format. Supported data includes historical daily stock prices, real-time key statistics, historical key ratios, financial statements, dividends, splits, economic data from FRED, and FOREX rates from Oanda.
    • tq_mutate(): Used to add new columns to a data frame by integrating financial functions from packages like xts, zoo, quantmod, TTR, and PerformanceAnalytics.
    • tq_transmute(): Used to return a new data frame, which is necessary when performing operations that involve changes in periodicity.
    • tq_performance(): Integrates with PerformanceAnalytics to convert investment returns into various performance metrics.
    • tq_portfolio(): Aggregates asset returns from one or multiple groups into one or more portfolios.