longbridge-risk-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

longbridge-risk-analysis

Longbridge风险分析

Prompt-only analysis skill. Fetches price history and account positions to compute portfolio risk metrics (VaR, CVaR, max drawdown, Sharpe, Calmar) and runs historical scenario stress tests.
Response language: match the user's input language — Simplified Chinese / Traditional Chinese / English.
仅基于提示词的分析Skill。获取价格历史数据和账户持仓,计算投资组合风险指标(VaR、CVaR、最大回撤、夏普比率、卡玛比率)并运行历史情景压力测试。
响应语言:匹配用户输入语言——简体中文 / 繁体中文 / 英文。

When to use

使用场景

  • "帮我做风险分析" / "風險分析" / "run a risk analysis on my portfolio"
  • "计算 VaR" / "計算 VaR" / "calculate VaR"
  • "最大回撤是多少" / "最大回撤" / "what is the max drawdown"
  • "夏普比率分析" / "夏普比率" / "Sharpe ratio analysis"
  • "压力测试一下" / "壓力測試" / "run a stress test"
  • "如果2008年金融危机再来,我的组合会损失多少" / "historical scenario stress test"
  • "帮我做风险分析" / "風險分析" / "run a risk analysis on my portfolio"
  • "计算 VaR" / "計算 VaR" / "calculate VaR"
  • "最大回撤是多少" / "最大回撤" / "what is the max drawdown"
  • "夏普比率分析" / "夏普比率" / "Sharpe ratio analysis"
  • "压力测试一下" / "壓力測試" / "run a stress test"
  • "如果2008年金融危机再来,我的组合会损失多少" / "historical scenario stress test"

Workflow

工作流程

  1. Fetch current positions (if logged in) or use user-specified symbols.
  2. Fetch 252-day daily price history for each symbol concurrently.
  3. Compute portfolio daily return series (weighted by current/equal weights).
  4. Calculate risk metrics and run scenario analyses.
  5. Present a structured risk report.
  1. 获取当前持仓(若已登录)或使用用户指定的标的代码。
  2. 并发获取每个标的的252日每日价格历史数据。
  3. 计算投资组合每日收益序列(按当前权重/等权重加权)。
  4. 计算风险指标并运行情景分析。
  5. 生成结构化风险报告。

CLI

CLI命令

Run
longbridge <subcommand> --help
to verify exact flags before calling.
bash
undefined
调用前运行
longbridge <subcommand> --help
查看确切参数。
bash
undefined

Current positions (if logged in)

当前持仓(若已登录)

longbridge portfolio --format json longbridge positions --format json
longbridge portfolio --format json longbridge positions --format json

252-day daily price history per symbol (run concurrently)

每个标的的252日每日价格历史数据(并发运行)

longbridge kline <SYMBOL> --period day --count 252 --format json
undefined
longbridge kline <SYMBOL> --period day --count 252 --format json
undefined

Calculations

计算逻辑

Core Risk Metrics

核心风险指标

MetricMethod
Historical VaR (95%)5th percentile of 252-day daily portfolio return distribution
Historical VaR (99%)1st percentile of same distribution
Parametric VaR (95%)μ − 1.645σ (assuming normal distribution; annualised → daily)
CVaR / Expected Shortfall (95%)Mean of returns below VaR(95%) threshold
Max Drawdownmax peak-to-trough decline over the 252-day window
Sharpe Ratio(Annual return − 4% risk-free) ÷ Annual volatility
Calmar RatioAnnual return ÷
Volatility (ann.)Daily return std × √252
指标计算方法
历史VaR(95%)252日投资组合每日收益分布的第5百分位数
历史VaR(99%)同一分布的第1百分位数
参数法VaR(95%)μ − 1.645σ(假设正态分布;年化转日度)
CVaR / 预期损失(95%)VaR(95%)阈值以下收益的平均值
最大回撤252日窗口内最大的峰谷跌幅
夏普比率(年化收益率 − 4%无风险利率)÷ 年化波动率
卡玛比率年化收益率 ÷
年化波动率每日收益标准差 × √252

Historical Scenario Stress Tests

历史情景压力测试

Approximate the impact of each scenario on the portfolio by applying historically-observed drawdowns as a proxy. State clearly that these are illustrative estimates based on past market events.
ScenarioReference periodTypical equity drawdown
2008 GFCSep 2008 – Mar 2009S&P 500 −57%
2020 COVID crashFeb 2020 – Mar 2020S&P 500 −34%
2022 rate-hike cycleJan 2022 – Oct 2022S&P 500 −25%; Nasdaq −35%
2015 A-share crashJun 2015 – Aug 2015CSI 300 −45%
Apply sector beta adjustments where data allows; otherwise use index drawdown × portfolio beta (estimated from 60-day regression against benchmark).
通过应用历史观察到的回撤作为近似值,估算每个情景对投资组合的影响。需明确说明这些是基于过往市场事件的示意性估算。
情景参考时段典型股票回撤
2008年全球金融危机(GFC)2008年9月 – 2009年3月标普500指数 −57%
2020年新冠崩盘2020年2月 – 2020年3月标普500指数 −34%
2022年加息周期2022年1月 – 2022年10月标普500指数 −25%;纳斯达克指数 −35%
2015年A股崩盘2015年6月 – 2015年8月沪深300指数 −45%
在数据允许的情况下应用行业贝塔调整;否则使用指数回撤 × 投资组合贝塔(通过60日基准回归估算)。

Output template

输出模板

Portfolio Risk Analysis — Source: Longbridge Securities
Analysis window: 252 trading days  Date: <today>

[Risk Metrics]
- Daily VaR (95%, historical): <N>%   (1-day loss not exceeded 95% of the time)
- Daily VaR (99%, historical): <N>%
- CVaR / Expected Shortfall (95%): <N>%
- Max Drawdown (1yr): <N>%  (peak: <date> → trough: <date>)
- Annualised Volatility: <N>%
- Sharpe Ratio (rf=4%): <N>
- Calmar Ratio: <N>

[Scenario Stress Tests]
Scenario             Estimated Portfolio Loss   Notes
2008 GFC             −<N>%  (~$<X>)            Based on −57% S&P draw; beta adj.
2020 COVID           −<N>%  (~$<X>)            Based on −34% S&P draw
2022 Rate-hike       −<N>%  (~$<X>)            Based on −25% S&P draw
2015 A-share crash   −<N>%  (~$<X>)            Applies if holding A-shares

[Risk Summary]
- Tail risk level: {Low / Medium / High}
- Largest risk contributor: <symbol> (<N>% of portfolio risk)
- Key concern: <observation>

⚠️ 风险指标基于历史数据估算,不预测未来损失。/ 風險指標基於歷史數據估算,不預測未來損失。/ Risk metrics are historical estimates and do not predict future losses.
投资组合风险分析 — 来源:Longbridge证券
分析窗口:252个交易日 日期:<今日>

[风险指标]
- 日度VaR(95%,历史法):<N>%   (95%的情况下1日损失不会超过该值)
- 日度VaR(99%,历史法):<N>%
- CVaR / 预期损失(95%):<N>%
- 1年期最大回撤:<N>%  (峰值:<日期> → 谷值:<日期>)
- 年化波动率:<N>%
- 夏普比率(无风险利率=4%):<N>
- 卡玛比率:<N>

[情景压力测试]
情景                估算投资组合损失   备注
2008年全球金融危机   −<N>%  (~$<X>)   基于标普500指数−57%回撤;贝塔调整
2020年新冠崩盘       −<N>%  (~$<X>)   基于标普500指数−34%回撤
2022年加息周期       −<N>%  (~$<X>)   基于标普500指数−25%回撤
2015年A股崩盘       −<N>%  (~$<X>)   持有A股时适用

[风险总结]
- 尾部风险等级:{低 / 中 / 高}
- 最大风险贡献者:<标的代码>(占投资组合风险的<N>%)
- 关键关注点:<观察结论>

⚠️ 风险指标基于历史数据估算,不预测未来损失。/ 風險指標基於歷史數據估算,不預測未來損失。/ Risk metrics are historical estimates and do not predict future losses.

Error handling

错误处理

Situation简体回复繁體回復English reply
command not found: longbridge
回退到 MCP;若也不可用,请安装 longbridge-terminal回退到 MCP;若也不可用,請安裝 longbridge-terminalFall back to MCP; if unavailable, install longbridge-terminal.
stderr
not logged in
未登录,请提供要分析的标的列表未登入,請提供要分析的標的列表Not logged in — please provide symbol list to analyse.
Price history < 60 days数据不足,降级为近60日风险估算,结果可信度较低數據不足,降級為近60日風險估算Insufficient history; results may be less reliable.
Single-asset portfolio无法计算分散化效益,仅显示单资产指标無法計算分散化效益,僅顯示單資產指標Single asset — cannot compute diversification benefit.
情况简体回复繁体回复English reply
command not found: longbridge
回退到MCP;若MCP也不可用,请安装longbridge-terminal回退到MCP;若MCP也不可用,請安裝longbridge-terminalFall back to MCP; if unavailable, install longbridge-terminal.
stderr返回
not logged in
未登录,请提供要分析的标的列表未登入,請提供要分析的標的列表Not logged in — please provide symbol list to analyse.
价格历史数据<60天数据不足,降级为近60日风险估算,结果可信度较低數據不足,降級為近60日風險估算,結果可信度較低Insufficient history; results may be less reliable.
单资产投资组合无法计算分散化效益,仅显示单资产指标無法計算分散化效益,僅顯示單資產指標Single asset — cannot compute diversification benefit.

MCP fallback

MCP回退方案

If
longbridge
CLI is not installed, use MCP tools:
MCP toolCLI equivalent
mcp__longbridge__portfolio
longbridge portfolio
mcp__longbridge__positions
longbridge positions
mcp__longbridge__history_candlesticks
longbridge kline --period day
MCP setup:
claude mcp add --transport http longbridge https://openapi.longbridge.com/mcp
(
quote
scope;
trade_read
for account data).
若未安装
longbridge
CLI,使用MCP工具:
MCP工具对应CLI命令
mcp__longbridge__portfolio
longbridge portfolio
mcp__longbridge__positions
longbridge positions
mcp__longbridge__history_candlesticks
longbridge kline --period day
MCP配置:
claude mcp add --transport http longbridge https://openapi.longbridge.com/mcp
(需
quote
权限;获取账户数据需
trade_read
权限)。

Related skills

相关Skill

  • Portfolio health-check →
    longbridge-portfolio-diagnosis
  • Asset allocation frameworks →
    longbridge-asset-allocation
  • Portfolio rebalancing →
    longbridge-portfolio-rebalance
  • 投资组合健康检查 →
    longbridge-portfolio-diagnosis
  • 资产配置框架 →
    longbridge-asset-allocation
  • 投资组合再平衡 →
    longbridge-portfolio-rebalance

File layout

文件结构

longbridge-risk-analysis/
└── SKILL.md          # prompt-only, no scripts/
longbridge-risk-analysis/
└── SKILL.md          # 仅含提示词,无scripts/目录