Rstockwatch package has been created to provide a very simple interface for checking movements in stock prices in comparison to the market. This is implemented by accessing public data from Yahoo Finance by selecting a ticker of the stock, range of start and end dates and benchmark for comparison, like SP500. As a result of data processing with rstockwatch package, users will be able to generate two plots: one with two lines showing percentage change in profit since the start date and volumes of trading and another related to daily change in the volume of stock trades as shown at examples below.

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Functions description

This package is built with following four functions:

Comparison with similar packages in R Ecosystem

There are many packages written for analysis of stock data. One of relevant R package in this category is stockAnalyzer, which allows a lot of manipulations with time series data, such as creating moving averages or calculating other parameters for technical analysis. Power of Rstockwatch is in its simplicity, so users are not overwhelmed with all extra features and just have a simple view with key comparisons for a stock of interest.

Installation

You can install the development version from GitHub with (remove comment sign # before installng):

# install.packages("devtools")
# devtools::install_github("UBC-MDS/Rstockwatch")

Usage and Example

After the successful installation of this package user are recommend to restart the R session to update any dependencies packages. The functions in this package require input four parameters: stock_ticker, start_date, end_date and benchmark_ticker. Output results are in form of an plot based on “ggplot” package.

Import the functions from package with following commands:

library(Rstockwatch)

1. To check the profit percent

percent_change('AAPL', '2015-01-01', '2021-12-31')

2. To visualize the profit percentage change trend of a stock against stock market benchmark

profit_viz('AAPL', '2015-01-01', '2021-12-31', 'SPY')

3. To check daily trading volume change of a stock

volume_change('AAPL', '2021-01-01', '2021-12-31')

4. To visualize the volume change trend of a stock

volume_viz('AAPL', '2021-01-01', '2021-12-31')

Contributors

We welcome and recognize all contributions. Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

Dependencies

R Version 4.1 or above

tidyverse==1.3.1

knitr==1.36

testthat (>= 3.0.0)

ggplot2 ==3.3.5

tidyquant ==1.0.3



UBC-MDS/Rstockwatch documentation built on Feb. 7, 2022, 9:11 a.m.