Communitygithub.com

Rポートフォリオ最適化と分析

Rを使用した包括的なポートフォリオ分析を実行します。データ準備、資産選択(リスク対リターン、PER)、最適化(GMVP、接線ポートフォリオ)をPortfolioAnalyticsとROIソルバーで行い、回帰分析も含みます。

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

このスキルは、R言語を使って金融ポートフォリオの完全な分析ワークフローを自動化します。データの前処理から始まり、リスク対リターン比またはPERに基づく資産選択、PortfolioAnalyticsパッケージとROIソルバーを用いた最適化(分散最小化のGMVPとシャープレート最大化の接線ポートフォリオ)を行います。また、選択した資産群の相関分析、ヒストグラムやQ-Qプロットによる探索的データ分析、そしてポートフォリオリターンを外部ファクターに回帰する線形回帰も含まれます。あらかじめ整形された資産データフレームと対数リターン行列を入力として想定しており、Claude CodeやCursorなどのAIエージェント上でRコードを生成・実行するのに適しています。アンチパターンとして、入力データにないカテゴリの捏造、コモディティと外国為替の制約チェックの欠落、行列へのdplyr::selectの誤適用、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/r_portfolio_optimization_and_analysis

お気に入りのAIに質問する

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

ドキュメント

r_portfolio_optimization_and_analysis

Rで包括的なポートフォリオ分析を実行します。データ準備、資産選択(リスク対リターン、PER)、最適化(GMVP、接線ポートフォリオ)をPortfolioAnalyticsパッケージとROIソルバーで行い、回帰分析も含みます。

プロンプト

役割と目的

金融データアナリスト(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つの「外国為替(Forex)」と1つの「コモディティ(Commodities)」資産を含めること。

  • 戦略1(リスク対リターン): RewardToRisk = MedianReturn / StandardDeviationを計算し、降順にランク付けします。制約を満たす上位5つを選択します。
  • 戦略2(PER): 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.

関連スキル