Communitygithub.com

David-Li0406/meta-skill-evloving

R을 사용한 종합 포트폴리오 분석: 데이터 준비, 자산 선택(보상-위험, P/E), PortfolioAnalytics 패키지의 ROI 솔버를 활용한 최적화(GMVP, Tangency), 회귀 분석 실행

meta-skill-evloving란 무엇인가요?

이 기술은 금융 데이터 분석가가 R 환경에서 종합적인 포트폴리오 분석 워크플로우를 실행할 수 있도록 설계되었습니다. 데이터 준비 단계에서는 자산 데이터프레임(티커, 카테고리, 중간수익률, 표준편차, PER)과 로그 수익률 행렬을 입력으로 받아 전처리합니다. 자산 선택은 보상-위험 비율(Reward-to-Ratio) 또는 P/E 비율 기준으로 각각 5개 자산을 선정하며, 최소 1개 이상의 'Forex'와 'Commodities' 자산을 포함하도록 제약합니다. 포트폴리오 최적화는 `PortfolioAnalytics` 패키지의 `ROI` 솔버를 이용해 GMVP(분산 최소화, 공매도 금지)와 Tangency 포트폴리오(샤프 비율 최대화, 공매도 허용)를 계산합니다. 추가로 상관 분석, 시각화(히스토그램, Q-Q plot, Box-plot), 동일 가중 인덱스 생성, 외부 요인에 대한 회귀 분석(lm)을 수행하여 포트폴리오 성과를 설명합니다. 결과물로 선정된 자산 목록 CSV, 요약 통계량, 포트폴리오 가중치를 제공합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/David-Li0406/meta-skill-evloving/tree/HEAD/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/r_portfolio_optimization_and_analysis

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

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

문서

r_portfolio_optimization_and_analysis

R을 사용한 종합 포트폴리오 분석을 실행합니다. 데이터 준비, 자산 선택(보상-위험 비율, P/E), PortfolioAnalytics 패키지와 ROI 솔버를 활용한 최적화(GMVP, Tangency), 그리고 회귀 분석을 포함합니다.

프롬프트

역할 및 목표

재무 데이터 분석가(Financial Data Analyst) 역할을 수행하며, 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 (P/E 비율): 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"와 함께 사용합니다.
  • Tangency 포트폴리오 (TP) :
    • 목표: 샤프 비율 최대화 (objective_type = "tangency").
    • 제약: weight_sum min_sum = 1, max_sum = 1 (완전 투자).
    • 제약: box 제약을 추가하지 않습니다 (공매도 허용).
    • 최적화: optimize.portfolio를 optimize_method = "ROI"와 함께 사용합니다.

4. 데이터 탐색 및 회귀 분석

  • 선택된 자산에 대한 상관 분석을 수행합니다.
  • 히스토그램, Q-Q 플롯, Box-플롯을 생성합니다.
  • rowMeans(log_returns)를 사용하여 동일 가중 지수를 생성합니다.
  • lm()을 사용하여 포트폴리오 수익률을 외부 요인에 회귀합니다(예: lm(Portfolio_Return ~ Factor1 + Factor2)).

출력 요구사항

  • 선택된 자산 목록을 CSV로 내보냅니다.
  • extractWeights를 사용하여 요약 통계와 포트폴리오 가중치를 출력합니다.
  • 라이브러리를 로드하고, 수익률 행렬을 준비하며, 포트폴리오 사양을 정의하고, 제약 조건을 추가하며, 최적화를 실행하고 결과를 추출하는 명확하고 실행 가능한 R 코드 청크를 제공합니다.

안티-패턴

  • 입력 데이터에 제공되지 않은 자산 카테고리나 특정 자산 이름을 임의로 생성하지 마십시오.
  • Commodity 및 Forex 자산에 대한 제약 조건 검사를 건너뛰지 마십시오.
  • 데이터프레임으로 변환하지 않고 행렬 객체에 dplyr::select를 사용하지 마십시오.
  • 로그 수익률 계산 결과 첫 번째 행에 생성되는 NA 값을 처리하는 것을 잊지 마십시오.
  • GMVP 및 Tangency 포트폴리오에 대해 "ROI" 이외의 최적화 방법을 사용하지 마십시오.
  • Tangency 포트폴리오에 box 제약 조건을 추가하지 마십시오.

트리거

  • R로 포트폴리오 분석 수행
  • GMVP 및 Tangency를 사용하여 포트폴리오 가중치 최적화
  • 보상 대비 위험 비율을 기준으로 자산 선택
  • R에서 포트폴리오 수익률을 요인에 회귀
  • PortfolioAnalytics를 사용하여 포트폴리오 최적화

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

David-Li0406/meta-skill-evloving

Browser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.

David-Li0406/meta-skill-evloving

Create technical diagrams using Mermaid syntax for architecture, sequences, ERDs, flowcharts, and state machines. Use for visualizing system design, data flows, and processes. Triggers: diagram, mermaid, architecture diagram, sequence diagram, flowchart, ERD, entity relationship, state diagram, C4 model, component diagram, visualize, draw.

David-Li0406/meta-skill-evloving

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks

David-Li0406/meta-skill-evloving

Complete color manipulation and green screen effects system. PROACTIVELY activate for: (1) Green screen/chromakey removal, (2) Color grading with LUTs, (3) Color correction (levels, curves, white balance), (4) Colorkey/color removal effects, (5) Hue/saturation manipulation, (6) Color space conversions (BT.709, BT.2020, HDR), (7) Color isolation effects, (8) Teal and orange look, (9) Vintage/film looks, (10) Color keying for transparency. Provides: chromakey and colorkey filters, LUT application (lut3d), curves and levels adjustment, color balance, selective color manipulation, color space handling, HDR tone mapping, professional color grading chains.

David-Li0406/meta-skill-evloving

Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.

David-Li0406/meta-skill-evloving

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

David-Li0406/meta-skill-evloving

Build with OpenAI's stateless APIs - Chat Completions (GPT-5, GPT-4o), Embeddings, Images (DALL-E 3), Audio (Whisper + TTS), and Moderation. Includes Node.js SDK and fetch-based approaches for Cloudflare Workers. Use when: implementing chat completions with GPT-5/GPT-4o, streaming responses with SSE, using function calling/tools, creating structured outputs with JSON schemas, generating embeddings for RAG (text-embedding-3-small/large), generating images with DALL-E 3, editing images with GPT-Image-1, transcribing audio with Whisper, synthesizing speech with TTS (11 voices), moderating content (11 safety categories), or troubleshooting rate limits (429), invalid API keys (401), function calling failures, streaming parse errors, embeddings dimension mismatches, or token limit exceeded.

David-Li0406/meta-skill-evloving

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

David-Li0406/meta-skill-evloving

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

David-Li0406/meta-skill-evloving

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

David-Li0406/meta-skill-evloving

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

David-Li0406/meta-skill-evloving

Best practices for Remotion - Video creation in React

David-Li0406/meta-skill-evloving

Provides bidirectional translation (Chinese/English), grammar checking, and sentence polishing. Supports specific tense constraints, context-aware tone adjustment, and natural expression optimization. Outputs direct text without formatting.

David-Li0406/meta-skill-evloving

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

David-Li0406/meta-skill-evloving

生成Python脚本,利用FFmpeg将图片序列按3x3布局合并,或将合并图拆分。要求使用subprocess模块执行命令,并支持用户交互式输入路径。

David-Li0406/meta-skill-evloving

SOP for extracting and analyzing promotional activity details, handling time formatting, location mapping, payment logic, and step-by-step process validation.

David-Li0406/meta-skill-evloving

Specializes in creating TikTok short video scripts using an anthropomorphic 'Chef' perspective to explain wildlife food chains and survival environments, utilizing real field footage.

David-Li0406/meta-skill-evloving

针对TikTok平台,以拟人化视角(如动物作为厨师)创作系列短视频脚本。重点介绍野生动物、食物链及生态环境,要求使用野外实拍素材,风格幽默且具有教育意义。

David-Li0406/meta-skill-evloving

Generates KWL (Know, Want to know, Learned) charts for educational videos, specifically BrainPOP, using simple 7th-grade language and short, concise bullet points.

David-Li0406/meta-skill-evloving

Tracks complex, multi-session work using the Beads issue tracker and dependency graphs, and provides persistent memory that survives conversation compaction. Use when work spans multiple sessions, has complex dependencies, or needs persistent context across compaction cycles. Trigger with phrases like "create task for", "what's ready to work on", "show task", "track this work", "what's blocking", or "update status".

관련 스킬