• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
MRPRRSIDENT

MRPRRSIDENT

Optionevents

Public
Like
Optionevents
Home
Code
7
backend
1
frontend
10
shared
1
README.md
main.tsx
new-file-4782.ts
new-file-5090.tsx
Branches
2
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
index.ts
https://MRPRRSIDENT--e422e520949911f0a25e0224a6c84d84.web.val.run
README.md

MP Capital - FRTB Risk Calculator

A comprehensive FRTB (Fundamental Review of the Trading Book) Calculator built for MP Capital's risk management operations. This application calculates market risk capital requirements for banks and financial institutions according to the Basel III FRTB framework using the Simplified Standardized Approach.

🏦 Overview

This professional-grade financial risk management tool helps calculate regulatory capital requirements across multiple asset classes with comprehensive derivative product coverage:

Core Asset Classes

  • Equities - Cash equities, indices, ETFs, equity options, futures, and swaps
  • Fixed Income - Government bonds, corporate bonds, MBS, interest rate derivatives, bond futures
  • Foreign Exchange - Spot FX, forwards, options, futures, and exotic derivatives
  • Commodities - Energy, metals, agricultural products, and commodity derivatives

Derivative Products

  • Credit Derivatives - Credit default swaps, credit indices, structured credit products
  • Alternative Investments - Real estate, private equity, hedge funds, infrastructure
  • Volatility Derivatives - VIX products, variance swaps, volatility indices
  • Structured Products - Equity-linked, interest rate-linked, currency-linked notes

🎯 Key Features

Risk Calculation Engine

  • Delta Risk: Linear price risk from underlying asset movements
  • Vega Risk: Risk from volatility changes
  • Curvature Risk: Non-linear price risk (gamma effects)
  • Basel III Compliance: Uses official risk weights and correlation factors

Professional Interface

  • MP Capital Branding: Custom styling with company colors and fonts
  • Results Dashboard: Comprehensive risk visualization
  • Input Methods: Manual forms, Excel upload, sample data
  • Historical Risk Tracking: Date-stamped uploads with trend analysis and statistical significance testing
  • Excel Upload & Validation: Professional-grade file processing with:
    • Drag-and-drop interface
    • Comprehensive data validation and reconciliation
    • Detailed error and warning reporting
    • Format examples for all asset classes
    • Excel template download with sample data
    • Step-by-step processing workflow
  • Responsive Design: Works on desktop and mobile devices

Web Pages

  • /: Results dashboard with pre-calculated sample data
  • /input: Data input interface with multiple input methods
  • /excel-upload: Professional Excel upload with validation and reconciliation
  • /counterparty: Counterparty risk aggregation analysis
  • /architecture: System architecture and UML diagrams
  • /regulatory: Basel III FRTB regulatory factors and risk weights
  • /instruments: Comprehensive instrument hierarchy management with derivative products
  • /reports: Historical risk analysis and trend monitoring with statistical significance testing

API Endpoints

  • POST /api/calculate: Performs FRTB calculations
  • GET /api/sample-data: Returns sample trading book data
  • POST /api/counterparty-aggregation: Calculates counterparty risk aggregation
  • POST /api/validate-excel: Validates uploaded Excel data with comprehensive error reporting

🏗️ Architecture

├── backend/
│   └── index.ts              # Hono API server with HTTP trigger
├── frontend/
│   ├── index.html            # Results dashboard
│   └── input.html            # Data input interface
├── shared/
│   └── frtb-calculator.ts    # Core calculation engine
└── README.md

💰 Sample Results

With pre-loaded sample data:

  • Total Capital Requirement: ~$4.35 million
  • Risk-Weighted Assets: ~$54.3 million
  • Asset Class Breakdown:
    • Fixed Income: $2.9M (largest risk component)
    • FX: $518K
    • Commodities: $475K
    • Equities: $455K

🎨 Design System

MP Capital Brand Colors

  • Primary: #1a365d (Deep Navy)
  • Secondary: #2d5a87 (Medium Blue)
  • Accent: #4a90b8 (Light Blue)

Typography

  • Font: Inter (Google Fonts)
  • Weights: 300, 400, 500, 600, 700

🔧 Technical Stack

  • Backend: Hono.js framework
  • Frontend: Vanilla HTML/CSS/JavaScript
  • Styling: TailwindCSS + Custom MP Capital theme
  • File Handling: SheetJS for Excel processing
  • Deployment: Val Town serverless platform

📊 Regulatory Compliance

This calculator implements:

  • Basel III FRTB Simplified Standardized Approach
  • Official risk weights for all asset classes
  • Correlation adjustments and stress scenarios
  • Proper risk aggregation methodologies
  • Transparent calculations with detailed explanations

🚀 Usage

  1. Access the Application: Navigate to the main URL
  2. View Results: See pre-calculated sample results on the dashboard
  3. Input Data: Use /input to enter your own trading book positions
  4. Excel Upload: Use /excel-upload for professional file processing with:
    • Template Download: Get pre-configured Excel template
    • Format Validation: Comprehensive data quality checks
    • Error Reconciliation: Detailed reporting of data issues
    • Step-by-step Process: Upload → Validate → Calculate workflow
  5. Multiple Input Methods:
    • Manual form entry
    • Excel file upload (with template)
    • Load sample data for testing

📊 Risk Reports & Historical Analysis

The application features comprehensive historical risk tracking and statistical analysis:

🔧 Key Features

  • Date-Stamped Uploads: Each Excel upload includes trading date and optional description
  • Historical Data Storage: Automatic storage of all FRTB calculations with timestamps
  • Trend Visualization: Interactive charts showing risk evolution over time
  • Statistical Significance Testing: Advanced statistical methods to detect significant risk jumps
  • Asset Class Breakdown: Separate trend analysis for each asset class
  • Alert System: Automated detection of unusual risk movements

📈 Statistical Method: Modified Z-Score Analysis

The system uses a sophisticated statistical approach to identify significant risk changes:

  • Rolling Window: 30-day rolling mean and standard deviation calculation
  • Z-Score Calculation: Z = (Current Value - Rolling Mean) / Rolling Std Dev
  • Significance Thresholds:
    • High Alert: |Z| > 2.5 (99.4% confidence)
    • Medium Alert: |Z| > 2.0 (95.4% confidence)
    • Low Alert: |Z| > 1.5 (86.6% confidence)
  • Jump Detection: Identifies consecutive increases/decreases with statistical significance
  • Adaptive Analysis: Rolling statistics adapt to changing market conditions

📋 Report Features

  • Summary Statistics: Total data points, latest risk values, trend indicators
  • Interactive Charts: Clickable data points with detailed tooltips
  • Historical Data Table: Sortable table with all historical calculations
  • Significant Events: Highlighted periods of unusual risk activity
  • Export Capabilities: View detailed results for any historical date

📊 Excel Upload & Validation

The application features a comprehensive Excel upload system designed for professional trading book management:

🔧 Key Features

  • Drag-and-Drop Interface: Modern file upload with visual feedback
  • Template Download: Pre-configured Excel template with sample data
  • Multi-Sheet Support: Separate sheets for Equities, Fixed Income, FX, and Commodities
  • Data Validation: Comprehensive validation with detailed error reporting
  • Format Examples: Clear visual examples for all required data formats
  • Reconciliation Reports: Detailed analysis of data quality issues

📋 Required Excel Format

Each asset class requires a separate sheet with specific columns:

Equities Sheet:

  • Counterparty, Instrument, Notional, Delta, Vega, Curvature

Fixed Income Sheet:

  • Counterparty, Instrument, Notional, Duration, Convexity, Spread

FX Sheet:

  • Counterparty, Pair, Notional, Delta, Vega

Commodities Sheet:

  • Counterparty, Instrument, Notional, Delta, Vega

✅ Validation Features

  • Data Type Validation: Ensures numeric fields are properly formatted
  • Range Validation: Checks for realistic values (e.g., Delta between -1 and 1)
  • Required Field Validation: Ensures all mandatory fields are populated
  • Counterparty Tracking: Validates and tracks unique counterparty names
  • Warning System: Flags unusual but acceptable values
  • Error Reporting: Detailed line-by-line error identification

📈 Target Users

  • Risk Managers calculating regulatory capital
  • Compliance Teams ensuring Basel III adherence
  • Finance Professionals learning FRTB methodology
  • Banks & Financial Institutions requiring capital calculations

© 2024 MP Capital. All rights reserved.
Basel III FRTB Compliance Tool

HTTP
  • index.ts
    MRPRRSIDENT--e4…84.web.val.run
Code
backendfrontendsharedREADME.mdmain.tsxnew-file-4782.tsnew-file-5090.tsx
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.