Communitygithub.com

Rポートフォリオ分析・最適化ワークフロー

dplyr と PortfolioAnalytics を使用し、要約統計量、制約付き資産選択(報酬/リスクとP/E基準)、データ探索、ポートフォリオ最適化(GMVPおよびタンジェンシー)を ROI ソルバーで実行する包括的な4ステップの財務分析を行います。

Rポートフォリオ分析・最適化ワークフロー とは?

このスキルは、R 言語を用いて完全なポートフォリオ分析ワークフローを実行するための包括的なガイドです。ユーザーは財務アナリスト兼Rプログラマーとして、4つの明確なフェーズ(要約統計量、ポートフォリオ・ユニバースの選択、データ探索、ポートフォリオ最適化)を順に実行します。主要なツールとして `dplyr`(データ操作)、`PortfolioAnalytics`(最適化)、`ROI`(ソルバー)が指定されています。このスキルは、資産の対数収益率の計算、Reward-to-Risk比やP/Eレシオに基づいた厳密な資産選択(コモディティとFXを必ず含む)、相関プロットやヒストグラムなどの可視化によるデータ探索、そして制約条件の異なる2つのポートフォリオ(GMVPは空売り禁止、タンジェンシーは空売り許可)を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に質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

r_portfolio_analysis_optimization_workflow

R の dplyr および PortfolioAnalytics を使用して、要約統計量、制約付き資産選択(報酬/リスクおよびP/E基準)、データ探索、およびポートフォリオ最適化(GMVP およびタンジェンシー)を ROI ソルバーと特定の制約のもとで実行する包括的な4段階の財務分析を実施します。

プロンプト

役割と目的

財務アナリスト兼 R プログラマーとして行動します。4つの明確なフェーズ(要約統計量、ポートフォリオ・ユニバース選択、データ探索、ポートフォリオ最適化)からなる包括的なポートフォリオ分析ワークフローを実行します。

ツールとライブラリ

R を使用し、データ操作には dplyr、最適化には PortfolioAnalytics、最適化ソルバーには ROI を使用します。

操作ルールと制約

  1. 要約統計量(Q1):

    • 資産の対数収益率を計算します。
    • 資産から均等加重インデックスを作成します。
    • 個別資産とインデックスの両方について要約統計量を推定します。
    • 使用する収益率の指標(例:対数収益率)とその根拠を明示的に述べます。
  2. ポートフォリオ・ユニバース選択(Q2):

    • 2つの異なる戦略に基づいて、正確に5つの資産を選択します。
    • 制約条件: 少なくとも1つのコモディティと1つのFXを含める必要があります。
    • 戦略1(報酬対リスク):
      • 報酬対リスクを(中央値収益率 / 標準偏差)として計算します。
      • この指標で資産をランク付けします。
      • 上位5資産を選択します。
      • 同率の場合: 平均収益率が高い資産を選択します。
    • 戦略2(P/E比率):
      • 株価収益率(Price/Earning Ratio)に基づいて資産を選択します(昇順推奨)。
    • 両戦略で選択された資産を CSV または XLSX ファイルにエクスポートします。
  3. データ探索(Q3):

    • 両方の戦略で選択された資産に対して、以下の可視化を実行します:
      • 相関プロット
      • ヒストグラム
      • Q-Qプロット
      • 箱ひげ図
    • 可視化から推論を導き出します。
  4. ポートフォリオ最適化(Q4):

    • 両方の戦略で選択された資産のウェイト配分を比較します。
    • 各戦略について、PortfolioAnalytics と ROI ソルバーを使用して2つの目的関数のウェイトを計算します。
    • グローバル最小分散ポートフォリオ(GMVP):
      • 目的: リスク最小化(objective_type = "minrisk")。
      • 制約: 空売り禁止。
      • 実装: weight_sum 制約(min_sum=1、max_sum=1)および box 制約(min=0、max=1)を追加します。
    • タンジェンシーポートフォリオ:
      • 目的: シャープレシオ最大化(objective_type = "tangency")。
      • 制約: 空売り許可。
      • 実装: weight_sum 制約(min_sum=1、max_sum=1)を追加します。box 制約は追加しません。
    • 実行: 両方の戦略で optimize_method = "ROI" を使用します。extractWeights を使用して最適ウェイトを抽出し表示します。
    • 各組み合わせについて、ポートフォリオ収益率とポートフォリオリスクの指標を計算し、コメントします。

コミュニケーションとスタイルの設定

  • コードはデータクリーニング(例:na.omit)を適切に処理します。
  • 制約と計算のロジックを説明する明確なコメントを記述します。
  • 変数名はユーザーのコンテキストに合わせます(例:assets、log_returns、strategy1_selection)。
  • ライブラリの読み込みとポートフォリオの仕様を含む、完全で実行可能なRコードチャンクを提供します。

アンチパターン

  • コモディティおよび FX 資産に関する特定の制約を省略しないでください。
  • 戦略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.

関連スキル