Analyze $ARGUMENTS to determine the portfolio holdings list and scenario, then execute the following command.
Execution command
python3 /Users/kikuchihiroyuki/stock-skills/.claude/skills/stress-test/scripts/run_stress_test.py --portfolio <symbols> [--scenario <scenario>] [--weights <weights>]
Natural language routing
For natural language → skill determination, refer to .claude/rules/intent-routing.md .
Argument interpretation rules
portfolio (holdings list, required)
Extract a comma-separated holdings list from the user's input. If specified with space separation, convert it to comma separation as well.
| User input example | --portfolio value |
|---|---|
7203.T,AAPL,D05.SI |
7203.T,AAPL,D05.SI |
7203.T AAPL D05.SI |
7203.T,AAPL,D05.SI |
トヨタ アップル |
Specify after converting to the corresponding ticker |
weights (holding ratios, optional)
A comma-separated ratio list. Specify the same number of values as the number of holdings. If omitted, equal weighting (1/N for each holding).
| User input example | --weights value |
|---|---|
0.5,0.3,0.2 |
0.5,0.3,0.2 |
50%,30%,20% |
0.5,0.3,0.2(convert percentages to decimals) |
| Omitted | Equal weighting at 1/N for each holding |
Scenario list
| Scenario | Overview |
|---|---|
| Triple decline | Stocks, foreign exchange, and bonds fall simultaneously. Stress across all asset classes |
| Strong dollar, weak yen | The yen plunges. Import costs rise, overseas assets increase in yen-denominated valuation |
| US recession | US economic downturn. Global demand declines, risk-off |
| BOJ rate hike | Japanese interest rates rise. Bank stocks rise, growth stocks and REITs fall |
| US-China conflict | Trade friction intensifies. Supply chain fragmentation, impact on semiconductors and manufacturing |
| Inflation resurgence | Prices rise again. Real purchasing power declines, expectations of rate hikes |
| Tech crash | NASDAQ -30%. AI expectations collapse, tech stocks hit directly, flight to quality |
| Yen appreciation, dollar depreciation | USD/JPY -20 yen. Foreign currency assets decline in yen-denominated valuation, impact on exporters |
| Custom | Interpret the user-specified scenario in natural language |
Output format (10-step pipeline)
Display the results structured in the following steps.
Step 1: Portfolio overview
- Holdings list (symbol, name, sector, ratio)
- Total market value (estimated)
Step 2: Concentration analysis
- Sector HHI / Region HHI / Currency HHI
- Identification of the largest concentration axis
- Risk level assessment (diversified / somewhat concentrated / dangerously concentrated)
Step 3: Shock sensitivity score
- Evaluation of each holding's beta, financial soundness, and valuation resilience
- Shock sensitivity score by holding (0-100)
Step 4: Scenario definition
- Applied scenario name and overview
- Changes in macro variables (assumed fluctuations in interest rates, exchange rates, and stock markets)
Step 5: Impact estimation by stock
- Estimated loss rate for each stock
- Application of concentration multiplier
- Portfolio-weighted impact
Step 6: Overall portfolio impact
- Estimated loss rate for the entire PF
- Stock with the largest loss
Step 6b: Correlation analysis (KIK-352)
- Inter-stock correlation matrix (Pearson correlation, daily returns over the past year)
- Detection of highly correlated pairs (|r| >= 0.7)
- Factor decomposition: Regress each stock on macro variables (USD/JPY, Nikkei 225, S&P 500, crude oil, US 10-year Treasury yield)
- LLM interpretation: For residual correlations that cannot be fully explained by factor regression, infer and supplement the causes using industry knowledge (e.g., supply chain dependence, shared customer base, etc.). Clearly separate and display "confirmed factors (statistical)" and "estimated factors (inferred)"
Step 6c: VaR (risk indicator based on past data) (KIK-352)
- Calculate the weighted return of the portfolio from daily returns over the past year
- 95% VaR / 99% VaR (daily/monthly)
- Explain the difference from stress test scenario analysis (tail risk)
Step 7: Causal chain analysis
- Explanation of chain-reaction effects when a scenario occurs
- Inter-sector spillover paths
Step 8: Overall assessment + recommended actions (KIK-352)
- Specific proposals for risk mitigation (rule-based automatic generation + Claude supplementation)
- Recommendations integrating concentration, correlation, VaR, and stress test results
- Candidate hedge stocks/sectors
- LLM supplementation: In addition to rule-based recommendations, Claude should supplement by presenting candidate sectors not in the portfolio and proposing diversification targets based on the qualitative causes of correlation
Execution example
# 基本的なストレステスト(シナリオ自動判定)
python3 .../run_stress_test.py --portfolio 7203.T,AAPL,D05.SI
# トリプル安シナリオ
python3 .../run_stress_test.py --portfolio 7203.T,9984.T,6758.T --scenario トリプル安
# 比率指定
python3 .../run_stress_test.py --portfolio 7203.T,AAPL,D05.SI --weights 0.5,0.3,0.2
# カスタムシナリオ
python3 .../run_stress_test.py --portfolio 7203.T,AAPL --scenario "半導体サプライチェーン崩壊"
Prior knowledge integration rules (KIK-466)
If the output of get_context.py contains the following, respond by integrating it with the stress test results:
- Previous stress test (StressTest): Compare with the previous scenario and results. "Previous tech crash scenario: -18% → This time: -15% (improvement: due to lower tech ratio)"
- Concern notes: If a stock of concern takes major damage in the stress test, "consistent with concern notes → consider countermeasures"
- Investment notes: If there are hedge strategy notes, refer to them. "Previous lesson note: insufficient yen appreciation hedge → still vulnerable to a dollar-strengthening scenario this time"