/fundManageR

An Investment Management toolkit for R. Because Excel is a threat to the global financial system.

Primary LanguageROtherNOASSERTION

fundManageR

fundManageR — R’s Investment Management Toolkit
Because the Industry Must Liberate Itself from the Chains of Excel

fundManageR

What is fundManageR?

Outside of a few isolated pockets, the participants in the $67,0000,000,000 + United States investment management are trapped in Excel-centric universe. This is a dangerous state of being

Whether you are talking about Private Equity, Venture Capital, Real Estate Private Equity or Hedge Funds, industry professionals are executing important business functions dangerously and inefficiently through a maze of Excel spreadsheets.

The purpose of this package is to provide R proficient industry professionals a generalized framework that provides out-of-the-box access to functions that perform many standardizable industry pertinent calculations.

As an added bonus this package also wraps access to a growing array of data silos, including the first full wrapper of the SEC’s Investment Adviser Public Disclosure database in any of the major programming languages. It’s my hope that this package’s data acquisition functionality will be of use to industry professionals, academics, journalists, or anyone who enjoys exploring interesting data sets.

Why fundManageR?

Excel, while convenient for some, is poorly suited for important data analysis and modelling. Billions of dollars have been lost throughout the investment management universe as a direct result of uncaught Excel errors. Here are few examples:

Further more, for many of the most common calculations, there is countless duplication of methods to perform common calculations, and in many cases formulas are left unchecked and errors end up having extreme consequences down the line.

Though in its extreme infancy, fundManageR is my attempt to provide an easy to use framework for these calculations to be performed in R, through an open and readable API, consistent with Hadley Wickham’s tidy tools manifesto. These calculations have fault checks to ensure accuracy and designed for iteration which allows for complex calculations that Excel would be unable to execute.

The package’s other motive is to provide easy access to the financial industry’s dark data, hidden and public APIs. This should enable better transparency around one of the United States’ most vital industries. As the old saying goes, when in doubt Follow the Money, fundManageR should help to do this.

Package Dependencies

In order for this package to work you need the packages listed below must be installed. You can run the code snippet to install them if necessary.

For pdftools you may need to follow the installation instructions here.

packages <- 
  c("curl", "curlconverter", "dplyr", "formattable", "httr", "jsonlite", 'devtools',
    "lazyeval", "lubridate", "magrittr", "pdftools", "purrr", "readr",  'quantmod',
    "readxl", "rvest", "stringi", "stringr", "tibble", "tidyr", 'tidyverse',
    "xml2", "")

lapply(packages, install.packages)

Package Installation

devtools::install_github("abresler/fundManageR")

Package Idioms

fundManageR is built around 2 full function families and another with 1 usable, but powerful, with many more on the way.

  • calculate_ – this function family performs common industry specific and generalized calculations.
  • `` – this function family retrieves data either from a specified silo or based upon user inputs.
  • visualize_ – this function family performs pre-packaged visualizations geared towards the data this package brings in or helps the user to create.

calculate_ Functions

  • calculate_cash_flow_dates – Calculates summary cash flows for a specified dates and cash flows
  • calculate_irr_periods – Calculates interal rate of return for specified dates and cash flows
  • calculate_cash_flows_returns – Calculates investment returns for specified dates and cash flows
  • calculate_cash_flow_waterfall – Calculates a cash flow waterfall given specified dates, cash flows and promote structure
  • calculate_cash_flow_waterfall_partnership – Calculates partnership level returns and waterfall given specified equity splits, promote structure, and cash flows.
  • calculate_loan_payment – Calculates loan repayment data given specified parameters
  • calculate_residual_valuation_ebitda_multiples – Calculates residual values given specified EBITDA and EBITDA Multiples
  • calculate_residual_valuation_cap_rates – Calculates residual value given specified Net Operating Income and Capitalization Rates
  • calculate_leverage_metrics – Caluclates crude leveraged cash flow metrics for a given set of inputs. Ideal for back of the envelope type calculations of a potential leveraged asset purchase.
  • calculate_valuation_post_money – Calculates entity ownership post investment
  • calculate_days_accrued_pref – Calculates accrued preference/interest for a specified period.

Parallel Computing

This package now supports parallel computing for all iterative functions. In order to utilize this just run `future::plan with your selected method.

For example to use muiltiprocess.

library(fundManageR)
library(future)
plan(multiprocess) 
fred_symbols(symbols = c("DGS10", "DGS2", "DGS30"))

ADV API

  • adv_period_urls – Retrieves all possible ADV summary periods.
  • adv_managers_current_period_summary – Retrieves summary data for ADV filing managers from the most recent monthly filing period.
  • adv_managers_periods_summaries– Retrieves summary ADV filings for specified periods and filing type. By default the files will be saved to and loaded from a temporary directory however a user can override this default by specifying a file directory. If you specify a file directory you can also specify folder name, if you don’t do this the folder adv_data is created by default. You can also tell the function to delete the folders and empty the trash by setting remove_files and empty_trash to TRUE.
  • sec_adv_manager_sitemap– Retrieves a data frame with the possible detailed ADV sections and their descriptions.
  • adv_managers_metadata – Retrieves metadata for specified search name or CRD ID; fastest way to search for managers you may wish to explore further.
  • adv_managers_filings – Retrieves detailed ADV filing for specified Central Registration Depository ID [CRD] and/or company name by by specified ADV section.
  • adv_managers_brochures – Retrieves and OCRs for SEC mandated annual Uniform Requirements for the Investment Adviser Brochure and Brochure Supplements for specified CRDs and/or company names.

visualize_ Functions

  • visualize_tibble – This function allows the user to visualize a data frame object to better understand the structure and contents of a data frame. The function utlizes the fantastic listviewer package which wraps Jos de Jong’s JSON Editor project

Vignettes

Interactive Analysis Tools

Brief Examples

Most Recent ADV Summary Data

library(fundManageR)
recent_period_summary <- 
  adv_managers_current_period_summary(file_directory = NULL)

Detailed Manager Search

test_manager <- 
  fundManageR::adv_managers_filings(
    search_names = 'EJF Capital',
    crd_ids = 156663,
    all_sections = T,
    assign_to_environment = T
  )

YCombinator Alumni

ycombinator_alumni <- 
  fundManageR::ycombinator_alumni()

ycombinator_alumni %>% 
  visualize_tibble(edit = F) ## visualize it
IRR Calculation
library(dplyr)
dates <- 
  c("2015-10-09", "2016-09-26") %>% lubridate::ymd()

land_purchase_price <-
  -1000000 %>% formattable::currency()

land_sale_price <-
  1300000 %>% formattable::currency()

cash_flows <- 
  c(land_purchase_price, land_sale_price)

fundManageR::calculate_irr_periods(dates = dates, cash_flows = cash_flows, return_wide = T)