R/CalcNGR.R

Defines functions CalcNGR

Documented in CalcNGR

#' Calculates the Net/Gross ratio used under the CEM regulatory framework
#' @title Calculates the Net/Gross ratio (NGR)
#' @param MtM_Vector A vector containing the trades to be netted
#' @return The Net-Gross ratio (NGR)
#' @export
#' @author Tasos Grivas <tasos@@openriskcalculator.com>
#'
CalcNGR = function(MtM_Vector)
{
  if (all(MtM_Vector== 0)) 
  { NGR = 1  
  } else if(all(MtM_Vector< 0))
  { NGR = 0
  } else
  {   NGR = max(sum(MtM_Vector),0)/sum(max(MtM_Vector,0))
  }
  return(NGR)
}

Try the xVA package in your browser

Any scripts or data that you put into this service are public.

xVA documentation built on Aug. 28, 2022, 1:06 a.m.