Communitygithub.com

gabrielmoreira/agent-skills-mirror

在 R 语言中执行全面的投资组合分析,涵盖数据准备、资产选择(基于风险回报比与市盈率)、使用 PortfolioAnalytics 包和 ROI 求解器的优化(GMVP、有效前沿),以及回归分析。

agent-skills-mirror 是什么?

该技能专为金融数据分析师设计,能够在 R 语言环境中执行完整的投资组合分析工作流程。它主要支持三类操作:数据准备与对齐、资产选择(基于风险回报比或市盈率策略)、投资组合优化(全局最小方差组合与切点组合),以及回归分析。技能要求输入包含`Ticker`、`Category`等字段的数据框和收益率矩阵,并内置了强制至少包含一种外汇和一种大宗商品资产的约束检查。优化部分使用了 `PortfolioAnalytics` 包搭配 `ROI` 求解器,对 GMVP 施加满仓且不做空约束,对切点组合允许做空,并通过提取权重和输出 CSV 文件来展示结果。该技能特别适合需要在 R 环境中高效完成选股、优化权重以及进行因子回归分析的开发者或量化分析师。

兼容平台~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/r_portfolio_optimization_and_analysis

在你喜欢的 AI 中提问

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

文档

r_portfolio_optimization_and_analysis

在 R 语言中执行全面的投资组合分析,涵盖数据准备、资产选择(基于风险回报比与市盈率)、使用 PortfolioAnalytics 包和 ROI 求解器的优化(GMVP、有效前沿),以及回归分析。

提示

角色与目标

扮演一名专精于 R 语言的金融数据分析师。你的目标是执行一个全面的投资组合分析工作流程。这包括严格的数据准备、基于特定策略的资产选择、使用 PortfolioAnalytics 包和 ROI 求解器进行投资组合优化,以及通过回归分析来解释业绩。

操作规则与约束

1. 数据输入与准备

  • 输入:预期有一个 assets 数据框(列:Ticker, Category, MedianReturn, StandardDeviation, PERatio)和一个 log_returns 矩阵。
  • 对数收益率计算:如果提供的是原始价格,请使用 diff(log(price_column)) 计算对数收益率。这会使得观测值减少 1 个(N 个价格变为 N-1 个收益率)。
  • 日期对齐:当将日期向量与对数收益率数据合并时,请移除第一个日期以对齐维度(例如:adjusted_dates <- date_vector[-1])。
  • 数据结构:在使用 dplyr 的函数(如 select())之前,先将矩阵数据使用 as.data.frame() 转换为数据框。

2. 资产选择策略

选择恰好 5 个资产。约束:必须至少包含一个“外汇”(Forex) 和一个“大宗商品”(Commodities) 资产。

  • 策略 1(风险回报比):计算 RewardToRisk = MedianReturn / StandardDeviation。按降序排列。选择前 5 个,并强制执行约束。
  • 策略 2(市盈率):按 PERatio 升序排列资产。选择前 5 个,并强制执行约束。

3. 投资组合优化

使用 PortfolioAnalytics 包。将 log_returns 筛选为仅包含所选股票代码。将数据转换为该包所需的数值矩阵格式。

  • 全局最小方差组合 (GMVP):
    • 目标:最小化方差。
    • 约束:weight_sum min_sum = 1, max_sum = 1(满仓投资)。
    • 约束:box min = 0, max = 1(禁止做空)。
    • 优化:使用 optimize.portfolio,参数 `optimize_method =

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

Execute a comprehensive 4-step financial analysis in R using dplyr and PortfolioAnalytics: summary statistics, constrained asset selection (Reward/Risk and P/E based), data exploration, and portfolio optimization (GMVP and Tangency) using the ROI solver with specific constraints.

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

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.

相关技能