body {
font-family: ‘Segoe UI’, Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
color: #333;
line-height: 1.6;
margin: 0;
padding: 0;
}
.container {
max-width: 1000px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
}
header {
background-color: #004a99;
color: #fff;
padding: 20px 0;
text-align: center;
width: 100%;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
header h1 {
margin: 0;
font-size: 2.5em;
font-weight: 700;
}
.calculator-section {
width: 100%;
margin-top: 30px;
padding: 25px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #fdfdfd;
}
.calculator-section h2 {
color: #004a99;
text-align: center;
margin-bottom: 25px;
font-size: 1.8em;
}
.input-group {
margin-bottom: 20px;
width: 100%;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #555;
}
.input-group input[type=”number”],
.input-group select {
width: calc(100% – 22px);
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
box-sizing: border-box;
}
.input-group select {
cursor: pointer;
}
.input-group .helper-text {
font-size: 0.85em;
color: #777;
margin-top: 5px;
display: block;
}
.error-message {
color: #dc3545;
font-size: 0.85em;
margin-top: 5px;
display: none; /* Hidden by default */
}
.error-message.visible {
display: block;
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 25px;
gap: 10px;
}
.button-group button {
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
font-weight: 600;
transition: background-color 0.3s ease;
flex-grow: 1;
}
.btn-calculate {
background-color: #004a99;
color: white;
}
.btn-calculate:hover {
background-color: #003366;
}
.btn-reset {
background-color: #6c757d;
color: white;
}
.btn-reset:hover {
background-color: #5a6268;
}
.results-section {
margin-top: 30px;
padding: 25px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #fdfdfd;
width: 100%;
box-sizing: border-box;
}
.results-section h2 {
color: #004a99;
text-align: center;
margin-bottom: 25px;
font-size: 1.8em;
}
#results-output {
text-align: center;
}
.primary-result {
font-size: 2.5em;
font-weight: 700;
color: #28a745;
background-color: #e9f7ec;
padding: 15px 20px;
border-radius: 6px;
margin-bottom: 20px;
display: inline-block;
min-width: 200px;
}
.intermediate-results div, .key-assumptions div {
margin-bottom: 10px;
font-size: 1.1em;
color: #555;
}
.intermediate-results span, .key-assumptions span {
font-weight: 600;
color: #004a99;
}
.formula-explanation {
margin-top: 20px;
font-size: 0.95em;
color: #666;
border-top: 1px dashed #ccc;
padding-top: 15px;
}
.copy-button {
background-color: #17a2b8;
color: white;
padding: 10px 15px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 0.95em;
margin-top: 20px;
transition: background-color 0.3s ease;
}
.copy-button:hover {
background-color: #138496;
}
.chart-container {
margin-top: 30px;
padding: 25px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #fdfdfd;
width: 100%;
box-sizing: border-box;
text-align: center;
}
.chart-container h2 {
color: #004a99;
margin-bottom: 25px;
font-size: 1.8em;
}
canvas {
max-width: 100%;
height: auto;
}
.table-container {
margin-top: 30px;
padding: 25px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #fdfdfd;
width: 100%;
box-sizing: border-box;
overflow-x: auto;
}
.table-container h2 {
color: #004a99;
margin-bottom: 25px;
font-size: 1.8em;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #004a99;
color: white;
font-weight: 600;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #e9ecef;
}
caption {
font-size: 1.1em;
color: #555;
margin-bottom: 10px;
font-weight: 600;
caption-side: top;
text-align: left;
}
.article-section {
margin-top: 40px;
padding: 30px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.article-section h2, .article-section h3 {
color: #004a99;
margin-bottom: 15px;
}
.article-section h2 {
font-size: 2em;
border-bottom: 2px solid #004a99;
padding-bottom: 10px;
}
.article-section h3 {
font-size: 1.5em;
margin-top: 25px;
}
.article-section p, .article-section ul, .article-section ol {
margin-bottom: 15px;
font-size: 1.05em;
}
.article-section ul, .article-section ol {
padding-left: 25px;
}
.article-section li {
margin-bottom: 8px;
}
.faq-item {
margin-bottom: 15px;
padding: 10px;
border-left: 3px solid #004a99;
background-color: #f9f9f9;
border-radius: 4px;
}
.faq-item strong {
color: #004a99;
display: block;
margin-bottom: 5px;
}
.internal-links {
margin-top: 30px;
padding: 25px;
background-color: #fdfdfd;
border: 1px solid #e0e0e0;
border-radius: 8px;
}
.internal-links h3 {
color: #004a99;
margin-bottom: 15px;
font-size: 1.5em;
text-align: center;
}
.internal-links ul {
list-style: none;
padding: 0;
}
.internal-links li {
margin-bottom: 10px;
}
.internal-links a {
color: #004a99;
text-decoration: none;
font-weight: 600;
}
.internal-links a:hover {
text-decoration: underline;
}
.internal-links p {
font-size: 0.95em;
color: #666;
margin-top: 5px;
}
.summary {
font-size: 1.1em;
color: #555;
margin-bottom: 25px;
text-align: center;
padding: 15px;
background-color: #eef7ff;
border-left: 4px solid #004a99;
border-radius: 4px;
}
@media (max-width: 768px) {
.container {
margin: 10px;
padding: 15px;
}
header h1 {
font-size: 1.8em;
}
.calculator-section, .results-section, .chart-container, .table-container, .article-section, .internal-links {
padding: 15px;
}
.primary-result {
font-size: 2em;
}
.button-group {
flex-direction: column;
gap: 10px;
}
.button-group button {
width: 100%;
}
}
Basel II Risk Weight Calculator
Calculate Risk-Weighted Assets (RWA)
This calculator helps financial institutions determine the risk weights for various credit exposures under the Basel II framework, a crucial step in calculating regulatory capital requirements.
The total value of the financial exposure (e.g., loan amount, bond value).
Sovereign (Developed Countries)
Sovereign (Emerging Countries)
Corporates (Investment Grade)
Corporates (Non-Investment Grade)
Retail
Commercial Real Estate (Performing)
Commercial Real Estate (Non-Performing)
Residential Real Estate (Performing)
Residential Real Estate (Non-Performing)
Unsecured Retail
Other Assets
Subordinated Debt
Equity Exposures (Standardised)
Cash and Gold
Select the category that best fits the exposure.
Enter the credit rating if available (e.g., from S&P, Moody’s). This can refine risk weights for certain categories.
Enter the PD as a decimal (e.g., 0.01 for 1%). Used for IRB approaches, not standard.
Enter the LGD as a decimal (e.g., 0.45 for 45%). Used for IRB approaches, not standard.
Calculation Results
Risk-Weighted Assets (RWA) = Exposure Value × Risk Weight (%)
The Risk Weight (%) is determined by the exposure’s category and, in some cases, its credit rating or specific parameters like PD and LGD (for more advanced approaches).
Risk Weight Distribution
Basel II Standardised Approach Risk Weights
| Exposure Category | Risk Weight (%) | Notes |
|---|---|---|
| Sovereign (Developed Countries) | 20% | Based on credit rating |
| Sovereign (Emerging Countries) | 50% | Based on credit rating |
| Corporates (Investment Grade) | 20% | Based on credit rating |
| Corporates (Non-Investment Grade) | 100% | Based on credit rating |
| Retail | 75% | Subject to specific criteria |
| Commercial Real Estate (Performing) | 125% | Subject to specific criteria |
| Commercial Real Estate (Non-Performing) | 150% | Higher risk |
| Residential Real Estate (Performing) | 100% | Subject to specific criteria |
| Residential Real Estate (Non-Performing) | 150% | Higher risk |
| Unsecured Retail | 100% | Higher risk |
| Other Assets | 100% | General category |
| Subordinated Debt | 100% | Higher risk |
| Equity Exposures (Standardised) | 100% | Standard approach |
| Cash and Gold | 0% | Lowest risk |
What is Basel II Risk Weight?
The Basel II Risk Weight is a crucial metric within the Basel Accords, specifically designed to quantify the credit risk associated with a bank’s assets. It’s not a direct measure of the asset’s value but rather a factor that translates the exposure amount into Risk-Weighted Assets (RWA). Regulatory bodies use RWA to determine the minimum amount of capital a bank must hold to absorb unexpected losses. A higher risk weight implies a higher perceived risk of default, thus requiring more capital to be held against that exposure. Understanding and accurately calculating the Basel II Risk Weight is fundamental for financial institutions to ensure solvency, manage risk effectively, and comply with international banking regulations.
Who Should Use It?
The primary users of Basel II Risk Weight calculations are regulated financial institutions, including:
- Commercial Banks
- Investment Banks
- Credit Unions
- Other deposit-taking institutions
Internal risk management departments, compliance officers, treasury teams, and capital adequacy managers within these institutions rely heavily on these calculations. External auditors and banking supervisors also utilize these figures to assess a bank’s financial health and adherence to regulatory standards. While the direct calculation is for institutions, understanding the concept is beneficial for anyone interested in bank regulation and financial stability.
Common Misconceptions
- Misconception: Risk Weight is the same as the asset’s interest rate.
Reality: Risk weight reflects credit risk, while interest rate reflects the cost of borrowing or return on lending. They are distinct concepts. - Misconception: A 0% risk weight means zero risk.
Reality: A 0% risk weight (like for cash) indicates the lowest regulatory capital charge due to minimal credit risk, but operational or liquidity risks may still exist. - Misconception: Basel II Risk Weight applies only to loans.
Reality: It applies to a wide range of credit exposures, including bonds, derivatives, guarantees, and even certain equity holdings. - Misconception: The risk weight is fixed for each asset class.
Reality: While categories provide a baseline, specific credit ratings, collateral, and the chosen regulatory approach (Standardised vs. Internal Ratings-Based) can significantly alter the final risk weight.
Basel II Risk Weight Formula and Mathematical Explanation
The Basel II framework introduced a more sophisticated approach to calculating regulatory capital. For credit risk, the core calculation involves determining Risk-Weighted Assets (RWA). The most common method for many institutions is the Standardised Approach.
Standardised Approach Formula
The fundamental formula for calculating RWA under the Standardised Approach is straightforward:
RWA = Exposure Value × Risk Weight (%)
Variable Explanations
- Exposure Value: This is the nominal amount of the asset or financial instrument that carries credit risk. For a loan, it’s typically the outstanding principal amount. For a bond, it’s the market value or book value.
- Risk Weight (%): This is a percentage assigned to the exposure based on its perceived credit risk. Basel II provides specific risk weights for different asset classes and counterparty types (e.g., sovereigns, corporates, retail). These weights are often adjusted based on external credit ratings.
Variables Table (Standardised Approach Example)
| Variable | Meaning | Unit | Typical Range / Values |
|---|---|---|---|
| Exposure Value | The principal amount of the asset exposed to credit risk. | Currency Unit (e.g., USD, EUR) | ≥ 0 |
| Risk Weight (%) | A regulatory factor reflecting the credit risk of the exposure. | Percentage (%) | 0% to 150% (or higher in specific cases) |
| Risk-Weighted Assets (RWA) | The calculated value representing the riskiness of the asset for capital adequacy purposes. | Currency Unit (e.g., USD, EUR) | ≥ 0 |
Internal Ratings-Based (IRB) Approach Considerations
For sophisticated banks that have received regulatory approval, the IRB approach allows for more granular risk assessment. In this approach, banks use their own internal models to estimate key risk components:
- Probability of Default (PD): The likelihood that a borrower will default within a one-year period.
- Loss Given Default (LGD): The proportion of the exposure that would be lost if the borrower defaults.
- Exposure at Default (EAD): The estimated exposure value at the time of default (can differ from current exposure due to potential future drawdowns).
- Maturity (M): The remaining term to maturity of the exposure.
The RWA calculation under IRB is more complex, often involving sophisticated formulas that incorporate these parameters. For example, a simplified version for corporate exposures might look like:
RWA = N( (1-b(PD))⁻¹ Φ(PD) + sqrt(PD/(1-PD)) * a(M) * 1.06 ) * EAD * 12.5 * LGD
Where N is the cumulative distribution function of the standard normal distribution, Φ is the inverse CDF, b(PD) is a function of PD, and a(M) is a maturity adjustment factor. This calculator primarily focuses on the Standardised Approach for simplicity, but acknowledges the existence of the IRB approach.
Practical Examples (Real-World Use Cases)
Example 1: Corporate Loan
A bank has provided a loan of €5,000,000 to a medium-sized corporation. The corporation has a credit rating of ‘BBB+’ from a recognized rating agency, placing it in the ‘Investment Grade’ category for corporate exposures under Basel II. The bank uses the Standardised Approach.
- Exposure Value: €5,000,000
- Risk Category: Corporates (Investment Grade)
- Assigned Risk Weight: 20% (based on the category and rating)
Calculation:
RWA = €5,000,000 × 20% = €1,000,000
Interpretation: The bank must hold regulatory capital against €1,000,000 of RWA. If the minimum capital ratio is 8%, the required capital for this specific exposure would be €80,000 (8% of €1,000,000).
Example 2: Residential Mortgage
A bank holds a portfolio of residential mortgages. One performing mortgage has an outstanding balance of $250,000. Under the Basel II Standardised Approach, performing residential real estate exposures typically carry a risk weight of 100%.
- Exposure Value: $250,000
- Risk Category: Residential Real Estate (Performing)
- Assigned Risk Weight: 100%
Calculation:
RWA = $250,000 × 100% = $250,000
Interpretation: This mortgage contributes $250,000 to the bank’s total RWA. The required capital, assuming an 8% ratio, would be $20,000.
Example 3: Sovereign Exposure
A bank holds bonds issued by a developed country’s government with a face value of €10,000,000. Sovereign exposures to developed countries typically have a very low risk weight, often 0% or 20% depending on the specific country’s creditworthiness and regulatory rules.
- Exposure Value: €10,000,000
- Risk Category: Sovereign (Developed Country)
- Assigned Risk Weight: 20% (assuming it’s not a zero-risk country)
Calculation:
RWA = €10,000,000 × 20% = €2,000,000
Interpretation: This sovereign exposure adds €2,000,000 to the RWA. This highlights how Basel II treats exposures to highly stable governments as less risky, requiring less capital.
How to Use This Basel II Risk Weight Calculator
Our Basel II Risk Weight Calculator is designed for ease of use, providing quick insights into regulatory capital requirements. Follow these simple steps:
Step-by-Step Instructions
- Enter Exposure Value: Input the total monetary value of the financial asset you wish to assess (e.g., the loan amount, bond principal).
- Select Risk Category: Choose the category that best describes the exposure from the dropdown menu. This is the primary determinant of the risk weight under the Standardised Approach.
- Input Credit Rating (Optional): If the exposure has an external credit rating (e.g., AAA, BB+), enter it. For some categories, this can refine the risk weight. If not applicable or unavailable, leave it blank.
- Enter PD & LGD (Optional): These fields are primarily relevant for banks using the Internal Ratings-Based (IRB) approach. If you are using the Standardised Approach, you can typically ignore these.
- Click ‘Calculate RWA’: Press the button to see the results.
How to Read Results
- Primary Result (Risk-Weighted Assets): This is the main output, showing the calculated RWA in the same currency unit as your input exposure. This figure is used to determine capital adequacy.
- Risk Weight (%): Displays the percentage assigned to your exposure based on the inputs.
- Credit Quality Score: A simplified indicator derived from the risk category and rating, offering a quick glance at perceived risk.
- Estimated Capital Requirement: This shows the minimum capital needed, assuming a standard 8% capital ratio (as per Basel requirements). It’s calculated as 8% of the RWA.
Decision-Making Guidance
The results from this Basel II Risk Weight Calculator can inform several key decisions:
- Capital Allocation: Understand how much capital needs to be set aside for different types of assets.
- Risk Management: Identify exposures with high risk weights that might require closer monitoring or mitigation strategies.
- Pricing: Factor in the cost of capital associated with high-RWA assets when setting loan or product pricing.
- Portfolio Management: Analyze the overall risk profile of the institution’s asset portfolio and adjust diversification strategies.
Remember, this calculator primarily uses the Standardised Approach. For institutions using the IRB approach, more detailed internal models are required.
Key Factors That Affect Basel II Risk Weight Results
Several factors influence the final Basel II Risk Weight assigned to an exposure, impacting the calculated RWA and subsequent capital requirements. Understanding these is key to accurate risk assessment:
- Asset Class / Exposure Category: This is the most significant factor. Basel II categorizes exposures (e.g., sovereign, corporate, retail, mortgages) and assigns baseline risk weights reflecting the general risk profile of each class. Higher-risk categories naturally receive higher weights.
- Credit Quality / Rating: For many categories (like corporates and sovereigns), external credit ratings (e.g., from S&P, Moody’s, Fitch) are used to differentiate risk within a class. A higher rating (e.g., AAA) leads to a lower risk weight, while a lower rating (e.g., B-) results in a higher weight. This calculator uses predefined weights but acknowledges rating’s role.
- Counterparty Type: The nature of the entity the bank has exposure to matters. Exposures to highly stable governments are treated differently than those to speculative corporations or individuals.
- Maturity of Exposure: While less prominent in the Standardised Approach’s basic calculation, longer-term exposures can sometimes be considered riskier, especially under the IRB framework, as there’s more time for credit quality to deteriorate.
- Collateral and Guarantees: The presence of eligible collateral (like property for mortgages) or guarantees from creditworthy third parties can reduce the effective risk of an exposure. Basel II provides specific rules for recognizing these risk mitigants, potentially lowering the risk weight.
- Regulatory Approach Chosen: Banks can use either the Standardised Approach (simpler, relies on regulatory-defined weights and ratings) or the Internal Ratings-Based (IRB) approach (more complex, uses internal models for PD, LGD, EAD). The IRB approach generally allows for lower capital requirements for well-managed banks with sophisticated risk systems, as it can better capture specific risks.
- Performing vs. Non-Performing Status: For certain asset classes like real estate, the distinction between performing (payments are up-to-date) and non-performing (payments are significantly delayed or defaulted) exposures leads to substantially different risk weights, reflecting the increased credit loss potential of non-performing assets.
Frequently Asked Questions (FAQ)
A1: Basel III built upon Basel II, primarily by increasing capital requirements (especially for Tier 1 capital), introducing new capital buffers (like the Capital Conservation Buffer and Countercyclical Buffer), and enhancing the framework for market risk and operational risk. For credit risk, Basel III refined the calculation of RWA, particularly for complex products and securitizations, and introduced stricter criteria for recognizing credit risk mitigation techniques.
A2: Yes, depending on the regulatory approach and specific circumstances. Under the Standardised Approach, the primary risk weight is determined by the asset class. However, if external ratings are used, the weight can be adjusted. Under the IRB approach, internal models calculate a unique risk weight based on PD, LGD, and EAD. Furthermore, the treatment of collateral or guarantees can modify the final risk weight.
A3: A 100% risk weight means that the exposure is treated as having a standard level of credit risk. For every $1 of exposure value, $1 is added to the Risk-Weighted Assets (RWA). This implies that the bank needs to hold capital equivalent to 8% of this exposure value (assuming an 8% minimum capital ratio).
A4: Under the Standardised Approach, unrated exposures often receive a higher risk weight than their rated counterparts. For example, an unrated corporate exposure might receive a 100% risk weight, whereas an investment-grade rated corporate exposure might only get 20%. This reflects the uncertainty associated with the lack of an external credit assessment.
A5: This calculator primarily focuses on the Standardised Approach for credit risk, which is the most common method. It includes typical risk weights for major asset classes and allows for optional input of credit ratings. It does not cover the complexities of the Internal Ratings-Based (IRB) approach in full detail, nor does it address market risk, operational risk, or specific advanced techniques like securitization framework calculations.
A6: Probability of Default (PD) and Loss Given Default (LGD) are key inputs for the Internal Ratings-Based (IRB) approach. PD estimates the likelihood of default, while LGD estimates the loss incurred if default occurs. These parameters, along with Exposure at Default (EAD), are used in sophisticated formulas to calculate RWA, allowing for a more risk-sensitive capital charge than the Standardised Approach.
A7: Basel II impacts profitability by requiring banks to hold more capital against riskier assets. This capital has a cost (e.g., shareholder expectations for return on equity). Higher RWA means more capital is required, potentially reducing the Return on Equity (ROE) if profitability doesn’t increase proportionally. Conversely, efficient risk management that lowers RWA can improve ROE.
A8: Basel III introduced significant changes, including stricter capital requirements, leverage ratios, and liquidity standards. For credit risk, Basel III refined RWA calculations, particularly for counterparty credit risk (e.g., derivatives) and securitizations. It also introduced capital buffers and aimed to reduce procyclicality, meaning risk weights might be more sensitive to economic cycles under Basel III.
Related Tools and Internal Resources
-
Capital Adequacy Ratio (CAR) Calculator
Understand how your RWA translates into regulatory capital ratios like Tier 1 and Total CAR.
-
Guide to Credit Risk Mitigation Techniques
Learn how collateral and guarantees can reduce exposure risk and potentially lower RWA.
-
Basel III Framework Explained
Explore the evolution from Basel II to Basel III and the latest regulatory requirements.
-
Loan Portfolio Analysis Tool
Analyze the risk profile and RWA contribution of your entire loan book.
-
Sovereign Risk Assessment Guide
Deep dive into factors affecting sovereign credit risk and their impact on Basel weights.
-
Understanding Corporate Credit Ratings
Learn how credit ratings are assigned and their significance in Basel II calculations.
var chartInstance = null; // Global variable to hold chart instance
function validateInput(id, min, max, errorMessageId, helperText) {
var input = document.getElementById(id);
var errorElement = document.getElementById(errorMessageId);
var value = parseFloat(input.value);
errorElement.innerText = ”;
errorElement.classList.remove(‘visible’);
input.style.borderColor = ‘#ccc’;
if (input.value === ”) {
// Allow empty for optional fields like rating, PD, LGD
if (id === ‘creditRating’ || id === ‘probabilityOfDefault’ || id === ‘lossGivenDefault’) {
return true;
}
errorElement.innerText = ‘This field is required.’;
errorElement.classList.add(‘visible’);
input.style.borderColor = ‘#dc3545’;
return false;
}
if (isNaN(value)) {
errorElement.innerText = ‘Please enter a valid number.’;
errorElement.classList.add(‘visible’);
input.style.borderColor = ‘#dc3545’;
return false;
}
if (min !== null && value max) {
errorElement.innerText = ‘Value exceeds maximum limit (‘ + max + ‘).’;
errorElement.classList.add(‘visible’);
input.style.borderColor = ‘#dc3545’;
return false;
}
return true;
}
function calculateRWA() {
var exposureValue = document.getElementById(‘exposureValue’);
var riskCategorySelect = document.getElementById(‘riskCategory’);
var probabilityOfDefaultInput = document.getElementById(‘probabilityOfDefault’);
var lossGivenDefaultInput = document.getElementById(‘lossGivenDefault’);
var exposureValueError = document.getElementById(‘exposureValueError’);
var probabilityOfDefaultError = document.getElementById(‘probabilityOfDefaultError’);
var lossGivenDefaultError = document.getElementById(‘lossGivenDefaultError’);
var isValid = true;
// Validate Exposure Value
if (!validateInput(‘exposureValue’, 0, null, ‘exposureValueError’)) isValid = false;
// Validate PD (Optional, but if entered, must be valid)
if (probabilityOfDefaultInput.value !== ”) {
if (!validateInput(‘probabilityOfDefault’, 0, 1, ‘probabilityOfDefaultError’)) isValid = false;
} else {
probabilityOfDefaultError.innerText = ”;
probabilityOfDefaultError.classList.remove(‘visible’);
probabilityOfDefaultInput.style.borderColor = ‘#ccc’;
}
// Validate LGD (Optional, but if entered, must be valid)
if (lossGivenDefaultInput.value !== ”) {
if (!validateInput(‘lossGivenDefault’, 0, 1, ‘lossGivenDefaultError’)) isValid = false;
} else {
lossGivenDefaultError.innerText = ”;
lossGivenDefaultError.classList.remove(‘visible’);
lossGivenDefaultInput.style.borderColor = ‘#ccc’;
}
if (!isValid) {
return;
}
var exposure = parseFloat(exposureValue.value);
var riskWeightPercent = parseFloat(riskCategorySelect.value) * 100; // Convert decimal to percentage
var pd = parseFloat(probabilityOfDefaultInput.value) || 0; // Default to 0 if empty or invalid
var lgd = parseFloat(lossGivenDefaultInput.value) || 0; // Default to 0 if empty or invalid
var rwa = exposure * (riskWeightPercent / 100);
var capitalRequirement = rwa * 0.08; // Assuming 8% capital ratio
// Simplified Credit Quality Score (example logic)
var creditQualityScore = “Average”;
if (riskWeightPercent <= 20) creditQualityScore = "Excellent";
else if (riskWeightPercent <= 50) creditQualityScore = "Good";
else if (riskWeightPercent <= 100) creditQualityScore = "Moderate";
else creditQualityScore = "High Risk";
document.getElementById('riskWeightedAssets').innerText = formatCurrency(rwa);
document.getElementById('riskWeightPercentage').getElementsByTagName('span')[0].innerText = riskWeightPercent.toFixed(2);
document.getElementById('creditQualityScore').getElementsByTagName('span')[0].innerText = creditQualityScore;
document.getElementById('capitalRequirement').getElementsByTagName('span')[0].innerText = formatCurrency(capitalRequirement);
updateChart(exposure, riskWeightPercent, rwa);
}
function formatCurrency(amount) {
if (isNaN(amount) || amount === null) return '–';
// Basic currency formatting, assuming no specific currency symbol needed for RWA
return amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0 });
}
function resetCalculator() {
document.getElementById('exposureValue').value = '1000000';
document.getElementById('riskCategory').value = '1.00'; // Default to Corporates (Non-Investment Grade) or similar common value
document.getElementById('creditRating').value = '';
document.getElementById('probabilityOfDefault').value = '';
document.getElementById('lossGivenDefault').value = '';
document.getElementById('exposureValueError').innerText = '';
document.getElementById('exposureValueError').classList.remove('visible');
document.getElementById('probabilityOfDefaultError').innerText = '';
document.getElementById('probabilityOfDefaultError').classList.remove('visible');
document.getElementById('lossGivenDefaultError').innerText = '';
document.getElementById('lossGivenDefaultError').classList.remove('visible');
document.getElementById('exposureValue').style.borderColor = '#ccc';
document.getElementById('probabilityOfDefault').style.borderColor = '#ccc';
document.getElementById('lossGivenDefault').style.borderColor = '#ccc';
// Reset results display
document.getElementById('riskWeightedAssets').innerText = '–';
document.getElementById('riskWeightPercentage').getElementsByTagName('span')[0].innerText = '–';
document.getElementById('creditQualityScore').getElementsByTagName('span')[0].innerText = '–';
document.getElementById('capitalRequirement').getElementsByTagName('span')[0].innerText = '–';
// Reset chart
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
var ctx = document.getElementById('riskWeightChart').getContext('2d');
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); // Clear canvas
}
function copyResults() {
var rwa = document.getElementById('riskWeightedAssets').innerText;
var riskWeight = document.getElementById('riskWeightPercentage').getElementsByTagName('span')[0].innerText;
var creditQuality = document.getElementById('creditQualityScore').getElementsByTagName('span')[0].innerText;
var capitalReq = document.getElementById('capitalRequirement').getElementsByTagName('span')[0].innerText;
var exposureValue = document.getElementById('exposureValue').value;
var riskCategory = document.getElementById('riskCategory').options[document.getElementById('riskCategory').selectedIndex].text;
var creditRating = document.getElementById('creditRating').value || 'N/A';
var pd = document.getElementById('probabilityOfDefault').value || 'N/A';
var lgd = document.getElementById('lossGivenDefault').value || 'N/A';
var textToCopy = "— Basel II Risk Weight Calculation Results —\n\n";
textToCopy += "Key Metrics:\n";
textToCopy += "- Risk-Weighted Assets (RWA): " + rwa + "\n";
textToCopy += "- Risk Weight: " + riskWeight + "%\n";
textToCopy += "- Credit Quality Score: " + creditQuality + "\n";
textToCopy += "- Estimated Capital Requirement (8%): " + capitalReq + "\n\n";
textToCopy += "Assumptions/Inputs:\n";
textToCopy += "- Exposure Value: " + exposureValue + "\n";
textToCopy += "- Risk Category: " + riskCategory + "\n";
textToCopy += "- Credit Rating: " + creditRating + "\n";
textToCopy += "- Probability of Default (PD): " + pd + "\n";
textToCopy += "- Loss Given Default (LGD): " + lgd + "\n";
navigator.clipboard.writeText(textToCopy).then(function() {
alert('Results copied to clipboard!');
}).catch(function(err) {
console.error('Failed to copy results: ', err);
alert('Failed to copy results. Please copy manually.');
});
}
function updateChart(exposure, riskWeightPercent, rwa) {
var ctx = document.getElementById('riskWeightChart').getContext('2d');
// Destroy previous chart instance if it exists
if (chartInstance) {
chartInstance.destroy();
}
// Sample data for chart – representing different risk categories
// In a real scenario, you might pre-populate or dynamically generate this based on common categories
var chartData = {
labels: ['Cash/Gold (0%)', 'Sovereign Dev (20%)', 'Corp Inv (20%)', 'Retail (75%)', 'CRE Perf (125%)', 'CRE NonPerf (150%)', 'Other (100%)'],
datasets: [{
label: 'Risk Weight (%)',
data: [0, 20, 20, 75, 125, 150, 100],
backgroundColor: [
'rgba(40, 167, 69, 0.6)', // Green for low risk
'rgba(0, 74, 153, 0.6)', // Primary blue for medium risk
'rgba(0, 74, 153, 0.6)',
'rgba(255, 193, 7, 0.6)', // Yellow for moderate risk
'rgba(220, 53, 69, 0.6)', // Red for high risk
'rgba(220, 53, 69, 0.6)',
'rgba(108, 117, 125, 0.6)' // Gray for general
],
borderColor: [
'rgba(40, 167, 69, 1)',
'rgba(0, 74, 153, 1)',
'rgba(0, 74, 153, 1)',
'rgba(255, 193, 7, 1)',
'rgba(220, 53, 69, 1)',
'rgba(220, 53, 69, 1)',
'rgba(108, 117, 125, 1)'
],
borderWidth: 1,
yAxisID: 'y-axis-risk-weight' // Assign to the risk weight axis
},
{
label: 'RWA Contribution (Example)',
// This dataset is illustrative. A real dynamic chart might show contribution based on input.
// For simplicity, we'll show a scaled version of the input RWA against a baseline exposure.
data: [
(exposure * 0.00 / 1000000), // Scaled for visibility
(exposure * 0.20 / 1000000),
(exposure * 0.20 / 1000000),
(exposure * 0.75 / 1000000),
(exposure * 1.25 / 1000000),
(exposure * 1.50 / 1000000),
(exposure * 1.00 / 1000000)
],
backgroundColor: 'rgba(28, 134, 237, 0.5)', // Different color for RWA
borderColor: 'rgba(28, 134, 237, 1)',
borderWidth: 1,
yAxisID: 'y-axis-rwa' // Assign to the RWA axis
}]
};
chartInstance = new Chart(ctx, {
type: 'bar',
data: chartData,
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
title: {
display: true,
text: 'Exposure Category'
}
},
'y-axis-risk-weight': {
type: 'linear',
position: 'left',
title: {
display: true,
text: 'Risk Weight (%)'
},
ticks: {
beginAtZero: true,
callback: function(value) {
return value + '%';
}
},
grid: {
drawOnChartArea: true, // Only draw grid lines for this axis
}
},
'y-axis-rwa': {
type: 'linear',
position: 'right',
title: {
display: true,
text: 'RWA Contribution (Scaled Example)'
},
ticks: {
beginAtZero: true,
callback: function(value) {
// Scale back for display if needed, or just show relative value
return formatCurrency(value * 1000000); // Example scaling
}
},
grid: {
drawOnChartArea: false, // Don't draw grid lines overlapping the other axis
}
}
},
plugins: {
title: {
display: true,
text: 'Basel II Risk Weights and RWA Contribution by Category'
},
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
if (context.dataset.label.includes('Risk Weight')) {
label += context.parsed.y + '%';
} else {
label += formatCurrency(context.parsed.y * 1000000); // Scale back RWA example
}
}
return label;
}
}
}
}
}
});
}
// Initial calculation on load to populate chart with defaults
document.addEventListener('DOMContentLoaded', function() {
resetCalculator(); // Set default values
calculateRWA(); // Perform initial calculation to display default chart
});
// Add event listeners for real-time updates on input changes
document.getElementById('exposureValue').addEventListener('input', calculateRWA);
document.getElementById('riskCategory').addEventListener('change', calculateRWA);
document.getElementById('creditRating').addEventListener('input', calculateRWA); // Optional, but good for UX
document.getElementById('probabilityOfDefault').addEventListener('input', calculateRWA);
document.getElementById('lossGivenDefault').addEventListener('input', calculateRWA);