Portfolio Manager
Overview
Analyze and manage investment portfolios by integrating with Alpaca MCP Server to fetch real-time holdings data, then performing comprehensive analysis covering asset allocation, diversification, risk metrics, individual position evaluation, and rebalancing recommendations. Generate detailed portfolio reports with actionable insights.
This skill leverages Alpaca's brokerage API through MCP (Model Context Protocol) to access live portfolio data, ensuring analysis is based on actual current positions rather than manually entered data.
When to Use
Invoke this skill when the user requests:
- - "Analyze my portfolio"
- "Review my current positions"
- "What's my asset allocation?"
- "Check my portfolio risk"
- "Should I rebalance my portfolio?"
- "Evaluate my holdings"
- "Portfolio performance review"
- "What stocks should I buy or sell?"
- Any request involving portfolio-level analysis or management
Prerequisites
Alpaca MCP Server Setup
This skill requires Alpaca MCP Server to be configured and connected. The MCP server provides access to:
- - Current portfolio positions
- Account equity and buying power
- Historical positions and transactions
- Market data for held securities
MCP Server Tools Used:
- -
get_account_info - Fetch account equity, buying power, cash balance - INLINECODE1 - Retrieve all current positions with quantities, cost basis, market value
- INLINECODE2 - Historical portfolio performance data
- Market data tools for price quotes and fundamentals
If Alpaca MCP Server is not connected, inform the user and provide setup instructions from references/alpaca_mcp_setup.md.
Workflow
Step 1: Fetch Portfolio Data via Alpaca MCP
Use Alpaca MCP Server tools to gather current portfolio information:
1.1 Get Account Information:
CODEBLOCK0
1.2 Get Current Positions:
CODEBLOCK1
1.3 Get Portfolio History (Optional):
CODEBLOCK2
Data Validation:
- - Verify all positions have valid ticker symbols
- Confirm market values sum to approximate account equity
- Check for any stale or inactive positions
- Handle edge cases (fractional shares, options, crypto if supported)
Step 2: Enrich Position Data
For each position in the portfolio, gather additional market data and fundamentals:
2.1 Current Market Data:
- - Real-time or delayed price quotes
- Daily volume and liquidity metrics
- 52-week range
- Market capitalization
2.2 Fundamental Data:
Use WebSearch or available market data APIs to fetch:
- - Sector and industry classification
- Key valuation metrics (P/E, P/B, dividend yield)
- Recent earnings and financial health indicators
- Analyst ratings and price targets
- Recent news and material developments
2.3 Technical Analysis:
- - Price trend (20-day, 50-day, 200-day moving averages)
- Relative strength
- Support and resistance levels
- Momentum indicators (RSI, MACD if available)
Step 3: Portfolio-Level Analysis
Perform comprehensive portfolio analysis using frameworks from reference files:
3.1 Asset Allocation Analysis
Read references/asset-allocation.md for allocation frameworks
Analyze current allocation across multiple dimensions:
By Asset Class:
- - Equities vs Fixed Income vs Cash vs Alternatives
- Compare to target allocation for user's risk profile
- Assess if allocation matches investment goals
By Sector:
- - Technology, Healthcare, Financials, Consumer, etc.
- Identify sector concentration risks
- Compare to benchmark sector weights (e.g., S&P 500)
By Market Cap:
- - Large-cap vs Mid-cap vs Small-cap distribution
- Concentration in mega-caps
- Market cap diversification score
By Geography:
- - US vs International vs Emerging Markets
- Domestic concentration risk assessment
Output Format:
CODEBLOCK3
3.2 Diversification Analysis
Read references/diversification-principles.md for diversification theory
Evaluate portfolio diversification quality:
Position Concentration:
- - Identify top holdings and their aggregate weight
- Flag if any single position exceeds 10-15% of portfolio
- Calculate Herfindahl-Hirschman Index (HHI) for concentration measurement
Sector Concentration:
- - Identify dominant sectors
- Flag if any sector exceeds 30-40% of portfolio
- Compare to benchmark sector diversity
Correlation Analysis:
- - Estimate correlation between major positions
- Identify highly correlated holdings (potential redundancy)
- Assess true diversification benefit
Number of Positions:
- - Optimal range: 15-30 stocks for individual portfolios
- Flag if under-diversified (<10 stocks) or over-diversified (>50 stocks)
Output:
CODEBLOCK4
3.3 Risk Analysis
Read references/portfolio-risk-metrics.md for risk measurement frameworks
Calculate and interpret key risk metrics:
Volatility Measures:
- - Estimated portfolio beta (weighted average of position betas)
- Individual position volatilities
- Portfolio standard deviation (if historical data available)
Downside Risk:
- - Maximum drawdown (from portfolio history)
- Current drawdown from peak
- Positions with significant unrealized losses
Risk Concentration:
- - Percentage in high-volatility stocks (beta > 1.5)
- Percentage in speculative/unprofitable companies
- Leverage usage (if applicable)
Tail Risk:
- - Exposure to potential black swan events
- Single-stock concentration risk
- Sector-specific event risk
Output:
CODEBLOCK5
3.4 Performance Analysis
Evaluate portfolio performance using available data:
Absolute Returns:
- - Overall portfolio unrealized P&L ($ and %)
- Best performing positions (top 5 by % gain)
- Worst performing positions (bottom 5 by % loss)
Time-Weighted Returns (if history available):
- - YTD return
- 1-year, 3-year, 5-year annualized returns
- Compare to benchmark (S&P 500, relevant index)
Position-Level Performance:
- - Winners vs Losers ratio
- Average gain on winning positions
- Average loss on losing positions
- Positions near 52-week highs/lows
Output:
CODEBLOCK6
Step 4: Individual Position Analysis
For key positions (top 10-15 by portfolio weight), perform detailed analysis:
Read references/position-evaluation.md for position analysis framework
For each significant position:
4.1 Current Thesis Validation:
- - Why was this position initiated? (if known from user context)
- Has the investment thesis played out or broken?
- Recent company developments and news
4.2 Valuation Assessment:
- - Current valuation metrics (P/E, P/B, etc.)
- Compare to historical valuation range
- Compare to sector peers
- Overvalued / Fair / Undervalued assessment
4.3 Technical Health:
- - Price trend (uptrend, downtrend, sideways)
- Position relative to moving averages
- Support and resistance levels
- Momentum status
4.4 Position Sizing:
- - Current weight in portfolio
- Is size appropriate given conviction and risk?
- Overweight or underweight vs optimal
4.5 Action Recommendation:
- - HOLD - Position is well-sized and thesis intact
- ADD - Underweight given opportunity, thesis strengthening
- TRIM - Overweight or valuation stretched
- SELL - Thesis broken, better opportunities elsewhere
Output per position:
CODEBLOCK7
Step 5: Rebalancing Recommendations
Read references/rebalancing-strategies.md for rebalancing approaches
Generate specific rebalancing recommendations:
5.1 Identify Rebalancing Triggers:
- - Positions that have drifted significantly from target weights
- Sector/asset class allocations requiring adjustment
- Overweight positions to trim (exceeded threshold)
- Underweight areas to add (below threshold)
- Tax considerations (capital gains implications)
5.2 Develop Rebalancing Plan:
Positions to TRIM:
- - Overweight positions (>threshold deviation from target)
- Stocks that have run up significantly (valuation concerns)
- Concentrated positions exceeding 15-20% of portfolio
- Positions with broken thesis
Positions to ADD:
- - Underweight sectors or asset classes
- High-conviction positions currently underweight
- New opportunities to improve diversification
Cash Deployment:
- - If excess cash (>10% of portfolio), suggest deployment
- Prioritize based on opportunity and allocation gaps
5.3 Prioritization:
Rank rebalancing actions by priority:
- 1. Immediate - Risk reduction (trim concentrated positions)
- High Priority - Major allocation drift (>10% from target)
- Medium Priority - Moderate drift (5-10% from target)
- Low Priority - Fine-tuning and opportunistic adjustments
Output:
CODEBLOCK8
Step 6: Generate Portfolio Report
Create comprehensive markdown report saved to repository root:
Filename: INLINECODE4
Report Structure:
CODEBLOCK9
Step 7: Interactive Follow-up
Be prepared to answer follow-up questions:
Common Questions:
"Why should I sell [SYMBOL]?"
- - Explain specific concerns (valuation, thesis breakdown, concentration)
- Provide supporting data
- Offer alternative positions if applicable
"What should I buy instead?"
- - Suggest specific stocks to improve allocation
- Explain how they address portfolio gaps
- Provide brief investment thesis
"What's my biggest risk?"
- - Identify primary risk factor (concentration, sector exposure, volatility)
- Quantify the risk
- Suggest mitigation strategies
"How does my portfolio compare to [benchmark]?"
- - Compare allocation, sector weights, risk metrics
- Highlight key differences
- Assess if differences are justified
"Should I rebalance now or wait?"
- - Consider market conditions, tax implications, transaction costs
- Provide timing recommendation with rationale
"Can you analyze [specific position] in more detail?"
- - Perform deep-dive analysis using us-stock-analysis skill if needed
- Integrate findings back into portfolio context
Analysis Frameworks
Target Allocation Templates
This skill includes reference allocation models for different investor profiles:
Read references/target-allocations.md for detailed models:
- - Conservative (Capital preservation, income focus)
- Moderate (Balanced growth and income)
- Growth (Long-term capital appreciation)
- Aggressive (Maximum growth, high risk tolerance)
Each model includes:
- - Asset class targets (Stocks/Bonds/Cash/Alternatives)
- Sector guidelines
- Market cap distribution
- Geographic allocation
- Position sizing rules
Use these as comparison benchmarks when user hasn't specified their allocation strategy.
Risk Profile Assessment
If user's target allocation is unknown, assess appropriate risk profile based on:
- - Age (if mentioned)
- Investment timeline (if mentioned)
- Current allocation (reveals preferences)
- Position types (conservative vs speculative stocks)
Read references/risk-profile-questionnaire.md for assessment framework
Output Guidelines
Tone and Style:
- - Objective and analytical
- Actionable recommendations with clear rationale
- Acknowledge uncertainty in market forecasts
- Balance optimism with risk awareness
- Quantify whenever possible
Data Presentation:
- - Tables for comparisons and metrics
- Percentages for allocations and returns
- Dollar amounts for absolute values
- Consistent formatting throughout report
Recommendation Clarity:
- - Explicit action verbs (TRIM, ADD, HOLD, SELL)
- Specific quantities (sell XX shares, add $X,XXX)
- Priority levels (Immediate, High, Medium, Low)
- Supporting rationale for each recommendation
Visual Descriptions:
- - Describe allocation breakdowns as if creating pie charts
- Sector weights as bar chart equivalents
- Performance trends with directional indicators (↑ ↓ →)
Reference Files
Load these references as needed during analysis:
references/alpaca-mcp-setup.md
- - When: User needs help setting up Alpaca MCP Server
- Contains: Installation instructions, API key configuration, MCP server connection steps, troubleshooting
references/asset-allocation.md
- - When: Analyzing portfolio allocation or creating rebalancing plan
- Contains: Asset allocation theory, optimal allocation by risk profile, sector allocation guidelines, rebalancing triggers
references/diversification-principles.md
- - When: Assessing portfolio diversification quality
- Contains: Modern portfolio theory basics, correlation concepts, optimal position count, concentration risk thresholds, diversification metrics
references/portfolio-risk-metrics.md
- - When: Calculating risk scores or interpreting volatility
- Contains: Beta calculation, standard deviation, Sharpe ratio, maximum drawdown, Value at Risk (VaR), risk-adjusted return metrics
references/position-evaluation.md
- - When: Analyzing individual holdings for buy/hold/sell decisions
- Contains: Position analysis framework, thesis validation checklist, position sizing guidelines, sell discipline criteria
references/rebalancing-strategies.md
- - When: Developing rebalancing recommendations
- Contains: Rebalancing methodologies (calendar-based, threshold-based, tactical), tax optimization strategies, transaction cost considerations, implementation timing
references/target-allocations.md
- - When: Need benchmark allocations for comparison
- Contains: Model portfolios for conservative/moderate/growth/aggressive investors, sector target ranges, market cap distributions
references/risk-profile-questionnaire.md
- - When: User hasn't specified risk tolerance or target allocation
- Contains: Risk assessment questions, scoring methodology, risk profile classification
Error Handling
If Alpaca MCP Server is not connected:
- 1. Inform user that Alpaca integration is required
- Provide setup instructions from references/alpaca-mcp-setup.md
- Offer alternative: manual data entry (less ideal, user provides CSV of positions)
If API returns incomplete data:
- - Proceed with available data
- Note limitations in report
- Suggest manual verification for missing positions
If position data seems stale:
- - Flag the issue
- Recommend refreshing connection or checking Alpaca status
- Proceed with analysis but caveat findings
If user has no positions:
- - Acknowledge empty portfolio
- Offer portfolio construction guidance instead of analysis
- Suggest using value-dividend-screener or us-stock-analysis for stock ideas
Advanced Features
Tax-Loss Harvesting Opportunities
Identify positions with unrealized losses suitable for tax-loss harvesting:
- - Positions with losses >5%
- Holding period considerations (avoid wash sale rule)
- Replacement security suggestions (similar but not substantially identical)
Dividend Income Analysis
For portfolios with dividend-paying stocks:
- - Estimate annual dividend income
- Dividend growth rate trajectory
- Dividend coverage and sustainability
- Yield on cost for long-term holdings
Correlation Matrix
For portfolios with 5-20 positions:
- - Estimate correlation between major positions
- Identify redundant positions (correlation >0.8)
- Suggest diversification improvements
Scenario Analysis
Model portfolio behavior under different scenarios:
- - Bull Market (+20% equity appreciation)
- Bear Market (-20% equity decline)
- Sector Rotation (Tech weakness, Value strength)
- Rising Rates (Impact on growth stocks and bonds)
Example Queries
Basic Portfolio Review:
- - "Analyze my portfolio"
- "Review my positions"
- "How's my portfolio doing?"
Allocation Analysis:
- - "What's my asset allocation?"
- "Am I too concentrated in tech?"
- "Show me my sector breakdown"
Risk Assessment:
- - "Is my portfolio too risky?"
- "What's my portfolio beta?"
- "What are my biggest risks?"
Rebalancing:
- - "Should I rebalance?"
- "What should I buy or sell?"
- "How can I improve diversification?"
Performance:
- - "What are my best and worst positions?"
- "How am I performing vs the market?"
- "Which stocks are winning and losing?"
Position-Specific:
- - "Should I sell [SYMBOL]?"
- "Is [SYMBOL] overweight in my portfolio?"
- "What should I do with [SYMBOL]?"
Limitations and Disclaimers
Include in all reports:
This analysis is for informational purposes only and does not constitute financial advice. Investment decisions should be made based on individual circumstances, risk tolerance, and financial goals. Past performance does not guarantee future results. Consult with a qualified financial advisor before making investment decisions.
Data accuracy depends on Alpaca API and third-party market data sources. Verify critical information independently. Tax implications are estimates only; consult a tax professional for specific guidance.
投资组合经理
概述
通过与Alpaca MCP服务器集成,获取实时持仓数据,对投资组合进行分析与管理,涵盖资产配置、多元化、风险指标、单个头寸评估及再平衡建议。生成包含可执行洞察的详细投资组合报告。
该技能通过MCP(模型上下文协议)利用Alpaca的券商API访问实时投资组合数据,确保分析基于实际当前持仓,而非手动输入数据。
使用场景
当用户提出以下请求时调用此技能:
- - 分析我的投资组合
- 查看我当前的持仓
- 我的资产配置是什么?
- 检查我的投资组合风险
- 我应该重新平衡我的投资组合吗?
- 评估我的持仓
- 投资组合业绩回顾
- 我应该买入或卖出哪些股票?
- 任何涉及投资组合层面分析或管理的请求
前提条件
Alpaca MCP服务器设置
此技能需要配置并连接Alpaca MCP服务器。MCP服务器提供以下访问权限:
- - 当前投资组合持仓
- 账户权益和购买力
- 历史持仓和交易记录
- 持有证券的市场数据
使用的MCP服务器工具:
- - getaccountinfo - 获取账户权益、购买力、现金余额
- getpositions - 检索所有当前持仓,包括数量、成本基础、市值
- getportfolio_history - 历史投资组合业绩数据
- 用于报价和基本面的市场数据工具
如果Alpaca MCP服务器未连接,请告知用户并提供references/alpacamcpsetup.md中的设置说明。
工作流程
步骤1:通过Alpaca MCP获取投资组合数据
使用Alpaca MCP服务器工具收集当前投资组合信息:
1.1 获取账户信息:
使用 mcpalpacagetaccountinfo 获取:
- - 账户权益(投资组合总价值)
- 现金余额
- 购买力
- 账户状态
1.2 获取当前持仓:
使用 mcpalpacaget_positions 获取所有持仓:
- - 股票代码
- 持有数量
- 平均入场价格(成本基础)
- 当前市场价格
- 当前市值
- 未实现盈亏(美元和百分比)
- 持仓占投资组合百分比
1.3 获取投资组合历史(可选):
使用 mcpalpacagetportfoliohistory 进行业绩分析:
数据验证:
- - 确认所有持仓具有有效的股票代码
- 确认市值总和约等于账户权益
- 检查是否存在过期或无效持仓
- 处理边缘情况(如支持碎股、期权、加密货币)
步骤2:丰富持仓数据
对于投资组合中的每个持仓,收集额外的市场数据和基本面信息:
2.1 当前市场数据:
- - 实时或延迟报价
- 日成交量和流动性指标
- 52周范围
- 市值
2.2 基本面数据:
使用网络搜索或可用的市场数据API获取:
- - 行业和板块分类
- 关键估值指标(市盈率、市净率、股息率)
- 近期盈利和财务健康指标
- 分析师评级和目标价
- 近期新闻和重大进展
2.3 技术分析:
- - 价格趋势(20日、50日、200日移动平均线)
- 相对强弱
- 支撑位和阻力位
- 动量指标(RSI、MACD,如可用)
步骤3:投资组合层面分析
使用参考文件中的框架进行全面的投资组合分析:
3.1 资产配置分析
阅读 references/asset-allocation.md 了解配置框架
从多个维度分析当前配置:
按资产类别:
- - 股票 vs 固定收益 vs 现金 vs 另类投资
- 与用户风险偏好的目标配置进行比较
- 评估配置是否符合投资目标
按行业:
- - 科技、医疗、金融、消费等
- 识别行业集中度风险
- 与基准行业权重(如标普500)进行比较
按市值:
- - 大盘股 vs 中盘股 vs 小盘股分布
- 超大盘股集中度
- 市值多元化评分
按地域:
- - 美国 vs 国际 vs 新兴市场
- 国内集中度风险评估
输出格式:
markdown
资产配置
当前配置 vs 目标
| 资产类别 | 当前 | 目标 | 偏差 |
|---|
| 美国股票 | XX.X% | YY.Y% | +/- Z.Z% |
| ... |
行业分布
[饼图描述或包含行业百分比的表格]
前十大持仓
| 排名 | 代码 | 占投资组合百分比 | 行业 |
|---|
| 1 | AAPL | X.X% | 科技 |
| ... |
3.2 多元化分析
阅读 references/diversification-principles.md 了解多元化理论
评估投资组合多元化质量:
持仓集中度:
- - 识别前几大持仓及其总权重
- 标记任何单一持仓是否超过投资组合的10-15%
- 计算赫芬达尔-赫希曼指数(HHI)衡量集中度
行业集中度:
- - 识别主导行业
- 标记任何行业是否超过投资组合的30-40%
- 与基准行业多样性进行比较
相关性分析:
- - 估算主要持仓之间的相关性
- 识别高度相关的持仓(潜在冗余)
- 评估真实的多元化收益
持仓数量:
- - 最佳范围:个人投资组合15-30只股票
- 标记是否多元化不足(<10只股票)或过度多元化(>50只股票)
输出:
markdown
多元化评估
集中度风险: [低 / 中 / 高]
- - 前五大持仓占投资组合的XX%
- 最大单一持仓:[代码] 占XX%
行业多元化: [优秀 / 良好 / 一般 / 较差]
- - 主导行业:[行业名称] 占XX%
- [跨行业平衡性评估]
持仓数量: [最佳 / 多元化不足 / 过度多元化]
相关性担忧:
- - [列出任何高度相关的持仓对]
- [多元化改进建议]
3.3 风险分析
阅读 references/portfolio-risk-metrics.md 了解风险衡量框架
计算并解读关键风险指标:
波动率指标:
- - 估算投资组合贝塔值(持仓贝塔值的加权平均)
- 单个头寸波动率
- 投资组合标准差(如有历史数据)
下行风险:
- - 最大回撤(来自投资组合历史)
- 当前距峰值的回撤
- 具有重大未实现亏损的持仓
风险集中度:
- - 高波动性股票(贝塔 > 1.5)的百分比
- 投机性/亏损公司的百分比
- 杠杆使用情况(如适用)
尾部风险:
- - 对潜在黑天鹅事件的敞口
- 单只股票集中度风险
- 特定行业事件风险
输出:
markdown
风险评估
整体风险特征: [保守 / 稳健 / 激进]
投资组合贝塔值: X.XX(市场为1.00)
最大回撤: -XX.X%(从$XXX,XXX 到 $XXX,XXX)
高风险持仓:
| 代码 | 占投资组合百分比 | 贝塔值 | 风险因素 |
|---|
| [代码] | XX% | X.XX | [高波动性 / 近期亏损 / 等] |
风险集中度:
- - XX% 集中于单一行业([行业])
- XX% 集中于贝塔 > 1.5 的股票
- [其他集中度风险]
风险评分: XX/100([低/中/高]风险)
3.4 业绩分析
使用可用数据评估投资组合业绩:
绝对收益:
- - 投资组合整体未实现盈亏(美元和百分比)
- 表现最佳的持仓(涨幅前5)
- 表现最差的持仓(跌幅后5)
时间加权收益(如有历史数据):
- - 年初至今收益
- 1年、3年、5年年化收益
- 与基准(标普500、相关指数)比较
持仓层面业绩:
- - 赢家与输家比率
- 赢家持仓的平均收益
- 输家持仓的平均亏损
- 接近52周高/低点的持仓
输出:
markdown
业绩回顾
投资组合总价值: $XXX,XXX
总未实现盈亏: $XX