Package: stocks 2.0.0

stocks: Stock Market Analysis

Functions for analyzing and visualizing stock market data. Main features are loading and aligning historical data, calculating performance metrics for individual funds or portfolios (e.g. annualized growth, maximum drawdown, Sharpe/Sortino ratio), and creating graphs.

Authors:Dane R. Van Domelen

stocks_2.0.0.tar.gz
stocks_2.0.0.zip(r-4.5)stocks_2.0.0.zip(r-4.4)stocks_2.0.0.zip(r-4.3)
stocks_2.0.0.tgz(r-4.4-x86_64)stocks_2.0.0.tgz(r-4.4-arm64)stocks_2.0.0.tgz(r-4.3-x86_64)stocks_2.0.0.tgz(r-4.3-arm64)
stocks_2.0.0.tar.gz(r-4.5-noble)stocks_2.0.0.tar.gz(r-4.4-noble)
stocks_2.0.0.tgz(r-4.4-emscripten)stocks_2.0.0.tgz(r-4.3-emscripten)
stocks.pdf |stocks.html
stocks/json (API)

# Install 'stocks' in R:
install.packages('stocks', repos = c('https://vandomed.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/vandomed/stocks/issues

Uses libs:
  • c++– GNU Standard C++ Library v3
Datasets:

On CRAN:

investment-analysisportfolio-constructionportfolio-optimizationsharpe-ratiostock-markettime-series

4.61 score 22 stars 37 scripts 178 downloads 44 exports 86 dependencies

Last updated 4 years agofrom:03244f454a. Checks:OK: 1 NOTE: 8. Indexed: yes.

TargetResultDate
Doc / VignettesOKOct 25 2024
R-4.5-win-x86_64NOTEOct 25 2024
R-4.5-linux-x86_64NOTEOct 25 2024
R-4.4-win-x86_64NOTEOct 25 2024
R-4.4-mac-x86_64NOTEOct 25 2024
R-4.4-mac-aarch64NOTEOct 25 2024
R-4.3-win-x86_64NOTEOct 25 2024
R-4.3-mac-x86_64NOTEOct 25 2024
R-4.3-mac-aarch64NOTEOct 25 2024

Exports:beta_trailing50calc_metriccalc_metricscalc_metrics_123calc_metrics_2fundscalc_metrics_3fundscalc_metrics_overtimecontango_hedgedcontango_simpleconvert_gaincum_metricdaily_yearlydiffsgains_pricesgains_rateget_sp500_tickerslabel_metricload_gainsload_pricesmddmetric_decimalsmetric_labelmetric_titlemetric_unitsmoving_meanpchangespdiffsplot_gainsplot_growthplot_metricsplot_metrics_123plot_metrics_2fundsplot_metrics_3fundsplot_metrics_overtimeprices_gainsprices_rateratiosrolling_metricrrrsharpesortinotargetalltargetbeta_twofundsticker_dates

Dependencies:askpassbase64encbslibcachemclicolorspacecpp11crosstalkcurldata.tabledigestdplyrevaluatefansifarverfastmapfastmatchfontawesomefsgenericsggplot2ggrepelgluegtablehighrhtmltoolshtmlwidgetshttrisobandjquerylibjsonliteknitrlabelinglaterlatticelazyevallifecyclelubridatemagrittrMASSMatrixmemoisemgcvmimemunsellnlmeopensslpillarpkgconfigplotlypromisespurrrquantmodR6rappdirsrbenchmarkRColorBrewerRcppRcppArmadilloRcppEigenRcppParallelrlangrmarkdownrollrvestsassscalesselectrstringistringrsystibbletidyrtidyselecttimechangetinytexTTRutf8vctrsviridisLitewithrxfunxml2xtsyamlzoo

Readme and manuals

Help Manual

Help pageTopics
Calculate Beta Using Last 50 Daily Gainsbeta_trailing50
Calculate Performance Metriccalc_metric
Calculate Performance Metricscalc_metrics
Calculate Performance Metrics for Any Combination of Individual Funds, 2-Fund Portfolios, and 3-Fund Portfolioscalc_metrics_123
Calculate Performance Metrics for 2-Fund Portfolios with Varying Allocationscalc_metrics_2funds
Calculate Performance Metrics for 3-Fund Portfolios with Varying Allocationscalc_metrics_3funds
Calculate Performance Metrics over Timecalc_metrics_overtime
Backtest a Hedged Contango-Based Volatility Trading Strategycontango_hedged
Backtest a Simple Contango-Based Volatility Trading Strategycontango_simple
Convert Gain from One Time Interval to Anotherconvert_gain
Calculate Cumulative Performance Metricscum_metric
Convert Daily Gain to X-year Gaindaily_yearly
Lagged Differences (Alternate Implementation)diffs
Ticker Symbols for FANG Stocks (Facebook Apple, Netflix, Google)fang
Convert Sequence of Gains to Sequence of Pricesgains_prices
Calculate Growth Rate from Sequence of Gainsgains_rate
Get S&P 500 Ticker Symbols as on a Particular Dateget_sp500_tickers
High-Yield ETFs from ETFdb.comhighyield.etfs highyield_etfs
Convert Label back to Performance Metriclabel_metric
Largest 100 Market Cap ETFs (as of 3/2/18) and Inception Dateslargest.etfs largest_etfs
Download Historical Gainsload_gains
Download Historical Pricesload_prices
Maximum Drawdownmdd
Performance Metric Choicesmetric.choices metric_choices
Get Number of Decimals for Performance Metricmetric_decimals
Lookup Table for Performance Metricsmetric.info metric_info
Get Label for Performance Metricmetric_label
Get Title for Performance Metricmetric_title
Get Units for Performance Metricmetric_units
Moving Averagesmoving_mean
Lagged Proportion Changespchanges
Lagged Proportion Differencespdiffs
Plot Gains for One Investment vs. Anotherplot_gains
Plot Investment Growthplot_growth
Plot One Performance Metric (Sorted Bar Plot) or One vs. Another (Scatterplot) for a Group of Individual Fundsplot_metrics
Plot One Performance Metric vs. Another for Any Number of Single Funds, 2-Fund Portfolios, and 3-Fund Portfoliosplot_metrics_123
Plot One Performance Metric vs. Another for 2-Fund Portfoliosplot_metrics_2funds
Plot One Performance Metric vs. Another for 3-Fund Portfoliosplot_metrics_3funds
Plot One Performance Metric over Time or One vs. Another over Timeplot_metrics_overtime
Convert Sequence of Prices to Sequence of Gainsprices_gains
Calculate Growth Rate From a Vector of Pricesprices_rate
Ratios of Subsequent Elements in a Vectorratios
Calculate Moving-Window Performance Metricsrolling_metric
Risk-Return Ratiorrr
Sector SPDR ETFssector.spdr.etfs sector_spdr_etfs
Sharpe Ratiosharpe
Sortino Ratiosortino
Lookup Table for Wikipedia S&P 500 Pagessp500.dates sp500_dates
Stock Market Analysisstocks
Backtest a Fixed-Allocation Trading Strategytargetall
Backtest a Two-Fund Strategy that Targets a Certain Betatargetbeta_twofunds
Get Yahoo! Finance Start/End Dates for Tickersticker_dates
Convert Title back to Performance Metrictitle_metric
Vanguard ETF'svanguard.etfs vanguard_etfs
Vanguard Mutual Fundsvanguard.funds vanguard_funds
Vanguard Productsvanguard.products vanguard_products