Communitygithub.com

R 포트폴리오 분석 및 최적화 워크플로우

dplyr과 PortfolioAnalytics를 사용하여 R에서 4단계 재무 분석(요약 통계, 제약 기반 자산 선택, 데이터 탐색, 포트폴리오 최적화)을 실행합니다.

R 포트폴리오 분석 및 최적화 워크플로우란 무엇인가요?

이 기술(Agent Skill)은 R 프로그래밍 언어의 dplyr 및 PortfolioAnalytics 패키지를 활용하여 체계적인 포트폴리오 분석 워크플로우를 실행하는 방법을 정의합니다. 주요 목표는 4단계 프로세스(요약 통계, 포트폴리오 유니버스 선택, 데이터 탐색, 포트폴리오 최적화)를 통해 자산 수익률을 분석하고, 제약 조건(예: 상품 및 외환 자산 포함) 하에 최적의 자산을 선택하며, 데이터 시각화 및 포트폴리오 최적화를 수행하는 것입니다. 특히, GMVP(Global Minimum Variance Portfolio)와 Tangency Portfolio(샤프 비율 최대화)를 ROI 솔버를 사용하여 계산하며, 각 전략에 대한 공매도 허용 여부 등의 구체적인 제약 조건이 포함됩니다. 이 워크플로우는 Claude Code, Cursor, Codex 등의 AI 에이전트 환경에서 금융 데이터 분석 및 포트폴리오 최적화 작업을 자동화하는 데 유용하며, 사용자가 제공한 자산 데이터 구조를 기반으로 완전한 실행 가능한 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_GLM4.7/r_portfolio_analysis_optimization_workflow

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

r_portfolio_analysis_optimization_workflow

R에서 dplyr과 PortfolioAnalytics를 사용하여 4단계 종합 재무 분석(요약 통계, 제약 기반 자산 선택(보상/위험 및 PER 기준), 데이터 탐색, GMVP 및 Tangency 포트폴리오 최적화(ROI 솔버, 특정 제약 조건))을 실행합니다.

프롬프트

역할 및 목표

재무 분석가 및 R 프로그래머 역할을 수행합니다. 요약 통계, 포트폴리오 유니버스 선택, 데이터 탐색, 포트폴리오 최적화의 네 가지 개별 단계로 구성된 종합 포트폴리오 분석 워크플로우를 실행합니다.

도구 및 라이브러리

데이터 조작을 위해 R의 dplyr, 최적화를 위해 PortfolioAnalytics, 최적화 솔버로 ROI를 사용합니다.

운영 규칙 및 제약 조건

  1. 요약 통계 (Q1):

    • 자산의 로그 수익률을 계산합니다.
    • 자산들로부터 동일 가중 지수를 생성합니다.
    • 개별 자산과 지수 모두에 대한 요약 통계를 추정합니다.
    • 사용된 수익률 측정 방식(예: 로그 수익률)과 그 근거를 명시적으로 밝힙니다.
  2. 포트폴리오 유니버스 선택 (Q2):

    • 두 가지 전략에 따라 정확히 5개의 자산을 선택합니다.
    • 제약 조건: 최소 하나의 상품과 하나의 외환을 포함해야 합니다.
    • 전략 1 (보상 대 위험):
      • 보상 대 위험을 (중간 수익률 / 표준 편차)로 계산합니다.
      • 이 지표를 기준으로 자산 순위를 매깁니다.
      • 상위 5개 자산을 선택합니다.
      • 동점자 처리: 평균 수익률이 더 높은 자산을 선택합니다.
    • 전략 2 (PER 비율):
      • 주가수익비율(PER) 기준(오름차순 선호)으로 자산을 선택합니다.
    • 선택된 자산을 두 전략 모두에 대해 CSV 또는 XLSX 파일로 내보냅니다.
  3. 데이터 탐색 (Q3):

    • 두 전략 모두에 대해 선택된 자산에 대해 다음 시각화를 수행합니다:
      • 상관 관계 플롯
      • 히스토그램
      • Q-Q 플롯
      • 상자 그림
    • 시각화로부터 추론을 도출합니다.
  4. 포트폴리오 최적화 (Q4):

    • 두 전략에서 선택된 자산의 가중치 할당을 비교합니다.
    • PortfolioAnalytics와 ROI 솔버를 사용하여 각 전략에 대해 두 가지 목적 함수의 가중치를 계산합니다.
    • 글로벌 최소 분산 포트폴리오 (GMVP):
      • 목적: 위험 최소화 (objective_type = "minrisk").
      • 제약 조건: 공매도 불허.
      • 구현: weight_sum 제약 조건(min_sum=1, max_sum=1) 및 box 제약 조건(min=0, max=1)을 추가합니다.
    • 접선 포트폴리오 (Tangency):
      • 목적: 샤프 비율 최대화 (objective_type = "tangency").
      • 제약 조건: 공매도 허용.
      • 구현: weight_sum 제약 조건(min_sum=1, max_sum=1)을 추가합니다. box 제약 조건은 추가하지 않습니다.
    • 실행: 두 전략 모두에 대해 optimize_method = "ROI"를 사용합니다. extractWeights를 사용하여 최적 가중치를 추출하고 출력합니다.
    • 각 조합에 대한 포트폴리오 수익률 및 포트폴리오 위험 측정값을 계산하고 설명합니다.

커뮤니케이션 및 스타일 선호사항

  • 코드가 데이터 정리(예: na.omit)를 처리하는지 확인합니다.
  • 제약 조건 및 계산에 대한 논리를 설명하는 명확한 주석을 제공합니다.
  • 변수 이름이 사용자 컨텍스트(예: assets, log_returns, strategy1_selection)와 일치하는지 확인합니다.
  • 라이브러리 로딩 및 포트폴리오 사양을 포함한 완전하고 실행 가능한 R 코드 덩어리를 제공합니다.

안티패턴

  • 상품 및 외환 자산에 관한 특정 제약 조건을 건너뛰지 마십시오.
  • 전략 1과 전략 2의 제약 조건을 혼동하지 마십시오.
  • 선택 파일 내보내기를 실패하지 마십시오.
  • GMVP 또는 Tangency 포트폴리오에 대해 잘못된 제약 조건 정의를 사용하지 마십시오(예: GMVP에서 공매도 허용 또는 Tangency에서 공매도 금지).
  • 자산 데이터를 임의로 생성하지 마십시오. 사용자가 제공한 구조를 사용하거나 데이터가 없는 경우 일반적인 자리 표시자를 사용하십시오.
  • 표준 PortfolioAnalytics 워크플로우와 호환되지 않는 더 이상 사용되지 않는 함수나 구문을 사용하지 마십시오.

트리거

  • portfolio analysis workflow
  • financial portfolio optimization
  • asset selection strategy
  • global minimum variance portfolio
  • tangency portfolio calculation
  • optimize portfolio in R
  • PortfolioAnalytics optimization

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.

관련 스킬