Communitygithub.com

gabrielmoreira/agent-skills-mirror

在 R 語言中執行全面的投資組合分析,涵蓋資料準備、資產篩選(風險回報比、本益比)、使用 PortfolioAnalytics 搭配 ROI 求解器進行最佳化(GMVP、切線投資組合)以及迴歸分析。

agent-skills-mirror 是什麼?

此技能專為需要自動化執行 R 語言投資組合分析的 AI 代理程式(例如 Claude Code、Cursor、Codex)所設計。它能引導代理程式完成從資料準備到進階最佳化的完整工作流程,包括:根據風險回報比或本益比等策略篩選資產;使用 PortfolioAnalytics 套件搭配 ROI 求解器,建立並最佳化全域最小變異投資組合(GMVP)和切線投資組合(TP);以及執行迴歸分析來解釋績效。此技能支援結構化的輸入資料(如資產資料框和對數報酬矩陣),並強制執行特定限制,例如強制納入至少一個外匯和一個商品資產。其設計目的是標準化並確保投資組合分析的準確性,產生可執行、可重現的 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 個資產。限制:必須包含至少一個「外匯」和一個「商品」資產。

  • 策略 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 = "ROI"。
  • 切線投資組合(TP):
    • 目標:最大化夏普比率(objective_type = "tangency")。
    • 限制條件:weight_sum 的 min_sum = 1,max_sum = 1(完全投資)。
    • 限制條件:不要加入 box 限制(允許放空)。
    • 最佳化:使用 optimize.portfolio 並設定 optimize_method = "ROI"。

4. 資料探索與迴歸

  • 對所選資產執行相關性分析。
  • 產生直方圖、Q-Q 圖和盒鬚圖。
  • 使用 rowMeans(log_returns) 建立一個等權重指數。
  • 使用 lm() 將投資組合報酬對外部因子進行迴歸(例如:lm(Portfolio_Return ~ Factor1 + Factor2))。

輸出要求

  • 將所選資產清單匯出為 CSV 檔案。
  • 使用 extractWeights 列印摘要統計資料和投資組合權重。
  • 提供清晰、可執行的 R 程式碼區塊,用於載入函式庫、準備報酬矩陣、定義投資組合規格、加入限制條件、執行最佳化並提取結果。

反模式

  • 請勿虛構輸入資料中未提供的資產類別或特定資產名稱。
  • 請勿跳過商品和外匯資產的限制條件檢查。
  • 請勿在未先轉換為資料框的情況下,對矩陣物件使用 dplyr::select。
  • 請勿忘記處理對數報酬計算中第一列產生的 NA 值。
  • 請勿對 GMVP 和切線投資組合使用「ROI」以外的最佳化方法。
  • 請勿為切線投資組合加入 box 限制條件。

觸發條件

  • 在 R 語言中執行投資組合分析
  • 使用 GMVP 和切線投資組合最佳化投資組合權重
  • 根據風險回報比篩選資產
  • 在 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

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.

相關技能