Skip to content

Instantly share code, notes, and snippets.

View knshiro's full-sized avatar
🍷
Creating a network for international Food and Beverage professionals

Ugo Bataillard knshiro

🍷
Creating a network for international Food and Beverage professionals
View GitHub Profile
/* Expected exposure is the expected (average) credit exposure conditional on positive market values */
def expectedExposure(marketValues: Seq[Double]): Double = {
val exposures = marketValues.filter(_ > 0f)
if (exposures.size == 0) 0.0
else exposures.sum / exposures.size
}
/* A high percentile (95%) of the distribution of exposures at any particular future date. Also called Peak Exposure (PE) */
def potentialFutureExposure(marketValues: Seq[Double], confidenceLevel: Double): Double = {
val exposures = marketValues.filter(_ > 0)