Communitygithub.com

gabrielmoreira/agent-skills-mirror

使用 R 语言中的 dplyr 和 PortfolioAnalytics 执行一套完整的四步金融分析流程:汇总统计、受约束的资产选择(基于收益风险比和市盈率)、数据探索以及投资组合优化(全局最小方差组合和切线组合),采用 ROI 求解器并遵循特定约束。

agent-skills-mirror 是什么?

该技能为 AI 智能体(如 Claude Code、Codex 等)提供了一套结构化的金融分析工作流,完全基于 R 语言实现。技能核心在于将复杂的投资组合管理过程拆解为四个逻辑清晰的阶段:首先计算对数收益率并生成汇总统计;然后通过两种不同策略(收益风险比与市盈率)从包含商品和外汇的资产池中筛选出恰好 5 个资产;接着对所选资产进行相关性图、直方图、QQ 图和箱线图等可视化探索;最后使用 PortfolioAnalytics 包和 ROI 求解器,在严格的约束条件下(如禁止卖空与允许卖空)计算全局最小方差组合与切线组合的最优权重,并输出投资组合的收益与风险指标。该技能特别强调对资产类型(商品和外汇)的强制要求、不同策略约束的区分、完整的代码可执行性,并避免使用已弃用的函数,确保分析结果可靠且符合现代金融工程实践。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/gabrielmoreira/agent-skills-mirror/tree/HEAD/mirrors/repos/ECNU-ICALK@AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/r_portfolio_analysis_optimization_workflow

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

r_portfolio_analysis_optimization_workflow

使用 R 语言中的 dplyr 和 PortfolioAnalytics 执行一套完整的四步金融分析流程:汇总统计、受约束的资产选择(基于收益风险比和市盈率)、数据探索以及投资组合优化(全局最小方差组合和切线组合),采用 ROI 求解器并遵循特定约束。

提示

角色与目标

担任金融分析师和 R 程序员。执行由四个不同阶段组成的全面投资组合分析工作流:汇总统计、投资组合标的筛选、数据探索和投资组合优化。

工具与库

使用 R 语言,借助 dplyr 进行数据处理,PortfolioAnalytics 进行优化,并使用 ROI 作为优化求解器。

操作规则与约束

  1. 汇总统计(Q1):

    • 计算资产的对数收益率。
    • 根据这些资产创建一个等权重指数。
    • 估算单个资产和该指数的汇总统计量。
    • 明确说明所使用的收益率度量(例如,对数收益率)及其选择理由。
  2. 投资组合标的筛选(Q2):

    • 基于两种不同策略精确选择 5 个资产。
    • 约束: 必须至少包含一个商品类资产和一个外汇类资产。
    • 策略 1(收益风险比):
      • 计算收益风险比 = 中位数收益率 / 标准差。
      • 按此指标对资产排序。
      • 选择前 5 个资产。
      • 平局处理: 选择均值收益率较高的资产。
    • 策略 2(市盈率):
      • 基于市盈率选择资产(优先选择升序排列的资产)。
    • 将两种策略选定的资产导出为 CSV 或 XLSX 文件。
  3. 数据探索(Q3):

    • 对两种策略选定的资产执行以下可视化:
      • 相关性图
      • 直方图
      • Q-Q 图
      • 箱线图
    • 从可视化结果中得出推论。
  4. 投资组合优化(Q4):

    • 比较两种策略所选资产的权重分配。
    • 针对每种策略,使用 PortfolioAnalytics 和 ROI 求解器计算两种目标函数下的权重。
    • 全局最小方差组合:
      • 目标:最小化风险(objective_type = "minrisk")。
      • 约束:不允许卖空。
      • 实现:添加权重总和约束(min_sum=1,max_sum=1)和盒子约束(min=0,max=1)。
    • 切线组合:
      • 目标:最大化夏普比率(objective_type = "tangency")。
      • 约束:允许卖空。
      • 实现:添加权重总和约束(min_sum=1,max_sum=1)。不要添加盒子约束。
    • 执行: 对两种策略均使用 optimize_method = "ROI"。使用 extractWeights 提取并打印最优权重。
    • 计算每种组合的投资组合收益率和投资组合风险指标,并加以评论。

沟通与风格偏好

  • 确保代码处理数据清理(例如,na.omit)。
  • 提供清晰的注释,解释约束和计算的逻辑。
  • 确保变量名与用户的上下文匹配(例如,assets,log_returns,strategy1_selection)。
  • 提供完整、可执行的 R 代码块,包括库加载和投资组合规范。

反模式

  • 不能跳过关于商品和外汇资产的特定约束。
  • 不能混淆策略 1 和策略 2 的约束。
  • 不能忘记导出筛选结果文件。
  • 不能为 GMVP 或切线组合使用错误的约束定义(例如,在 GMVP 中允许卖空,或在切线组合中禁止卖空)。
  • 不能编造资产数据;应使用用户提供的结构,或在数据缺失时使用通用占位符。
  • 不能使用已弃用的函数或与标准 PortfolioAnalytics 工作流不兼容的语法。

触发器

  • 投资组合分析工作流
  • 金融投资组合优化
  • 资产选择策略
  • 全局最小方差组合
  • 切线组合计算
  • 在 R 中优化投资组合
  • PortfolioAnalytics 优化

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

gabrielmoreira/agent-skills-mirror

Design exclusive bonus packages that make YOUR affiliate link the obvious choice. Triggers on: "create bonuses for", "bonus stack", "what bonuses should I offer", "bonus ideas for", "exclusive bonuses", "differentiate my affiliate link", "why buy through my link", "affiliate bonuses", "bonus package", "what can I offer as a bonus", "design bonuses", "build a bonus stack".

gabrielmoreira/agent-skills-mirror

Design irresistible affiliate offers using the Hormozi Grand Slam framework. Triggers on: "create an offer for", "design my offer", "grand slam offer", "make an irresistible offer", "why should someone buy through my link", "offer framework", "value proposition for", "Hormozi offer", "offer stack", "make my offer irresistible", "craft an offer", "what makes my offer different", "offer design", "increase perceived value".

gabrielmoreira/agent-skills-mirror

Create YOUR personal guarantee on top of the product's guarantee for risk reversal. Triggers on: "create a guarantee", "guarantee for my affiliate", "risk reversal", "money back guarantee", "what guarantee can I offer", "reduce buyer risk", "guarantee copy", "how to guarantee", "affiliate guarantee", "personal guarantee", "risk-free offer", "satisfaction guarantee", "results guarantee".

gabrielmoreira/agent-skills-mirror

Build high-converting affiliate landing pages as single self-contained HTML files. Triggers on: "create a landing page for", "build a landing page", "product landing page", "affiliate landing page", "comparison page for", "vs page", "single product page", "conversion page", "sales page for affiliate", "landing page HTML", "build me a page for", "create a page to promote [product]", "I need a landing page", "make a page for [product]".

gabrielmoreira/agent-skills-mirror

Build a single-product deep-dive showcase page as a self-contained HTML file. Triggers on: "build a product showcase page", "deep dive landing page for [product]", "create a product spotlight page", "product feature page", "single product page", "detailed page about [product]", "build a page showing everything about [product]", "create a long-form product page", "build a sales page for [product]", "product deep dive page", "make a feature breakdown page for [product]".

gabrielmoreira/agent-skills-mirror

Build email capture landing pages (squeeze pages) as single self-contained HTML files. Triggers on: "build a squeeze page", "email capture page", "lead magnet page", "create an opt-in page", "build an email list page", "lead capture landing page", "create a freebie page", "build a page to collect emails", "opt-in landing page", "email signup page for [product/niche]", "create a lead magnet landing page", "build a page that captures emails before sending to affiliate offer".

gabrielmoreira/agent-skills-mirror

Design the complete free-to-premium value ladder for affiliate promotions. Triggers on: "value ladder", "customer journey", "upsell path", "ascension model", "free to paid funnel", "tripwire offer", "upsell strategy", "downsell", "product ladder", "price ladder", "customer ascension", "funnel architecture", "map my funnel", "design my funnel stages", "monetization path".

gabrielmoreira/agent-skills-mirror

Build a webinar or live event registration page as a self-contained HTML file with countdown timer, speaker bio, agenda, and registration form. Triggers on: "build a webinar registration page", "create a webinar sign-up page", "event registration landing page", "live training registration page", "workshop sign-up page", "create a webinar page", "build an event page", "free webinar landing page", "live demo registration page", "online event page", "create a registration page for my webinar", "build a training event page".

gabrielmoreira/agent-skills-mirror

Audit paid-ad landing pages for message match, mobile experience, performance, accessibility, trust, forms, consent, tracking, security, and conversion friction. Use for landing-page audit, post-click experience, LP audit, conversion-rate optimization, form optimization, ad-to-page message match, redirects, blocked navigation, or requests involving private, loopback, link-local, or metadata IP destinations.

gabrielmoreira/agent-skills-mirror

Automate Klipfolio tasks via Rube MCP (Composio). Always search tools first for current schemas.

gabrielmoreira/agent-skills-mirror

Review UI code for Web Interface Guidelines compliance.

gabrielmoreira/agent-skills-mirror

Generates a single-screen KivyMD application with a centered vertical layout for a personal portfolio, including a profile image, name, role description, biography, and footer.

gabrielmoreira/agent-skills-mirror

Generates a responsive, SEO-optimized landing page for service businesses using Tailwind CSS, featuring specific sections (Header, Hero, Who We Are, Services, Contact) and a responsive grid layout for service cards.

gabrielmoreira/agent-skills-mirror

Execute comprehensive portfolio analysis in R, covering data preparation, asset selection (Reward-to-Risk, P/E), optimization (GMVP, Tangency) using PortfolioAnalytics with the ROI solver, and regression analysis.

gabrielmoreira/agent-skills-mirror

Generate and rewrite marketing content for software services and portfolios. Adapts tone from professional agency to customer-centric, handles style mimicry, formatting constraints, and strictly manages perspective (e.g., removing first-person pronouns for portfolio contexts).

gabrielmoreira/agent-skills-mirror

When the user wants to design, deploy, or measure Apple Custom Product Pages (CPP) — the alternate App Store product pages with different screenshots, preview videos, and promo text shown to users coming from specific URLs (typically ad campaigns or social posts). Use when the user mentions "Custom Product Page", "CPP", "alternate product page", "App Store URL variant", "ASA CPP", "campaign-specific landing page", "product page per audience", "App Store Connect CPP", "ppoUrl", "?cpp=" parameter, or "show different screenshots to different ad audiences". For App Store A/B tests on the default page, see ab-test-store-listing. For paid ad campaigns that route to CPPs, see apple-search-ads or ua-campaign.

gabrielmoreira/agent-skills-mirror

Generate complete, deploy-ready landing pages from any repository. Use when creating a homepage for an open-source project, building a project website, converting a README into a marketing page, or standardizing landing pages across multiple repos.

gabrielmoreira/agent-skills-mirror

Shapes job-seeking personal sites: thirty-second hero, outcome-led case studies, hybrid home-plus-project routes, and frictionless contact CTAs, with heavy motion that degrades on mobile. Use for developer, designer, or creative portfolio work. Not a SaaS marketing landing page and not a WebGL engine tutorial.

相关技能