#182easyRisk
Stress Test Scenario
Time Limit: 2sMemory: 256MB
Problem
Given a portfolio of positions, each with a weight and a beta (sensitivity to the market), compute the portfolio's percentage loss under a market stress scenario.
Each position's loss is proportional to its weight, beta, and the market decline:
Input Format
- Line 1: integer
n(number of positions) - Next
nlines: two floatsweight betaper position - Last line: float
market_drop(percentage)
Output Format
The portfolio loss as a percentage, to 4 decimal places.
Examples
Example 1
Input(Line 1: integer n (number of positions))
3 0.4 1.2 0.3 0.8 0.3 1.5 10.0
Output
11.7000
Loss = 0.4*1.2*10 + 0.3*0.8*10 + 0.3*1.5*10 = 4.8 + 2.4 + 4.5 = 11.7%.
Example 2
Input(Line 1: integer n (number of positions))
2 0.5 1.0 0.5 1.0 5.0
Output
5.0000
Both positions have beta=1, so portfolio loss equals market drop.
Constraints
- •1 ≤ n ≤ 100
- •0 ≤ weight_i ≤ 1, weights sum to 1
- •0 ≤ beta_i ≤ 5
- •0 < market_drop ≤ 50 (in percent)
- •Output portfolio loss percentage to 4 decimal places
Loading interactive editor…