Token导航 LogoToken导航

Agent Skill · 前端设计

portfolio-optimization(投资组合优化)

portfolio-optimization 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

portfolio-optimization 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描有提醒项,按安装量在前端设计类的 10,216 个 Skill 里排第 2,288。

总安装 2,472周安装 101GitHub Stars 93下载 456核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:portfolio-optimization(投资组合优化)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/portfolio-optimization
安装命令:
npx skills add https://github.com/letta-ai/skills --skill portfolio-optimization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill portfolio-optimization

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

portfolio-optimization 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理。通过 npx skills add 命令从 GitHub 仓库安装并使用。

安装前需确认权限范围、维护状态,以及是否触发联网或文件操作。建议结合原始 README 和仓库内容核验具体用法和功能边界。

来源仓库内路径:skills/portfolio-optimization

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/letta-ai/skills --skill portfolio-optimization;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

portfolio-optimization 怎么安装?

在终端执行 npx skills add https://github.com/letta-ai/skills --skill portfolio-optimization。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

portfolio-optimization 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

portfolio-optimization 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

portfolio-optimization 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

portfolio-optimization 用的人多吗?

公开数据是累计安装 2,472 次,近一周安装 101 次,下载 456 次,GitHub 93 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

portfolio-optimization 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
portfolio-optimization

投资组合优化 · 本页

2,47293需要联网MIT有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Portfolio Optimization

Overview

This skill provides guidance for implementing high-performance portfolio optimization algorithms using Python C extensions. It covers the workflow for creating C extensions that interface with NumPy arrays, proper verification strategies, and common pitfalls to avoid when optimizing numerical computations.

When to Apply This Skill

Apply this skill when:

  • Implementing portfolio risk calculations (variance, volatility, Sharpe ratio)
  • Optimizing matrix-vector operations for large asset portfolios
  • Creating C extensions for Python numerical code
  • Performance requirements specify speedup ratios (e.g., >= 1.2x)
  • Working with covariance matrices and portfolio weights

Recommended Workflow

Phase 1: Codebase Understanding

Before writing any code:

  1. Read all relevant source files completely - Understand the baseline implementation, data structures, and expected interfaces
  2. Identify the mathematical operations - Common operations include:

- Matrix-vector multiplication (covariance matrix times weights) - Dot products (weights times returns) - Square root operations (for volatility from variance)

  1. Understand the test suite - Know what correctness tolerances are expected (e.g., 1e-10) and what performance benchmarks must be met
  2. Document the input/output contracts - Array shapes, data types (typically float64), and return value specifications

Phase 2: Implementation Planning

Consider these factors before implementation:

  1. Why C provides speedup:

- Eliminates Python interpreter overhead - Enables direct memory access without bounds checking - Allows compiler optimizations (vectorization, loop unrolling) - Reduces temporary array allocations

  1. Design decisions to make:

- Whether to use NumPy C API for zero-copy array access - Memory layout assumptions (C-contiguous vs Fortran-contiguous) - Error handling strategy for type mismatches and dimension errors

  1. Potential algorithmic optimizations:

- Cache-friendly memory access patterns (row-major iteration for C arrays) - SIMD vectorization opportunities - Minimizing Python-to-C data conversion overhead

Phase 3: C Extension Implementation

When implementing the C extension:

  1. Include proper headers:

- Python.h (must be first) - numpy/arrayobject.h for NumPy array access

  1. Initialize NumPy in the module init function:

- Call import_array() to initialize NumPy C API

  1. Use NumPy C API for array access:

- PyArray_DATA() for getting data pointer - PyArray_DIM() for dimensions - PyArray_STRIDE() for memory strides - Check PyArray_IS_C_CONTIGUOUS() for memory layout

  1. Implement robust error handling:

- Validate array dimensions match expected shapes - Check data types (expect NPY_FLOAT64 for double precision) - Handle non-contiguous arrays (either reject or handle strides) - Set appropriate Python exceptions on error

Phase 4: Python Wrapper Implementation

Create a Python module that:

  1. Imports the C extension module
  2. Provides a clean interface matching the baseline API
  3. Handles any necessary array preparation (ensuring contiguity)
  4. Documents the interface clearly

Phase 5: Verification Strategy

Critical: Verify every change completely

  1. After editing files, re-read them - Confirm edits were applied correctly, especially for multi-line changes
  2. Test incrementally:

- Build the C extension first and verify it compiles - Test individual functions before running full benchmarks - Use small test cases for correctness verification before scaling up

  1. Correctness verification:

- Compare outputs against baseline implementation - Use appropriate numerical tolerances (typically 1e-10 for double precision) - Test with known inputs where expected outputs can be calculated manually

  1. Performance verification:

- Run benchmarks with representative data sizes - Verify speedup meets requirements across different portfolio sizes - Test edge cases: small portfolios (n=1, n=10), large portfolios (n=5000+)

Edge Cases to Handle

Ensure the implementation addresses:

  1. Empty portfolios (n=0) - Return appropriate default or error
  2. Single-asset portfolios (n=1) - Degenerate case for covariance
  3. Dimension mismatches - Weights vector length vs covariance matrix dimensions
  4. Invalid inputs:

- Non-square covariance matrices - NaN or infinity values in inputs - Negative variance (mathematically invalid)

  1. Memory considerations:

- Non-contiguous NumPy arrays - Memory allocation failures in C code - Large portfolios that may stress memory

Common Pitfalls to Avoid

Code Completeness

  • Never truncate code in edit operations - always provide complete implementations
  • Verify file contents after editing to confirm changes applied correctly
  • Document all design choices explicitly

Testing Approach

  • Avoid going directly from implementation to full benchmark testing
  • Test each function individually before integration testing
  • Do not rely solely on "tests pass" for validation - understand why they pass

C Extension Specific

  • Always check NumPy array types before accessing data
  • Handle reference counting properly to avoid memory leaks
  • Initialize NumPy API with import_array() in module init
  • Use PyErr_SetString() to set exceptions on errors

Performance Validation

  • Verify speedup is consistent across different input sizes
  • Profile if further optimizations might be needed
  • Consider the overhead of Python-to-C transitions for small inputs

Build and Test Commands

Typical workflow commands:

# Build the C extension
python setup.py build_ext --inplace

# Run correctness tests
python -c "from portfolio_optimized import *; # test calls"

# Run benchmark
python benchmark.py

# Run full test suite
pytest test_portfolio.py -v

Verification Checklist

Before considering the task complete:

  • All source files read and understood
  • C extension compiles without warnings
  • Individual functions tested for correctness
  • Numerical results match baseline within tolerance
  • Performance meets speedup requirements
  • Edge cases explicitly tested or handled
  • Error handling implemented for invalid inputs
  • File contents verified after all edits
  • No memory leaks in C code (proper reference counting)

平台分布

Claude Code

31.66%
按下载量换算144

OpenCode

21.63%
按下载量换算99

Antigravity

17.13%
按下载量换算78

Codex

13.49%
按下载量换算62

Gemini CLI

8.71%
按下载量换算40

Cursor

3.53%
按下载量换算16

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills