Skip to main content
deleted 181 characters in body
Source Link

I've converted the following formula for a Banking regulatory regulation, to help calculate how much money the bank needs to set aside:

Capital Requirement Formula

I know it's not the perfect code, but it outputs the correct values. Could anyone give me some pointers on how to make the operation more Pythonic?

def capital_requirement(r, lgd, pd, madj, tenor):
    '''Returns the capital requirement.'''
    madjcoeff = 1.5
    tsub = 2.5
    a1 = (stat.norm.ppf(pd) + r**0.5 * stat.norm.ppf(0.999)) / ((1 - r)**0.5)
    b1 = lgd * stat.norm.cdf(a1) - lgd * pd
    return b1 * (1 + ((tenor - tsub) * madj)) / (1- madjcoeff * madj)

See: https://en.wikipedia.org/wiki/Capital_requirement

I've converted the following formula for a Banking regulatory regulation, to help calculate how much money the bank needs to set aside:

Capital Requirement Formula

I know it's not the perfect code, but it outputs the correct values. Could anyone give me some pointers on how to make the operation more Pythonic?

def capital_requirement(r, lgd, pd, madj, tenor):
    '''Returns the capital requirement.'''
    madjcoeff = 1.5
    tsub = 2.5
    a1 = (stat.norm.ppf(pd) + r**0.5 * stat.norm.ppf(0.999)) / ((1 - r)**0.5)
    b1 = lgd * stat.norm.cdf(a1) - lgd * pd
    return b1 * (1 + ((tenor - tsub) * madj)) / (1- madjcoeff * madj)

See: https://en.wikipedia.org/wiki/Capital_requirement

I know it's not the perfect code, but it outputs the correct values. Could anyone give me some pointers on how to make the operation more Pythonic?

def capital_requirement(r, lgd, pd, madj, tenor):
    '''Returns the capital requirement.'''
    madjcoeff = 1.5
    tsub = 2.5
    a1 = (stat.norm.ppf(pd) + r**0.5 * stat.norm.ppf(0.999)) / ((1 - r)**0.5)
    b1 = lgd * stat.norm.cdf(a1) - lgd * pd
    return b1 * (1 + ((tenor - tsub) * madj)) / (1- madjcoeff * madj)

See: https://en.wikipedia.org/wiki/Capital_requirement

Source Link

Banking: Calculate the Capital Requirement to calculate Risk-Weighted Assets

I've converted the following formula for a Banking regulatory regulation, to help calculate how much money the bank needs to set aside:

Capital Requirement Formula

I know it's not the perfect code, but it outputs the correct values. Could anyone give me some pointers on how to make the operation more Pythonic?

def capital_requirement(r, lgd, pd, madj, tenor):
    '''Returns the capital requirement.'''
    madjcoeff = 1.5
    tsub = 2.5
    a1 = (stat.norm.ppf(pd) + r**0.5 * stat.norm.ppf(0.999)) / ((1 - r)**0.5)
    b1 = lgd * stat.norm.cdf(a1) - lgd * pd
    return b1 * (1 + ((tenor - tsub) * madj)) / (1- madjcoeff * madj)

See: https://en.wikipedia.org/wiki/Capital_requirement