creditportfolioanalyseR

creditportfolioanalyseR is a package that carries out stochastic modelling for bond portfolios.

Installation

You can install the development version of creditportfolioanalyseR like so:

  1. Create an Azure DevOps Personal Access Token:
  2. Install the package in R:
# Edit .Renviron file
usethis::edit_r_environ()

# Add this line to the .Renviron file, 
# where you overwrite your-personal-access-token 
# with the token you copied to your clipboard:
AZURE_PAT=your-personal-access-token

# Save and restart R
.rs.restartR()

# Make sure you have the remotes and the git2r packages.
install.packages("remotes")
install.packages("git2r")

# Then install without exposing token in code.
remotes::install_git(
  url = "https://dev.azure.com/BarnettWaddingham/Insurance%20Consulting/_git/creditportfolioanalyseR",
  credentials = git2r::cred_user_pass("PAT", Sys.getenv("AZURE_PAT")),
  force = TRUE
)

library(creditportfolioanalyseR)

Example

This is a basic example to run the model:

library(creditportfolioanalyseR)

# Load the sample parameters.  
# This creates a list object, with parameters as items in the list
# Each list item can be edited to customise how the model is run
parameters <- get_sample_parameters()

# Load the template configuration.
# You can download the template xlsx template file by running 
# download_template_config <- function(dest_path = "config_template.xlsx")
# If you create your own custom config, then get_config should be pointed to your own config file.
config <- get_config()

# The model is designed to run several scenarios with slightly tweaked parameters
# Create a model results varaible to store all model results.
model_results <- c()

# Run the model for your paramaters and config.
model_results$scenario_results <-
  run_stochastic_model(
    num_workers = 1, # Required for all runs
    parameters = parameters, # Required for all runs
    config = config, # Required for all runs
    
    # All remaining parameters are optional, and are used to overwrite parameters for this run.
    seed_number = NA,
    default_recovery = NA,
    correlation = NA,
    duration = 5,
    num_simulations = NA,
    maturity_cashflow = NA,
    model_concentration = NA,
    debug_outputs = NA,
    end_year_rebalance = 3,
    sector = NA,
    date = NA,
    transition_vector = NA,
    portfolio_name = "1000_BBB",
    concentration_name = NA
  )
#> 1.44 sec elapsed

Versioning

The version number has four levels, e.g. 1.0.0.5. From lowest to highest
- Level 4: non-functional chores (documentation, unit tests, etc.)
- Level 3: bug-fixes and modest refactors
- Level 2: New feature
- Level 1: Release versions

Methodology

[TBC]

Contributing

Contributions are appreciated. Please report suggestions to Amit ().

Keeping readme up-to-date

Keep this document up to date by editing README.Rmd and rendering with devtools::build_readme().