risk-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

risk-management

风险管理

Purpose

用途

This skill enables quantitative analysis, modeling, and mitigation of financial risks. It processes data to calculate metrics like Value at Risk (VaR), stress testing, and suggests strategies to reduce exposure, such as hedging or diversification.
该技能可实现金融风险的量化分析、建模与缓解。它会处理数据以计算风险价值(VaR)、压力测试等指标,并提出对冲或多元化等降低风险敞口的策略。

When to Use

使用场景

Use this skill for scenarios involving financial uncertainty, like portfolio risk assessment, credit risk evaluation, or market volatility analysis. Apply it when you need data-driven insights to comply with regulations (e.g., Basel III) or optimize investment decisions.
当面临金融不确定性场景时使用该技能,例如投资组合风险评估、信用风险评估或市场波动性分析。当您需要基于数据的洞察来遵守法规(如巴塞尔协议III)或优化投资决策时,也可应用该技能。

Key Capabilities

核心能力

  • Perform VaR calculations using historical or Monte Carlo simulations.
  • Build risk models for market, credit, or operational risks with inputs like asset prices or default probabilities.
  • Generate mitigation strategies, such as recommending stop-loss levels or portfolio rebalancing based on risk thresholds.
  • Integrate with data sources for real-time analysis, supporting formats like CSV, JSON, or API feeds.
  • Output results in structured formats, including reports or JSON for further processing.
  • 使用历史模拟或Monte Carlo模拟执行VaR计算。
  • 利用资产价格或违约概率等输入,构建市场风险、信用风险或操作风险的风险模型。
  • 生成缓解策略,例如根据风险阈值建议止损水平或投资组合再平衡。
  • 与数据源集成以支持实时分析,兼容CSV、JSON或API馈送等格式。
  • 以结构化格式输出结果,包括报告或可用于进一步处理的JSON。

Usage Patterns

使用模式

Always initialize with authentication via
$OPENCLAW_API_KEY
. For CLI, pipe data inputs directly; for API, use asynchronous calls for large datasets. Start by loading configuration files (e.g., YAML for model parameters). Common pattern: Analyze risk -> Review outputs -> Apply mitigation. For code integration, import the SDK and wrap calls in try-except blocks. Example 1: Analyze a stock portfolio's market risk by providing historical prices. Example 2: Evaluate credit risk for a loan portfolio and generate mitigation recommendations.
始终通过
$OPENCLAW_API_KEY
进行身份验证后初始化。对于CLI,直接通过管道输入数据;对于API,针对大型数据集使用异步调用。首先加载配置文件(例如用于模型参数的YAML文件)。常见模式:分析风险 -> 审查输出 -> 应用缓解策略。对于代码集成,导入SDK并将调用包裹在try-except块中。示例1:通过提供历史价格分析股票投资组合的市场风险。示例2:评估贷款组合的信用风险并生成缓解建议。

Common Commands/API

常用命令/API

Use the OpenClaw CLI for quick tasks or the REST API for programmatic access. Authentication requires setting
$OPENCLAW_API_KEY
in your environment.
  • CLI Command:
    openclaw risk analyze --type market --model var --input portfolio.csv --confidence 95

    This calculates 95% VaR for market risk; output is a JSON file with metrics.
  • API Endpoint: POST https://api.openclaw.ai/v1/risk/analyze
    Body:
    {"type": "credit", "data": {"loans": [{"amount": 100000, "rating": "A"}]}, "model": "default-prob"}

    Response: JSON object with risk score and strategies, e.g.,
    {"var": 5000, "mitigation": ["increase collateral"]}
    .
  • Code Snippet (Python):
    python
    import openclaw
    openclaw.set_key(os.environ['OPENCLAW_API_KEY'])
    result = openclaw.risk.analyze(type='operational', data={'events': [100, 200]}, model='monte-carlo')
    print(result['mitigation'])
  • Config Format: YAML for custom models, e.g.,
    model:
      type: var
      parameters:
        window: 252  # trading days
        confidence: 0.95
使用OpenClaw CLI完成快速任务,或使用REST API进行程序化访问。身份验证需要在环境中设置
$OPENCLAW_API_KEY
  • CLI命令:
    openclaw risk analyze --type market --model var --input portfolio.csv --confidence 95

    该命令计算市场风险的95% VaR;输出为包含指标的JSON文件。
  • API端点:POST https://api.openclaw.ai/v1/risk/analyze
    请求体:
    {"type": "credit", "data": {"loans": [{"amount": 100000, "rating": "A"}]}, "model": "default-prob"}

    响应:包含风险评分和策略的JSON对象,例如
    {"var": 5000, "mitigation": ["increase collateral"]}
  • 代码片段(Python):
    python
    import openclaw
    openclaw.set_key(os.environ['OPENCLAW_API_KEY'])
    result = openclaw.risk.analyze(type='operational', data={'events': [100, 200]}, model='monte-carlo')
    print(result['mitigation'])
  • 配置格式:自定义模型使用YAML,例如
    model:
      type: var
      parameters:
        window: 252  # trading days
        confidence: 0.95

Integration Notes

集成说明

Integrate by setting
$OPENCLAW_API_KEY
and using the SDK in your application. For web apps, handle webhooks for asynchronous results (e.g., POST to your endpoint on completion). Connect to data providers like Bloomberg via custom adapters; specify in config:
{"data_source": "bloomberg", "api_endpoint": "https://api.bloomberg.com/data"}
. Ensure compatibility with other OpenClaw skills by chaining outputs, e.g., pipe risk analysis results into a financial-analysis skill.
通过设置
$OPENCLAW_API_KEY
并在应用中使用SDK完成集成。对于Web应用,处理异步结果的Webhook(例如完成后POST到您的端点)。通过自定义适配器连接到Bloomberg等数据提供商;在配置中指定:
{"data_source": "bloomberg", "api_endpoint": "https://api.bloomberg.com/data"}
。通过链式输出确保与其他OpenClaw技能的兼容性,例如将风险分析结果传递给financial-analysis技能。

Error Handling

错误处理

Always validate inputs before commands (e.g., check for required fields like
--input
). For API calls, catch HTTP errors: if status >= 400, retry up to 3 times with exponential backoff. Common errors: 401 (unauthorized – check
$OPENCLAW_API_KEY
), 400 (bad request – verify JSON schema), or 500 (server error – log and notify). In code, use:
python
try:
    result = openclaw.risk.analyze(...)
except openclaw.APIError as e:
    if e.status == 401:
        print("Reauthenticate with $OPENCLAW_API_KEY")
    else:
        raise
Log all errors with timestamps and include debug flags, e.g.,
openclaw risk analyze --debug
.
执行命令前始终验证输入(例如检查
--input
等必填字段)。对于API调用,捕获HTTP错误:如果状态码>=400,最多重试3次并使用指数退避策略。常见错误:401(未授权 – 检查
$OPENCLAW_API_KEY
)、400(错误请求 – 验证JSON schema)或500(服务器错误 – 记录并通知)。在代码中使用:
python
try:
    result = openclaw.risk.analyze(...)
except openclaw.APIError as e:
    if e.status == 401:
        print("Reauthenticate with $OPENCLAW_API_KEY")
    else:
        raise
记录所有带时间戳的错误,并启用调试标志,例如
openclaw risk analyze --debug

Graph Relationships

关联关系

  • Related to: financial-analysis (shares finance tag for combined data processing), portfolio-management (uses risk outputs for optimization).
  • Connected via: quantitative-analysis (common modeling techniques), mitigation-strategies (links to compliance tools).
  • Dependencies: Requires financial cluster skills for data input; provides outputs for decision-making skills.
  • 相关技能:financial-analysis(共享finance标签以进行联合数据处理)、portfolio-management(使用风险输出进行优化)。
  • 关联方式:quantitative-analysis(通用建模技术)、mitigation-strategies(链接到合规工具)。
  • 依赖项:需要金融集群技能提供数据输入;为决策类技能提供输出。