Learn R Programming

StockDistFit

The goal of StockDistFit is to provide functions that help in fitting probability distributions to financial data, specifically stock returns and prices. These functions can be used to compare the goodness of fit of different distributions and choose the most appropriate one, which can aid in making investment decisions or modeling financial phenomena. The package also includes function for cumulative wealth generated over time, given the initial wealth. Overall, StockDistFit aims to simplify the process of fitting and analyzing probability distributions for financial data.

Installation

You can install the development version of StockDistFit from GitHub with:

# install.packages("devtools")
devtools::install_github("njuguna-brian/StockDistFit")

Example

An example is the following

library(StockDistFit)
df <- asset_loader("path/to/data/folder", "AAPL", "Close")
df_returns <- weekly_return(df)

# Fit a normal Distribution to the Closing Price
norm_fit(df_returns)

Copy Link

Version

Install

install.packages('StockDistFit')

Monthly Downloads

175

Version

1.0.0

License

GPL (>= 3)

Maintainer

Brian Njuguna

Last Published

May 9th, 2023

Functions in StockDistFit (1.0.0)

skew.normal_fit

Fit Skew Normal Distribution to a vector of returns/stock prices.
sym.hd_fit

Fit a Symmetric Hyperbolic Distribution to a vector of return/stock prices.
weekly_return

Compute Weekly Returns of a Vector.
vg_fit

Fit Variance Gamma Distribution to a vector of return/stock prices.
t_fit

Fit Student's t Distribution to a vector of returns/stock prices.
monthly_return

Compute Monthly Returns of a Vector.
sym.vg_fit

Fit Symmetric Variance Gamma Distribution to a vector of returns/stock prices.
data.cumret

Compute Cumulative Returns of a Vector.
asset_loader

Load Asset Data.
AMZN

Amazon.com Inc. Stock Prices Dataset
cauchy_fit

Fit Cauchy Distribution to a vector of returns/stock prices.
fit_multiple_dist

Fits Multiple Probability Distributions to several assets/stock prices.
best_dist

Find the best distribution based on AIC values
annual_return

Compute Annual Returns of a Vector.
norm_fit

Fit Normal Distribution to a Vector/stock prices.
nig_fit

Fit Normal Inverse Gaussian (NIG) Distribution to a vector of returns/stock prices.
skew.ged_fit

Fit Skewed Generalized Error Distribution to a vector of returns/stock prices.
ged_fit

Fit Generalized Error Distribution to a vector of returns/stock prices.
ghd_fit

Fit Generalized Hyperbolic Distribution to a vector of returns/stock prices.
AAPL

Apple Inc. stock prices dataset
TSLA

Tesla Inc. Stock Prices Dataset
GOOG

Alphabet Inc Inc. Stock Prices Dataset
hd_fit

Fit Hyperbolic distribution to return/stock prices.
skew.t_fit

Fit Skewed Student-t Distribution to a vector of returns/stock prices.
sym.ghd_fit

Fit Symmetric Generalized Hyperbolic Distribution to returns/stock prices.